Methods Summary |
---|
public void | close()
getDelegate().close();
|
public javax.persistence.EntityManager | createEntityManager()
return getDelegate().createEntityManager();
|
public javax.persistence.EntityManager | createEntityManager(java.util.Map map)
return getDelegate().createEntityManager(map);
|
private javax.persistence.EntityManagerFactory | getDelegate()
if( entityManagerFactory == null ) {
entityManagerFactory = lookupEntityManagerFactory(unitName);
if( entityManagerFactory == null ) {
throw new IllegalStateException
("Unable to retrieve EntityManagerFactory for unitName "
+ unitName);
}
}
return entityManagerFactory;
|
public boolean | isOpen()
return getDelegate().isOpen();
|
static javax.persistence.EntityManagerFactory | lookupEntityManagerFactory(java.lang.String emfUnitName)Lookup physical EntityManagerFactory based on current component
invocation.
InvocationManager invMgr = Switch.getSwitch().getInvocationManager();
ComponentInvocation inv = invMgr.getCurrentInvocation();
EntityManagerFactory emf = null;
if( inv != null ) {
Object descriptor =
Switch.getSwitch().getDescriptorFor(inv.getContainerContext());
emf = lookupEntityManagerFactory(inv.getInvocationType(),
emfUnitName, descriptor);
}
return emf;
|
public static javax.persistence.EntityManagerFactory | lookupEntityManagerFactory(int invType, java.lang.String emfUnitName, java.lang.Object descriptor)
Application app = null;
BundleDescriptor module = null;
EntityManagerFactory emf = null;
switch (invType) {
case ComponentInvocation.EJB_INVOCATION:
EjbDescriptor ejbDesc = (EjbDescriptor) descriptor;
module = ejbDesc.getEjbBundleDescriptor();
app = module.getApplication();
break;
case ComponentInvocation.SERVLET_INVOCATION:
module = (WebBundleDescriptor) descriptor;
app = module.getApplication();
break;
case ComponentInvocation.APP_CLIENT_INVOCATION:
module = (ApplicationClientDescriptor) descriptor;
app = module.getApplication();
break;
default:
break;
}
// First check module-level for a match.
if (module != null) {
if (emfUnitName != null) {
emf = module.getEntityManagerFactory(emfUnitName);
} else {
Set<EntityManagerFactory> emFactories = module
.getEntityManagerFactories();
if (emFactories.size() == 1) {
emf = emFactories.iterator().next();
}
}
}
// If we're in an .ear and no module-level persistence unit was
// found, check for an application-level match.
if ((app != null) && (emf == null)) {
if (emfUnitName != null) {
emf = app.getEntityManagerFactory(emfUnitName, module);
} else {
Set<EntityManagerFactory> emFactories = app
.getEntityManagerFactories();
if (emFactories.size() == 1) {
emf = emFactories.iterator().next();
}
}
}
return emf;
|