Пример #1
0
 public void commitChanges(VariableInstance var, ScopeFrame scopeFrame, Node value)
     throws ExternalVariableModuleException {
   if (var.declaration.extVar != null) /* external variable */ {
     if (__log.isDebugEnabled())
       __log.debug(
           "Write external variable: name="
               + var.declaration
               + " value="
               + DOMUtils.domToString(value));
     VariableInstance related = scopeFrame.resolve(var.declaration.extVar.related);
     Node reference = null;
     try {
       reference = fetchVariableData(var, scopeFrame, true);
     } catch (FaultException fe) {
       // In this context this is not necessarily a problem, since the assignment may re-init the
       // related var
     }
     VariableContext.ValueReferencePair vrp = _brc.writeExtVar(var, reference, value);
     commitChanges(related, scopeFrame, vrp.reference);
   } else /* normal variable */ {
     if (__log.isDebugEnabled())
       __log.debug(
           "Write variable: name=" + var.declaration + " value=" + DOMUtils.domToString(value));
     _brc.commitChanges(var, value);
   }
   writeProperties(var, value);
 }
Пример #2
0
 /**
  * Proxy to {@link OdeRTInstanceContext#initializeVariable(Variable, Node)} then write properties.
  */
 public Node initializeVariable(VariableInstance var, ScopeFrame scopeFrame, Node val)
     throws ExternalVariableModuleException {
   try {
     if (var.declaration.extVar != null) /* external variable */ {
       if (__log.isDebugEnabled())
         __log.debug(
             "Initialize external variable: name="
                 + var.declaration
                 + " value="
                 + DOMUtils.domToString(val));
       Node reference = null;
       try {
         reference = fetchVariableData(var, scopeFrame, true);
       } catch (FaultException fe) {
         // In this context this is not necessarily a problem, since the assignment may re-init the
         // related var
       }
       if (reference != null) val = _brc.readExtVar(var, reference);
       return val;
     } else /* normal variable */ {
       if (__log.isDebugEnabled())
         __log.debug(
             "Initialize variable: name="
                 + var.declaration
                 + " value="
                 + DOMUtils.domToString(val));
       return _brc.initializeVariable(var, val);
     }
   } finally {
     writeProperties(var, val);
   }
 }
Пример #3
0
 public Node fetchVariableData(
     VariableInstance variable, ScopeFrame scopeFrame, boolean forWriting) throws FaultException {
   if (variable.declaration.extVar != null) {
     // Note, that when using external variables, the database will not contain the value of the
     // variable, instead we need to go the external variable subsystems.
     Element reference =
         (Element)
             _brc.fetchVariableData(
                 scopeFrame.resolve(variable.declaration.extVar.related), false);
     try {
       Node ret = _brc.readExtVar(variable, reference);
       if (ret == null) {
         throw new FaultException(
             _runtime._oprocess.constants.qnUninitializedVariable,
             "The external variable \""
                 + variable.declaration.name
                 + "\" has not been initialized.");
       }
       return ret;
     } catch (IncompleteKeyException ike) {
       // This indicates that the external variable needed to be written do, put has not been.
       __log.error(
           "External variable could not be read due to incomplete key; the following key "
               + "components were missing: "
               + ike.getMissing());
       throw new FaultException(
           _runtime._oprocess.constants.qnUninitializedVariable,
           "The extenral variable \""
               + variable.declaration.name
               + "\" has not been properly initialized;"
               + "the following key compoenents were missing:"
               + ike.getMissing());
     } catch (ExternalVariableModuleException e) {
       throw new BpelEngineException(e);
     }
   } else /* not external */ {
     Node data = _brc.fetchVariableData(variable, forWriting);
     if (data == null) {
       // Special case of messageType variables with no part
       if (variable.declaration.type instanceof OMessageVarType) {
         OMessageVarType msgType = (OMessageVarType) variable.declaration.type;
         if (msgType.parts.size() == 0) {
           Document doc = DOMUtils.newDocument();
           Element root = doc.createElement("message");
           doc.appendChild(root);
           return root;
         }
       }
       throw new FaultException(
           _runtime._oprocess.constants.qnUninitializedVariable,
           "The variable " + variable.declaration.name + " isn't properly initialized.");
     }
     return data;
   }
 }
Пример #4
0
 /** Record all values of properties of a 'MessageType' variable for efficient lookup. */
 private void writeProperties(VariableInstance variable, Node value) {
   if (variable.declaration.type instanceof OMessageVarType) {
     for (OProcess.OProperty property : variable.declaration.getOwner().properties) {
       OProcess.OPropertyAlias alias = property.getAlias(variable.declaration.type);
       if (alias != null) {
         try {
           String val =
               extractProperty((Element) value, alias, variable.declaration.getDescription());
           if (val != null) _brc.writeVariableProperty(variable, property.name, val);
         } catch (UninitializedVariableException uve) {
           // This really should not happen, since we are writing to a variable that we just
           // modified.
           __log.fatal(
               "Couldn't extract property '"
                   + property.toString()
                   + "' in property pre-extraction: "
                   + uve);
           throw new RuntimeException(uve);
         } catch (FaultException e) {
           // This will fail as we're basically trying to extract properties on all received
           // messages
           // for optimization purposes.
           if (__log.isDebugEnabled())
             __log.debug(
                 "Couldn't extract property '"
                     + property.toString()
                     + "' in property pre-extraction: "
                     + e.toString());
         }
       }
     }
   }
 }
Пример #5
0
 /** Called when the process completes to clean up any outstanding message exchanges. */
 private void cleanupOutstandingMyRoleExchanges(FaultInfo optionalFaultData) {
   // TODO: all this should be moved into the engine. We don't really need the ORM to find
   // these mexs, we can just scan the database
   String[] mexRefs = getORM().releaseAll();
   for (String mexId : mexRefs) {
     _brc.noreply(mexId, optionalFaultData);
   }
 }
Пример #6
0
 /** Proxy to {@link VariableContext#readVariableProperty(Variable, QName)}. */
 public String readProperty(VariableInstance variable, OProcess.OProperty property)
     throws FaultException {
   try {
     return _brc.readVariableProperty(variable, property.name);
   } catch (UninitializedVariableException e) {
     throw new FaultException(_runtime._oprocess.constants.qnUninitializedVariable);
   }
 }
Пример #7
0
  public Node fetchPartnerRoleEndpointReferenceData(PartnerLinkInstance link)
      throws FaultException {
    Element epr = _brc.fetchPartnerRoleEndpointReferenceData(link);
    if (epr == null) {
      throw new FaultException(_runtime._oprocess.constants.qnUninitializedPartnerRole);
    }

    return epr;
  }
Пример #8
0
 /**
  * Proxy to {@link RecoveryContext#registerActivityForRecovery(String, long, String, Date,
  * Element, String[], int)}.
  */
 public void registerActivityForRecovery(
     ActivityRecoveryChannel recoveryChannel,
     long id,
     String reason,
     Date dateTime,
     Element details,
     String[] actions,
     int retryCount) {
   _brc.registerActivityForRecovery(
       recoveryChannel.export(), id, reason, dateTime, details, actions, retryCount);
 }
Пример #9
0
  public void writeCorrelation(CorrelationSetInstance cset, CorrelationKey ckeyVal)
      throws FaultException {
    OScope.CorrelationSet csetdef = cset.declaration;
    QName[] propNames = new QName[csetdef.properties.size()];
    for (int m = 0; m < csetdef.properties.size(); m++) {
      OProcess.OProperty oProperty = csetdef.properties.get(m);
      propNames[m] = oProperty.name;
    }

    ckeyVal.setUnique(cset.declaration.isUnique());
    _brc.writeCorrelation(cset, propNames, ckeyVal);
  }
Пример #10
0
 /**
  * @param instance
  * @param operation
  * @param outboundMsg
  * @param object
  */
 public String invoke(
     String invokeId,
     PartnerLinkInstance instance,
     Operation operation,
     Element outboundMsg,
     Object object)
     throws FaultException {
   try {
     return _brc.invoke(invokeId, instance, operation, outboundMsg);
   } catch (UninitializedPartnerEPR e) {
     throw new FaultException(_runtime._oprocess.constants.qnUninitializedPartnerRole);
   }
 }
Пример #11
0
  /** Proxy to {@link IOContext#reply(PartnerLink, String, String, Element, QName) }. */
  public void reply(
      PartnerLinkInstance plink, String opName, String bpelmex, Element element, QName fault)
      throws FaultException {
    String mexid = getORM().release(plink, opName, bpelmex);
    if (mexid == null) throw new FaultException(_runtime._oprocess.constants.qnMissingRequest);

    try {
      _brc.reply(mexid, plink, opName, element, fault);
    } catch (NoSuchOperationException e) {
      // reply to operation that is either not defined or one-way. Perhaps this should be detected
      // at compile time?
      throw new FaultException(
          _runtime._oprocess.constants.qnMissingRequest,
          "Undefined two-way operation \"" + opName + "\".");
    }
  }
Пример #12
0
  /** Proxy to {@link BpelRuntimeContext# }. */
  public void cancel(PickResponseChannel responseChannel) {
    final String id = responseChannel.export();
    _brc.cancelSelect(id);

    getORM().cancel(id);

    _vpu.inject(
        new JacobRunnable() {
          private static final long serialVersionUID = 6157913683737696396L;

          public void run() {
            TimerResponseChannel responseChannel = importChannel(id, TimerResponseChannel.class);
            responseChannel.onCancel();
          }
        });
  }
Пример #13
0
  public void select(
      PickResponseChannel pickResponseChannel,
      Date timeout,
      boolean createInstance,
      Selector[] selectors)
      throws FaultException {

    final String pickResponseChannelStr = pickResponseChannel.export();

    int conflict = getORM().findConflict(selectors);
    if (conflict != -1)
      throw new FaultException(
          _runtime._oprocess.constants.qnConflictingReceive, selectors[conflict].toString());

    getORM().register(pickResponseChannelStr, selectors);

    _brc.select(pickResponseChannelStr, timeout, selectors);
  }
Пример #14
0
 public boolean isVariableInitialized(VariableInstance var) {
   return _brc.isVariableInitialized(var);
 }
Пример #15
0
 public boolean isPartnerRoleEndpointInitialized(PartnerLinkInstance pLink) {
   return _brc.isPartnerRoleEndpointInitialized(pLink);
 }
Пример #16
0
 public void setAtomicScope(boolean atomicScope) {
   _brc.setAtomicScope(atomicScope);
 }
Пример #17
0
 public Node getProcessProperty(QName propertyName) {
   return _brc.getProcessProperty(propertyName);
 }
Пример #18
0
 public void setRetriesDone() {
   _brc.setAtomicScopeRetriesDone();
 }
Пример #19
0
 public boolean isCorrelationInitialized(CorrelationSetInstance correlationSet) {
   return _brc.isCorrelationInitialized(correlationSet);
 }
Пример #20
0
 public boolean isRetryable() {
   return _brc.isAtomicScopeRetryable();
 }
Пример #21
0
 /** Proxy to {@link ProcessControlContext#terminate()}. */
 public void terminate() {
   cleanupOutstandingMyRoleExchanges(null);
   _brc.terminate();
 }
Пример #22
0
 public int getRetryDelay() {
   return _brc.getAtomicScopeRetryDelay();
 }
Пример #23
0
 public boolean isFirstTry() {
   return _brc.isAtomicScopeFirstTry();
 }
Пример #24
0
 /** Proxy to {@link IOContext#getPartnerFaultExplanation(String) }. */
 public String getPartnerFaultExplanation(String mexId) {
   return _brc.getPartnerFaultExplanation(mexId);
 }
Пример #25
0
 /**
  * Proxy to {@link OdeRTInstanceContext#sendEvent(org.apache.ode.bpel.evt.ProcessInstanceEvent) }.
  */
 public void sendEvent(ProcessInstanceStartedEvent evt) {
   _brc.sendEvent(evt);
 }
Пример #26
0
 /** Proxy to {@link ProcessControlContext#forceFlush() }. */
 public void forceFlush() {
   _brc.forceFlush();
 }
Пример #27
0
 public void completedFault(FaultData faultData) {
   cleanupOutstandingMyRoleExchanges(faultData);
   _brc.completedFault(faultData);
 }
Пример #28
0
 public void setRetriedOnce() {
   _brc.setAtomicScopeRetriedOnce();
 }
Пример #29
0
 public void completedOk() {
   cleanupOutstandingMyRoleExchanges(null);
   _brc.completedOk();
 }
Пример #30
0
 /** Proxy to {@link ProcessControlContext#forceRollback() }. */
 public void forceRollback() {
   _brc.forceRollback();
 }