0 Replies Latest reply on May 27, 2016 8:25 AM by Shankar Vai

    JBPM PerProcessInstance without persistence

    Shankar Vai Newbie

      Hi,

      Can anyone please let me know how to set up a JBPM without persistence. I am using Per Process Instance strategy. I tried .persistence(false) but it failed.

       

      @Inject
      private static InjectableRegisterableItemsFactory factory;

      @PersistenceUnit(unitName = "jbpm.domain")

      private EntityManagerFactory emf;

      private RuntimeEnvironment environment;

      @Inject
      @Kjar
      private DeploymentService deploymentService;

      @Produces
      public EntityManagerFactory produceEntityManagerFactory() {

         if (this.emf == null) {

         this.emf = Persistence

        .createEntityManagerFactory("jbpm.domain");
         }

         return this.emf;
      }

       

      @Produces
      @Default
      @RequestScoped
      public EntityManager create() {

         return this.emf.createEntityManager();
      }

       

      public void dispose(@Disposes @Default EntityManager entityManager) {

         if (entityManager.isOpen()) {

        entityManager.close();
         }

      }

       

       

      @Produces
      @PerProcessInstance
      public RuntimeEnvironment produceEnvironment(EntityManagerFactory emf) {

         if (environment != null) {

        return environment;
         }

        

         environment = RuntimeEnvironmentBuilder.Factory.get()

        .newClasspathKmoduleDefaultBuilder("myBase", "my")

         .entityManagerFactory(emf)
         .registerableItemsFactory(factory)

        .addAsset(ResourceFactory

        .newClassPathResource("com/foo/WF.bpmn2"), ResourceType.BPMN2)

        .get();
        
        if (factory != null) {

         factory.setAuditlogger(new CustomWorkingMemoryLogger(emf, environment.getEnvironment()));
         }

        

         return environment;
      }

       

      @Produces
      public DeploymentService getDeploymentService() {

         return this.deploymentService;
      }

       

      @Produces
      public IdentityProvider produceIdentityProvider() {

         return new IdentityProviderImpl();
      }

       

      public class IdentityProviderImpl implements IdentityProvider {

         @Override
         public String getName() {

         return null;
         }

       

         @Override
         public List<String> getRoles() {

         return Collections.emptyList();
         }

       

         @Override
         public boolean hasRole(String arg0) {

         return false;
         }

      }