diff --git a/src/jpa-engine/core/pom.xml b/src/jpa-engine/core/pom.xml index 8b7c9835f..10d46173f 100644 --- a/src/jpa-engine/core/pom.xml +++ b/src/jpa-engine/core/pom.xml @@ -1,170 +1,212 @@ - 4.0.0 - - - com.impetus.kundera.core - core-parent - 2.11-SNAPSHOT - + 4.0.0 + com.impetus.kundera.core - kundera-core - jar - kundera-core - http://maven.apache.org + core-parent + 2.11-SNAPSHOT + + + com.impetus.kundera.core + kundera-core + jar + kundera-core + http://maven.apache.org - - - junit - junit - 4.8.2 - test - + + + junit + junit + 4.8.2 + test + - - directory-naming - naming-java - 0.8 - test - + + directory-naming + naming-java + 0.8 + test + - - commons-lang - commons-lang - 2.4 - - - javax.persistence - persistence-api - 2.0 - - - javax.validation - validation-api - 1.1.0.Final - - - cglib - cglib - 2.2.2 - + + commons-lang + commons-lang + 2.4 + + + javax.persistence + persistence-api + 2.0 + + + javax.validation + validation-api + 1.1.0.Final + + + cglib + cglib + 2.2.2 + - - commons-logging - commons-logging - 1.1.1 - - - - org.slf4j - slf4j-api - 1.7.5 - - - javassist - javassist - 3.12.1.GA - - - com.google.guava - guava - 13.0.1 - - - javax.transaction - jta - 1.1 - + + commons-logging + commons-logging + 1.1.1 + + + + org.slf4j + slf4j-api + 1.7.5 + + + javassist + javassist + 3.12.1.GA + + + com.google.guava + guava + 13.0.1 + + + javax.transaction + jta + 1.1 + - - com.thoughtworks.xstream - xstream - 1.4.3 - + + com.thoughtworks.xstream + xstream + 1.4.3 + - - - commons-configuration - commons-configuration - 1.9 - + + + commons-configuration + commons-configuration + 1.9 + - - - com.vividsolutions - jts - 1.11 - - - xerces - xercesImpl - - - + + + com.vividsolutions + jts + 1.11 + + + xerces + xercesImpl + + + + + org.osgi + org.osgi.core + 4.3.1 + jar + + + + + + + + maven-assembly-plugin + 2.2.1 + + + jar-with-dependencies + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8.1 + + private + true + + - - - - - - maven-assembly-plugin - 2.2.1 - - - jar-with-dependencies - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.8.1 - - private - true - - + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + test-jar + + + + + + **/index/LuceneIndexer.class + **/persistence/EntityReaderTest.class + + + + + + - - org.apache.maven.plugins - maven-jar-plugin - 2.2 - - - - test-jar - - - - - **/index/LuceneIndexer.class - **/persistence/EntityReaderTest.class - - - - - + + maven-jar-plugin + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + + org.apache.felix + maven-bundle-plugin + + + bundle-manifest + process-classes + + manifest + + + + + + ${project.groupId}.${project.artifactId} + ${project.artifactId} + ${project.version} + com.impetus.kundera.osgi.Activator + + com.impetus.kundera.* + + * + + + - - + + diff --git a/src/jpa-engine/core/src/main/java/com/impetus/kundera/configure/PersistenceUnitConfiguration.java b/src/jpa-engine/core/src/main/java/com/impetus/kundera/configure/PersistenceUnitConfiguration.java index dddee0bc6..51fb4ed0e 100644 --- a/src/jpa-engine/core/src/main/java/com/impetus/kundera/configure/PersistenceUnitConfiguration.java +++ b/src/jpa-engine/core/src/main/java/com/impetus/kundera/configure/PersistenceUnitConfiguration.java @@ -49,6 +49,8 @@ public class PersistenceUnitConfiguration extends AbstractSchemaConfiguration implements Configuration { + private ClassLoader classLoader = this.getClass().getClassLoader(); + /** The log instance. */ private static Logger log = LoggerFactory.getLogger(PersistenceUnitConfiguration.class); @@ -105,6 +107,8 @@ public void configure(PersistenceUnitInfo puInfo) { log.info("Loading Metadata from persistence.xml ..."); + this.classLoader = puInfo.getClassLoader(); + ApplicationMetadata appMetadata = kunderaMetadata.getApplicationMetadata(); Map metadatas = new HashMap(); @@ -132,7 +136,7 @@ private Map findPersistenceMetadatas() throws I Enumeration xmls = null; try { - xmls = this.getClass().getClassLoader().getResources(puLocation); + xmls = classLoader.getResources(puLocation); } catch (IOException ioex) { @@ -219,6 +223,8 @@ private void mergeProperties(PersistenceUnitInfo puInfo, ApplicationMetadata app { metadata.addJarFile(url.getPath()); } + + metadata.getProperties().put("com.vtrack.kundera.classloader", classLoader); } } diff --git a/src/jpa-engine/core/src/main/java/com/impetus/kundera/osgi/Activator.java b/src/jpa-engine/core/src/main/java/com/impetus/kundera/osgi/Activator.java new file mode 100644 index 000000000..1864827c1 --- /dev/null +++ b/src/jpa-engine/core/src/main/java/com/impetus/kundera/osgi/Activator.java @@ -0,0 +1,54 @@ +package com.impetus.kundera.osgi; + +import com.impetus.kundera.KunderaPersistence; +import java.util.Hashtable; +import javax.persistence.spi.PersistenceProvider; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +/** + * Used to discover/resolve JPA providers in an OSGi environment. + * + * @author v.dzalbo + */ +public class Activator implements BundleActivator { + + // following is so Aries can find and extend us for OSGi RFC 143 + public static final String PERSISTENCE_PROVIDER_ARIES = "javax.persistence.provider"; + // following would be set by Aries to expose their OSGi enabled provider + public static final String PERSISTENCE_PROVIDER = PersistenceProvider.class.getName(); + public static final String OSGI_PERSISTENCE_PROVIDER = KunderaPersistence.class.getName(); + private static BundleContext ctx = null; + private static ServiceRegistration svcReg = null; + + @Override + public void start(BundleContext ctx) throws Exception { + + + this.ctx = ctx; + PersistenceProvider provider = new KunderaPersistence(); + Hashtable props = new Hashtable(); + // Aries queries for service providers by property "javax.persistence.provider" + props.put(PERSISTENCE_PROVIDER_ARIES, OSGI_PERSISTENCE_PROVIDER); + // The persistence service tracker in the geronimo spec api bundle examines + // the property named "javax.persistence.PersistenceProvider" rather than + // the the property provided for Aries. In order to properly track the Kundera + // provider, this property must be set upon service registration. + props.put(PERSISTENCE_PROVIDER, OSGI_PERSISTENCE_PROVIDER); + svcReg = ctx.registerService(PERSISTENCE_PROVIDER, provider, props); + + } + + @Override + public void stop(BundleContext ctx) throws Exception { + if (svcReg != null) { + svcReg.unregister(); + svcReg = null; + } + this.ctx = null; + + } + +} diff --git a/src/kundera-mongo/pom.xml b/src/kundera-mongo/pom.xml index b62c1f48e..7b33c8d16 100644 --- a/src/kundera-mongo/pom.xml +++ b/src/kundera-mongo/pom.xml @@ -95,7 +95,41 @@ - --> + --> + + maven-jar-plugin + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + + org.apache.felix + maven-bundle-plugin + + + bundle-manifest + process-classes + + manifest + + + + + + ${project.groupId}.${project.artifactId} + ${project.artifactId} + ${project.version} + + com.impetus.client.mongodb.* + + * + + + + + diff --git a/src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBClient.java b/src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBClient.java index be3e601dc..16ef161dc 100644 --- a/src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBClient.java +++ b/src/kundera-mongo/src/main/java/com/impetus/client/mongodb/MongoDBClient.java @@ -453,8 +453,8 @@ public DBCursor getDBCursorInstance(BasicDBObject mongoQuery, BasicDBObject orde BasicDBObject keys, String documentName) { DBCollection dbCollection = mongoDb.getCollection(documentName); - DBCursor cursor = orderBy != null ? dbCollection.find(mongoQuery, keys).sort(orderBy) : dbCollection.find( - mongoQuery, keys).limit(maxResult); + DBCursor cursor = orderBy != null ? dbCollection.find(mongoQuery, keys).sort(orderBy).limit(maxResult) : + dbCollection.find(mongoQuery, keys).limit(maxResult); return cursor; }