⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scope.java

📁 ejb3 java session bean
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      }    }    return null;  }  /**   * Finds a handler for a fault thrown with associated data among the handlers with the given name.   * @param name the fault name   * @param dataType the type of fault data   * @return a fault handler with the given name for the specified data type; <code>null</code> if   * no such handler was found   */  public Catch selectCatch(QName name, VariableType dataType) {    if (traceEnabled) {      log.trace("looking for fault handler with name '"          + name          + "' and variable type '"          + dataType          + '\'');    }    Iterator namedCatchIt = new FilterIterator(faultHandlers.iterator(), new NamedCatchPredicate(        name));    return selectCatch(namedCatchIt, dataType);  }  /**   * Finds a handler for a fault thrown with associated data among the unnamed handlers.   * @param dataType the type of fault data   * @return an unnamed fault handler for the specified data type; <code>null</code> if no such   * handler was found   */  public Catch selectCatch(VariableType dataType) {    if (traceEnabled)      log.trace("looking for fault handler with no name and variable type '" + dataType);    Iterator unnamedCatchIt = new FilterIterator(faultHandlers.iterator(), UNNAMED_CATCH_PREDICATE);    return selectCatch(unnamedCatchIt, dataType);  }  /**   * Finds a handler for a fault thrown with associated data among the given handlers. For each   * handler <i>h</i>:   * <ul>   * <li>if <i>h</i> has a faultVariable whose type matches the type of the fault data then <i>h</i>   * is selected</li>   * <li>otherwise if the type of fault data is a WSDL message which contains a single part defined   * by an element, and <i>h</i> has a faultVariable whose type matches the type of the element   * used to define the part then <i>h</i> is selected</li>   * <li>otherwise if <i>h</i> does not specify a faultVariable then <i>h</i> is selected</li>   * </ul>   * @param dataType the type of fault data   * @return the selected fault handler, or <code>null</code> if no handler is able to catch the   * fault   */  private static Catch selectCatch(Iterator handlerIt, VariableType dataType) {    Catch selectedCatch = null;    while (handlerIt.hasNext()) {      Catch currentCatch = (Catch) handlerIt.next();      if (traceEnabled)        log.trace("examining catch: " + currentCatch);      // look for a fault variable      VariableDefinition variable = currentCatch.getFaultVariable();      if (variable != null) {        VariableType handlerType = variable.getType();        if (handlerType.equals(dataType)) {          // current handler matches exactly the fault type; it has the highest          // priority, select it and stop the search          selectedCatch = currentCatch;          if (traceEnabled)            log.trace("selected catch with matching type: " + selectedCatch);          break;        }        else if (dataType.isMessage() && handlerType.isElement()) {          // fault data is a WSDL message, and the handler has an element          // variable          MessageType messageType;          if (dataType instanceof MessageType)            messageType = (MessageType) dataType;          else {            // reacquire proxy of the proper type            Session hbSession = JbpmContext.getCurrentJbpmContext().getSession();            messageType = (MessageType) hbSession.load(MessageType.class,                hbSession.getIdentifier(dataType));          }          QName elementName = WsdlUtil.getDocLitElementName(messageType.getMessage());          // do the handler element and the message part element match?          if (handlerType.getName().equals(elementName)) {            // current handler matches the element, select it but keep looking            // for a exact type match            selectedCatch = currentCatch;            if (traceEnabled)              log.trace("selected catch with matching element: " + selectedCatch);          }        }      }      else if (selectedCatch == null) {        // this handler does not define a variable, select it only if no other        // handler (of higher priority) has been selected        selectedCatch = currentCatch;        if (traceEnabled)          log.trace("selected catch with no type:" + selectedCatch);      }    }    return selectedCatch;  }  public List getOnEvents() {    return onEvents;  }  public void addOnEvent(OnEvent onEvent) {    adoptActivity(onEvent);    onEvents.add(onEvent);  }  public List getOnAlarms() {    return onAlarms;  }  public void addOnAlarm(OnAlarm onAlarm) {    adoptActivity(onAlarm);    onAlarms.add(onAlarm);  }  public boolean isIsolated() {    return isolated;  }  public void setIsolated(boolean isolated) {    this.isolated = isolated;  }  public boolean isImplicit() {    return implicit;  }  public void setImplicit(boolean implicit) {    this.implicit = implicit;  }  // composite activity override  // //////////////////////////////////////////////////////////////////////////  public boolean isScope() {    return true;  }  public VariableDefinition findVariable(String name) {    VariableDefinition variable = getVariable(name);    return variable != null ? variable : super.findVariable(name);  }  public CorrelationSetDefinition findCorrelationSet(String name) {    CorrelationSetDefinition correlationSet = getCorrelationSet(name);    return correlationSet != null ? correlationSet : super.findCorrelationSet(name);  }  public PartnerLinkDefinition findPartnerLink(String name) {    PartnerLinkDefinition partnerLink = getPartnerLink(name);    return partnerLink != null ? partnerLink : super.findPartnerLink(name);  }  public Node addNode(Node node) {    if (!(node instanceof Activity))      throw new IllegalArgumentException("not an activity: " + node);    setActivity((Activity) node);    return node;  }  public Node removeNode(Node node) {    if (node == null)      throw new IllegalArgumentException("node is null");    if (!node.equals(activity))      return null;    unsetActivity();    return node;  }  public void reorderNode(int oldIndex, int newIndex) {    if (activity == null || oldIndex != 0 || newIndex != 0) {      throw new IndexOutOfBoundsException("could not reorder element: oldIndex="          + oldIndex          + ", newIndex="          + newIndex);    }  }  public List getNodes() {    return activity != null ? Collections.singletonList(activity) : null;  }  public Node getNode(String name) {    return hasNode(name) ? activity : null;  }  public Map getNodesMap() {    return activity != null ? Collections.singletonMap(activity.getName(), activity) : null;  }  public boolean hasNode(String name) {    return activity != null && activity.getName().equals(name);  }  protected boolean isChildInitial(Activity child) {    /*     * this method is only invoked from child.isInitial() on its composite activity; therefore, it     * is valid to assume the argument is the primary activity of this scope     */    return true;  }  // activity override  // //////////////////////////////////////////////////////////////////////////  public GraphElement getParent() {    return isGlobal() ? processDefinition : super.getParent();  }  public ProcessDefinition getProcessDefinition() {    return isGlobal() ? processDefinition : super.getProcessDefinition();  }  public BpelProcessDefinition getBpelProcessDefinition() {    if (!isGlobal())      return super.getBpelProcessDefinition();    // check whether process definition reference has the proper type already    if (processDefinition instanceof BpelProcessDefinition)      return (BpelProcessDefinition) processDefinition;    // reacquire proxy of proper type    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();    BpelGraphSession graphSession = BpelGraphSession.getContextInstance(jbpmContext);    BpelProcessDefinition bpelProcessDefinition = graphSession.loadProcessDefinition(processDefinition.getId());    // update process definition reference    processDefinition = bpelProcessDefinition;    return bpelProcessDefinition;  }  protected boolean suppressJoinFailure() {    return isGlobal() ? getSuppressJoinFailure().booleanValue() : super.suppressJoinFailure();  }  public boolean isGlobal() {    return getCompositeActivity() == null;  }  public Collection findNestedScopes() {    /*     * start from the enclosed activity so that this scope does not appear in the resulting     * collection     */    NestedScopeFinder finder = new NestedScopeFinder();    activity.accept(finder);    return finder.getScopes();  }  public Scope findNestedScope(String name) {    for (Iterator i = findNestedScopes().iterator(); i.hasNext();) {      Scope nestedScope = (Scope) i.next();      if (nestedScope.getName().equals(name))        return nestedScope;    }    return null;  }  public ScopeInstance createInstance(Token token) {    ScopeInstance instance = ScopeInstance.createScopeInstance(this, token);    token.getProcessInstance().getContextInstance().createVariable(VARIABLE_NAME, instance, token);    return instance;  }  public ScopeInstance createEventInstance(Token token) {    ScopeInstance instance = ScopeInstance.createEventInstance(this, token);    token.getProcessInstance().getContextInstance().createVariable(VARIABLE_NAME, instance, token);    return instance;  }  public static ScopeInstance getInstance(Token token) {    return (ScopeInstance) token.getProcessInstance().getContextInstance().getVariable(        VARIABLE_NAME, token);  }  private static class NamedCatchPredicate implements Predicate {    private final QName faultName;    NamedCatchPredicate(QName faultName) {      this.faultName = faultName;    }    public boolean evaluate(Object arg) {      Catch catcher = (Catch) arg;      return faultName.equals(catcher.getFaultName());    }  }  private static final Predicate UNNAMED_CATCH_PREDICATE = new Predicate() {    public boolean evaluate(Object arg) {      Catch catcher = (Catch) arg;      return catcher.getFaultName() == null;    }  };}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -