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);
 }
示例#2
0
  public void invokeInstance(MyRoleMessageExchangeImpl mex, RoutingInfo routing) {
    Operation operation = getMyRoleOperation(mex.getOperationName());
    if (__log.isDebugEnabled()) {
      __log.debug(
          "INPUTMSG: "
              + routing.correlator.getCorrelatorId()
              + ": ROUTING to existing instance "
              + routing.messageRoute.getTargetInstance().getInstanceId());
    }

    ProcessInstanceDAO instanceDao = routing.messageRoute.getTargetInstance();
    BpelProcess process2 =
        _process._engine._activeProcesses.get(instanceDao.getProcess().getProcessId());

    // Reload process instance for DAO.
    BpelRuntimeContextImpl instance = process2.createRuntimeContext(instanceDao, null, null);
    instance.inputMsgMatch(routing.messageRoute.getGroupId(), routing.messageRoute.getIndex(), mex);

    // Kill the route so some new message does not get routed to
    // same process instance.
    routing.correlator.removeRoutes(routing.messageRoute.getGroupId(), instanceDao);

    // send process instance event
    CorrelationMatchEvent evt =
        new CorrelationMatchEvent(
            new QName(process2.getOProcess().targetNamespace, process2.getOProcess().getName()),
            process2.getProcessDAO().getProcessId(),
            instanceDao.getInstanceId(),
            routing.matchedKeySet);
    evt.setPortType(mex.getPortType().getQName());
    evt.setOperation(operation.getName());
    evt.setMexId(mex.getMessageExchangeId());

    process2._debugger.onEvent(evt);
    // store event
    process2.saveEvent(evt, instanceDao);

    mex.setCorrelationStatus(MyRoleMessageExchange.CorrelationStatus.MATCHED);
    mex.getDAO().setInstance(routing.messageRoute.getTargetInstance());
    if (mex.getDAO().getCreateTime() == null)
      mex.getDAO().setCreateTime(instance.getCurrentEventDateTime());

    instance.execute();
  }