Fixes unlistedclasses regression introduced by config admin support
diff --git a/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/GeminiUtil.java b/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/GeminiUtil.java
index 71e587e..c143992 100644
--- a/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/GeminiUtil.java
+++ b/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/GeminiUtil.java
@@ -51,6 +51,9 @@
public static String OSGI_JDBC_DRIVER_VERSION_PROPERTY = "osgi.jdbc.driver.version";
public static String OSGI_JPA_PROVIDER_VERSION_PROPERTY = "osgi.jpa.provider.version";
+ // Private property used to pass punit info through to provider as a property
+ public static String PUNIT_INFO_PROPERTY = "gemini.jpa.punitInfo";
+
/*============================*/
/* Helper and Utility methods */
/*============================*/
@@ -164,6 +167,13 @@
}
}
+ // Function to print out series of objects for classloading purposes
+ public static void debugClassLoader(Object... args) {
+ if (GeminiSystemProperties.debugClassloader()) {
+ privateDebug(args);
+ }
+ }
+
// Function to print out debug string and classloader info for classloading debugging
public static void debugClassLoader(String s, ClassLoader cl) {
if (GeminiSystemProperties.debugClassloader()) {
diff --git a/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/ProviderWrapper.java b/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/ProviderWrapper.java
index 7bee719..27c19b5 100644
--- a/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/ProviderWrapper.java
+++ b/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/ProviderWrapper.java
@@ -17,6 +17,7 @@
import static org.eclipse.gemini.jpa.GeminiUtil.debug;
import static org.eclipse.gemini.jpa.GeminiUtil.fatalError;
+import static org.eclipse.gemini.jpa.GeminiUtil.PUNIT_INFO_PROPERTY;
import java.util.Collection;
import java.util.HashMap;
@@ -85,15 +86,15 @@
debug("ProviderWrapper createEMF invoked for p-unit: ", emName, " props: ", properties);
- PUnitInfo pUnitInfo = mgr.getPUnitsByName().get(emName);
- if (pUnitInfo == null)
+ PUnitInfo unitInfo = mgr.getPUnitsByName().get(emName);
+ if (unitInfo == null)
fatalError("createEntityManagerFactory() called on provider, but punit has not been registered: ", null);
// Create a new properties map and put all of the properties in it
Map<String,Object> props = new HashMap<String,Object>();
// First the props from config admin if any are there
- if (pUnitInfo.getConfigProperties() != null) {
- props.putAll(pUnitInfo.getConfigProperties());
+ if (unitInfo.getConfigProperties() != null) {
+ props.putAll(unitInfo.getConfigProperties());
}
// Now the props passed into this createEMF call (may overwrite config admin props)
if (properties != null) {
@@ -103,7 +104,7 @@
// Create a composite loader that loads from the punit bundle and the provider bundle
CompositeClassLoader compositeLoader = CompositeClassLoader.createCompositeLoader(
mgr.getBundleContext(),
- pUnitInfo.getBundle());
+ unitInfo.getBundle());
// Bug 385170 - If user supplies a classloader then tack it on the front
if (props.containsKey(PersistenceUnitProperties.CLASSLOADER)) {
ClassLoader userLoader = (ClassLoader) props.get(PersistenceUnitProperties.CLASSLOADER);
@@ -112,12 +113,15 @@
props.put(PersistenceUnitProperties.CLASSLOADER, compositeLoader);
// Pass in the data source as a property
- DataSource ds = mgr.getDataSourceUtil().acquireDataSource(pUnitInfo, properties);
+ DataSource ds = mgr.getDataSourceUtil().acquireDataSource(unitInfo, properties);
if (ds != null)
props.put(PersistenceUnitProperties.NON_JTA_DATASOURCE, ds);
// Specify the name and location of the persistence descriptor
- props.put(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, fullDescriptorPath(pUnitInfo));
+ props.put(PersistenceUnitProperties.ECLIPSELINK_PERSISTENCE_XML, fullDescriptorPath(unitInfo));
+
+ // Put in a private property that we can use later on in the call stack to get the punit info
+ props.put(PUNIT_INFO_PROPERTY, unitInfo);
// Now make the call
EntityManagerFactory emf = nativeProvider.createEntityManagerFactory(emName, props);
diff --git a/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/classloader/EclipseDotClasspathHelper.java b/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/classloader/EclipseDotClasspathHelper.java
index dad63bc..d3d38dc 100644
--- a/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/classloader/EclipseDotClasspathHelper.java
+++ b/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/classloader/EclipseDotClasspathHelper.java
@@ -15,7 +15,7 @@
package org.eclipse.gemini.jpa.classloader;
import static org.eclipse.gemini.jpa.GeminiUtil.close;
-import static org.eclipse.gemini.jpa.GeminiUtil.debug;
+import static org.eclipse.gemini.jpa.GeminiUtil.debugClassLoader;
import static org.eclipse.gemini.jpa.GeminiUtil.fatalError;
import java.io.InputStream;
@@ -53,11 +53,11 @@
InputStream in = null;
try {
in = resource.openStream();
- debug("Parsing Eclipse .classpath");
+ debugClassLoader("Parsing Eclipse .classpath");
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(in, handler);
String binPath = handler.getBinPath();
- debug("Finished parsing Eclipse .classpath: ", binPath);
+ debugClassLoader("Finished parsing Eclipse .classpath: ", binPath);
return binPath;
} catch(Throwable ex) {
fatalError("Could not parse .classpath ", ex);
diff --git a/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/eclipselink/BundleArchive.java b/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/eclipselink/BundleArchive.java
index 9b9d7fa..ef84e08 100644
--- a/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/eclipselink/BundleArchive.java
+++ b/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/eclipselink/BundleArchive.java
@@ -12,9 +12,12 @@
* Contributors:
* tware - initial implementation
* ssmith - support for user specified Eclipse project bin path
+ * mkeith - adapted to new property, changed to use gemini debugging
******************************************************************************/
package org.eclipse.gemini.jpa.eclipselink;
+import static org.eclipse.gemini.jpa.GeminiUtil.debugClassLoader;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -24,9 +27,6 @@
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.eclipse.gemini.jpa.classloader.EclipseDotClasspathHelper;
import org.eclipse.persistence.internal.jpa.deployment.ArchiveBase;
@@ -36,18 +36,12 @@
/**
* A bundle archive subclasses from EclipseLink's Bundle framework in order
* to allow use of the Bundle API to look inside persistence units.
- * @author tware
- *
*/
-@SuppressWarnings({"rawtypes","deprecation"})
public class BundleArchive extends ArchiveBase implements Archive {
protected Bundle bundle = null;
protected EclipseDotClasspathHelper pdeClasspathHelper = new EclipseDotClasspathHelper();
-
- @SuppressWarnings("unused")
- private Logger logger;
-
+
/**
* This is used for Eclipse PDE support. PDE does not always store entries
* at the root of the bundle. We store the size of the path prefix in the bundle when
@@ -56,20 +50,10 @@
*/
protected Integer pathPrefixSize = null;
- public BundleArchive(URL rootUrl, Map properties, String descriptorLocation) throws MalformedURLException {
- this(rootUrl, properties, descriptorLocation, Logger.global);
- }
-
- public BundleArchive(URL rootUrl, Map properties, String descriptorLocation, Logger logger)
+ public BundleArchive(URL rootUrl, String descriptorLocation, Bundle b)
throws MalformedURLException {
super(rootUrl, descriptorLocation);
- this.bundle = (Bundle)properties.get("org.eclipse.gemini.jpa.bundle");
- logger.entering("BundleArchive", "BundleArchive " + rootUrl);
- this.logger = logger;
-
- this.descriptorLocation = descriptorLocation;
- logger.logp(Level.FINER, "BundleArchive", "BundleArchive", // NOI18N
- "rootURL = {0}", rootURL); // NOI18N
+ this.bundle = b;
}
public Iterator<String> getEntries() {
@@ -93,9 +77,9 @@
e.printStackTrace();
}
}
+ debugClassLoader("BundleArchive.getEntries() found entries: ",result);
return result.iterator();
}
-
protected String trimClassName(String path){
return path.substring(pathPrefixSize);
@@ -115,6 +99,5 @@
return bundle.getEntry(entryPath);
}
- public void close() {
- }
+ public void close() {}
}
diff --git a/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/eclipselink/OSGiArchiveFactoryImpl.java b/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/eclipselink/OSGiArchiveFactoryImpl.java
index 7cc0031..cf6e752 100644
--- a/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/eclipselink/OSGiArchiveFactoryImpl.java
+++ b/org.eclipse.gemini.jpa/src/org/eclipse/gemini/jpa/eclipselink/OSGiArchiveFactoryImpl.java
@@ -11,42 +11,50 @@
*
* Contributors:
* tware - initial implementation
+ * mkeith - cleaned up, added debugging
******************************************************************************/
package org.eclipse.gemini.jpa.eclipselink;
+import static org.eclipse.gemini.jpa.GeminiUtil.debugClassLoader;
+
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Map;
-import java.util.logging.Level;
+import org.eclipse.gemini.jpa.GeminiUtil;
+import org.eclipse.gemini.jpa.PUnitInfo;
import org.eclipse.persistence.internal.jpa.deployment.ArchiveFactoryImpl;
import org.eclipse.persistence.internal.jpa.deployment.JarInputStreamURLArchive;
import org.eclipse.persistence.jpa.Archive;
/**
- * Subclass of EclipseLink's ArchiveFactoryImpl
+ * Subclass of EclipseLink's ArchiveFactoryImpl.
* This subclass allows construction of a BundleArchive which can use the Bundle API
- * to extract information out of a persistence unit
- * @author tware
- *
+ * to extract information out of a persistence unit.
*/
@SuppressWarnings({"rawtypes"})
public class OSGiArchiveFactoryImpl extends ArchiveFactoryImpl{
@Override
public Archive createArchive(URL rootUrl, String descriptorLocation, Map properties) throws URISyntaxException, IOException {
- logger.entering("ArchiveFactoryImpl", "createArchive", new Object[]{rootUrl, descriptorLocation});
- String protocol = rootUrl.getProtocol();
- logger.logp(Level.FINER, "ArchiveFactoryImpl", "createArchive", "protocol = {0}", protocol);
-
- if (properties != null && properties.get("org.eclipse.gemini.jpa.bundle") != null){
- if (isJarInputStream(rootUrl)){
- return new JarInputStreamURLArchive(rootUrl, descriptorLocation);
- } else {
- return new BundleArchive(rootUrl,properties, descriptorLocation, logger);
+ debugClassLoader("ArchiveFactoryImpl.createArchive, url=",rootUrl," descLocation=",descriptorLocation," props=",properties);
+
+ // Pull the bundle out from the PUnitInfo property (set by ProviderWrapper in createEMF call)
+ if (properties != null) {
+ PUnitInfo unitInfo = (PUnitInfo)properties.get(GeminiUtil.PUNIT_INFO_PROPERTY);
+ if (unitInfo != null) {
+ if (isJarInputStream(rootUrl)){
+ debugClassLoader(" returning JarInputStreamURLArchive");
+ return new JarInputStreamURLArchive(rootUrl, descriptorLocation);
+ } else {
+ debugClassLoader(" returning BundleArchive, bundle=",unitInfo.getBundle());
+ return new BundleArchive(rootUrl, descriptorLocation, unitInfo.getBundle());
+ }
}
}
+ // If none of that worked out then the call must have been through a different route
+ debugClassLoader(" returning default parent archive");
return super.createArchive(rootUrl, descriptorLocation, properties);
}
}