Ejemplo n.º 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);
 }
Ejemplo n.º 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);
   }
 }
Ejemplo n.º 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;
   }
 }
Ejemplo n.º 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());
         }
       }
     }
   }
 }
Ejemplo n.º 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);
   }
 }
Ejemplo n.º 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);
   }
 }
Ejemplo n.º 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;
  }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
  }
Ejemplo n.º 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);
   }
 }
Ejemplo n.º 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 + "\".");
    }
  }
Ejemplo n.º 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();
          }
        });
  }
Ejemplo n.º 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);
  }
Ejemplo n.º 14
0
 public boolean isVariableInitialized(VariableInstance var) {
   return _brc.isVariableInitialized(var);
 }
Ejemplo n.º 15
0
 public boolean isPartnerRoleEndpointInitialized(PartnerLinkInstance pLink) {
   return _brc.isPartnerRoleEndpointInitialized(pLink);
 }
Ejemplo n.º 16
0
 public void setAtomicScope(boolean atomicScope) {
   _brc.setAtomicScope(atomicScope);
 }
Ejemplo n.º 17
0
 public Node getProcessProperty(QName propertyName) {
   return _brc.getProcessProperty(propertyName);
 }
Ejemplo n.º 18
0
 public void setRetriesDone() {
   _brc.setAtomicScopeRetriesDone();
 }
Ejemplo n.º 19
0
 public boolean isCorrelationInitialized(CorrelationSetInstance correlationSet) {
   return _brc.isCorrelationInitialized(correlationSet);
 }
Ejemplo n.º 20
0
 public boolean isRetryable() {
   return _brc.isAtomicScopeRetryable();
 }
Ejemplo n.º 21
0
 /** Proxy to {@link ProcessControlContext#terminate()}. */
 public void terminate() {
   cleanupOutstandingMyRoleExchanges(null);
   _brc.terminate();
 }
Ejemplo n.º 22
0
 public int getRetryDelay() {
   return _brc.getAtomicScopeRetryDelay();
 }
Ejemplo n.º 23
0
 public boolean isFirstTry() {
   return _brc.isAtomicScopeFirstTry();
 }
Ejemplo n.º 24
0
 /** Proxy to {@link IOContext#getPartnerFaultExplanation(String) }. */
 public String getPartnerFaultExplanation(String mexId) {
   return _brc.getPartnerFaultExplanation(mexId);
 }
Ejemplo n.º 25
0
 /**
  * Proxy to {@link OdeRTInstanceContext#sendEvent(org.apache.ode.bpel.evt.ProcessInstanceEvent) }.
  */
 public void sendEvent(ProcessInstanceStartedEvent evt) {
   _brc.sendEvent(evt);
 }
Ejemplo n.º 26
0
 /** Proxy to {@link ProcessControlContext#forceFlush() }. */
 public void forceFlush() {
   _brc.forceFlush();
 }
Ejemplo n.º 27
0
 public void completedFault(FaultData faultData) {
   cleanupOutstandingMyRoleExchanges(faultData);
   _brc.completedFault(faultData);
 }
Ejemplo n.º 28
0
 public void setRetriedOnce() {
   _brc.setAtomicScopeRetriedOnce();
 }
Ejemplo n.º 29
0
 public void completedOk() {
   cleanupOutstandingMyRoleExchanges(null);
   _brc.completedOk();
 }
Ejemplo n.º 30
0
 /** Proxy to {@link ProcessControlContext#forceRollback() }. */
 public void forceRollback() {
   _brc.forceRollback();
 }