Package org.jbpm.api

Examples of org.jbpm.api.ProcessEngine


* Hello world!
*/
public class App {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        ProcessEngine processEngine = (ProcessEngine) ctx.getBean("processEngine");
    }
View Full Code Here


  final static Map<String, ProcessEngine> processEngines = new HashMap<String, ProcessEngine>();

  private static final Log log = LogFactory.getLog(AntHelper.class);

  public static ProcessEngine getProcessEngine(String jbpmCfgXml) {
    ProcessEngine processEngine = (JbpmConfiguration) processEngines.get(jbpmCfgXml);
    if (processEngine == null) {
      Configuration configuration = new Configuration();
      if (jbpmCfgXml!=null) {
        log.debug("using jbpm configuration "+jbpmCfgXml);
        configuration.setResource(jbpmCfgXml);
View Full Code Here

    Thread currentThread = Thread.currentThread();
    ClassLoader originalClassLoader = currentThread.getContextClassLoader();
    currentThread.setContextClassLoader(JbpmDeployTask.class.getClassLoader());
    try {
      // get the JbpmConfiguration
      ProcessEngine processEngine = AntHelper.getProcessEngine(jbpmCfg);
     
      // if attribute process is set, deploy that process file
      if (file!=null) {
        deployFile(processEngine, file);
      }
View Full Code Here

  public ProcessEngineRefBinding() {
    super("process-engine-ref");
  }

  public Object parse(Element element, Parse parse, Parser parser) {
    ProcessEngine processEngine = (ProcessEngine) parse.findObject(ProcessEngine.class);
    return new ProcessEngineDescriptor(processEngine);
  }
View Full Code Here

      return;
    }
   
    database = args[0];
   
    ProcessEngine processEngine = new ConfigurationImpl()
        .skipDbCheck()
        .buildProcessEngine();
   
    try {
      processEngine.execute(new Command<Object>(){
        private static final long serialVersionUID = 1L;
        public Object execute(Environment environment) throws Exception {
          Session session = environment.get(Session.class);
          DbHelper.executeSqlResource("create/jbpm."+database+".create.sql", session);
          PropertyImpl.createProperties(session);
          return null;
        }
      });

      log.info("jBPM DB create completed successfully.");

    } catch (Exception e) {
      log.error("ERROR: jBPM DB create FAILED", e);

    } finally {
      processEngine.close();
    }
  }
View Full Code Here

      return;
    }
   
    database = args[0];
   
    ProcessEngine processEngine = new ConfigurationImpl()
      .skipDbCheck()
      .buildProcessEngine();
 
    try {
      JbpmVersion jbpmVersion = (JbpmVersion) processEngine.execute(new Command<Object>(){
        private static final long serialVersionUID = 1L;
        public Object execute(Environment environment) throws Exception {
          Session session = environment.get(Session.class);
          if (!PropertyImpl.propertiesTableExists(session)) {
            try {
              session.createSQLQuery("select CLASSNAME_ from JBPM4_VARIABLE").list();
              return JbpmVersion.V_4_1;

            } catch (HibernateException e) {
              return JbpmVersion.V_4_0;
            }
          }
   
          String dbVersion = PropertyImpl.getDbVersion(session);
          if (dbVersion == null) {
            throw new JbpmException("property table exists, but no db version property is present");
          }
   
          return JbpmVersion.getJbpmVersion(dbVersion);
        }
      });

      if (jbpmVersion == JbpmVersion.V_4_2) {
        throw new JbpmException("jBPM schema is already up to date");
      }

      if (jbpmVersion.isEarlier(JbpmVersion.V_4_1)) {
        processEngine.execute(new Command<Object>(){
          private static final long serialVersionUID = 1L;
          public Object execute(Environment environment) throws Exception {
            Session session = environment.get(Session.class);
            DbHelper.executeSqlResource("upgrade-4.0-to-4.1/jbpm." + database + ".upgrade.sql", session);
            return null;
          }
        });
      }

      if (jbpmVersion.isEarlier(JbpmVersion.V_4_2)) {
        processEngine.execute(new Command<Object>(){
          private static final long serialVersionUID = 1L;
          public Object execute(Environment environment) throws Exception {
            Session session = environment.get(Session.class);
            DbHelper.executeSqlResource("upgrade-4.1-to-4.2/jbpm." + database + ".upgrade.sql", session);
            PropertyImpl.upgradeProperties(session);
            return null;
          }
        });
        processEngine.execute(new Command<Object>(){
          private static final long serialVersionUID = 1L;
          public Object execute(Environment environment) throws Exception {
            Session session = environment.get(Session.class);
            // find deployments without a langid property
            List<DeploymentProperty> deploymentProperties = session.createCriteria(DeploymentProperty.class)
                .add(Restrictions.eq("key", DeploymentImpl.KEY_PROCESS_DEFINITION_ID))
                .list();

            for (DeploymentProperty deploymentProperty : deploymentProperties) {
              String objectName = deploymentProperty.getObjectName();
              DeploymentImpl deployment = deploymentProperty.getDeployment();
              deployment.setProcessLanguageId(objectName, "jpdl-4.0");
            }
            return null;
          }
        });
      }

      log.info("jBPM DB upgrade completed successfully.");

    } catch (Exception e) {
      log.error("ERROR: jBPM DB upgrade FAILED", e);

    } finally {
      processEngine.close();
    }
  }
View Full Code Here

  public <T> T withProcessToolContextNonJta(ReturningProcessToolContextCallback<T> callback) {
        T result = null;

    Session session = registry.getSessionFactory().openSession();
    try {
      ProcessEngine pi = getProcessEngine();
      try {
        Transaction tx = session.beginTransaction();
        try {
          ProcessToolContextImpl ctx = new ProcessToolContextImpl(session, this, pi);
          result = callback.processWithContext(ctx);
        } catch (RuntimeException e) {
          logger.log(Level.SEVERE, e.getMessage(), e);
          try {
            tx.rollback();
          } catch (Exception e1) {
            logger.log(Level.WARNING, e1.getMessage(), e1);
          }
          throw e;
        }
        tx.commit();
      }
      finally {
        pi.close();
      }
    } finally {
      session.close();
    }
        return result;
View Full Code Here

            }
            if (ut.getStatus() != Status.STATUS_ACTIVE)
                ut.begin();
            Session session = registry.getSessionFactory().getCurrentSession();
            try {
                ProcessEngine pi = getProcessEngine();
                try {
                    try {
                        ProcessToolContextImpl ctx = new ProcessToolContextImpl(session, this, pi);
                        result = callback.processWithContext(ctx);
                    } catch (Exception e) {
                        logger.log(Level.SEVERE, e.getMessage(), e);
                        try {
                            ut.rollback();
                        } catch (Exception e1) {
                            logger.log(Level.WARNING, e1.getMessage(), e1);
                        }
                        throw e;
                    }
                } finally {
                    pi.close();
                }
            } finally {
                session.flush();
            }
            ut.commit();
View Full Code Here

  {
    /* Create command and query */
       Command<List<T>> cmd = new ProcessEngineCommand();

       /* Execute specified query using given parameters */
       ProcessEngine processEngine = getProcessEngine(ctx);
       List<T> tasks = processEngine.execute(cmd);
      
       return tasks;
  }
View Full Code Here

   */
     private ProcessEngine getProcessEngine(ProcessToolContext ctx)
     {
       if (ctx instanceof ProcessToolContextImpl)
       {
         ProcessEngine engine = ((ProcessToolContextImpl) ctx).getProcessEngine();
         if (userAuthenticationLogin != null)
           engine.setAuthenticatedUserId(userAuthenticationLogin);

         return engine;
       }
       else
         throw new IllegalArgumentException(ctx + " not an instance of " + ProcessToolContextImpl.class.getName());
View Full Code Here

TOP

Related Classes of org.jbpm.api.ProcessEngine

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.