Hi!
My first try:
public class JPAServiceOpenEJBImpl implements JPAService
{
public EntityManager getPersistenceContext( String unitName, String name ) {
// get JtaEntityManagerRegistry
JtaEntityManagerRegistry jtaEntityManagerRegistry =
SystemInstance.get().getComponent(JtaEntityManagerRegistry.class);
EntityManagerFactory factory = getPersistenceUnit( unitName );
JtaEntityManager jtaEntityManager = new
JtaEntityManager(jtaEntityManagerRegistry, factory, null, false);
return jtaEntityManager;
}
public EntityManagerFactory getPersistenceUnit( String unitName ) {
EntityManagerFactory factory;
try {
Context context =
SystemInstance.get().getComponent(ContainerSystem.class).getJNDIContext();
factory = (EntityManagerFactory)
context.lookup("openejb/PersistenceUnit/" + unitName);
} catch (NamingException e) {
throw new WebBeansCreationException( "PersistenceUnit '" + unitName
+ "' not found" );
}
return factory;
}
completely weird, or do I at least go in the right direction?
txs and LieGrue,
strub
--- Mark Struberg <[email protected]> schrieb am Mi, 25.3.2009:
> Von: Mark Struberg <[email protected]>
> Betreff: obtaining the JtaEntityManager
> An: [email protected]
> Datum: Mittwoch, 25. März 2009, 14:48
>
> Hi!
>
>
> I currently code the integration of OpenEJB into
> OpenWebBeans and need your help.
>
> The JSR-299 spec requires us to inject @PersistenceContext
> and @PersistenceUnit into contextual beans. If we are
> running with OpenEJB, I like to inject the JtaEntityManager
> OpenEJB provides. So my question is:
>
> How can I obtain the JtaEntityManager?
>
> Is there an easy way to get it from OpenEJB or hand over
> the control to let OpenEJB inject it into our beans field?
>
> txs in advance and LieGrue,
> strub
>
>
>
>