// If a bundle has registered for a persistence unit
// then wrap the bundle to support the ClassLoader interface.
Bundle bundle = puToBundle.get(persistenceUnitName);
if (bundle != null) {
ClassLoader bundleClassLoader = new BundleProxyClassLoader(bundle);
loaders.add(bundleClassLoader);
}
if ((propertyClassLoader == null) && (bundle == null)) {
throw EntityManagerSetupException.couldNotFindPersistenceUnitBundle(persistenceUnitName);
}
// Add the EclipseLink Core bundle loader so we can see classes
// (such as platforms) in fragments,
BundleContext context = Activator.getContext();
if (context != null) {
// context is set in the Activator which may might
// not be called in an RCP application
Bundle[] bundles = context.getBundles();
Bundle coreBundle = null;
for (int i = 0; i < bundles.length; i++) {
if (ORG_ECLIPSE_PERSISTENCE_CORE.equals(bundles[i].getSymbolicName())) {
coreBundle = bundles[i];
loaders.add(new BundleProxyClassLoader(coreBundle));
break;
}
}
// Add the EclipseLink JPA bundle ClassLoader so that we can load
// EclipseLink classes.
ClassLoader eclipseLinkJpaClassLoader = new BundleProxyClassLoader(context.getBundle());
loaders.add(eclipseLinkJpaClassLoader);
}
// If the only classloader is the one passes as a property
// then no point building a composite--just use the one passed.