12-09-2013 12:33 AM
private BeanManager getBeanManager() {
try {
return (BeanManager) InitialContext.doLookup("java:comp/BeanManager");
}
catch (final NamingException e) {
e.printStackTrace();
}
return null;
}
@SuppressWarnings("unchecked")
private T lookup(final Class clazz) {
final BeanManager bm = getBeanManager();
final Iterator> iter = bm.getBeans(clazz).iterator();
if (!iter.hasNext()) {
throw new IllegalStateException("CDI BeanManager cannot find an instance of requested type " + clazz.getName());
}
final Bean bean = (Bean) iter.next();
final CreationalContext ctx = bm.createCreationalContext(bean);
return (T) bm.getReference(bean, clazz, ctx);
}
EntityManagerFactory emf = null;
EntityManager em = null;
BeanManager bm = getBeanManager();
emf = lookup(EntityManagerFactory.class);
System.out.println("Contents of emf ::::"+emf);
em = emf.createEntityManager();
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="dataSourceJndiName" value="java:comp/BeanManager" />
<property name="transactionsExternallyManaged" value="true" />
<property name="history" value="audit" />
<property name="jobExecutorActivate" value="true" />
<property name="jdbcUrl" value="jdbc:oracle:thin:@localhost:1521:xe" />
<property name="jdbcDriver" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUsername" value="fm" />
<property name="jdbcPassword" value="fm123" />
<property name="databaseSchemaUpdate" value="true" />
</bean>
</beans>
12-10-2013 07:29 AM
12-11-2013 12:39 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.