You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by tj...@apache.org on 2015/01/07 20:37:45 UTC
svn commit: r1650143 [3/7] - in /aries/branches/subsystemsR6: ./ blueprint/
blueprint/blueprint-authz/
blueprint/blueprint-authz/src/main/java/org/apache/aries/blueprint/authorization/impl/
blueprint/blueprint-authz/src/test/java/org/apache/aries/bluep...
Modified: aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java Wed Jan 7 19:37:42 2015
@@ -45,11 +45,7 @@ import javax.transaction.UserTransaction
import org.apache.aries.jpa.container.itest.entities.Car;
import org.apache.aries.jpa.itest.AbstractJPAItest;
-import org.junit.Ignore;
import org.junit.Test;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.CoreOptions;
-import org.ops4j.pax.exam.Option;
public abstract class JPAContextTest extends AbstractJPAItest {
@@ -82,7 +78,6 @@ public abstract class JPAContextTest ext
EntityManagerFactory emf = getProxyEMF(BP_TEST_UNIT);
final EntityManager managedEm = emf.createEntityManager();
-
ensureTREBehaviour(false, managedEm, "contains", new Object());
ensureTREBehaviour(false, managedEm, "createNamedQuery", "hi");
ensureTREBehaviour(false, managedEm, "createNativeQuery", "hi");
@@ -116,8 +111,7 @@ public abstract class JPAContextTest ext
ensureTREBehaviour(true, managedEm, "find", Object.class, new Object(), LockModeType.OPTIMISTIC);
ensureTREBehaviour(false, managedEm, "find", Object.class, new Object(), LockModeType.NONE,
new HashMap());
- ensureTREBehaviour(true, managedEm, "find", Object.class, new Object(), LockModeType.OPTIMISTIC,
- new HashMap());
+ ensureTREBehaviour(true, managedEm, "find", Object.class, new Object(), LockModeType.OPTIMISTIC, new HashMap());
ensureTREBehaviour(false, managedEm, "getCriteriaBuilder");
ensureTREBehaviour(true, managedEm, "getLockMode", new Object());
ensureTREBehaviour(false, managedEm, "getMetamodel");
@@ -139,7 +133,11 @@ public abstract class JPAContextTest ext
ensureTREBehaviour(false, managedEm, "createNativeQuery", "hi", "hi");
ensureTREBehaviour(false, managedEm, "createQuery", "hi");
ensureTREBehaviour(false, managedEm, "find", Object.class, new Object());
+ ut.rollback();
+ ut.begin();
ensureTREBehaviour(false, managedEm, "flush");
+ ut.rollback();
+ ut.begin();
ensureTREBehaviour(false, managedEm, "getDelegate");
ensureTREBehaviour(false, managedEm, "getFlushMode");
ensureTREBehaviour(false, managedEm, "getReference", Object.class, new Object());
@@ -333,41 +331,48 @@ public abstract class JPAContextTest ext
assertEquals("black", list.get(0).getColour());
assertEquals("C3CCC", list.get(0).getNumberPlate());
- assertEquals(5, list.get(1).getNumberOfSeats());
- assertEquals(1200, list.get(1).getEngineSize());
- assertEquals("blue", list.get(1).getColour());
+ assertEquals(2, list.get(1).getNumberOfSeats());
+ assertEquals(2000, list.get(1).getEngineSize());
+ assertEquals("red", list.get(1).getColour());
assertEquals("A1AAA", list.get(1).getNumberPlate());
}
- private void ensureTREBehaviour(boolean expectedToFail, EntityManager em, String methodName, Object... args) throws Exception {
- List<Class<?>> argTypes = new ArrayList<Class<?>>();
- for(Object o : args) {
- if(o instanceof Map)
- argTypes.add(Map.class);
- else if (o instanceof CriteriaQuery)
- argTypes.add(CriteriaQuery.class);
- else
- argTypes.add(o.getClass());
- }
-
- Method m = EntityManager.class.getMethod(methodName,
- argTypes.toArray(new Class[args.length]));
-
- try {
- m.invoke(em, args);
- if(expectedToFail)
- fail("A transaction is required");
- } catch (InvocationTargetException ite) {
- if(expectedToFail &&
- !!!(ite.getCause() instanceof TransactionRequiredException))
- fail("We got the wrong failure. Expected a TransactionRequiredException" +
- ", got a " + ite.toString());
- else if (!!!expectedToFail &&
- ite.getCause() instanceof TransactionRequiredException)
- fail("We got the wrong failure. Expected not to get a TransactionRequiredException" +
- ", but we got one anyway!");
+ private void ensureTREBehaviour(boolean expectedToFail, EntityManager em, String methodName,
+ Object... args) throws Exception {
+ List<Class<?>> argTypes = new ArrayList<Class<?>>();
+ for (Object o : args) {
+ if (o instanceof Map)
+ argTypes.add(Map.class);
+ else if (o instanceof CriteriaQuery)
+ argTypes.add(CriteriaQuery.class);
+ else
+ argTypes.add(o.getClass());
+ }
+
+ Method m = EntityManager.class.getMethod(methodName, argTypes.toArray(new Class[args.length]));
+
+ try {
+ m.invoke(em, args);
+ if (expectedToFail) {
+ fail("Should have failed with TransactionRequiredException");
+ }
+ } catch (InvocationTargetException ite) {
+ Throwable e = ite;
+ while(e != null && !(e instanceof TransactionRequiredException)) {
+ e = e.getCause();
+ }
+ if(e==null) {
+ e = ite.getCause();
+ }
+ if (expectedToFail && !(ite.getCause() instanceof TransactionRequiredException)) {
+ fail("We got the wrong failure. Expected a TransactionRequiredException" + ", got a "
+ + ite.toString());
+ } else if (!expectedToFail && ite.getCause() instanceof TransactionRequiredException) {
+ fail("We got the wrong failure. Expected not to get a TransactionRequiredException"
+ + ", but we got one anyway!");
+ }
+ }
}
- }
}
Modified: aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/OpenjpaContextTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/OpenjpaContextTest.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/OpenjpaContextTest.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/OpenjpaContextTest.java Wed Jan 7 19:37:42 2015
@@ -26,7 +26,7 @@ public class OpenjpaContextTest extends
public Option[] configuration() {
return options(
baseOptions(),
- ariesJpa(),
+ ariesJpa20(),
transactionWrapper(),
openJpa(),
testBundle()
Modified: aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java Wed Jan 7 19:37:42 2015
@@ -28,147 +28,178 @@ import org.osgi.framework.ServiceReferen
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public abstract class AbstractJPAItest extends AbstractIntegrationTest {
- protected static final String TEST_UNIT = "test-unit";
- protected static final String BP_TEST_UNIT = "bp-test-unit";
- protected static final String BP_XA_TEST_UNIT = "bp-xa-test-unit";
- protected static final String TEST_BUNDLE_NAME = "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle";
- private static final String FILTER_CONTAINER_MANAGED = "(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)";
- private static final String FILTER_PROXY = "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*)";
-
- protected void registerClient(String unitName) {
- PersistenceContextProvider provider = context().getService(PersistenceContextProvider.class);
- HashMap<String, Object> props = new HashMap<String, Object>();
- props.put(PersistenceContextProvider.PERSISTENCE_CONTEXT_TYPE, PersistenceContextType.TRANSACTION);
- provider.registerContext(unitName, bundleContext.getBundle(), props);
- }
-
- protected EntityManagerFactory getProxyEMF(String name) {
- return context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=" + name + ")"
- + FILTER_CONTAINER_MANAGED + FILTER_PROXY +")");
- }
-
- protected EntityManagerFactory getEMF(String name) {
- return context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=" + name + ")" + FILTER_CONTAINER_MANAGED + ")");
- }
-
- @SuppressWarnings("rawtypes")
- protected ServiceReference[] getEMFRefs(String name) throws InvalidSyntaxException {
- return bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=" + name + ")"
- + FILTER_CONTAINER_MANAGED + ")");
- }
-
- @SuppressWarnings("rawtypes")
- protected ServiceReference[] getProxyEMFRefs(String name)
- throws InvalidSyntaxException {
- return bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=" + name + ")"
- + FILTER_CONTAINER_MANAGED + FILTER_PROXY + ")");
- }
+ protected static final String TEST_UNIT = "test-unit";
+ protected static final String BP_TEST_UNIT = "bp-test-unit";
+ protected static final String BP_XA_TEST_UNIT = "bp-xa-test-unit";
+ protected static final String TEST_BUNDLE_NAME = "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle";
+ private static final String FILTER_CONTAINER_MANAGED = "(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)";
+ private static final String FILTER_PROXY = "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*)";
+
+ protected void registerClient(String unitName) {
+ PersistenceContextProvider provider = context().getService(PersistenceContextProvider.class);
+ HashMap<String, Object> props = new HashMap<String, Object>();
+ props.put(PersistenceContextProvider.PERSISTENCE_CONTEXT_TYPE, PersistenceContextType.TRANSACTION);
+ provider.registerContext(unitName, bundleContext.getBundle(), props);
+ }
+
+ protected EntityManagerFactory getProxyEMF(String name) {
+ String filter = "(&(osgi.unit.name=" + name + ")" + FILTER_CONTAINER_MANAGED + FILTER_PROXY + ")";
+ return context().getService(EntityManagerFactory.class, filter, 5000);
+ }
+
+ protected EntityManagerFactory getEMF(String name) {
+ return context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=" + name + ")" + FILTER_CONTAINER_MANAGED + ")");
+ }
+
+ @SuppressWarnings("rawtypes")
+ protected ServiceReference[] getEMFRefs(String name) throws InvalidSyntaxException {
+ return bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=" + name + ")"
+ + FILTER_CONTAINER_MANAGED + ")");
+ }
+ @SuppressWarnings("rawtypes")
+ protected ServiceReference[] getProxyEMFRefs(String name) throws InvalidSyntaxException {
+ return bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=" + name + ")"
+ + FILTER_CONTAINER_MANAGED + FILTER_PROXY + ")");
+ }
+
+ private MavenArtifactProvisionOption mvnBundle(String groupId, String artifactId) {
+ return mavenBundle(groupId, artifactId).versionAsInProject();
+ }
- protected Option baseOptions() {
+ protected Option baseOptions() {
String localRepo = System.getProperty("maven.repo.local");
-
+
if (localRepo == null) {
localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
}
- return composite(
- junitBundles(),
+ return composite(junitBundles(),
mavenBundle("org.ops4j.pax.logging", "pax-logging-api", "1.7.2"),
mavenBundle("org.ops4j.pax.logging", "pax-logging-service", "1.7.2"),
- mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
+ mvnBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
// this is how you set the default log level when using pax
// logging (logProfile)
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
- when(localRepo != null).useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo))
- );
+ when(localRepo != null).useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)));
+ }
+
+ private Option ariesJpaInternal() {
+ return composite(
+ frameworkProperty("org.osgi.framework.system.packages")
+ .value("javax.accessibility,javax.activation,javax.activity,javax.annotation,javax.annotation.processing,javax.crypto,javax.crypto.interfaces,javax.crypto.spec,javax.imageio,javax.imageio.event,javax.imageio.metadata,javax.imageio.plugins.bmp,javax.imageio.plugins.jpeg,javax.imageio.spi,javax.imageio.stream,javax.jws,javax.jws.soap,javax.lang.model,javax.lang.model.element,javax.lang.model.type,javax.lang.model.util,javax.management,javax.management.loading,javax.management.modelmbean,javax.management.monitor,javax.management.openmbean,javax.management.relation,javax.management.remote,javax.management.remote.rmi,javax.management.timer,javax.naming,javax.naming.directory,javax.naming.event,javax.naming.ldap,javax.naming.spi,javax.net,javax.net.ssl,javax.print,javax.print.attribute,javax.print.attribute.standard,javax.print.event,javax.rmi,javax.rmi.CORBA,javax.rmi.ssl,javax.script,javax.security.auth,javax.security.auth.callback,javax.security.auth.kerberos,ja
vax.security.auth.login,javax.security.auth.spi,javax.security.auth.x500,javax.security.cert,javax.security.sasl,javax.sound.midi,javax.sound.midi.spi,javax.sound.sampled,javax.sound.sampled.spi,javax.sql,javax.sql.rowset,javax.sql.rowset.serial,javax.sql.rowset.spi,javax.swing,javax.swing.border,javax.swing.colorchooser,javax.swing.event,javax.swing.filechooser,javax.swing.plaf,javax.swing.plaf.basic,javax.swing.plaf.metal,javax.swing.plaf.multi,javax.swing.plaf.synth,javax.swing.table,javax.swing.text,javax.swing.text.html,javax.swing.text.html.parser,javax.swing.text.rtf,javax.swing.tree,javax.swing.undo,javax.tools,javax.xml,javax.xml.bind,javax.xml.bind.annotation,javax.xml.bind.annotation.adapters,javax.xml.bind.attachment,javax.xml.bind.helpers,javax.xml.bind.util,javax.xml.crypto,javax.xml.crypto.dom,javax.xml.crypto.dsig,javax.xml.crypto.dsig.dom,javax.xml.crypto.dsig.keyinfo,javax.xml.crypto.dsig.spec,javax.xml.datatype,javax.xml.namespace,javax.xml.parsers,javax.xml.soap,
"
+ + "javax.xml.stream; version=1.0,javax.xml.stream.events; version=1.0,javax.xml.stream.util; version=1.0,"
+ + "javax.xml.transform,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transform.stax,javax.xml.transform.stream,javax.xml.validation,javax.xml.ws,javax.xml.ws.handler,javax.xml.ws.handler.soap,javax.xml.ws.http,javax.xml.ws.soap,javax.xml.ws.spi,javax.xml.xpath,org.ietf.jgss,org.omg.CORBA,org.omg.CORBA.DynAnyPackage,org.omg.CORBA.ORBPackage,org.omg.CORBA.TypeCodePackage,org.omg.CORBA.portable,org.omg.CORBA_2_3,org.omg.CORBA_2_3.portable,org.omg.CosNaming,org.omg.CosNaming.NamingContextExtPackage,org.omg.CosNaming.NamingContextPackage,org.omg.Dynamic,org.omg.DynamicAny,org.omg.DynamicAny.DynAnyFactoryPackage,org.omg.DynamicAny.DynAnyPackage,org.omg.IOP,org.omg.IOP.CodecFactoryPackage,org.omg.IOP.CodecPackage,org.omg.Messaging,org.omg.PortableInterceptor,org.omg.PortableInterceptor.ORBInitInfoPackage,org.omg.PortableServer,org.omg.PortableServer.CurrentPackage,org.omg.PortableServer.POAManagerPackage,org.omg.PortableServer.POAPackage,org.omg.P
ortableServer.ServantLocatorPackage,org.omg.PortableServer.portable,org.omg.SendingContext,org.omg.stub.java.rmi,org.w3c.dom,org.w3c.dom.bootstrap,org.w3c.dom.css,org.w3c.dom.events,org.w3c.dom.html,org.w3c.dom.ls,org.w3c.dom.ranges,org.w3c.dom.stylesheets,org.w3c.dom.traversal,org.w3c.dom.views,org.xml.sax,org.xml.sax.ext,org.xml.sax.helpers"),
+
+ mvnBundle("org.ow2.asm", "asm-all"),
+
+ mvnBundle("org.apache.aries.proxy", "org.apache.aries.proxy.api"),
+ mvnBundle("org.apache.aries.proxy", "org.apache.aries.proxy.impl"),
+
+ mvnBundle("org.apache.aries.jndi", "org.apache.aries.jndi.api"),
+ mvnBundle("org.apache.aries.jndi", "org.apache.aries.jndi.core"),
+ mvnBundle("org.apache.aries.jndi", "org.apache.aries.jndi.url"),
+
+ mvnBundle("org.apache.aries.quiesce", "org.apache.aries.quiesce.api"),
+ mvnBundle("org.apache.aries", "org.apache.aries.util"),
+
+ mvnBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.api"),
+ mvnBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.core"),
+
+ mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.api"),
+ mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container"),
+ mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.context"),
+ mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.blueprint.aries"),
+
+ mvnBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
+ mvnBundle("org.apache.aries.transaction", "org.apache.aries.transaction.manager"),
+
+ mvnBundle("commons-lang", "commons-lang"),
+ mvnBundle("commons-collections", "commons-collections"),
+ mvnBundle("commons-pool", "commons-pool"),
+
+ mvnBundle("org.apache.derby", "derby")
+ );
+ }
+
+ protected Option ariesJpa20() {
+ return composite(
+ ariesJpaInternal(),
+ mvnBundle("org.osgi", "org.osgi.enterprise"),
+ mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec", "1.1")
+ );
+ }
+
+ protected Option ariesJpa21() {
+ return composite(
+ ariesJpaInternal(),
+ mvnBundle("org.eclipse.persistence", "javax.persistence")
+ );
+ }
+
+ protected Option transactionWrapper() {
+ return mvnBundle("org.apache.aries.transaction", "org.apache.aries.transaction.wrappers");
+ }
+
+ protected Option eclipseLink() {
+ return composite(
+ mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-dbcp"),
+ mvnBundle("org.eclipse.persistence", "org.eclipse.persistence.jpa"),
+ mvnBundle("org.eclipse.persistence", "org.eclipse.persistence.core"),
+ mvnBundle("org.eclipse.persistence", "org.eclipse.persistence.asm"),
+ mvnBundle("org.eclipse.persistence", "org.eclipse.persistence.antlr"),
+ mvnBundle("org.eclipse.persistence", "org.eclipse.persistence.jpa.jpql"),
+ mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.eclipselink.adapter")
+ );
+ }
+
+ protected Option openJpa() {
+ return composite(
+ mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.serp"),
+ mvnBundle("org.apache.geronimo.specs", "geronimo-servlet_2.5_spec"),
+ mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-dbcp"),
+ mvnBundle("org.apache.xbean", "xbean-asm4-shaded"),
+ mvnBundle("org.apache.openjpa", "openjpa")
+ );
}
-
- protected Option ariesJpa() {
- return composite(
- frameworkProperty("org.osgi.framework.system.packages")
- .value("javax.accessibility,javax.activation,javax.activity,javax.annotation,javax.annotation.processing,javax.crypto,javax.crypto.interfaces,javax.crypto.spec,javax.imageio,javax.imageio.event,javax.imageio.metadata,javax.imageio.plugins.bmp,javax.imageio.plugins.jpeg,javax.imageio.spi,javax.imageio.stream,javax.jws,javax.jws.soap,javax.lang.model,javax.lang.model.element,javax.lang.model.type,javax.lang.model.util,javax.management,javax.management.loading,javax.management.modelmbean,javax.management.monitor,javax.management.openmbean,javax.management.relation,javax.management.remote,javax.management.remote.rmi,javax.management.timer,javax.naming,javax.naming.directory,javax.naming.event,javax.naming.ldap,javax.naming.spi,javax.net,javax.net.ssl,javax.print,javax.print.attribute,javax.print.attribute.standard,javax.print.event,javax.rmi,javax.rmi.CORBA,javax.rmi.ssl,javax.script,javax.security.auth,javax.security.auth.callback,javax.security.auth.kerberos,javax.securit
y.auth.login,javax.security.auth.spi,javax.security.auth.x500,javax.security.cert,javax.security.sasl,javax.sound.midi,javax.sound.midi.spi,javax.sound.sampled,javax.sound.sampled.spi,javax.sql,javax.sql.rowset,javax.sql.rowset.serial,javax.sql.rowset.spi,javax.swing,javax.swing.border,javax.swing.colorchooser,javax.swing.event,javax.swing.filechooser,javax.swing.plaf,javax.swing.plaf.basic,javax.swing.plaf.metal,javax.swing.plaf.multi,javax.swing.plaf.synth,javax.swing.table,javax.swing.text,javax.swing.text.html,javax.swing.text.html.parser,javax.swing.text.rtf,javax.swing.tree,javax.swing.undo,javax.tools,javax.xml,javax.xml.bind,javax.xml.bind.annotation,javax.xml.bind.annotation.adapters,javax.xml.bind.attachment,javax.xml.bind.helpers,javax.xml.bind.util,javax.xml.crypto,javax.xml.crypto.dom,javax.xml.crypto.dsig,javax.xml.crypto.dsig.dom,javax.xml.crypto.dsig.keyinfo,javax.xml.crypto.dsig.spec,javax.xml.datatype,javax.xml.namespace,javax.xml.parsers,javax.xml.soap,javax.xml.s
tream,javax.xml.stream.events,javax.xml.stream.util,javax.xml.transform,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transform.stax,javax.xml.transform.stream,javax.xml.validation,javax.xml.ws,javax.xml.ws.handler,javax.xml.ws.handler.soap,javax.xml.ws.http,javax.xml.ws.soap,javax.xml.ws.spi,javax.xml.xpath,org.ietf.jgss,org.omg.CORBA,org.omg.CORBA.DynAnyPackage,org.omg.CORBA.ORBPackage,org.omg.CORBA.TypeCodePackage,org.omg.CORBA.portable,org.omg.CORBA_2_3,org.omg.CORBA_2_3.portable,org.omg.CosNaming,org.omg.CosNaming.NamingContextExtPackage,org.omg.CosNaming.NamingContextPackage,org.omg.Dynamic,org.omg.DynamicAny,org.omg.DynamicAny.DynAnyFactoryPackage,org.omg.DynamicAny.DynAnyPackage,org.omg.IOP,org.omg.IOP.CodecFactoryPackage,org.omg.IOP.CodecPackage,org.omg.Messaging,org.omg.PortableInterceptor,org.omg.PortableInterceptor.ORBInitInfoPackage,org.omg.PortableServer,org.omg.PortableServer.CurrentPackage,org.omg.PortableServer.POAManagerPackage,org.omg.PortableServer.PO
APackage,org.omg.PortableServer.ServantLocatorPackage,org.omg.PortableServer.portable,org.omg.SendingContext,org.omg.stub.java.rmi,org.w3c.dom,org.w3c.dom.bootstrap,org.w3c.dom.css,org.w3c.dom.events,org.w3c.dom.html,org.w3c.dom.ls,org.w3c.dom.ranges,org.w3c.dom.stylesheets,org.w3c.dom.traversal,org.w3c.dom.views,org.xml.sax,org.xml.sax.ext,org.xml.sax.helpers"),
- //mavenBundle("org.osgi", "org.osgi.compendium").versionAsInProject(),
- //mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.cglib").versionAsInProject(),
- mavenBundle("org.osgi", "org.osgi.enterprise").versionAsInProject(),
- mavenBundle("org.ow2.asm", "asm-all").versionAsInProject(),
-
- mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.api").versionAsInProject(),
- mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.impl").versionAsInProject(),
-
- mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.api").versionAsInProject(),
- mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.core").versionAsInProject(),
- mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.url").versionAsInProject(),
-
- mavenBundle("org.apache.aries.quiesce", "org.apache.aries.quiesce.api").versionAsInProject(),
- mavenBundle("org.apache.aries", "org.apache.aries.util").versionAsInProject(),
-
- mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.api").versionAsInProject(),
- mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.core").versionAsInProject(),
-
- mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec", "1.1"),
- // mavenBundle("org.hibernate.javax.persistence", "hibernate-jpa-2.1-api").versionAsInProject(),
- mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.api").versionAsInProject(),
- mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container").versionAsInProject(),
- mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.context").versionAsInProject(),
- mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.blueprint.aries").versionAsInProject(),
-
- mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec").versionAsInProject(),
- mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.manager").versionAsInProject(),
-
- mavenBundle("commons-lang", "commons-lang").versionAsInProject(),
- mavenBundle("commons-collections", "commons-collections").versionAsInProject(),
- mavenBundle("commons-pool", "commons-pool").versionAsInProject(),
-
- mavenBundle("org.apache.derby", "derby").versionAsInProject()
-
- );
- }
-
- protected Option transactionWrapper() {
- return mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.wrappers" ).versionAsInProject();
- }
-
- protected Option eclipseLink() {
- return composite(
- mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.jpa").versionAsInProject(),
- mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.core").versionAsInProject(),
- mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.asm").versionAsInProject(),
- mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.antlr").versionAsInProject(),
- mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.eclipselink.adapter").versionAsInProject()
+
+ protected Option hibernate() {
+ return composite(
+ mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.antlr"),
+ mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.ant"),
+ mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.dom4j"),
+ mvnBundle("org.apache.servicemix.bundles" , "org.apache.servicemix.bundles.serp"),
+ mvnBundle("com.fasterxml", "classmate"),
+ mvnBundle("org.javassist", "javassist"),
+ mvnBundle("org.jboss.logging", "jboss-logging"),
+ mvnBundle("org.hibernate.common", "hibernate-commons-annotations"),
+ mvnBundle("org.jboss", "jandex"),
+ mvnBundle("org.hibernate", "hibernate-core"),
+ mvnBundle("org.hibernate", "hibernate-entitymanager"),
+ mvnBundle("org.hibernate", "hibernate-osgi")
);
- }
-
- protected Option openJpa() {
- return composite(
- mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.serp").versionAsInProject(),
- mavenBundle("org.apache.geronimo.specs", "geronimo-servlet_2.5_spec").versionAsInProject(),
- mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.commons-dbcp").versionAsInProject(),
- mavenBundle("org.apache.xbean","xbean-asm4-shaded").versionAsInProject(),
- mavenBundle("org.apache.openjpa", "openjpa").versionAsInProject()
- );
- }
-
- protected Option testDs() {
- return mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.testds").versionAsInProject();
- }
-
- protected MavenArtifactProvisionOption derbyDataSourceFactory() {
- return mavenBundle("org.ops4j.pax.jdbc", "pax-jdbc-derby").versionAsInProject();
- }
-
- protected MavenArtifactProvisionOption testBundle() {
- return mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle").versionAsInProject();
- }
-
- protected MavenArtifactProvisionOption testBundleBlueprint() {
- return mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.blueprint.itest.bundle").versionAsInProject();
- }
-
- protected MavenArtifactProvisionOption testBundleEclipseLink() {
- return mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle.eclipselink");
- }
-
- protected MavenArtifactProvisionOption testBundleAdvanced() {
- return mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.advanced.itest.bundle").versionAsInProject();
- }
+ }
+
+ protected Option testDs() {
+ return mvnBundle("org.apache.aries.transaction", "org.apache.aries.transaction.testds");
+ }
+
+ protected MavenArtifactProvisionOption derbyDataSourceFactory() {
+ return mvnBundle("org.ops4j.pax.jdbc", "pax-jdbc-derby");
+ }
+
+ protected MavenArtifactProvisionOption testBundle() {
+ return mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle");
+ }
+
+ protected MavenArtifactProvisionOption testBundleBlueprint() {
+ return mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.blueprint.itest.bundle");
+ }
+
+ protected MavenArtifactProvisionOption testBundleEclipseLink() {
+ return mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle.eclipselink");
+ }
+
+ protected MavenArtifactProvisionOption testBundleAdvanced() {
+ return mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.advanced.itest.bundle");
+ }
}
Modified: aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java Wed Jan 7 19:37:42 2015
@@ -15,114 +15,28 @@
*/
package org.apache.aries.jpa.quiesce.itest;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.ops4j.pax.exam.CoreOptions.options;
-
-import java.util.Collections;
-
-import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
-import javax.sql.DataSource;
-import javax.transaction.UserTransaction;
-import org.apache.aries.jpa.itest.AbstractJPAItest;
-import org.apache.aries.quiesce.manager.QuiesceCallback;
-import org.apache.aries.quiesce.participant.QuiesceParticipant;
-import org.junit.After;
import org.junit.Test;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerMethod;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-@ExamReactorStrategy(PerMethod.class)
-public class QuiesceJPATest extends AbstractJPAItest {
- private static final int WAIT_TIME = 200;
- private static final String JPA_CONTAINER = "org.apache.aries.jpa.container";
- private static final String JPA_CONTEXT = "org.apache.aries.jpa.container.context";
- private final String TEST_BUNDLE = "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle";
-
- @Inject
- UserTransaction tm;
-
- //This is load bearing. we have to wait to create the EntityManager until the DataSource is available
- @Inject
- DataSource ds;
-
- private class TestQuiesceCallback implements QuiesceCallback{
-
- protected int calls = 0;
-
- public void bundleQuiesced(Bundle... arg0) {
- calls++;
- }
-
- public boolean bundleClearedUp()
- {
- return calls == 1;
- }
- }
-
- private class MultiQuiesceCallback extends TestQuiesceCallback implements QuiesceCallback{
-
- private boolean contextFirst = true;
-
- public void bundleQuiesced(Bundle... arg0) {
- if(++calls == 1)
- try {
- getEMF(TEST_UNIT);
- } catch (Throwable t){
- contextFirst = false;
- if(t instanceof RuntimeException)
- throw (RuntimeException) t;
- else if (t instanceof Error)
- throw (Error) t;
- else
- throw new RuntimeException(t);
- }
-
- }
-
- public boolean bundleClearedUp()
- {
- return calls == 2 && contextFirst;
- }
- }
-
-
- @After
- public void restartTestBundles() throws BundleException {
- restartTestBundle();
- restartBundle(JPA_CONTAINER);
- restartBundle(JPA_CONTEXT);
- try {
- tm.rollback();
- } catch (Exception e) {
- // Ignore
- }
- }
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+@ExamReactorStrategy(PerClass.class)
+public class QuiesceJPATest extends AbstractQuiesceJPATest {
@Test
public void testSimpleContextQuiesce() throws Exception {
registerClient(TEST_UNIT);
getProxyEMF(TEST_UNIT);
- //Quiesce it
- TestQuiesceCallback callback = getQuiesceCallback(JPA_CONTEXT, TEST_BUNDLE);
+ // Quiesce should work
+ TestQuiesceCallback callback = quiesce(JPA_CONTEXT, TEST_BUNDLE);
Thread.sleep(WAIT_TIME);
assertFinished(callback);
-
assertNoProxyEMFForTestUnit();
+ // After restart emf should be there again
restartTestBundle();
-
getProxyEMF(TEST_UNIT);
}
@@ -130,41 +44,27 @@ public class QuiesceJPATest extends Abst
public void testComplexContextQuiesce() throws Exception {
registerClient(TEST_UNIT);
- EntityManagerFactory emf = getProxyEMF(TEST_UNIT);
- tm.begin();
- emf.createEntityManager().getProperties();
-
- TestQuiesceCallback callback = getQuiesceCallback(JPA_CONTEXT, TEST_BUNDLE);
- assertNotFinished(callback);
-
- emf = getProxyEMF(TEST_UNIT);
- tm.commit();
- assertTrue("Quiesce not finished", callback.bundleClearedUp());
- assertNoProxyEMFForTestUnit();
+ testQuiesceContext();
restartTestBundle();
- emf = getProxyEMF(TEST_UNIT);
- tm.begin();
- emf.createEntityManager().getProperties();
- tm.commit();
-
- Thread.sleep(WAIT_TIME);
-
//Test again to make sure we don't hold state over
- emf = getProxyEMF(TEST_UNIT);
+ testQuiesceContext();
+ }
+
+ private void testQuiesceContext() throws Exception {
+ EntityManagerFactory emf = getProxyEMF(TEST_UNIT);
tm.begin();
emf.createEntityManager().getProperties();
- callback = getQuiesceCallback(JPA_CONTEXT, TEST_BUNDLE);
+ TestQuiesceCallback callback = quiesce(JPA_CONTEXT, TEST_BUNDLE);
assertNotFinished(callback);
- emf = getProxyEMF(TEST_UNIT);
+ getProxyEMF(TEST_UNIT);
tm.commit();
-
assertFinished(callback);
assertNoProxyEMFForTestUnit();
- }
+ }
@Test
public void testContextRuntimeQuiesce() throws Exception {
@@ -174,7 +74,7 @@ public class QuiesceJPATest extends Abst
tm.begin();
emf.createEntityManager().getProperties();
- TestQuiesceCallback callback = getQuiesceCallback(JPA_CONTEXT, JPA_CONTEXT);
+ TestQuiesceCallback callback = quiesce(JPA_CONTEXT, JPA_CONTEXT);
assertNotFinished(callback);
emf = getProxyEMF(TEST_UNIT);
@@ -186,35 +86,34 @@ public class QuiesceJPATest extends Abst
@Test
public void testSimpleUnitQuiesce() throws Exception {
- assertEMFForTestUnit();
+ getEMF(TEST_UNIT);
- TestQuiesceCallback callback = getQuiesceCallback(JPA_CONTAINER, TEST_BUNDLE);
+ TestQuiesceCallback callback = quiesce(JPA_CONTAINER, TEST_BUNDLE);
Thread.sleep(WAIT_TIME);
assertFinished(callback);
assertNoEMFForTestUnit();
restartTestBundle();
- assertEMFForTestUnit();
+ getEMF(TEST_UNIT);
}
@Test
public void testComplexUnitQuiesce() throws Exception {
- quiesceUnit();
+ testQuiesceUnit();
restartTestBundle();
- getEMF(TEST_UNIT).createEntityManager().close();
//Test a second time to make sure state isn't held
- quiesceUnit();
+ testQuiesceUnit();
}
- private void quiesceUnit() throws Exception {
+ private void testQuiesceUnit() throws Exception {
EntityManager em = getEMF(TEST_UNIT).createEntityManager();
- TestQuiesceCallback callback = getQuiesceCallback(JPA_CONTAINER, TEST_BUNDLE);
+ TestQuiesceCallback callback = quiesce(JPA_CONTAINER, TEST_BUNDLE);
assertNotFinished(callback);
- assertEMFForTestUnit();
+ getEMF(TEST_UNIT);
em.close();
assertFinished(callback);
assertNoEMFForTestUnit();
@@ -225,146 +124,13 @@ public class QuiesceJPATest extends Abst
EntityManagerFactory emf = getEMF(TEST_UNIT);
EntityManager em = emf.createEntityManager();
- TestQuiesceCallback callback = getQuiesceCallback(JPA_CONTAINER, JPA_CONTAINER);
+ TestQuiesceCallback callback = quiesce(JPA_CONTAINER, JPA_CONTAINER);
assertNotFinished(callback);
- assertEMFForTestUnit();
- em.close();
- assertFinished(callback);
- assertNoEMFForTestUnit();
- }
-
- @Test
- public void testComplexQuiesceInteraction() throws Exception {
- registerClient(TEST_UNIT);
-
- EntityManagerFactory emf = getProxyEMF(TEST_UNIT);
- tm.begin();
- emf.createEntityManager().getProperties();
-
- //Quiesce the Unit, nothing should happen
- TestQuiesceCallback unitCallback = getQuiesceCallback(JPA_CONTAINER, TEST_BUNDLE);
- assertNotFinished(unitCallback);
-
- emf = getProxyEMF(TEST_UNIT);
-
- //Quiesce the context, still nothing
- TestQuiesceCallback contextCallback = getQuiesceCallback(JPA_CONTEXT, TEST_BUNDLE);
- assertNotFinished(unitCallback, contextCallback);
-
- emf = getProxyEMF(TEST_UNIT);
-
- //Keep the unit alive
- emf = getEMF(TEST_UNIT);
-
- EntityManager em = emf.createEntityManager();
- tm.commit();
- assertFinished(contextCallback);
- assertNoProxyEMFForTestUnit();
- assertEMFForTestUnit();
+ getEMF(TEST_UNIT);
em.close();
-
- assertFinished(unitCallback);
- assertNoEMFForTestUnit();
- }
-
- @Test
- public void testComplexQuiesceInteraction2() throws Exception {
- registerClient(TEST_UNIT);
-
- EntityManagerFactory emf = getProxyEMF(TEST_UNIT);
-
- tm.begin();
-
- emf.createEntityManager().getProperties();
-
- MultiQuiesceCallback callback = new MultiQuiesceCallback();
-
- //Quiesce the Unit, nothing should happen
- QuiesceParticipant participant = getParticipant(JPA_CONTAINER);
- participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
- TEST_BUNDLE)));
-
- //Quiesce the context, still nothing
- participant = getParticipant(JPA_CONTEXT);
- participant.quiesce(callback, Collections.singletonList(
- context().getBundleByName(TEST_BUNDLE)));
- assertNotFinished(callback);
-
- emf = getProxyEMF(TEST_UNIT);
- assertEMFForTestUnit();
-
- tm.commit();
-
assertFinished(callback);
assertNoEMFForTestUnit();
}
- private void assertFinished(TestQuiesceCallback callback) {
- assertTrue("Quiesce not finished", callback.bundleClearedUp());
- }
-
- private void assertNotFinished(TestQuiesceCallback... callbacks)
- throws InterruptedException {
- Thread.sleep(WAIT_TIME);
- for (TestQuiesceCallback callback : callbacks) {
- assertFalse("Quiesce finished", callback.bundleClearedUp());
- }
- }
-
- private void assertNoEMFForTestUnit() throws InvalidSyntaxException {
- assertNull("No unit should exist", getEMFRefs(TEST_UNIT));
- }
-
- private void assertEMFForTestUnit() {
- getEMF(TEST_UNIT);
- }
-
- private void assertNoProxyEMFForTestUnit() throws InvalidSyntaxException {
- assertNull("No context should exist", getProxyEMFRefs(TEST_UNIT));
- }
-
- private TestQuiesceCallback getQuiesceCallback(String participantName, String bundleName) throws InvalidSyntaxException {
- QuiesceParticipant participant = getParticipant(participantName);
- TestQuiesceCallback callback = new TestQuiesceCallback();
- participant.quiesce(callback, Collections.singletonList(context().getBundleByName(bundleName)));
- return callback;
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- private QuiesceParticipant getParticipant(String bundleName) throws InvalidSyntaxException {
- ServiceReference[] refs = bundleContext.getServiceReferences(QuiesceParticipant.class.getName(), null);
-
- if(refs != null) {
- for(ServiceReference ref : refs) {
- if(ref.getBundle().getSymbolicName().equals(bundleName))
- return (QuiesceParticipant) bundleContext.getService(ref);
- }
- }
-
-
- return null;
- }
-
- private void restartTestBundle() throws BundleException {
- restartBundle(TEST_BUNDLE_NAME);
- }
-
- private void restartBundle(String bundleName) throws BundleException {
- Bundle b = context().getBundleByName(bundleName);
- b.stop();
- b.start();
- }
-
- @Configuration
- public Option[] configuration() {
- return options(
- baseOptions(),
- ariesJpa(),
- openJpa(),
- testDs(),
- testBundle()
- );
- }
-
}
Modified: aries/branches/subsystemsR6/jpa/jpa-container-testbundle-eclipselink/pom.xml
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-testbundle-eclipselink/pom.xml?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-testbundle-eclipselink/pom.xml (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-testbundle-eclipselink/pom.xml Wed Jan 7 19:37:42 2015
@@ -30,9 +30,9 @@
<groupId>org.apache.aries.jpa</groupId>
<artifactId>org.apache.aries.jpa.container.itest.bundle.eclipselink</artifactId>
- <version>0.3.1-SNAPSHOT</version>
+ <version>1.0.3-SNAPSHOT</version>
<packaging>bundle</packaging>
- <name>Test Bundle for Aries JPA Container iTests</name>
+ <name>Test Bundle for Aries JPA Container iTests Eclipselink</name>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jpa/jpa-container-testbundle-eclipselink</connection>
@@ -46,11 +46,13 @@
org.apache.aries.jpa.container.itest*
</aries.osgi.export.pkg>
<aries.osgi.import>
- javax.persistence;version="[1.0.0,3.0.0)",
+ javax.persistence*;version="[1.1,3.0)",
*
</aries.osgi.import>
<aries.osgi.private.pkg/>
<aries.osgi.symbolic.name>${project.artifactId}</aries.osgi.symbolic.name>
+ <!-- Only test bundle -->
+ <aries.skip.version.check>true</aries.skip.version.check>
</properties>
<dependencies>
@@ -60,24 +62,8 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jpa_2.0_spec</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>org.eclipse.persistence.jpa</artifactId>
- <version>2.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>org.eclipse.persistence.core</artifactId>
- <version>2.1.0</version>
- </dependency>
-
- <dependency>
<groupId>org.eclipse.persistence</groupId>
- <artifactId>org.eclipse.persistence.asm</artifactId>
+ <artifactId>javax.persistence</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
Modified: aries/branches/subsystemsR6/jpa/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/persistence.xml?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/persistence.xml (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-testbundle-eclipselink/src/main/resources/META-INF/persistence.xml Wed Jan 7 19:37:42 2015
@@ -17,11 +17,12 @@
specific language governing permissions and limitations
under the License.
-->
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
- version="1.0">
-
+<persistence version="2.1"
+ xmlns="http://xmlns.jcp.org/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
+ http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+
<persistence-unit name="test-unit" transaction-type="RESOURCE_LOCAL">
<description>Test persistence unit for the JPA Container and Context iTests</description>
<jta-data-source>osgi:service/javax.sql.DataSource</jta-data-source>
@@ -32,34 +33,54 @@
</properties>
</persistence-unit>
-
- <persistence-unit name="bp-test-unit" transaction-type="JTA">
- <description>Test persistence unit for the JPA Container and Context iTests</description>
- <jta-data-source>blueprint:comp/jta</jta-data-source>
- <non-jta-data-source>blueprint:comp/nonjta</non-jta-data-source>
- <class>org.apache.aries.jpa.container.itest.entities.Car</class>
- <exclude-unlisted-classes>true</exclude-unlisted-classes>
- <properties>
- <!-- These properties are creating the database on the fly. We are using them to avoid the tests having
- to create a database -->
- <property name="eclipselink.target-database" value="Derby"/>
- <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
- <property name="eclipselink.ddl-generation.output-mode" value="database" />
- </properties>
- </persistence-unit>
-
- <persistence-unit name="bp-xa-test-unit" transaction-type="JTA">
- <description>Test persistence unit for the JPA Container and Context iTests</description>
- <jta-data-source>blueprint:comp/xa</jta-data-source>
- <non-jta-data-source>blueprint:comp/nonjta</non-jta-data-source>
- <class>org.apache.aries.jpa.container.itest.entities.Car</class>
- <exclude-unlisted-classes>true</exclude-unlisted-classes>
- <properties>
- <!-- These properties are creating the database on the fly. We are using them to avoid the tests having
- to create a database -->
- <property name="eclipselink.target-database" value="Derby"/>
- <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
- <property name="eclipselink.ddl-generation.output-mode" value="database" />
- </properties>
- </persistence-unit>
+
+ <persistence-unit name="bp-test-unit" transaction-type="JTA">
+ <description>Test persistence unit for the JPA Container and Context iTests</description>
+ <jta-data-source>blueprint:comp/jta</jta-data-source>
+ <non-jta-data-source>blueprint:comp/nonjta</non-jta-data-source>
+ <class>org.apache.aries.jpa.container.itest.entities.Car</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ <properties>
+<!-- These properties are creating the database on the fly. We are using them to avoid the tests having
+ to create a database -->
+ <property name="eclipselink.target-database" value="Derby" />
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ </properties>
+ </persistence-unit>
+
+ <persistence-unit name="bp-xa-test-unit" transaction-type="JTA">
+ <description>Test persistence unit for the JPA Container and Context iTests</description>
+ <jta-data-source>blueprint:comp/xa</jta-data-source>
+ <non-jta-data-source>blueprint:comp/nonjta</non-jta-data-source>
+ <class>org.apache.aries.jpa.container.itest.entities.Car</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ <properties>
+<!-- These properties are creating the database on the fly. We are using them to avoid the tests having
+ to create a database -->
+ <property name="eclipselink.target-database" value="Derby" />
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
+ <property name="eclipselink.ddl-generation.output-mode" value="database" />
+ </properties>
+ </persistence-unit>
+
+ <persistence-unit name="script-test-unit" transaction-type="RESOURCE_LOCAL">
+ <properties>
+ <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:TEST;create=true"/>
+ <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+ <property name="eclipselink.target-database" value="Derby"/>
+ <property name="javax.persistence.schema-generation.database.action"
+ value="drop-and-create"/>
+ <property name="javax.persistence.schema-generation.create-source"
+ value="script"/>
+ <property name="javax.persistence.schema-generation.create-script-source"
+ value="META-INF/sql/create.sql" />
+ <property name="javax.persistence.sql-load-script-source"
+ value="META-INF/sql/data.sql" />
+ <property name="javax.persistence.schema-generation.drop-source"
+ value="script" />
+ <property name="javax.persistence.schema-generation.drop-script-source"
+ value="META-INF/sql/drop.sql" />
+ </properties>
+ </persistence-unit>
</persistence>
Modified: aries/branches/subsystemsR6/jpa/jpa-container-testbundle/pom.xml
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-testbundle/pom.xml?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-testbundle/pom.xml (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-testbundle/pom.xml Wed Jan 7 19:37:42 2015
@@ -41,12 +41,17 @@
</scm>
<properties>
+ <!-- As this is only a test bundle we skip the check -->
+ <aries.skip.version.check>true</aries.skip.version.check>
+
<!-- Export package versions are maintained in packageinfo files -->
<aries.osgi.export.pkg>
org.apache.aries.jpa.container.itest.entities
</aries.osgi.export.pkg>
<aries.osgi.import>
javax.persistence;version="[1.0.0,3.0.0)",
+ org.hibernate.proxy;resolution:=optional,
+ javassist.util.proxy;resolution:=optional,
*
</aries.osgi.import>
<aries.osgi.private.pkg />
@@ -55,15 +60,9 @@
<dependencies>
<dependency>
- <groupId>org.hibernate.javax.persistence</groupId>
- <artifactId>hibernate-jpa-2.1-api</artifactId>
- <version>1.0.0.Final</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.openjpa</groupId>
- <artifactId>openjpa</artifactId>
- <version>2.2.2</version>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ <version>1.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
@@ -79,29 +78,6 @@
</instructions>
</configuration>
</plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>process-classes</phase>
- <configuration>
- <tasks>
- <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask" classpathref="maven.compile.classpath" />
- <openjpac>
- <classpath refid="maven.compile.classpath" />
- <classpath>
- <pathelement location="target/classes" />
- <pathelement location="src/main/resources" />
- </classpath>
- </openjpac>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
Modified: aries/branches/subsystemsR6/jpa/jpa-container-testbundle/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-testbundle/src/main/resources/META-INF/persistence.xml?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-testbundle/src/main/resources/META-INF/persistence.xml (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-testbundle/src/main/resources/META-INF/persistence.xml Wed Jan 7 19:37:42 2015
@@ -24,12 +24,20 @@
<persistence-unit name="test-unit" transaction-type="RESOURCE_LOCAL">
<description>Test persistence unit for the JPA Container and Context iTests</description>
+
<jta-data-source>osgi:service/javax.sql.DataSource</jta-data-source>
<non-jta-data-source>osgi:service/javax.sql.DataSource</non-jta-data-source>
- <class>org.apache.aries.jpa.container.itest.entities.Car</class>
- <exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
-
+ <!-- This is to avoid compile time enhancement which would conflict with hibernate -->
+ <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
+
+ <!-- These properties are creating the database on the fly. We are using them to avoid the tests having
+ to create a database -->
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+ <property name="openjpa.jdbc.DBDictionary" value="derby"/>
+
+ <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyTenSevenDialect"/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
@@ -37,13 +45,14 @@
<description>Test persistence unit for the JPA Container and Context iTests</description>
<jta-data-source>blueprint:comp/jta</jta-data-source>
<non-jta-data-source>blueprint:comp/nonjta</non-jta-data-source>
- <class>org.apache.aries.jpa.container.itest.entities.Car</class>
- <exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- These properties are creating the database on the fly. We are using them to avoid the tests having
to create a database -->
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.jdbc.DBDictionary" value="derby"/>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyTenSevenDialect"/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
</properties>
</persistence-unit>
@@ -51,20 +60,18 @@
<description>Test persistence unit for the JPA Container and Context iTests</description>
<jta-data-source>blueprint:comp/xa</jta-data-source>
<non-jta-data-source>blueprint:comp/nonjta</non-jta-data-source>
- <class>org.apache.aries.jpa.container.itest.entities.Car</class>
- <exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- These properties are creating the database on the fly. We are using them to avoid the tests having
to create a database -->
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.jdbc.DBDictionary" value="derby"/>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyTenSevenDialect"/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
<persistence-unit name="dsf-test-unit" transaction-type="RESOURCE_LOCAL">
<description>Test persistence unit for the JPA Container DataSourceFactory iTests</description>
- <class>org.apache.aries.jpa.container.itest.entities.Car</class>
- <exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- These properties are creating the database on the fly. We are using them to avoid the tests having
to create a database -->
@@ -72,13 +79,13 @@
<property name="javax.persistence.jdbc.databaseName" value="memory:TEST;create=true"/>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.jdbc.DBDictionary" value="derby"/>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyTenSevenDialect"/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
<persistence-unit name="dsf-xa-test-unit" transaction-type="JTA">
<description>Test persistence unit for the JPA Container DataSourceFactory iTests</description>
- <class>org.apache.aries.jpa.container.itest.entities.Car</class>
- <exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- These properties are creating the database on the fly. We are using them to avoid the tests having
to create a database -->
@@ -86,6 +93,8 @@
<property name="javax.persistence.jdbc.databaseName" value="memory:TEST;create=true"/>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
<property name="openjpa.jdbc.DBDictionary" value="derby"/>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyTenSevenDialect"/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
</properties>
</persistence-unit>
</persistence>
Modified: aries/branches/subsystemsR6/jpa/jpa-container/pom.xml
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container/pom.xml?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container/pom.xml (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container/pom.xml Wed Jan 7 19:37:42 2015
@@ -31,7 +31,7 @@
<groupId>org.apache.aries.jpa</groupId>
<artifactId>org.apache.aries.jpa.container</artifactId>
<packaging>bundle</packaging>
- <version>1.0.2-SNAPSHOT</version>
+ <version>1.0.3-SNAPSHOT</version>
<name>Aries JPA Container</name>
<scm>
@@ -96,9 +96,9 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.hibernate.javax.persistence</groupId>
- <artifactId>hibernate-jpa-2.1-api</artifactId>
- <version>1.0.0.Final</version>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ <version>1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
Modified: aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java Wed Jan 7 19:37:42 2015
@@ -22,10 +22,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Hashtable;
import java.util.Map;
-import java.util.Set;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -37,6 +35,10 @@ import javax.persistence.spi.Persistence
import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
import org.apache.aries.jpa.container.PersistenceUnitConstants;
import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
+import org.apache.aries.jpa.container.quiesce.impl.DestroyCallback;
+import org.apache.aries.jpa.container.quiesce.impl.EMFProxyFactory;
+import org.apache.aries.jpa.container.quiesce.impl.NamedCallback;
+import org.apache.aries.jpa.container.quiesce.impl.QuiesceEMF;
import org.apache.aries.util.AriesFrameworkUtil;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -50,29 +52,11 @@ import org.slf4j.LoggerFactory;
* This class manages the lifecycle of Persistence Units and their associated
* {@link EntityManagerFactory} objects.
*/
+@SuppressWarnings({
+ "unchecked", "rawtypes"
+})
public class EntityManagerFactoryManager implements ServiceTrackerCustomizer {
- /**
- * A callback for a named persistence units
- */
- class NamedCallback {
- private final Set<String> names;
- private final DestroyCallback callback;
- public NamedCallback(Collection<String> names, DestroyCallback countdown) {
- this.names = new HashSet<String>(names);
- callback = countdown;
- }
-
- public void callback(String name) {
- boolean winner;
- synchronized (this) {
- winner = !!!names.isEmpty() && names.remove(name) && names.isEmpty();
- }
- if(winner)
- callback.callback();
- }
- }
-
/** The container's {@link BundleContext} */
private final BundleContext containerContext;
/** The persistence bundle */
@@ -84,7 +68,7 @@ public class EntityManagerFactoryManager
/** The original parsed data */
private Collection<ParsedPersistenceUnit> parsedData;
/** A Map of created {@link EntityManagerFactory}s */
- private Map<String, CountingEntityManagerFactory> emfs = null;
+ private Map<String, EntityManagerFactory> emfs = null;
/** The {@link ServiceRegistration} objects for the {@link EntityManagerFactory}s */
private ConcurrentMap<String, ServiceRegistration> registrations = null;
/** Quiesce this Manager */
@@ -107,18 +91,13 @@ public class EntityManagerFactoryManager
* {@link PersistenceBundleManager} that is synchronized
* on itself, and the resulting manager should be immediately
* stored in the bundleToManager Map
- *
+ *
+ * @param containerCtx
* @param b
- * @param infos
- * @param ref
- * @param parsedUnits
*/
- public EntityManagerFactoryManager(BundleContext containerCtx, Bundle b, Collection<ParsedPersistenceUnit> parsedUnits, ServiceReference ref, Collection<? extends ManagedPersistenceUnitInfo> infos) {
+ public EntityManagerFactoryManager(BundleContext containerCtx, Bundle b) {
containerContext = containerCtx;
bundle = b;
- provider = ref;
- persistenceUnits = getInfoMap(infos);
- parsedData = parsedUnits;
}
private Map<String, ? extends ManagedPersistenceUnitInfo> getInfoMap(
@@ -145,9 +124,12 @@ public class EntityManagerFactoryManager
* @param ref The provider service reference
* @return true if the the provider is being used by this manager
*/
- public synchronized boolean providerRemoved(ServiceReference ref) {
-
- boolean toReturn = provider.equals(ref);
+ public synchronized boolean providerRemoved(ServiceReference ref)
+ {
+ boolean toReturn = false;
+ if (provider != null) {
+ toReturn = provider.equals(ref);
+ }
if(toReturn)
destroy();
@@ -171,8 +153,6 @@ public class EntityManagerFactoryManager
//If we are Resolved as a result of having stopped
//and missed the STOPPING event we need to unregister
unregisterEntityManagerFactories();
- //Create the EMF objects if necessary
- createEntityManagerFactories();
break;
//Starting and active both require EMFs to be registered
case Bundle.STARTING :
@@ -208,7 +188,7 @@ public class EntityManagerFactoryManager
if(registrations != null) {
for(Entry<String, ServiceRegistration> entry : registrations.entrySet()) {
AriesFrameworkUtil.safeUnregisterService(entry.getValue());
- emfs.get(entry.getKey()).clearQuiesce();
+ clearQuiesce(emfs.get(entry.getKey()));
persistenceUnits.get(entry.getKey()).unregistered();
}
// remember to set registrations to be null
@@ -216,14 +196,21 @@ public class EntityManagerFactoryManager
}
}
+
private void unregisterEntityManagerFactory(String unit) {
if(registrations != null) {
AriesFrameworkUtil.safeUnregisterService(registrations.remove(unit));
- emfs.get(unit).clearQuiesce();
+ clearQuiesce(emfs.get(unit));
persistenceUnits.get(unit).unregistered();
}
}
-
+
+ private void clearQuiesce(EntityManagerFactory emf) {
+ if (emf instanceof QuiesceEMF) {
+ ((QuiesceEMF) emf).clearQuiesce();
+ }
+ }
+
/**
* Register {@link EntityManagerFactory} services
*
@@ -248,7 +235,7 @@ public class EntityManagerFactoryManager
PersistenceUnitConstants.OSGI_UNIT_PROVIDER, provider));
}
//Register each EMF
- for(Entry<String, ? extends EntityManagerFactory> entry : emfs.entrySet())
+ for(Entry<String, EntityManagerFactory> entry : emfs.entrySet())
{
Hashtable<String,Object> props = new Hashtable<String, Object>();
@@ -302,7 +289,7 @@ public class EntityManagerFactoryManager
return true;
}
}
-
+
/**
* Create {@link EntityManagerFactory} services for this peristence unit
* throws InvalidPersistenceUnitException if this {@link EntityManagerFactory} is no longer
@@ -310,7 +297,7 @@ public class EntityManagerFactoryManager
*/
private void createEntityManagerFactories() throws InvalidPersistenceUnitException {
if (emfs == null) {
- emfs = new HashMap<String, CountingEntityManagerFactory>();
+ emfs = new HashMap<String, EntityManagerFactory>();
}
//Only try if we have a provider and EMFs
if(provider == null || !emfs.isEmpty() || quiesce) {
@@ -329,7 +316,8 @@ public class EntityManagerFactoryManager
ManagedPersistenceUnitInfo mpui = persistenceUnits.get(unitName);
try {
EntityManagerFactory emf = providerService.createContainerEntityManagerFactory(mpui.getPersistenceUnitInfo(), mpui.getContainerProperties());
- emfs.put(unitName, new CountingEntityManagerFactory(emf, unitName));
+ EntityManagerFactory emfProxy = EMFProxyFactory.createProxy(emf, unitName);
+ emfs.put(unitName, emfProxy);
} catch (Exception e) {
_logger.warn("Error creating EntityManagerFactory", e);
}
@@ -339,6 +327,8 @@ public class EntityManagerFactoryManager
containerContext.ungetService(provider);
}
}
+
+
/**
* Manage the EntityManagerFactories for the following
@@ -395,7 +385,7 @@ public class EntityManagerFactoryManager
if(registrations != null)
unregisterEntityManagerFactories();
if(emfs != null) {
- for(Entry<String, ? extends EntityManagerFactory> entry : emfs.entrySet()) {
+ for(Entry<String, EntityManagerFactory> entry : emfs.entrySet()) {
try {
entry.getValue().close();
} catch (Exception e) {
@@ -414,11 +404,12 @@ public class EntityManagerFactoryManager
{
return parsedData;
}
+
/** Quiesce this Manager */
public void quiesce(DestroyCallback countdown) {
//Find the EMFs to quiesce, and their Service registrations
- Map<CountingEntityManagerFactory, ServiceRegistration> entries = new HashMap<CountingEntityManagerFactory, ServiceRegistration>();
+ Map<EntityManagerFactory, ServiceRegistration> entries = new HashMap<EntityManagerFactory, ServiceRegistration>();
Collection<String> names = new ArrayList<String>();
synchronized(this) {
if((bundle.getState() & (Bundle.ACTIVE | Bundle.STARTING)) != 0)
@@ -434,14 +425,19 @@ public class EntityManagerFactoryManager
if(entries.isEmpty())
countdown.callback();
else {
- NamedCallback callback = new NamedCallback(names, countdown);
- for(Entry<CountingEntityManagerFactory, ServiceRegistration> entry : entries.entrySet()) {
- CountingEntityManagerFactory emf = entry.getKey();
- emf.quiesce(callback, entry.getValue());
+ NamedCallback callback = new NamedCallback(names, countdown);
+ for(Entry<EntityManagerFactory, ServiceRegistration> entry : entries.entrySet()) {
+ quiesce(entry.getKey(), callback, entry.getValue());
}
}
}
-
+
+ private void quiesce(EntityManagerFactory emf, NamedCallback callback, ServiceRegistration reg) {
+ if (emf instanceof QuiesceEMF) {
+ ((QuiesceEMF) emf).quiesce(callback, reg);
+ }
+ }
+
@Override
public StringBuffer addingService(ServiceReference reference) {
//Use String.valueOf to save us from nulls
@@ -514,4 +510,5 @@ public class EntityManagerFactoryManager
}
}
}
+
}
Modified: aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleHelper.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleHelper.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleHelper.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleHelper.java Wed Jan 7 19:37:42 2015
@@ -219,6 +219,7 @@ public class PersistenceBundleHelper
//Remember to trim off the "!/"
String toLocate = location.substring(bangIndex + 2);
+ @SuppressWarnings("resource")
JarInputStream jis = new JarInputStream(url.openStream());
JarEntry entry = jis.getNextJarEntry();
Modified: aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java Wed Jan 7 19:37:42 2015
@@ -19,6 +19,7 @@
package org.apache.aries.jpa.container.impl;
+import java.io.Closeable;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -46,10 +47,15 @@ import org.apache.aries.jpa.container.pa
import org.apache.aries.jpa.container.parsing.PersistenceDescriptorParser;
import org.apache.aries.jpa.container.parsing.PersistenceDescriptorParserException;
import org.apache.aries.jpa.container.parsing.impl.PersistenceDescriptorParserImpl;
+import org.apache.aries.jpa.container.quiesce.impl.CountdownCallback;
+import org.apache.aries.jpa.container.quiesce.impl.DestroyCallback;
+import org.apache.aries.jpa.container.quiesce.impl.QuiesceHandler;
+import org.apache.aries.jpa.container.quiesce.impl.QuiesceParticipantFactory;
import org.apache.aries.jpa.container.tx.impl.OSGiTransactionManager;
import org.apache.aries.jpa.container.unit.impl.ManagedPersistenceUnitInfoFactoryImpl;
import org.apache.aries.util.AriesFrameworkUtil;
import org.apache.aries.util.VersionRange;
+import org.apache.aries.util.io.IOUtils;
import org.apache.aries.util.tracker.RecursiveBundleTracker;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
@@ -70,11 +76,9 @@ import org.slf4j.LoggerFactory;
* It also keeps track of PersistenceProvider services and delegates the EMF creation to the
* matching PersistenceProvider
*/
-public class PersistenceBundleManager implements BundleTrackerCustomizer, ServiceTrackerCustomizer, BundleActivator
+@SuppressWarnings("rawtypes")
+public class PersistenceBundleManager implements BundleTrackerCustomizer, ServiceTrackerCustomizer, BundleActivator, QuiesceHandler
{
- /** The QuiesceParticipant implementation class name */
- private static final String QUIESCE_PARTICIPANT_CLASS = "org.apache.aries.quiesce.participant.QuiesceParticipant";
-
/** Logger */
private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.jpa.container");
@@ -110,10 +114,8 @@ public class PersistenceBundleManager im
private RecursiveBundleTracker tracker;
private ServiceTracker serviceTracker;
- /** The quiesce participant service */
- private ServiceRegistration quiesceReg;
/** A callback to shutdown the quiesce participant when it is done */
- private DestroyCallback quiesceParticipant;
+ private Closeable quiesceParticipant;
/** Are we quiescing */
private AtomicBoolean quiesce = new AtomicBoolean(false);
@@ -283,11 +285,16 @@ public class PersistenceBundleManager im
EntityManagerFactoryManager mgr = (EntityManagerFactoryManager) object;
//If the bundle was updated we need to destroy it and re-initialize
//the EntityManagerFactoryManager
- if(event != null && event.getType() == BundleEvent.UPDATED) {
+ //If the bundle becomes unresolved we need to destroy persistenceUnits, since they
+ //keep a reference to bundle classloader which has wiring m_isDisposed set to true
+ //this occurs when Karaf BundleWatcher is used.
+ if(event != null && (event.getType() == BundleEvent.UPDATED || event.getType() == BundleEvent.UNRESOLVED)) {
mgr.destroy();
persistenceUnitFactory.destroyPersistenceBundle(ctx, bundle);
- //Don't add to the managersAwaitingProviders, the setupManager will do it
- setupManager(bundle, mgr, true);
+ if (event.getType() == BundleEvent.UPDATED) {
+ //Don't add to the managersAwaitingProviders, the setupManager will do it
+ setupManager(bundle, mgr, true);
+ }
} else {
try {
boolean reassign;
@@ -380,11 +387,11 @@ public class PersistenceBundleManager im
infos = persistenceUnitFactory.
createManagedPersistenceUnitMetadata(ctx, bundle, ref, pUnits);
}
- //Either update the existing manager or create a new one
- if(mgr != null)
- mgr.manage(pUnits, ref, infos);
- else
- mgr = new EntityManagerFactoryManager(ctx, bundle, pUnits, ref, infos);
+
+ if(mgr == null) {
+ mgr = new EntityManagerFactoryManager(ctx, bundle);
+ }
+ mgr.manage(pUnits, ref, infos);
//Register the manager (this may re-add, but who cares)
synchronized (this) {
@@ -634,6 +641,7 @@ public class PersistenceBundleManager im
}
+ @SuppressWarnings("unchecked")
public void start(BundleContext context) throws Exception {
ctx = context;
@@ -648,15 +656,7 @@ public class PersistenceBundleManager im
open();
- try{
- context.getBundle().loadClass(QUIESCE_PARTICIPANT_CLASS);
- //Class was loaded, register
- quiesceParticipant = new QuiesceParticipantImpl(this);
- quiesceReg = context.registerService(QUIESCE_PARTICIPANT_CLASS,
- quiesceParticipant, null);
- } catch (ClassNotFoundException e) {
- _logger.info(NLS.MESSAGES.getMessage("quiesce.manager.not.there"));
- }
+ QuiesceParticipantFactory.create(context, this);
}
private void initParser() {
@@ -667,22 +667,21 @@ public class PersistenceBundleManager im
public void stop(BundleContext context) throws Exception {
close();
AriesFrameworkUtil.safeUnregisterService(parserReg);
- AriesFrameworkUtil.safeUnregisterService(quiesceReg);
- if(quiesceParticipant != null)
- quiesceParticipant.callback();
+ IOUtils.close(quiesceParticipant);
}
public BundleContext getCtx() {
return ctx;
}
+ @Override
public void quiesceBundle(Bundle bundleToQuiesce, final DestroyCallback callback) {
boolean thisBundle = bundleToQuiesce.equals(ctx.getBundle());
if(thisBundle) {
quiesce.compareAndSet(false, true);
- AriesFrameworkUtil.safeUnregisterService(quiesceReg);
+
}
Collection<EntityManagerFactoryManager> toDestroyNow = new ArrayList<EntityManagerFactoryManager>();
@@ -712,7 +711,7 @@ public class PersistenceBundleManager im
if(quiesceNow.isEmpty()) {
callback.callback();
} else {
- DestroyCallback countdown = new CoundownCallback(quiesceNow.size(), callback);
+ DestroyCallback countdown = new CountdownCallback(quiesceNow.size(), callback);
for(EntityManagerFactoryManager emfm : quiesceNow)
emfm.quiesce(countdown);
Modified: aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/JPAHandler.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/JPAHandler.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/JPAHandler.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/JPAHandler.java Wed Jan 7 19:37:42 2015
@@ -106,9 +106,9 @@ public class JPAHandler extends DefaultH
pu.addClassName(s);
else if("exclude-unlisted-classes".equals(elementName))
pu.setExcludeUnlisted(Boolean.parseBoolean(s));
- else if ("2.0".equals(jpaVersion) && "shared-cache-mode".equals(elementName))
+ else if (checkJpa2Version() && "shared-cache-mode".equals(elementName))
pu.setSharedCacheMode(s);
- else if ("2.0".equals(jpaVersion) && "validation-mode".equals(elementName))
+ else if (checkJpa2Version() && "validation-mode".equals(elementName))
pu.setValidationMode(s);
}
@@ -128,4 +128,7 @@ public class JPAHandler extends DefaultH
return persistenceUnits;
}
+ private boolean checkJpa2Version() {
+ return ("2.0".equals(jpaVersion) || "2.1".equals(jpaVersion));
+ }
}
Modified: aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java Wed Jan 7 19:37:42 2015
@@ -26,13 +26,12 @@ import java.util.Properties;
import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
import org.osgi.framework.Bundle;
-import org.osgi.framework.ServiceReference;
/**
* An implementation of PersistenceUnit for parsed persistence unit metadata
*
*/
-@SuppressWarnings("unchecked")
+@SuppressWarnings({"unchecked", "rawtypes"})
public class PersistenceUnitImpl implements ParsedPersistenceUnit
{
/** A map to hold the metadata from the xml */
@@ -41,13 +40,6 @@ public class PersistenceUnitImpl impleme
private final Bundle bundle;
/**
- * The Service Reference for the provider to which this persistence
- * unit is tied
- */
- private ServiceReference provider;
-
-
- /**
* Create a new persistence unit with the given name, transaction type, location and
* defining bundle
*
@@ -174,14 +166,6 @@ public class PersistenceUnitImpl impleme
}
/**
- * @param providerRef
- */
- public void setProviderReference(ServiceReference providerRef)
- {
- provider = providerRef;
- }
-
- /**
* @param sharedCacheMode
*/
public void setSharedCacheMode(String sharedCacheMode)
Modified: aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/SchemaLocatingHandler.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/SchemaLocatingHandler.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/SchemaLocatingHandler.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/SchemaLocatingHandler.java Wed Jan 7 19:37:42 2015
@@ -40,6 +40,7 @@ public class SchemaLocatingHandler exten
* URI for the JPA persistence namespace
*/
private static final String PERSISTENCE_NS_URI = "http://java.sun.com/xml/ns/persistence";
+ private static final String PERSISTENCE_21_NS_URI = "http://xmlns.jcp.org/xml/ns/persistence";
/**
* A static cache of schemas in use in the runtime
@@ -53,7 +54,7 @@ public class SchemaLocatingHandler exten
Schema s = null;
String version = null;
- if(PERSISTENCE_NS_URI.equals(uri) && "persistence".equals(localName) ) {
+ if((PERSISTENCE_NS_URI.equals(uri) || PERSISTENCE_21_NS_URI.equals(uri)) && "persistence".equals(localName) ) {
version = attributes.getValue("version");
s = validate(version);
}
@@ -93,6 +94,8 @@ public class SchemaLocatingHandler exten
schemaURL = this.getClass().getResource("persistence.xsd.rsrc");
} else if ("2.0".equals(type)) {
schemaURL = this.getClass().getResource("persistence_2_0.xsd.rsrc");
+ } else if ("2.1".equals(type)) {
+ schemaURL = this.getClass().getResource("persistence_2_1.xsd.rsrc");
}
Schema schema = null;
Modified: aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/tx/impl/OSGiTransactionManager.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/tx/impl/OSGiTransactionManager.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/tx/impl/OSGiTransactionManager.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/tx/impl/OSGiTransactionManager.java Wed Jan 7 19:37:42 2015
@@ -20,11 +20,7 @@ package org.apache.aries.jpa.container.t
import java.util.concurrent.atomic.AtomicReference;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
import javax.transaction.InvalidTransactionException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
@@ -44,6 +40,7 @@ public class OSGiTransactionManager impl
private final SingleServiceTracker<TransactionManager> tracker;
+ @SuppressWarnings("unchecked")
public static void init(BundleContext ctx) {
try {
Modified: aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/tx/impl/XADatasourceEnlistingWrapper.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/tx/impl/XADatasourceEnlistingWrapper.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/tx/impl/XADatasourceEnlistingWrapper.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/tx/impl/XADatasourceEnlistingWrapper.java Wed Jan 7 19:37:42 2015
@@ -34,7 +34,6 @@ import javax.transaction.Status;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
import javax.transaction.xa.XAResource;
import org.apache.aries.jpa.container.impl.NLS;
Modified: aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java?rev=1650143&r1=1650142&r2=1650143&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java Wed Jan 7 19:37:42 2015
@@ -32,12 +32,14 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
+@SuppressWarnings("rawtypes")
public class ManagedPersistenceUnitInfoFactoryImpl implements
ManagedPersistenceUnitInfoFactory {
private ConcurrentMap<Bundle, Collection<ManagedPersistenceUnitInfoImpl>> persistenceUnits =
new ConcurrentHashMap<Bundle, Collection<ManagedPersistenceUnitInfoImpl>>();
+
public Collection<? extends ManagedPersistenceUnitInfo> createManagedPersistenceUnitMetadata(
BundleContext containerContext, Bundle persistenceBundle,
ServiceReference providerReference,