PersistenceUnitLoaderImplpublic class PersistenceUnitLoaderImpl extends Object implements PersistenceUnitLoader
Fields Summary |
---|
private static Logger | loggerlogger to log loader messages | private String | applicationLocation | private com.sun.enterprise.loader.InstrumentableClassLoader | classLoader | private Application | application | private static Map | integrationProperties |
Methods Summary |
---|
private void | closeEMFs(java.util.Collection entityManagerFactories)
logger.logp(Level.FINE, "PersistenceUnitLoaderImpl", "closeEMFs", // NOI18N
"entityManagerFactories.size() = {0}", // NOI18N
entityManagerFactories.size());
for (EntityManagerFactory emf : entityManagerFactories) {
try {
logger.logp(Level.FINE, "PersistenceUnitLoaderImpl",
"closeEMFs", "emf = {0}", emf);
emf.close();
} catch (Exception e) {
logger.log(Level.WARNING, e.getMessage(), e);
}
}
| public void | load(ApplicationInfo appInfo){@inheritDoc}
application = appInfo.getApplication();
applicationLocation = appInfo.getApplicationLocation();
classLoader = appInfo.getClassLoader();
if(logger.isLoggable(Level.FINE)) {
logger.fine("Loading persistence units for application: " +
applicationLocation);
}
for(PersistenceUnitDescriptor pu : appInfo.getReferencedPUs()) {
load(pu);
}
if(logger.isLoggable(Level.FINE)) {
logger.fine("Finished loading persistence units for application: " +
applicationLocation);
}
| private void | load(PersistenceUnitDescriptor pud)Loads an individual PersistenceUnitDescriptor and registers the
EntityManagerFactory in appropriate DOL structure.
if(logger.isLoggable(Level.FINE)) {
logger.fine("loading pud " + pud.getPuRoot()); // NOI18N
}
PersistenceUnitInfo pInfo = new PersistenceUnitInfoImpl(
pud,
applicationLocation,
classLoader);
if(logger.isLoggable(Level.FINE)) {
logger.fine("PersistenceInfo for this pud is :\n" + pInfo); // NOI18N
}
PersistenceProvider provider;
try {
// See we use application CL as opposed to system CL to load
// provider. This allows user to get hold of provider specific
// implementation classes in their code. But this also means
// provider must not use appserver implementation classes directly
// because once we implement isolation in our class loader hierarchy
// the only classes available to application class loader would be
// our appserver interface classes. By Sahoo
provider =
PersistenceProvider.class.cast(
ClassLoader.class.cast(classLoader)
.loadClass(pInfo.getPersistenceProviderClassName())
.newInstance());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
EntityManagerFactory emf = provider.createContainerEntityManagerFactory(
pInfo, integrationProperties);
logger.logp(Level.FINE, "PersistenceUnitLoaderImpl", "load", // NOI18N
"emf = {0}", emf); // NOI18N
RootDeploymentDescriptor rootDD = pud.getParent().getParent();
if (rootDD.isApplication()) {
Application.class.cast(rootDD).addEntityManagerFactory(
pInfo.getPersistenceUnitName(), pud.getPuRoot(), emf);
} else {
BundleDescriptor.class.cast(rootDD).addEntityManagerFactory(
pInfo.getPersistenceUnitName(), emf);
}
| public void | unload(ApplicationInfo appInfo){@inheritDoc}
application = appInfo.getApplication();
applicationLocation = appInfo.getApplicationLocation();
classLoader = appInfo.getClassLoader();
final boolean fineMsgLoggable = logger.isLoggable(Level.FINE);
if(fineMsgLoggable) {
logger.fine("Unloading persistence units for application: " + // NOI18N
applicationLocation);
}
closeEMFs(appInfo.getEntityManagerFactories());
if(fineMsgLoggable) {
logger.fine("Finished unloading persistence units for application: " + // NOI18N
applicationLocation);
}
|
|