Ejemplo n.º 1
0
  public void testReloadStates() throws Exception {
    File soupsDir =
        new File(CompatibilityTest.class.getClassLoader().getResource("soups").getFile());
    for (File soupState :
        soupsDir.listFiles(
            new FilenameFilter() {
              public boolean accept(File dir, String name) {
                return name.startsWith("soup");
              }
            })) {
      ExecutionQueueImpl soup = new ExecutionQueueImpl(CoreBpelTest.class.getClassLoader());

      soup.read(new FileInputStream(soupState));
      JacobVPU vpu = new JacobVPU(soup);
      CoreBpelTest instance = new CoreBpelTest();
      vpu.registerExtension(OdeRTInstanceContext.class, instance);

      instance._completedOk = false;
      instance._terminate = false;
      instance._fault = null;

      for (int i = 0;
          i < 1000 && !instance._completedOk && instance._fault == null && !instance._terminate;
          ++i) vpu.execute();
    }
  }
Ejemplo n.º 2
0
  public RuntimeInstanceImpl(RuntimeImpl runtime, ExecutionQueueImpl soup) {
    _runtime = runtime;
    _vpu = new JacobVPU();
    _vpu.registerExtension(OdeRTInstanceContext.class, this);
    if (soup == null) {
      _soup = new ExecutionQueueImpl(getClass().getClassLoader());
      _soup.setGlobalData(new OutstandingRequestManager());
    } else {
      _soup = soup;
    }

    _soup.setReplacementMap(_runtime._replacementMap);
    _vpu.setContext(_soup);
  }
Ejemplo n.º 3
0
 public String export() {
   if (type == Type.CHANNEL) {
     return JacobVPU.activeJacobThread().exportCommChannel(((CommChannel) target));
   } else {
     throw new UnsupportedOperationException("Cannot export channels of type " + type.toString());
   }
 }
Ejemplo n.º 4
0
  public void recoverActivity(
      final String channel, final long activityId, final String action, FaultInfo fault) {
    // TODO: better translation here?
    final FaultData fdata =
        (fault != null) ? new FaultData(fault.getFaultName(), null, fault.getExplanation()) : null;

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

          public void run() {
            ActivityRecoveryChannel recovery =
                importChannel(channel, ActivityRecoveryChannel.class);
            __log.info(
                "ActivityRecovery: Recovering activity "
                    + activityId
                    + " with action "
                    + action
                    + " on channel "
                    + recovery);
            if (recovery != null) {
              if ("cancel".equals(action)) recovery.cancel();
              else if ("retry".equals(action)) recovery.retry();
              else if ("fault".equals(action)) recovery.fault(fdata);
            }
          }
        });
  }
Ejemplo n.º 5
0
  /*
   * (non-Javadoc)
   *
   * @see org.apache.ode.bpel.engine.rapi.OdeInternalInstance#onInvokeResponse(java.lang.String, java.lang.String)
   */
  public void onInvokeResponse(final String invokeId, InvokeResponseType irt, final String mexid) {
    // NOTE: do the switch outside the inject, since we don't want to end up serializing
    // InvokeResponseType objects!
    switch (irt) {
      case REPLY:
        _vpu.inject(
            new BpelJacobRunnable() {
              private static final long serialVersionUID = -1095444335740879981L;

              public void run() {
                importChannel(invokeId, InvokeResponseChannel.class).onResponse();
              }
            });
        break;
      case FAULT:
        _vpu.inject(
            new BpelJacobRunnable() {
              private static final long serialVersionUID = -1095444335740879981L;

              public void run() {
                importChannel(invokeId, InvokeResponseChannel.class).onFault();
              }
            });
        break;
      case FAILURE:
        _vpu.inject(
            new BpelJacobRunnable() {
              private static final long serialVersionUID = -1095444335740879981L;

              public void run() {
                importChannel(invokeId, InvokeResponseChannel.class).onFailure();
              }
            });
        break;
    }
  }
Ejemplo n.º 6
0
  /*
   * (non-Javadoc)
   *
   * @see org.apache.ode.bpel.engine.rapi.OdeInternalInstance#onTimerEvent(java.lang.String)
   */
  public void onTimerEvent(final String timerId) {
    getORM().cancel(timerId);

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

          public void run() {
            // NOTE: note short cut, we chose timer id to be the same as the exported channel
            // representation.
            TimerResponseChannel responseChannel =
                importChannel(timerId, TimerResponseChannel.class);
            responseChannel.onTimeout();
          }
        });
  }
Ejemplo n.º 7
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.º 8
0
  /*
   * (non-Javadoc)
   *
   * @see org.apache.ode.bpel.engine.rapi.OdeInternalInstance#onMyRoleMessageExchange(java.lang.String, java.lang.String)
   */
  public void onSelectEvent(
      final String selectId, final String messageExchangeId, final int selectorIdx) {
    getORM().associate(selectId, messageExchangeId);

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

          public void run() {
            // NOTE: we chose the selectId to be the exported representation of the pick response
            // channel!
            PickResponseChannel responseChannel =
                importChannel(selectId, PickResponseChannel.class);
            responseChannel.onRequestRcvd(selectorIdx, messageExchangeId);
          }
        });
  }
Ejemplo n.º 9
0
 /* (non-Javadoc)
  * @see org.apache.ode.bpel.engine.rapi.OdeInternalInstance#createInstance(java.lang.String)
  */
 public void onCreateInstance(String messageExchangeId) {
   _vpu.inject(new PROCESS(_runtime._oprocess));
 }
Ejemplo n.º 10
0
 /*
  * (non-Javadoc)
  *
  * @see org.apache.ode.bpel.engine.rapi.OdeInternalInstance#execute()
  */
 public boolean execute() {
   return _vpu.execute();
 }