Package org.apache.ode.bpel.rtrep.v2.channels

Examples of org.apache.ode.bpel.rtrep.v2.channels.ParentScopeChannelListener


                    _completedChildren);

                // Create the compensation handler scope.
                instance(new SCOPE(ai,compHandlerScopeFrame, new LinkFrame(null)));

                object(new ParentScopeChannelListener(ai.parent) {
                    private static final long serialVersionUID = 8044120498580711546L;

                    public void compensate(OScope scope, SynchChannel ret) {
                        throw new AssertionError("Unexpected.");
                    }
View Full Code Here


        ACTIVE(ActivityInfo activity) {
            _activity = activity;
        }

        public void run() {
            object(false,new ParentScopeChannelListener(_activity.parent){
                private static final long serialVersionUID = -3357030137175178040L;

                public void compensate(OScope scope, SynchChannel ret) {
                    _psc.compensate(scope,ret);
                    instance(ACTIVE.this);
View Full Code Here

                public void terminate() {
                    _terminated = true;
                    replication(_child.self).terminate();
                    instance(WAITER.this);
                }
            }.or(new ParentScopeChannelListener(_child.parent) {
                private static final long serialVersionUID = 3907167240907524405L;

                public void compensate(OScope scope, SynchChannel ret) {
                    _self.parent.compensate(scope,ret);
                    instance(WAITER.this);
View Full Code Here

                    }
                });

                for (;active.hasNext();) {
                    final ChildInfo child = active.next();
                    mlSet.add(new ParentScopeChannelListener(child.activity.parent) {
                        private static final long serialVersionUID = -8027205709169238172L;

                        public void completed(FaultData faultData, Set<CompensationHandler> compensations) {
                            child.completed = true;
                            _compensations.addAll(compensations);
View Full Code Here

                    }
                });
                for (;active.hasNext();) {
                    // Checking out our children
                    final ChildInfo child = active.next();
                    mlSet.add(new ParentScopeChannelListener(child.activity.parent) {
                        private static final long serialVersionUID = -8027205709961438172L;

                        public void compensate(OScope scope, SynchChannel ret) {
                            // Forward compensation to parent
                            _self.parent.compensate(scope, ret);
View Full Code Here

        public TCONDINTERCEPT(ParentScopeChannel in) {
            _in = in;
        }

        public void run() {
            object(new ParentScopeChannelListener(_in) {
                private static final long serialVersionUID = 2667359535900385952L;

                public void compensate(OScope scope, SynchChannel ret) {
                    _self.parent.compensate(scope,ret);
                    instance(TCONDINTERCEPT.this);
View Full Code Here

                    }
                });

                // Handle messages from the child if it is still alive
                if (_child != null) {
                    mlSet.add(new ParentScopeChannelListener(_child.parent) {
                        private static final long serialVersionUID = -6934246487304813033L;

                        public void compensate(OScope scope, SynchChannel ret) {
                            //  If this scope does not have available compensations, defer to
                            // parent scope, otherwise do compensation.
                            if (_scopeFrame.availableCompensations == null)
                                _self.parent.compensate(scope, ret);
                            else {
                                // TODO: Check if we are doing duplicate compensation
                                List<CompensationHandler> compensations = findCompensationData(scope);
                                _scopeFrame.availableCompensations.removeAll(compensations);
                                instance(new ORDEREDCOMPENSATOR(compensations, ret));
                            }
                            instance(ACTIVE.this);
                        }

                        public void completed(FaultData flt, Set<CompensationHandler> compensations) {
                              // Set the fault to the activity's choice, if and only if no previous fault
                              // has been detected (first fault wins).
                              if (flt != null && _fault == null)
                                  _fault = flt;
                              _child = null;
                              _compensations.addAll(compensations);

                              if (flt == null)
                                  stopEventHandlers();
                              else
                                  terminateEventHandlers();

                              instance(ACTIVE.this);
                        }

                        public void cancelled() {
                            // Implicit scope holds links of the enclosed activity,
                            // they only get cancelled when we propagate upwards.
                            if (_oscope.implicitScope)
                                _self.parent.cancelled();
                            else
                                completed(null, CompensationHandler.emptySet());
                        }

                        public void failure(String reason, Element data) {
                            completed(createFault(OFailureHandling.FAILURE_FAULT_NAME, _self.o, null),
                                      CompensationHandler.emptySet());
                        }

                    });
                }

                // Similarly, handle messages from the event handler, if one exists
                // and if it has not completed.
                for (Iterator<EventHandlerInfo> i = _eventHandlers.iterator();i.hasNext();) {
                    final EventHandlerInfo ehi = i.next();

                    mlSet.add(new ParentScopeChannelListener(ehi.psc) {
                        private static final long serialVersionUID = -4694721357537858221L;

                        public void compensate(OScope scope, SynchChannel ret) {
                            // ACTIVE scopes do not compensate, send request up to parent.
                            _self.parent.compensate(scope, ret);
                            instance(ACTIVE.this);
                        }

                        public void completed(FaultData flt, Set<CompensationHandler> compenstations) {
                            // Set the fault to the activity's choice, if and only if no previous fault
                            // has been detected (first fault wins).
                            if (flt != null && _fault == null)
                                _fault = flt;
                            _eventHandlers.remove(ehi);
                            _compensations.addAll(compenstations);

                            if (flt != null) {
                                // Terminate child if we get a fault from the event handler.
                                if (_child != null && !_childTermRequested) {
                                    replication(_child.self).terminate();
                                    _childTermRequested = true;
                                }
                                terminateEventHandlers();
                            } else
                                stopEventHandlers();

                            instance(ACTIVE.this);
                        }

                        public void cancelled() { completed(null, CompensationHandler.emptySet()); }
                        public void failure(String reason, Element data) { completed(null, CompensationHandler.emptySet()); }
                    });
                }
                object(false, mlSet);
            } else /* nothing to wait for... */ {
                // Any compensation handlers that were available but not activated will be forgotten.
                Set<CompensationHandler> unreachableCompensationHandlers = _scopeFrame.availableCompensations;
                if (unreachableCompensationHandlers != null)
                    for (Iterator<CompensationHandler> i = unreachableCompensationHandlers.iterator(); i.hasNext(); ) {
                        CompensationHandler ch = i.next();
                        ch.compChannel.forget();
                    }
                _scopeFrame.availableCompensations = null;

                // Maintain a set of links needing dead-path elimination.
                Set<OLink> linksNeedingDPE = new HashSet<OLink>();
                if (_oscope.faultHandler != null)
                    for (Iterator<OCatch> i = _oscope.faultHandler.catchBlocks.iterator(); i.hasNext(); )
                        linksNeedingDPE.addAll(i.next().outgoingLinks);

                // We're done with the main work, if we were terminated, we will
                // need to load the termination handler:
                if (_terminated) {
                    __log.debug("Scope: " + _oscope + " was terminated.");
                    // ??? Should we forward
                    _self.parent.completed(null,_compensations);
                } else if (_fault != null) {

                    sendEvent(new ScopeFaultEvent(_fault.getFaultName(), _fault.getFaultLineNo(),_fault.getExplanation()));

                    // Find a fault handler for our fault.
                    OCatch catchBlock = _oscope.faultHandler == null ? null : findCatch(_oscope.faultHandler, _fault.getFaultName(), _fault.getFaultType());

                    // Collect all the compensation data for completed child scopes.
                    assert !!_eventHandlers.isEmpty();
                    assert _child == null;
                    if (catchBlock == null) {
                        // If we cannot find a catch block for this fault, then we simply propagate the fault
                        // to the parent. NOTE: the "default" fault handler as described in the BPEL spec
                        // must be generated by the compiler.
                        if (__log.isDebugEnabled())
                            __log.debug(_self + ": has no fault handler for "
                                + _fault.getFaultName() + "; scope will propagate FAULT!");


                        _self.parent.completed(_fault, _compensations);
                    } else /* catchBlock != null */ {
                        if (__log.isDebugEnabled())
                            __log.debug(_self + ": has a fault handler for "
                                + _fault.getFaultName() + ": "+ catchBlock);

                        linksNeedingDPE.removeAll(catchBlock.outgoingLinks);

                        // We have to create a scope for the catch block.
                        OdeInternalInstance ntive = getBpelRuntime();

                        ActivityInfo faultHandlerActivity = new ActivityInfo(genMonotonic(), catchBlock,
                                newChannel(TerminationChannel.class,"FH"), newChannel(ParentScopeChannel.class,"FH"));

                        ScopeFrame faultHandlerScopeFrame = new ScopeFrame(catchBlock,
                                ntive.createScopeInstance(_scopeFrame.scopeInstanceId, catchBlock),
                                _scopeFrame, _compensations, _fault);
                        if (catchBlock.faultVariable != null) {
                            try {
                                VariableInstance vinst =  faultHandlerScopeFrame.resolve(catchBlock.faultVariable);
                                initializeVariable(vinst, _fault.getFaultMessage());

                                // Generating event
                                VariableModificationEvent se = new VariableModificationEvent(vinst.declaration.name);
                                se.setNewValue(_fault.getFaultMessage());
                                if (_oscope.debugInfo != null)
                                    se.setLineNo(_oscope.debugInfo.startLine);
                                sendEvent(se);
                            } catch (Exception ex) {
                                __log.fatal(ex);
                                throw new InvalidProcessException(ex);
                            }
                        }

                        // Create the fault handler scope.
                        instance(new SCOPE(faultHandlerActivity,faultHandlerScopeFrame, SCOPE.this._linkFrame));

                        object(new ParentScopeChannelListener(faultHandlerActivity.parent) {
                            private static final long serialVersionUID = -6009078124717125270L;

                            public void compensate(OScope scope, SynchChannel ret) {
                                // This should never happen.
                                throw new AssertionError("received compensate request!");
View Full Code Here

                    deadPathRemaining(remaining);

                    _terminateRequested = true;
                    instance(ACTIVE.this);
                }
            }.or(new ParentScopeChannelListener(_child.parent) {
                private static final long serialVersionUID = 7195562310281985971L;

                public void compensate(OScope scope, SynchChannel ret) {
                    _self.parent.compensate(scope,ret);
                    instance(ACTIVE.this);
View Full Code Here

                    });

                }

                for (final ActivityInfo ai : _active) {
                    mlset.add(new ParentScopeChannelListener(ai.parent) {
                        private static final long serialVersionUID = 5341207762415360982L;

                        public void compensate(OScope scope, SynchChannel ret) {
                            _psc.compensate(scope, ret);
                            instance(WAITING.this);
View Full Code Here

            _oprocess.procesScope,
            newChannel(TerminationChannel.class), newChannel(ParentScopeChannel.class));
        ScopeFrame processFrame = new ScopeFrame(_oprocess.procesScope, scopeInstanceId, null, null);
        instance(new SCOPE(child, processFrame, new LinkFrame(null)));

        object(new ParentScopeChannelListener(child.parent) {
            private static final long serialVersionUID = -8564969578471906493L;

            public void compensate(OScope scope, SynchChannel ret) {
                assert false;
            }
View Full Code Here

TOP

Related Classes of org.apache.ode.bpel.rtrep.v2.channels.ParentScopeChannelListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.