I have a MVP application running as part of JBPM workbench. I notice in the human task service code this object can be used through injection however when I try to do this in my application I get a not bound issue on the injection of this interface - somewhere I am missing some plumbing to wire up this reference. I am able to get my application to work but instating everything as shown in the class below but I am concern as I think I am instantiating the EntityManagerFactory when I do not have to:
The class using persistence does this:
private JbpmServicesPersistenceManager pm = DakotaComponent.getPM();
The class that initializing the subsystem:
public abstract class DakotaComponent {
private static EntityManagerFactory emf = null;
private static JbpmServicesPersistenceManager pm = null;
/**
* Method to instantiate entity manager - override create tables when not in
* test mode.
*
* @param createTables
* if true have JPA create tables
* @return EntityManagerFactory for creating entity manager
*/
public static EntityManagerFactory getEntityManagerFactory(
boolean createTables) {
if (emf == null) {
if (createTables) {
emf = Persistence.createEntityManagerFactory("org.jbpm.domain");
} else {
HashMap<String, String> params = new HashMap<String, String>();
params.put("hibernate.hbm2ddl.auto", "none");
emf = Persistence.createEntityManagerFactory("org.jbpm.domain",
params);
}
}
return emf;
}
public static JbpmServicesPersistenceManager getPM()
{
if (pm == null)
{
JbpmServicesPersistenceManagerImpl pmImpl = new JbpmServicesPersistenceManagerImpl();
EntityManagerFactory emf = getEntityManagerFactory(false);
pmImpl.setEmf(emf);
EntityManager em = emf.createEntityManager();
pmImpl.setEm(emf.createEntityManager());
pmImpl.setTransactionManager(new JbpmJTATransactionManager());
pm =pmImpl;
}
return pm;
}
}