Package org.jbpm

Examples of org.jbpm.JbpmContext


   private void installProcessDefinitions()
   {
      if ( isProcessDeploymentEnabled() )
      {
         JbpmContext jbpmContext = getJbpmConfiguration().createJbpmContext();
         try
         {
            if (processDefinitions!=null)
            {
               for ( String definitionResource : processDefinitions )
               {
                  deployProcess(jbpmContext, definitionResource);
               }
            }
         }
         catch (RuntimeException e)
         {
            throw new RuntimeException("could not deploy a process definition", e);
         }
         finally
         {
            jbpmContext.close();
         }
      }
   }
View Full Code Here


      return pageflowConfiguration.createJbpmContext();
   }

   public static ProcessDefinition parseInputSource(InputSource inputSource)
   {
      JbpmContext jbpmContext = createPageflowContext();
      try
      {
         return new PageflowParser(inputSource).readProcessDefinition();
      }
      finally
      {
         jbpmContext.close();
      }
   }
View Full Code Here

    configuration.setObjectFactory(mockFactory);

    MockControl beanFactoryControl = MockControl.createNiceControl(BeanFactory.class);
    BeanFactory beanFactory = (BeanFactory) beanFactoryControl.getMock();

    JbpmContext context = new JbpmContext(null, mockFactory);
    factoryControl.expectAndReturn(mockFactory.createObject(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME), context, 3);
    beanFactoryControl.replay();
    factoryControl.replay();

    // configuration.setBeanFactory(beanFactory);
View Full Code Here

    MockControl factoryControl = MockControl.createControl(ObjectFactory.class);
    ObjectFactory mockFactory = (ObjectFactory) factoryControl.getMock();

    factoryControl.expectAndReturn(mockFactory.createObject(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME),
        new JbpmContext(null, mockFactory), 2);
    factoryControl.replay();
    configuration.setObjectFactory(mockFactory);
    configuration.afterPropertiesSet();

    JbpmConfiguration cfg = (JbpmConfiguration) configuration.getObject();
View Full Code Here

    configuration.setConfiguration(configurationResource);
    // configuration.setUseSpringObjectFactory(false);
    configuration.afterPropertiesSet();
    JbpmConfiguration cfg = (JbpmConfiguration) configuration.getObject();
    JbpmContext context = cfg.createJbpmContext();
  }
View Full Code Here

   */
  public static boolean hasPersistenceService(JbpmConfiguration configuration, String contextName) {
    Assert.notNull(configuration);
    String ctxName = (contextName == null ? JbpmContext.DEFAULT_JBPM_CONTEXT_NAME : contextName);

    JbpmContext context = configuration.createJbpmContext(ctxName);
    try {
      return hasPersistenceService(context);

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

   *
   * @param callback
   * @return
   */
  public Object execute(final JbpmCallback callback) {
    final JbpmContext context = getContext();

    try {
      // use the hibernateTemplate is present and if needed
      if (hibernateTemplate != null && hasPersistenceService) {

        // use hibernate template
        return hibernateTemplate.execute(new HibernateCallback() {
          /**
           * @see org.springframework.orm.hibernate3.HibernateCallback#doInHibernate(org.hibernate.Session)
           */
          public Object doInHibernate(Session session) throws HibernateException, SQLException {
            // inject the session in the context
            context.setSession(session);
            return callback.doInJbpm(context);
          }
        });
      }

View Full Code Here

   * Hook for subclasses for adding custom behavior.
   *
   * @return created of fetched from the thread jbpm context.
   */
  protected JbpmContext getContext() {
    JbpmContext context = jbpmConfiguration.createJbpmContext(contextName);

    return context;
  }
View Full Code Here

    // see if persistence is required

    // we don't have any other way to get the services then by creating a
    // jbpm context
    // secured in try/finally block
    JbpmContext dummy = getContext();
    try {

      if (JbpmUtils.hasPersistenceService(dummy)) {
        hasPersistenceService = true;
        logger.debug("jBPM persistence service present");
      }

      if (hibernateTemplate != null)
        logger.debug("hibernateTemplate present - jBPM persistence service will be managed by Spring");
      else {
        if (dummy.getSessionFactory() != null) {
          logger.debug("creating hibernateTemplate based on jBPM SessionFactory");
          hibernateTemplate = new HibernateTemplate(dummy.getSessionFactory());
        }
        else

          logger.debug("hibernateTemplate missing - jBPM will handle its own persistence");
      }

    }
    finally {
      dummy.close();
    }

  }
View Full Code Here

    else
      jbpmObjectFactory = objectFactory;

    jbpmConfiguration = new JbpmConfiguration(jbpmObjectFactory);

    JbpmContext context = null;
    try {
      // 2. inject the HB session factory if it is the case
      context = jbpmConfiguration.createJbpmContext(contextName);

      if (sessionFactory != null) {
        logger.info("using given Hibernate session factory");
        context.setSessionFactory(sessionFactory);
      }

      // 3. execute persistence operations
      hasPersistenceService = JbpmUtils.hasPersistenceService(jbpmConfiguration, contextName);

      if (hasPersistenceService) {
        logger.info("persistence service available...");
        if (createSchema) {
          logger.info("creating schema");
          jbpmConfiguration.createSchema(contextName);
        }

        if (processDefinitions != null || processDefinitionsResources != null) {
          if (processDefinitions != null) {
            String toString = Arrays.asList(processDefinitions).toString();
            logger.info("deploying process definitions:" + toString);

            // deploy the ProcessDefinitions
            for (int i = 0; i < processDefinitions.length; i++) {
              context.deployProcessDefinition(processDefinitions[i]);
            }
          }
          if (processDefinitionsResources != null) {
            ProcessDefinitionFactoryBean factory = new ProcessDefinitionFactoryBean();
            String toString = Arrays.asList(processDefinitionsResources).toString();
            logger.info("deploying process definitions (from resources):" + toString);

            for (int i = 0; i < processDefinitionsResources.length; i++) {
              factory.setDefinitionLocation(processDefinitionsResources[i]);
              factory.afterPropertiesSet();
              context.deployProcessDefinition((ProcessDefinition) factory.getObject());
            }
          }
        }
      }

      else {
        logger
            .info("persistence unavailable not available - schema create/drop and process definition deployment disabled");
      }

    }
    finally {
      if (context != null)
        context.close();
    }

  }
View Full Code Here

TOP

Related Classes of org.jbpm.JbpmContext

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.