コード例 #1
0
ファイル: PartnerLinkMyRoleImpl.java プロジェクト: zssdhl/ODE
  public void invokeNewInstance(MyRoleMessageExchangeImpl mex, RoutingInfo routing) {
    Operation operation = getMyRoleOperation(mex.getOperationName());

    if (__log.isDebugEnabled()) {
      __log.debug(
          "INPUTMSG: "
              + routing.correlator.getCorrelatorId()
              + ": routing failed, CREATING NEW INSTANCE");
    }
    ProcessDAO processDAO = _process.getProcessDAO();

    if (_process._pconf.getState() == ProcessState.RETIRED) {
      throw new InvalidProcessException(
          "Process is retired.", InvalidProcessException.RETIRED_CAUSE_CODE);
    }

    if (!_process.processInterceptors(mex, InterceptorInvoker.__onNewInstanceInvoked)) {
      __log.debug("Not creating a new instance for mex " + mex + "; interceptor prevented!");
      throw new InvalidProcessException(
          "Cannot instantiate process '" + _process.getPID() + "' any more.",
          InvalidProcessException.TOO_MANY_INSTANCES_CAUSE_CODE);
    }

    ProcessInstanceDAO newInstance = processDAO.createInstance(routing.correlator);

    BpelRuntimeContextImpl instance =
        _process.createRuntimeContext(newInstance, new PROCESS(_process.getOProcess()), mex);

    // send process instance event
    NewProcessInstanceEvent evt =
        new NewProcessInstanceEvent(
            new QName(_process.getOProcess().targetNamespace, _process.getOProcess().getName()),
            _process.getProcessDAO().getProcessId(),
            newInstance.getInstanceId());
    evt.setPortType(mex.getPortType().getQName());
    evt.setOperation(operation.getName());
    evt.setMexId(mex.getMessageExchangeId());
    _process._debugger.onEvent(evt);
    _process.saveEvent(evt, newInstance);
    mex.setCorrelationStatus(MyRoleMessageExchange.CorrelationStatus.CREATE_INSTANCE);
    mex.getDAO().setInstance(newInstance);
    if (mex.getDAO().getCreateTime() == null)
      mex.getDAO().setCreateTime(instance.getCurrentEventDateTime());

    _process._engine.acquireInstanceLock(newInstance.getInstanceId());
    instance.execute();
  }
コード例 #2
0
 private boolean deleteProcessDAO(BpelDAOConnection conn, QName pid) {
   final ProcessDAO proc = conn.getProcess(pid);
   if (proc != null) {
     // delete routes
     if (__log.isDebugEnabled()) __log.debug("Deleting only the process " + pid + "...");
     proc.deleteProcessAndRoutes();
     if (__log.isInfoEnabled()) __log.info("Deleted only the process " + pid + ".");
     // we do deferred instance cleanup only for hibernate, for now
     if (proc instanceof DeferredProcessInstanceCleanable
         && !DEFERRED_PROCESS_INSTANCE_CLEANUP_DISABLED) {
       // schedule deletion of process runtime data
       _engine._contexts.scheduler.scheduleMapSerializableRunnable(
           new ProcessCleanUpRunnable(((DeferredProcessInstanceCleanable) proc).getPidId()),
           new Date());
     } else if (proc instanceof DeferredProcessInstanceCleanable) {
       ((DeferredProcessInstanceCleanable) proc).deleteInstances(Integer.MAX_VALUE);
     }
     return true;
   }
   return false;
 }
コード例 #3
0
 private int compareInstanceUsingKey(
     String key, ProcessInstanceDAO instanceDAO1, ProcessInstanceDAO instanceDAO2) {
   String s1 = null;
   String s2 = null;
   boolean ascending = true;
   String orderKey = key;
   if (key.startsWith("+") || key.startsWith("-")) {
     orderKey = key.substring(1, key.length());
     if (key.startsWith("-")) ascending = false;
   }
   ProcessDAO process1 = getProcess(instanceDAO1.getProcess().getProcessId());
   ProcessDAO process2 = getProcess(instanceDAO2.getProcess().getProcessId());
   if ("pid".equals(orderKey)) {
     s1 = process1.getProcessId().toString();
     s2 = process2.getProcessId().toString();
   } else if ("name".equals(orderKey)) {
     s1 = process1.getProcessId().getLocalPart();
     s2 = process2.getProcessId().getLocalPart();
   } else if ("namespace".equals(orderKey)) {
     s1 = process1.getProcessId().getNamespaceURI();
     s2 = process2.getProcessId().getNamespaceURI();
   } else if ("version".equals(orderKey)) {
     s1 = "" + process1.getVersion();
     s2 = "" + process2.getVersion();
   } else if ("status".equals(orderKey)) {
     s1 = "" + instanceDAO1.getState();
     s2 = "" + instanceDAO2.getState();
   } else if ("started".equals(orderKey)) {
     s1 = ISO8601DateParser.format(instanceDAO1.getCreateTime());
     s2 = ISO8601DateParser.format(instanceDAO2.getCreateTime());
   } else if ("last-active".equals(orderKey)) {
     s1 = ISO8601DateParser.format(instanceDAO1.getLastActiveTime());
     s2 = ISO8601DateParser.format(instanceDAO2.getLastActiveTime());
   }
   if (ascending) return s1.compareTo(s2);
   else return s2.compareTo(s1);
 }
コード例 #4
0
 public int getNumInstances(QName processId) {
   ProcessDAO process = getProcess(processId);
   if (process != null) return process.getNumInstances();
   else return -1;
 }
コード例 #5
0
  @Override
  public void run() {
    // Remember all running PickReceive activities
    Set<OActivity> pickReceives = new HashSet<OActivity>();

    ActivityEventHandler evtHandler = ActivityEventHandler.getInstance();

    List<Running_Activity> activities = evtHandler.getRunningActivities();

    // Loop through all running activities
    for (Running_Activity run_Act : activities) {
      // Check if the activity belongs to our process instance
      if (run_Act.getProcessID().equals(getBpelRuntimeContext().getPid())) {
        // Get the activity over its xpath
        OActivity act =
            ReexecutionHandler.getActivity(
                run_Act.getXPath(), getBpelRuntimeContext().getBpelProcess().getOProcess());

        if (act != null) {
          if (act instanceof OPickReceive) {
            pickReceives.add(act);
          }
        }
      }
    }

    if (!pickReceives.isEmpty()) {
      ExecutionQueueImpl soup =
          (ExecutionQueueImpl) getBpelRuntimeContext().getVPU()._executionQueue;
      /*
       * Check the IMAManager for conflicting PickResponseChannels:
       */
      // Query the PickResponseChannels of all PICK's over the
      // execution queue
      // index list
      Set<PickResponseChannel> pickResponseChannels = new HashSet<PickResponseChannel>();
      if (!soup.getIndex().keySet().isEmpty()) {
        LinkedList<IndexedObject> list = null;

        Iterator<Object> keys = soup.getIndex().keySet().iterator();
        while (keys.hasNext()) {
          Key key = (Key) keys.next();
          if (key.getType().getClass() == OPickReceive.class) {
            if (pickReceives.contains(key.getType())) {
              list = soup.getIndex().get(key);
            } else {
              list = null;
            }
          }

          if (list != null) {
            Iterator<IndexedObject> iter = list.iterator();

            while (iter.hasNext()) {
              IndexedObject obj = iter.next();
              if (obj instanceof PICK) {
                pickResponseChannels.add(((PICK) obj).getPickResponseChannel());
              }
            }
          }
        }
      }

      for (PickResponseChannel channel : pickResponseChannels) {
        String channelStr = channel.export();
        // Remove the PickResponseChannel from the
        // IMAManager, if it is registered
        if (getBpelRuntimeContext().isIMAChannelRegistered(channelStr)) {
          getBpelRuntimeContext().cancelOutstandingRequests(channelStr);

          // Delete the corresponding outdated MessageRoute
          String correlatorStr =
              ChannelRegistry.getRegistry()
                  .getPickResponseChannelCorrelator(getBpelRuntimeContext().getPid(), channelStr);
          ProcessDAO process = getBpelRuntimeContext().getBpelProcess().getProcessDAO();
          CorrelatorDAO correlator = process.getCorrelator(correlatorStr);
          correlator.removeRoutes(
              channelStr, process.getInstance(getBpelRuntimeContext().getPid()));
        }
      }
    }

    instance(_iterationRunnable);
  }