Package org.uengine.processmanager

Examples of org.uengine.processmanager.ProcessManagerRemote


    }
    }

    public java.lang.Object getProcessVariable(java.lang.String in0, java.lang.String in1, java.lang.String in2) throws java.rmi.RemoteException {
        try {
          ProcessManagerRemote pm = processManagerFactory.getProcessManager();
      Object result = pm.getProcessVariable(in0, in1, in2);
      pm.applyChanges();
     
      return result;
    } catch (Exception e) {
      throw new RemoteException("WebServiceRemote:", e);
    }
View Full Code Here


        return null;
    }

    public void completeWorkitem(java.lang.String in0, java.lang.String in1, java.lang.String in2, org.uengine.kernel.ResultPayload in3) throws java.rmi.RemoteException {
        try {
          ProcessManagerRemote pm = processManagerFactory.getProcessManager();
      pm.completeWorkitem(in0, in1, in2, in3);
      pm.applyChanges();
    } catch (Exception e) {
      throw new RemoteException("WebServiceRemote:", e);
    }
    
    }
View Full Code Here

    String eventParentDivName = telnetMessage.getEventParentDivName();
    String eventDivName = telnetMessage.getEventDivName();
   
    if (!UEngineUtil.isNotEmpty(instanceId)) {
      ProcessManagerFactoryBean processManagerFactory = new ProcessManagerFactoryBean();
      ProcessManagerRemote pm = null;

      InitialContext context = null;
      UserTransaction tx = null;
      try {
        context = new InitialContext();
        tx = (GlobalContext.useManagedTransaction ? (UserTransaction) context.lookup(GlobalContext.USERTRANSACTION_JNDI_NAME) : null);
      } catch (NamingException e2) {
        e2.printStackTrace();
      }

      try {
        pm = processManagerFactory.getProcessManager();

        if (tx != null)
          tx.begin();

        String processDefinition = telnetMessage.getProcessDefinition();
        String endpoint = telnetMessage.getEndpoint();
       
        RoleMapping loggedRoleMapping = RoleMapping.create();
        loggedRoleMapping.setEndpoint(endpoint);

//        ActivityReference initiatorHumanActivityReference = pm.getInitiatorHumanActivityReference(processDefinition);
//        String initiatorDefVerId = initiatorHumanActivityReference.getActivity().getProcessDefinition().getId();
        String fantomInstanceId = pm.initialize(processDefinition, null, loggedRoleMapping);
       
//        ProcessInstance piRemote = pm.getProcessInstance(fantomInstanceId);
        pm.executeProcess(fantomInstanceId);
       
        pm.applyChanges();
       
        instanceId = fantomInstanceId;

        if (tx != null && tx.getStatus() != Status.STATUS_NO_TRANSACTION)
          tx.commit();

      } catch (Exception e) {
        try {
          pm.cancelChanges();
        } catch (Exception ex) {
        }

        try {
          if (tx != null && tx.getStatus() != Status.STATUS_NO_TRANSACTION)
            tx.rollback();
        } catch (IllegalStateException e1) {
          e1.printStackTrace();
        } catch (SecurityException e1) {
          e1.printStackTrace();
        } catch (SystemException e1) {
          e1.printStackTrace();
        }

      } finally {
        try {
          pm.remove();
        } catch (Exception e) {
        }
      }
    }
View Full Code Here

    roleMapping.setName(roleName);
   
   
    ProcessManagerFactoryBean processManagerFactory = new ProcessManagerFactoryBean();
    ProcessManagerRemote pm = null;

    InitialContext context = new InitialContext();
    UserTransaction tx = (GlobalContext.useManagedTransaction ? (UserTransaction) context.lookup(GlobalContext.USERTRANSACTION_JNDI_NAME) : null);

    boolean isSuccess = false;
   
    try {
      pm = processManagerFactory.getProcessManager();

      if (tx != null)
        tx.begin();

      isSuccess = workflowService.putRoleMapping(instanceId, roleMapping, pm);
      pm.applyChanges();

      if (tx != null && tx.getStatus() != Status.STATUS_NO_TRANSACTION)
        tx.commit();

    } catch (Exception e) {
      try {
        pm.cancelChanges();
      } catch (Exception ex) {
      }

      if (tx != null && tx.getStatus() != Status.STATUS_NO_TRANSACTION)
        tx.rollback();

    } finally {
      try {
        pm.remove();
      } catch (Exception e) {
      }
    }
   
    Element response = new Element(PUT_ROLEMAPPING_REQUEST, WORKFLOW_NAMESPACE).setText(String.valueOf(isSuccess));
View Full Code Here

    } else if ( WAITING_TYPE_WHILE.equals(howWait) ){
      final Thread waiter = new Thread(){

        public void run() {
          ProcessManagerFactoryBean pmfb = new ProcessManagerFactoryBean();
          ProcessManagerRemote pm = null;
          ProcessInstance instance = null;
         
          try {
            pm = pmfb.getProcessManager();
            instance = pm.getProcessInstance(instanceId);
          } catch (Exception e2) {
            try {
              pm.remove();
            } catch (RemoteException e) {
              e.printStackTrace();
            } catch (RemoveException e) {
              e.printStackTrace();
            }
            return;
          }

          try {
            Thread.sleep(getMilliSecond());
            fireComplete(instance);
            pm.applyChanges();
          } catch (Exception e) {
            try {
              pm.cancelChanges();
              pm.remove();
             
              pm = pmfb.getProcessManager();
              instance = pm.getProcessInstance(instanceId);

              fireFault(instance, e);
             
              pm.applyChanges();
            } catch (Exception e1) {
              e1.printStackTrace();
            }
          } finally{
            try {
              pm.remove();
            } catch (RemoteException e) {
              e.printStackTrace();
            } catch (RemoveException e) {
              e.printStackTrace();
            }
View Full Code Here

     String tracingTag = null;
  ProcessInstance instance = null;
  Activity activity = null;
//  boolean bRetry = false;
 
  ProcessManagerRemote pmb = null;
  try
  {     
    pmb = (new ProcessManagerFactoryBean()).getProcessManager();
   
    System.out.println ("WorkProcessor::onMessage() called...");
   
    MapMessage message = (MapMessage)omessage;
 
   
    String instanceId = message.getString("instance");
    String definitionName = message.getString("processDefinition");
    tracingTag = message.getString("tracingTag");
//    bRetry = message.getBoolean("retry");
//    String serviceName = message.getString("service");
//    String operationName = message.getString("operationName");

   
    instance = pmb.getProcessInstance(instanceId);
    if(instance.isRunning("")){ // if STOP signaled, don't execute anymore.
      activity = instance.getProcessDefinition().getActivity(tracingTag);
      activity.setRetryCount(instance, 5);
      instance.execute(tracingTag);
      pmb.applyChanges();
    }
   
    //ProcessDefinition pd = ProcessDefinition.getDefinition(definitionName, instance.getProcessTransactionContext());
   
/*    Parameter parameter = (Parameter)message.getObject("parameter");
    String endpoint = parameter.getEndpoint();
   
    Object[] parameters = parameter.getParameters();
    ServiceProvider sp = GlobalContext.getServiceProvider(serviceName);   
    for(int i=0; i<parameters.length; i++){
      if(parameters[i] instanceof ProcessVariable){
        parameters[i] = instance.get(tracingTag, ((ProcessVariable)parameters[i]).getName());
      }
    }
    Object result = sp.invokeService(endpoint, operationName, parameters);*/
   
  }
  catch(Throwable e)
  {
    try{
      pmb.cancelChanges();
    }catch(Exception ex){
      try{
        pmb.remove();
      }catch(Exception ex2){}
    }
   
    if(tracingTag !=null && instance!=null){
      UEngineException ue = null;
     
      if(!(e instanceof UEngineException)){
        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        e.printStackTrace(new PrintStream(bao));
        try{     
            ue = new UEngineException("uEngine Exception: " + e + "("+e.getMessage()+")", e);
            ue.setDetails(bao.toString());
        }catch(Exception e3){
          e3.printStackTrace();
        }
       
      }else
        ue = (UEngineException)e;
     
//      if(ejbContext.getEnvironment())
      try{   
        //fireFault must not be rolled back
        if(ue!=null){
          fireFault(instance, tracingTag, ue);
         
          /*LocalProcessManagerHomeLocal lpmh = (LocalProcessManagerHomeLocal)jndiContext.lookup("LocalProcessManagerHomeLocal");
          LocalProcessManagerLocal lpm = lpmh.create();
          lpm.fireFault(instance.getInstanceId(), tracingTag, ue);*/
         
          //instance.fireFault(tracingTag, ue);
        }
      }catch(Exception ex){
        ex.printStackTrace();
      }
    }
   
//    if(bRetry!=null)
    ejbContext.setRollbackOnly();
//    throw new EJBException((Exception)e);
  }finally{
    try {
      pmb.remove();
    } catch (RemoteException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (RemoveException e) {
      // TODO Auto-generated catch block
View Full Code Here

                }
               
              final boolean isRetrying = (retCnt > 0 && retCnt < maxRetry-1);
             
              ProcessManagerFactoryBean pmfb = new ProcessManagerFactoryBean();
              ProcessManagerRemote pm = null;
              ProcessInstance instance = null;
 
              try{
               
                if(act.isQueuingEnabled()){
                  pm = pmfb.getProcessManager();
                  instance = pm.getProcessInstance(instanceId);
                }else{
                  instance = finalInstance;
                }
               
                long timeInMillis_start = System.currentTimeMillis();
               
                System.out.println("- [uEngine] Start Executing Activity: " + act.getName() + " (" + act.getTracingTag() + ")");
               
               
                instance.execute(act.getTracingTag());
               
                long elapsedTime = (System.currentTimeMillis() - timeInMillis_start);
               
                PrintStream logWriter = (elapsedTime < ERROR_LEVEL_TIMEINMS ? System.out : System.err);
               
                logWriter.println("- [uEngine] End Executing Activity: " + act.getName() + " (" + act.getTracingTag() + ") - Elapsed Time : " + elapsedTime);
               
                if(pm!=null)
                  pm.applyChanges();
               
                success = true;
               
              }catch(Exception e){
 
                if(instance instanceof SimulatorProcessInstance){
                  try {
                    act.fireFault(instance, e);
                  } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                 
                }else{
                  UEngineException ue = null;
                  if(!(e instanceof UEngineException)){
                    ByteArrayOutputStream bao = new ByteArrayOutputStream();
                    e.printStackTrace(new PrintStream(bao));
                    try{     
                      ue = new UEngineException("uEngine Exception: " + e + "("+e.getMessage()+")", e);
                      ue.setDetails(bao.toString());
                    }catch(Exception e3){
                      e3.printStackTrace();
                    }
                 
                  }else
                    ue = (UEngineException)e;
                 
                  if(GlobalContext.useEJB)
                    WorkProcessorBean.fireFault(instance, act.getTracingTag(), ue);
                  else{
                   
                    final UEngineException finalUE = ue;
                   
                    /**
                     * run it after roll-back the main transaction to prevent that the fault marking job
                     * would be rolled back as well.
                     */
                    instance.getProcessTransactionContext().addTransactionListener(new TransactionListener(){
 
                      public void beforeCommit(TransactionContext tx) throws Exception {
                        // TODO Auto-generated method stub
                       
                      }
 
                      public void beforeRollback(TransactionContext tx) throws Exception {
                        // TODO Auto-generated method stub
                       
                      }
 
                      public void afterCommit(TransactionContext tx) throws Exception {
                        afterRollback(tx);
                       
                      }
 
                      public void afterRollback(TransactionContext tx) throws Exception {
                       
                        Thread faultMarker = new Thread(){
 
                          public void run() {
                            ProcessManagerFactoryBean pmfb = new ProcessManagerFactoryBean();
                            ProcessManagerRemote pm = null;
                            ProcessInstance instanceForFaultMarking = null;
         
                            try{
                              pm = pmfb.getProcessManager();
                              instanceForFaultMarking = pm.getProcessInstance(instanceId);
                              try{
                                //String oldStatus = act.getStatus(instanceForFaultMarking);
                               
                                act.fireFault(instanceForFaultMarking, finalUE);
                               
                                if(isRetrying){//Activity.STATUS_RETRYING.equals(oldStatus)){
                                  act.setStatus(instanceForFaultMarking, Activity.STATUS_RETRYING);
                                }
                               
                              }catch(Exception e){
                                throw new RuntimeException(e);
                                //e.printStackTrace();
                              }
                              pm.applyChanges();
                            } catch (Exception e1) {
                              if(pm!=null)
                                try {
                                  pm.cancelChanges();
                                } catch (RemoteException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                                }
                               
                            } finally{
                              try {
                                pm.remove();
                              } catch (RemoteException e2) {
                                // TODO Auto-generated catch block
                                e2.printStackTrace();
                              } catch (RemoveException e2) {
                                // TODO Auto-generated catch block
                                e2.printStackTrace();
                              }
                            }
                         
                          }
                         
                        };
                       
                        //faultMarker.run();
                        faultMarker.start(); //run it in a different thread if you want to make sure to separate the transaction.
                         
                      }
                     
                    });
                  }
                }
               
/*                if(act.isQueuingEnabled()){
                  try {
             
                    if(retCnt < act.getRetryLimit()){
                      act.setStatus(instance, Activity.STATUS_RETRYING);
                      act.setRetryCount(instance, retCnt+1);
                     
                      run(); //recursive call to retry
                    }
                  } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                  }
                }*/
 
               
                if(!act.isQueuingEnabled() && instance.getProcessTransactionContext().getSharedContext("faultTolerant")==null){

                  UEngineException richException = new UEngineException(e.getMessage(), null, e, instance, act);
                  throw new RuntimeException(richException);
                }
               
                if(pm!=null){
                  try {
                    pm.cancelChanges();
                  } catch (RemoteException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                  }
                }
              }finally{
                if(pm!=null)
                  try {
                    pm.remove();
                  } catch (RemoteException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                  } catch (RemoveException e) {
                    // TODO Auto-generated catch block
View Full Code Here

            return;
          }
         
          SubProcessActivity spAct = (SubProcessActivity)activity;
         
          ProcessManagerRemote pm = null;
          try{
            if(ptc.getProcessManager()!=null)
              pm = ptc.getProcessManager();
            else
              pm = (new ProcessManagerFactoryBean()).getProcessManagerForReadOnly();
     
            String versionId = pm.getProcessDefinitionProductionVersion(spAct.getDefinitionIdOnly());   
            ProcessDefinition spDef = ProcessDefinitionFactory.getInstance(ptc).getDefinition(versionId);
           
            if(spDef.isInitiateByFirstWorkitem()){
              ActivityReference actRefReturnedFromSP = spDef.getInitiatorHumanActivityReference(ptc);
             
              if(actRefReturnedFromSP==null){
                stop(null);
                return;
              }
             
              String scopeOfActFromSP = actRefReturnedFromSP.getAbsoluteTracingTag();
             
              if(scopeOfActFromSP == null){
                if(actRefReturnedFromSP.getActivity()!=null){
                  actRefReturnedFromSP.setAbsoluteTracingTag(spAct.getTracingTag() + "@" + actRefReturnedFromSP.getActivity().getTracingTag());
                  stop(actRefReturnedFromSP);
                  return;
                }
               
                stop(null);
                return;
              }
             
              actRefReturnedFromSP.setAbsoluteTracingTag(spAct.getTracingTag() + "@" + scopeOfActFromSP);
             
              stop(actRefReturnedFromSP);
            }
          }catch(Exception e){
            throw new RuntimeException(e);
          }finally{
            if(ptc.getProcessManager()==null)
              try {
                pm.remove();
              } catch (Exception e) {
              }
          }
        }
      }
View Full Code Here

   
    List<SchedulerItem> schedulerItems = this.getAllSchedule();
   
    for (final SchedulerItem item : schedulerItems) {
     
      ProcessManagerRemote pm = null;
      ProcessInstance instance = null;
     
      try {
        pm = pmfb.getProcessManager();
        try {
          instance = pm.getProcessInstance(item.getInstanceId());
        } catch (Exception e) {
        }
       
        if (instance != null) {
         
          if (item.getInstanceIsDeleted() == 0) {
            if (item.getStartDate().getTime() <= now.getTimeInMillis()) {
             
              instance.getProcessTransactionContext().addTransactionListener(new TransactionListener() {
               
                public void beforeRollback(TransactionContext tx) throws Exception {
                }
               
                public void beforeCommit(TransactionContext tx) throws Exception
                }
               
                public void afterRollback(TransactionContext tx) throws Exception
                }
               
                public void afterCommit(TransactionContext tx) throws Exception {
                  deleteSchedule(item.getIdx());   
                }
              });
             
              instance.getProcessDefinition().getActivity(item.getTracingTag()).fireComplete(instance);
             
            }
          } else {
            deleteSchedule(item.getIdx());
          }
        } else {
          deleteSchedule(item.getIdx());
        }
       
        pm.applyChanges()
     
      } catch (Exception e) {
        try {
          pm.cancelChanges();
        } catch (Exception e1) {
          e1.printStackTrace();
        }
      } finally{
        try {
          pm.remove();
        } catch (RemoteException e) {
          e.printStackTrace();
        } catch (RemoveException e) {
          e.printStackTrace();
        }
View Full Code Here

    out.close();
  }
 
  private String getDefinitionVersionResource(String defVerId) {
    ProcessManagerFactoryBean processManagerFactory = new ProcessManagerFactoryBean();
    ProcessManagerRemote pm = null;
    String content = null;
   
    try {
      pm = processManagerFactory.getProcessManagerForReadOnly();
      content = pm.getResource(defVerId);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        pm.remove();
      } catch (Exception e) {
      }
    }
   
    return content;
View Full Code Here

TOP

Related Classes of org.uengine.processmanager.ProcessManagerRemote

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.