aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1095075 [1/2] - in /aries/trunk/jpa: jpa-api/src/main/java/org/apache/aries/jpa/container/ jpa-api/src/main/java/org/apache/aries/jpa/container/parsing/ jpa-container-itest/ jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/ ...
Date Tue, 19 Apr 2011 13:05:01 GMT
Author: timothyjward
Date: Tue Apr 19 13:05:00 2011
New Revision: 1095075

URL: http://svn.apache.org/viewvc?rev=1095075&view=rev
Log:
ARIES-636 : Add support for load-time entity enhancement and annotation scanning

Added:
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/JPAWeavingAndAnnotationScanningTest.java
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/ops4j/
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/ops4j/pax/
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/ops4j/pax/runner/
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/ops4j/pax/runner/platform/
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/ops4j/pax/runner/platform/equinox/
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/ops4j/pax/runner/platform/equinox/internal/
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/ops4j/pax/runner/platform/equinox/internal/SsActivator.java
    aries/trunk/jpa/jpa-container-itest/src/test/resources/
    aries/trunk/jpa/jpa-container-itest/src/test/resources/META-INF/
    aries/trunk/jpa/jpa-container-itest/src/test/resources/META-INF/platform-equinox/
    aries/trunk/jpa/jpa-container-itest/src/test/resources/META-INF/platform-equinox/definition-3.7.0.V20110304.xml
    aries/trunk/jpa/jpa-container-itest/src/test/resources/ss-runner.properties
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/AnnotationScanner.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/AnnotationScannerFactory.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/JPAAnnotationScanner.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistry.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistryFactory.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java
    aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/weaving/
    aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/weaving/JPAWeavingHookTest.java
Modified:
    aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfoFactory.java
    aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/packageinfo
    aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/parsing/PersistenceDescriptorParser.java
    aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/parsing/packageinfo
    aries/trunk/jpa/jpa-container-itest/pom.xml
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/JPAInjectionTest.java
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java
    aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java
    aries/trunk/jpa/jpa-container/pom.xml
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoImpl.java
    aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java
    aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/parsing/PersistenceXMLParsingTest.java

Modified: aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfoFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfoFactory.java?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfoFactory.java (original)
+++ aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfoFactory.java Tue Apr 19 13:05:00 2011
@@ -91,7 +91,7 @@ public interface ManagedPersistenceUnitI
    *                            metadata from the persistence descriptor.
    * @return A Collection of {@link ManagedPersistenceUnitInfo} objects that can be used to create {@link EntityManagerFactory} instances
    */
-  public Collection<ManagedPersistenceUnitInfo> createManagedPersistenceUnitMetadata(BundleContext containerContext, Bundle persistenceBundle, ServiceReference providerReference, Collection<ParsedPersistenceUnit> persistenceMetadata);
+  public Collection<? extends ManagedPersistenceUnitInfo> createManagedPersistenceUnitMetadata(BundleContext containerContext, Bundle persistenceBundle, ServiceReference providerReference, Collection<ParsedPersistenceUnit> persistenceMetadata);
   
   /**
    * If no persistence units in a persistence bundle specify a JPA {@link PersistenceProvider} 

Modified: aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/packageinfo
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/packageinfo?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/packageinfo (original)
+++ aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/packageinfo Tue Apr 19 13:05:00 2011
@@ -16,4 +16,4 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-version 0.3.1
+version 0.4

Modified: aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/parsing/PersistenceDescriptorParser.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/parsing/PersistenceDescriptorParser.java?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/parsing/PersistenceDescriptorParser.java (original)
+++ aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/parsing/PersistenceDescriptorParser.java Tue Apr 19 13:05:00 2011
@@ -36,7 +36,7 @@ public interface PersistenceDescriptorPa
    * @return A collection of {@link ParsedPersistenceUnit}
    * @throws PersistenceDescriptorParserException  if any error occurs in parsing
    */
-  public abstract Collection<ParsedPersistenceUnit> parse(Bundle b,
+  public abstract Collection<? extends ParsedPersistenceUnit> parse(Bundle b,
       PersistenceDescriptor descriptor)
       throws PersistenceDescriptorParserException;
 

Modified: aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/parsing/packageinfo
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/parsing/packageinfo?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/parsing/packageinfo (original)
+++ aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/parsing/packageinfo Tue Apr 19 13:05:00 2011
@@ -16,4 +16,4 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-version 0.3.1
+version 0.4

Modified: aries/trunk/jpa/jpa-container-itest/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-itest/pom.xml?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container-itest/pom.xml (original)
+++ aries/trunk/jpa/jpa-container-itest/pom.xml Tue Apr 19 13:05:00 2011
@@ -224,6 +224,12 @@
         </dependency>
         <dependency>
             <groupId>org.apache.aries.jpa</groupId>
+            <artifactId>org.apache.aries.jpa.container.advanced.itest.bundle</artifactId>
+            <version>0.3.1-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.jpa</groupId>
             <artifactId>org.apache.aries.jpa.blueprint.itest.bundle</artifactId>
             <version>0.3.1-SNAPSHOT</version>
             <scope>test</scope>

Added: aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/JPAWeavingAndAnnotationScanningTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/JPAWeavingAndAnnotationScanningTest.java?rev=1095075&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/JPAWeavingAndAnnotationScanningTest.java (added)
+++ aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/advanced/features/itest/JPAWeavingAndAnnotationScanningTest.java Tue Apr 19 13:05:00 2011
@@ -0,0 +1,190 @@
+package org.apache.aries.jpa.advanced.features.itest;
+
+/*  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackages;
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
+import static org.ops4j.pax.exam.OptionUtils.combine;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+
+import java.util.Arrays;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.aries.jpa.container.PersistenceUnitConstants;
+import org.apache.aries.jpa.container.advanced.itest.bundle.entities.Car;
+import org.apache.openjpa.enhance.PersistenceCapable;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.util.tracker.ServiceTracker;
+
+@RunWith(JUnit4TestRunner.class)
+public class JPAWeavingAndAnnotationScanningTest {
+
+  public static final long DEFAULT_TIMEOUT = 10000;
+  
+  @Inject
+  protected BundleContext bundleContext;
+ 
+  @Test
+  public void testAnnotatedClassFound() throws Exception {
+    EntityManagerFactory emf = getOsgiService(bundleContext, EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))", DEFAULT_TIMEOUT);
+    
+    EntityManager em = emf.createEntityManager();
+    
+    em.getTransaction().begin();
+    
+    Car c = new Car();
+    
+    c.setColour("Blue");
+    c.setNumberPlate("AB11CDE");
+    c.setNumberOfSeats(7);
+    c.setEngineSize(1900);
+    
+    em.persist(c);
+    
+    em.getTransaction().commit();
+    
+    assertEquals(7, em.find(Car.class, "AB11CDE").getNumberOfSeats());
+  }
+  
+  @Test
+  public void testClassIsWoven() throws Exception {
+    
+    assertTrue("Not PersistenceCapable", Arrays.asList(Car.class.getInterfaces())
+        .contains(PersistenceCapable.class));
+  }
+  
+  protected <T> T getOsgiService(BundleContext bc, Class<T> type,
+      String filter, long timeout) {
+    ServiceTracker tracker = null;
+    try {
+      String flt;
+      if (filter != null) {
+        if (filter.startsWith("(")) {
+          flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")"
+              + filter + ")";
+        } else {
+          flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")("
+              + filter + "))";
+        }
+      } else {
+        flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
+      }
+      Filter osgiFilter = FrameworkUtil.createFilter(flt);
+      tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter,
+          null);
+      tracker.open();
+      // Note that the tracker is not closed to keep the reference
+      // This is buggy, has the service reference may change i think
+      Object svc = type.cast(tracker.waitForService(timeout));
+      if (svc == null) {
+        throw new RuntimeException("Gave up waiting for service " + flt);
+      }
+      return type.cast(svc);
+    } catch (InvalidSyntaxException e) {
+      throw new IllegalArgumentException("Invalid filter", e);
+    } catch (InterruptedException e) {
+      throw new RuntimeException(e);
+    }
+  }
+  
+  @org.ops4j.pax.exam.junit.Configuration
+  public static Option[] configuration() {
+    Option[] options = options(
+        bootDelegationPackages("javax.transaction", "javax.transaction.*"),
+        vmOption("-Dorg.osgi.framework.system.packages=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.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.name
 space,javax.xml.parsers,javax.xml.soap,javax.xml.stream,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.POAPackage,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,javax.transaction;partial=true;mandatory:=partial,javax.transaction.xa;partial=true;mandatory:=partial"),
+        
+        // Log
+        mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
+        mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
+        // Felix Config Admin
+        mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
+        // Felix mvn url handler
+        mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+
+        // this is how you set the default log level when using pax
+        // logging (logProfile)
+        systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+
+        // Bundles
+        mavenBundle("commons-lang", "commons-lang"),
+        mavenBundle("commons-collections", "commons-collections"),
+        mavenBundle("commons-pool", "commons-pool"),
+        mavenBundle("org.apache.aries", "org.apache.aries.util"),
+        mavenBundle("asm", "asm-all"),
+        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
+        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.api"),
+        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container"),
+        mavenBundle("org.apache.derby", "derby"),
+        mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
+        mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec"),
+        mavenBundle("org.apache.openjpa", "openjpa"),
+        mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.serp"),
+        mavenBundle("org.osgi", "org.osgi.compendium"),
+
+        //vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
+        //waitForFrameworkStartup(),
+        
+       
+//        mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.jpa"),
+//        mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.core"),
+//        mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.asm"),
+        
+        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.advanced.itest.bundle"),
+        
+        PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
+        equinox().version("3.7.0.v20110304"));
+    options = updateOptions(options);
+    return options;
+  }
+  
+  public static MavenArtifactProvisionOption mavenBundle(String groupId,
+      String artifactId) {
+    return CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId)
+        .versionAsInProject();
+  }
+  
+  protected static Option[] updateOptions(Option[] options) {
+    // We need to add pax-exam-junit here when running with the ibm
+    // jdk to avoid the following exception during the test run:
+    // ClassNotFoundException: org.ops4j.pax.exam.junit.Configuration
+    if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
+      Option[] ibmOptions = options(wrappedBundle(mavenBundle(
+          "org.ops4j.pax.exam", "pax-exam-junit")));
+      options = combine(ibmOptions, options);
+    }
+
+    return options;
+  }
+}

Modified: aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/JPAInjectionTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/JPAInjectionTest.java?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/JPAInjectionTest.java (original)
+++ aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/JPAInjectionTest.java Tue Apr 19 13:05:00 2011
@@ -42,7 +42,7 @@ import org.osgi.util.tracker.ServiceTrac
 
 @RunWith(JUnit4TestRunner.class)
 public class JPAInjectionTest {
-  public static final long DEFAULT_TIMEOUT = 60000;
+  public static final long DEFAULT_TIMEOUT = 10000;
 
   @Inject
   protected BundleContext bundleContext;

Modified: aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java (original)
+++ aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java Tue Apr 19 13:05:00 2011
@@ -45,7 +45,7 @@ import org.osgi.util.tracker.ServiceTrac
 
 @RunWith(JUnit4TestRunner.class)
 public class JPAContainerTest {
-  public static final long DEFAULT_TIMEOUT = 60000;
+  public static final long DEFAULT_TIMEOUT = 10000;
 
   @Inject
   protected BundleContext bundleContext;

Modified: aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java (original)
+++ aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java Tue Apr 19 13:05:00 2011
@@ -70,7 +70,7 @@ import org.osgi.util.tracker.ServiceTrac
 
 @RunWith(JUnit4TestRunner.class)
 public class JPAContextTest {
-  public static final long DEFAULT_TIMEOUT = 60000;
+  public static final long DEFAULT_TIMEOUT = 10000;
 
   @Inject
   protected BundleContext bundleContext;

Modified: aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java (original)
+++ aries/trunk/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java Tue Apr 19 13:05:00 2011
@@ -106,7 +106,7 @@ public class QuiesceJPATest {
   }
   
   
-  public static final long DEFAULT_TIMEOUT = 60000;
+  public static final long DEFAULT_TIMEOUT = 10000;
 
   @Inject
   protected BundleContext bundleContext;

Added: aries/trunk/jpa/jpa-container-itest/src/test/java/org/ops4j/pax/runner/platform/equinox/internal/SsActivator.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-itest/src/test/java/org/ops4j/pax/runner/platform/equinox/internal/SsActivator.java?rev=1095075&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container-itest/src/test/java/org/ops4j/pax/runner/platform/equinox/internal/SsActivator.java (added)
+++ aries/trunk/jpa/jpa-container-itest/src/test/java/org/ops4j/pax/runner/platform/equinox/internal/SsActivator.java Tue Apr 19 13:05:00 2011
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.ops4j.pax.runner.platform.equinox.internal;
+
+import org.ops4j.pax.runner.platform.PlatformBuilder;
+import org.ops4j.pax.runner.platform.builder.AbstractPlatformBuilderActivator;
+import org.osgi.framework.BundleContext;
+
+public class SsActivator extends AbstractPlatformBuilderActivator
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected PlatformBuilder[] createPlatformBuilders( final BundleContext bundleContext )
+    {
+        return new PlatformBuilder[]{
+            new EquinoxPlatformBuilder( bundleContext, "3.2.1" ),
+            new EquinoxPlatformBuilder( bundleContext, "3.3.0" ),
+            new EquinoxPlatformBuilder( bundleContext, "3.3.1" ),
+            new EquinoxPlatformBuilder( bundleContext, "3.3.2" ),
+            new EquinoxPlatformBuilder( bundleContext, "3.4.0" ),
+            new EquinoxPlatformBuilder( bundleContext, "3.4.1" ),
+            new EquinoxPlatformBuilder( bundleContext, "3.4.2" ),
+            new EquinoxPlatformBuilder( bundleContext, "3.5.0" ),
+            new EquinoxPlatformBuilder( bundleContext, "3.5.1" ),
+            new EquinoxPlatformBuilder( bundleContext, "3.6.0" ),
+            new EquinoxPlatformBuilder( bundleContext, "3.7.0.V20110304" ),
+            new EquinoxPlatformBuilderSnapshot( bundleContext )
+        };
+    }
+
+}

Added: aries/trunk/jpa/jpa-container-itest/src/test/resources/META-INF/platform-equinox/definition-3.7.0.V20110304.xml
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-itest/src/test/resources/META-INF/platform-equinox/definition-3.7.0.V20110304.xml?rev=1095075&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container-itest/src/test/resources/META-INF/platform-equinox/definition-3.7.0.V20110304.xml (added)
+++ aries/trunk/jpa/jpa-container-itest/src/test/resources/META-INF/platform-equinox/definition-3.7.0.V20110304.xml Tue Apr 19 13:05:00 2011
@@ -0,0 +1,8 @@
+<platform>
+
+  <name>Equinox 3.7.0</name>
+  <system>http://download.eclipse.org/equinox/drops/S-3.7M6-201103101119/org.eclipse.osgi_3.7.0.v20110304.jar</system>
+
+  <profile name="minimal" default="true"/>
+
+</platform>

Added: aries/trunk/jpa/jpa-container-itest/src/test/resources/ss-runner.properties
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-itest/src/test/resources/ss-runner.properties?rev=1095075&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container-itest/src/test/resources/ss-runner.properties (added)
+++ aries/trunk/jpa/jpa-container-itest/src/test/resources/ss-runner.properties Tue Apr 19 13:05:00 2011
@@ -0,0 +1,225 @@
+# --------------------------------------------------------------------------------------------------------------------
+# The following bundles will always be instantiated
+# --------------------------------------------------------------------------------------------------------------------
+# handler service (extender for url stream handlers)
+handler.service=org.ops4j.pax.runner.handler.internal.Activator
+# provision service (extender for scanners)
+provision.service=org.ops4j.pax.scanner.internal.Activator
+# platform service (extender for platforms)
+platform.service=org.ops4j.pax.runner.platform.internal.Activator
+
+# --------------------------------------------------------------------------------------------------------------------
+# Known handlers
+# --------------------------------------------------------------------------------------------------------------------
+# assembly protocol handler
+handler.assembly=org.ops4j.pax.url.assembly.internal.Activator
+# cache protocol handler
+handler.cache=org.ops4j.pax.url.cache.internal.Activator
+# classpath protocol handler
+handler.classpath=org.ops4j.pax.url.classpath.internal.Activator
+# dir protocol handler
+handler.dir=org.ops4j.pax.url.dir.internal.Activator
+# mvn protocol handler
+handler.mvn=org.ops4j.pax.url.mvn.internal.Activator
+# link protocol handler
+handler.link=org.ops4j.pax.url.link.internal.Activator
+# obr protocol handler
+handler.obr=org.ops4j.pax.url.obr.internal.Activator
+# war protocol handler
+handler.war=org.ops4j.pax.url.war.internal.Activator
+# wrap protocol handler
+handler.wrap=org.ops4j.pax.url.wrap.internal.Activator
+
+# --------------------------------------------------------------------------------------------------------------------
+# Known scanners
+# --------------------------------------------------------------------------------------------------------------------
+# scan-bundle
+scanner.bundle=org.ops4j.pax.scanner.bundle.internal.Activator
+# scan-composite
+scanner.composite=org.ops4j.pax.scanner.composite.internal.Activator
+# scan-dir
+scanner.dir=org.ops4j.pax.scanner.dir.internal.Activator
+# scan-file
+scanner.features=org.ops4j.pax.scanner.features.internal.Activator
+# scan-file
+scanner.file=org.ops4j.pax.scanner.file.internal.Activator
+# scan-obr
+scanner.obr=org.ops4j.pax.scanner.obr.internal.Activator
+# scan-pom
+scanner.pom=org.ops4j.pax.scanner.pom.internal.Activator
+
+# --------------------------------------------------------------------------------------------------------------------
+# Known platforms
+# --------------------------------------------------------------------------------------------------------------------
+## Equinox
+platform.equinox.3.2.1=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+platform.equinox.3.3.0=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+platform.equinox.3.3.1=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+platform.equinox.3.3.2=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+platform.equinox.3.4.0=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+platform.equinox.3.4.1=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+platform.equinox.3.4.2=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+platform.equinox.3.5.0=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+platform.equinox.3.5.1=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+platform.equinox.3.6.0=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+platform.equinox.SNAPSHOT=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+platform.equinox.V43PROTOTYPE-3.6.0.201003231329=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+platform.equinox.3.7.0.V20110304=org.ops4j.pax.runner.platform.equinox.internal.SsActivator
+# Felix
+platform.felix.1.0.0=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.1.0.1=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.1.0.3=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.1.0.4=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.1.2.0=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.1.2.1=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.1.2.2=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.1.4.0=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.1.4.1=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.1.6.0=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.1.6.1=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.1.8.0=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.1.8.1=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.2.0.0=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.2.0.1=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.2.0.2=org.ops4j.pax.runner.platform.felix.internal.Activator
+platform.felix.SNAPSHOT=org.ops4j.pax.runner.platform.felix.internal.Activator
+# Knopflerfish
+platform.knopflerfish.2.0.0=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.2.0.1=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.2.0.2=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.2.0.3=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.2.0.4=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.2.0.5=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.2.1.0=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.2.1.1=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.2.2.0=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.2.3.0=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.2.3.1=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.2.3.2=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.2.3.3=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.3.0.0=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+platform.knopflerfish.SNAPSHOT=org.ops4j.pax.runner.platform.knopflerfish.internal.Activator
+#Concierge
+platform.concierge.1.0.0=org.ops4j.pax.runner.platform.concierge.internal.Activator
+platform.concierge.SNAPSHOT=org.ops4j.pax.runner.platform.concierge.internal.Activator
+
+# --------------------------------------------------------------------------------------------------------------------
+# Aditional Services
+# --------------------------------------------------------------------------------------------------------------------
+service.obr=org.apache.felix.bundlerepository.Activator
+
+# --------------------------------------------------------------------------------------------------------------------
+# Default values.
+# Default values are used in case that an option / configuration property is not set.
+# --------------------------------------------------------------------------------------------------------------------
+# defaults for runner options
+# default list of handlers
+default.handlers=handler.mvn,handler.classpath,handler.war,handler.wrap,handler.obr,handler.link,handler.cache,handler.assembly,handler.dir
+# default list of scanners
+default.scanners=scanner.bundle,scanner.composite,scanner.dir,scanner.features,scanner.file,scanner.obr,scanner.pom
+# default platfom
+default.platform=platform.felix
+# default felix platform version
+default.platform.felix.version=2.0.2
+# default equinox platform version
+default.platform.equinox.version=3.5.1
+# default knopflerfish platform version
+default.platform.knopflerfish.version=2.3.3
+# default concierge platform version
+default.platform.concierge.version=1.0.0
+# default list of additional services
+default.services=service.obr
+# default obr repositories
+default.obr.repository.url=http://bundles.osgi.org/obr/browse?_xml=1&cmd=repository
+# default profiles repository
+default.profilesRepositories=http://scm.ops4j.org/repos/ops4j/projects/pax/runner-repository
+# default group id
+default.profilesGroupId=org.ops4j.pax.runner.profiles
+# default "snapshot" platform definition repository
+default.snapshotsRepository=http://scm.ops4j.org/repos/ops4j/projects/pax/runner-repository
+# default "snapshot" Felix platform definition URL
+default.felix.snapshot.definition.url=mvn:${snapshotsRepository}!org.ops4j.pax.runner.platforms/felix//xml
+# default "snapshot" Equinox platform definition URL
+default.equinox.snapshot.definition.url=mvn:${snapshotsRepository}!org.ops4j.pax.runner.platforms/equinox//xml
+# default "snapshot" Knopflerfish platform definition URL
+default.knopflerfish.snapshot.definition.url=mvn:${snapshotsRepository}!org.ops4j.pax.runner.platforms/knopflerfish//xml
+# default "snapshot" Concierge platform definition URL
+default.concierge.snapshot.definition.url=mvn:${snapshotsRepository}!org.ops4j.pax.runner.platforms/concierge//xml
+# default working directory
+default.workingDirectory=runner
+# default caching directory
+default.org.ops4j.pax.url.cache.workingDirectory=${workingDirectory}/cache
+# default platform working directory
+default.org.ops4j.pax.runner.platform.workingDirectory=${workingDirectory}
+
+
+# --------------------------------------------------------------------------------------------------------------------
+# Configuration properties alias
+# Alias are used to transform configuration properties from the fully qualified ones to simple option name or
+# to convert simple values from start arguments to the actual ones.
+# --------------------------------------------------------------------------------------------------------------------
+# aliases for runner options
+alias.platform=p
+alias.platform.equinox=platform.equinox
+alias.platform.e=platform.equinox
+alias.platform.eq=platform.equinox
+alias.platform.felix=platform.felix
+alias.platform.f=platform.felix
+alias.platform.knopflerfish=platform.knopflerfish
+alias.platform.k=platform.knopflerfish
+alias.platform.kf=platform.knopflerfish
+alias.platform.concierge=platform.concierge
+alias.platform.c=platform.concierge
+alias.version=v
+alias.snapshot=s
+alias.workingDirectory=dir
+
+# aliases for handlers
+alias.org.ops4j.pax.url.mvn.certificateCheck=certificateCheck
+alias.org.ops4j.pax.url.mvn.defaultRepositories=defaultRepositories,dr
+alias.org.ops4j.pax.url.mvn.localRepository=localRepository,lr,maven.repo.local
+alias.org.ops4j.pax.url.mvn.repositories=repositories,repos
+alias.org.ops4j.pax.url.mvn.settings=settings
+alias.org.ops4j.pax.url.mvn.useFallbackRepositories=useFallbackRepositories,ufr
+alias.org.ops4j.pax.url.obr.certificateCheck=certificateCheck
+alias.org.ops4j.pax.url.war.certificateCheck=certificateCheck
+alias.org.ops4j.pax.url.wrap.certificateCheck=certificateCheck
+alias.org.ops4j.pax.scanner.composite.certificateCheck=certificateCheck
+alias.org.ops4j.pax.scanner.features.certificateCheck=certificateCheck
+
+# aliases for platform options
+alias.org.ops4j.pax.runner.platform.bootDelegation=bootDelegation,bd
+alias.org.ops4j.pax.runner.platform.bundleStartLevel=bundleStartLevel,bsl
+alias.org.ops4j.pax.runner.platform.classpath=classPath,cp
+alias.org.ops4j.pax.runner.platform.console=console
+alias.org.ops4j.pax.runner.platform.definitionURL=definitionURL
+alias.org.ops4j.pax.runner.platform.frameworkProfile=frameworkProfile,fp
+alias.org.ops4j.pax.runner.platform.ee=ee
+alias.org.ops4j.pax.runner.platform.javaHome=javaHome,home
+alias.org.ops4j.pax.runner.platform.overwrite=overwrite
+alias.org.ops4j.pax.runner.platform.overwriteUserBundles=overwriteUserBundles
+alias.org.ops4j.pax.runner.platform.overwriteSystemBundles=overwriteSystemBundles
+alias.org.ops4j.pax.runner.platform.profileStartLevel=profileStartLevel,psl
+alias.org.ops4j.pax.runner.platform.startLevel=startLevel,sl
+alias.org.ops4j.pax.runner.platform.systemPackages=systemPackages,sp
+alias.org.ops4j.pax.runner.platform.usePersistedState=usePersistedState,ups
+alias.org.ops4j.pax.runner.platform.vmOptions=vmOptions,vmo
+alias.org.ops4j.pax.runner.platform.debugClassLoading=debugClassLoading,dcl
+alias.org.ops4j.pax.runner.platform.downloadFeedback=downloadFeedback,df
+alias.org.ops4j.pax.runner.platform.autoWrap=autoWrap
+alias.org.ops4j.pax.runner.platform.keepOriginalUrls=keepOriginalUrls,kou
+alias.org.ops4j.pax.runner.platform.bundleValidation=bundleValidation
+alias.org.ops4j.pax.runner.platform.skipInvalidBundles=skipInvalidBundles,sib
+alias.org.ops4j.pax.runner.platform.useAbsoluteFilePaths=useAbsoluteFilePaths,absoluteFilePaths,uafp
+
+# aliases for scanners
+alias.org.ops4j.pax.scanner.bundle.start=start
+alias.org.ops4j.pax.scanner.composite.start=start
+alias.org.ops4j.pax.scanner.dir.start=start
+alias.org.ops4j.pax.scanner.features.start=start
+alias.org.ops4j.pax.scanner.file.start=start
+alias.org.ops4j.pax.scanner.obr.start=start
+alias.org.ops4j.pax.scanner.pom.start=start
+
+# aliases for additional services
+alias.obr.repository.url=obrRepositories|obrRepos

Modified: aries/trunk/jpa/jpa-container/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/pom.xml?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/pom.xml (original)
+++ aries/trunk/jpa/jpa-container/pom.xml Tue Apr 19 13:05:00 2011
@@ -50,6 +50,9 @@
             org.apache.aries.jpa.container.parsing;version="[0.1.0,1.1.0)",
             org.apache.aries.quiesce.manager;version="[0.2,1.0)";resolution:=optional,
             org.apache.aries.quiesce.participant;version="[0.2,1.0)";resolution:=optional,
+            org.osgi.framework;version="[1.5,2)",
+            org.osgi.framework.hooks.weaving;version="[1,1.1)";resolution:=optional,
+            org.osgi.framework.wiring;version="[1,2)";resolution:=optional,
             *
         </aries.osgi.import>
       <aries.osgi.activator>
@@ -58,11 +61,25 @@
     </properties>
     
     <dependencies>
+        <!-- Use the Eclipse version of OSGi until the core 4.3 OSGi jar is available in Maven. -->        
         <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
-            <scope>provided</scope>
+            <groupId>org.eclipse</groupId>
+            <artifactId>osgi</artifactId>
+            <version>3.7M6</version>
+            <scope>system</scope>
+            <systemPath>${basedir}/../jpa-tmp/target/downloaded/org.eclipse.osgi_3.7.0.jar</systemPath>
         </dependency>
+    
+        <!-- <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId> -->
+            <!-- 
+                 We override the version here because we need it
+                 to compile our weaving hook. We still want our
+                 bundles to be able to run with 4.2 though!
+            -->
+            <!-- <version>4.3</version>
+        </dependency> -->
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
@@ -71,19 +88,40 @@
         <dependency>
             <artifactId>org.apache.aries.jpa.api</artifactId>
             <groupId>org.apache.aries.jpa</groupId>
-            <version>0.3.1-SNAPSHOT</version>
+            <version>0.4-SNAPSHOT</version>
+            
+            <exclusions>
+                <exclusion>
+                    <groupId>org.osgi</groupId>
+                    <artifactId>org.osgi.core</artifactId>                    
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.aries.quiesce</groupId>
             <artifactId>org.apache.aries.quiesce.api</artifactId>
             <version>0.3</version>
             <scope>provided</scope>
+            
+            <exclusions>
+                <exclusion>
+                    <groupId>org.osgi</groupId>
+                    <artifactId>org.osgi.core</artifactId>                    
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <artifactId>org.apache.aries.util</artifactId>
             <groupId>org.apache.aries</groupId>
             <version>0.4-SNAPSHOT</version>
             <scope>provided</scope>
+            
+            <exclusions>
+                <exclusion>
+                    <groupId>org.osgi</groupId>
+                    <artifactId>org.osgi.core</artifactId>                    
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
@@ -105,6 +143,13 @@
             <artifactId>org.apache.aries.testsupport.unit</artifactId>
             <scope>test</scope>
             <version>0.3</version>
+            
+            <exclusions>
+                <exclusion>
+                    <groupId>org.osgi</groupId>
+                    <artifactId>org.osgi.core</artifactId>                    
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <dependency>

Added: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/AnnotationScanner.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/AnnotationScanner.java?rev=1095075&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/AnnotationScanner.java (added)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/AnnotationScanner.java Tue Apr 19 13:05:00 2011
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jpa.container.annotation.impl;
+import java.util.Collection;
+
+import org.osgi.framework.Bundle;
+
+public interface AnnotationScanner {
+  /**
+   * Scan a bundle for classes annotated with @Entity, @MappedSuperClass, or @Embeddable
+   * @param b The bundle to scan
+   * @return A collection of class names
+   */
+  public Collection<String> findJPAAnnotatedClasses(Bundle b);
+}

Added: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/AnnotationScannerFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/AnnotationScannerFactory.java?rev=1095075&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/AnnotationScannerFactory.java (added)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/AnnotationScannerFactory.java Tue Apr 19 13:05:00 2011
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jpa.container.annotation.impl;
+
+/**
+ * Creates an {@link AnnotationScanner} on startup unless BundleWiring support
+ * is unavailable
+ */
+public class AnnotationScannerFactory {
+
+private static final AnnotationScanner _instance;
+  
+  static {
+    AnnotationScanner tr = null;
+    try {
+      Class.forName("org.osgi.framework.wiring.BundleWiring");
+      tr = new JPAAnnotationScanner();
+    } catch (ClassNotFoundException cnfe) {
+      //TODO log this
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    } 
+    _instance = tr;
+  }
+  /**
+   * Get the current {@link AnnotationScanner}, or null if none is available
+   * @return
+   */
+  public static AnnotationScanner getAnnotationScanner() {
+    return _instance;
+  }
+}

Added: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/JPAAnnotationScanner.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/JPAAnnotationScanner.java?rev=1095075&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/JPAAnnotationScanner.java (added)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/annotation/impl/JPAAnnotationScanner.java Tue Apr 19 13:05:00 2011
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jpa.container.annotation.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.persistence.Embeddable;
+import javax.persistence.Entity;
+import javax.persistence.MappedSuperclass;
+
+import org.apache.aries.jpa.container.unit.impl.TempBundleDelegatingClassLoader;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.wiring.BundleWiring;
+
+class JPAAnnotationScanner implements AnnotationScanner {
+
+  
+  public Collection<String> findJPAAnnotatedClasses(Bundle b) {
+    BundleWiring bw = b.adapt(BundleWiring.class);
+    Collection<String> resources = bw.listResources("/", "*.class", 
+        BundleWiring.LISTRESOURCES_LOCAL | BundleWiring.LISTRESOURCES_RECURSE);
+    
+    Collection<String> classes = new ArrayList<String>(); 
+    ClassLoader cl = new TempBundleDelegatingClassLoader(b, this.getClass().getClassLoader());
+    for(String s : resources) {
+      s = s.replace('/', '.').substring(0, s.length() - 6);
+      try {
+        Class<?> clazz = Class.forName(s, false, cl);
+        
+        if(clazz.isAnnotationPresent(Entity.class) ||
+           clazz.isAnnotationPresent(MappedSuperclass.class) ||
+           clazz.isAnnotationPresent(Embeddable.class)) {
+          classes.add(s);
+        }
+        
+      } catch (ClassNotFoundException cnfe) {
+        
+      } catch (NoClassDefFoundError ncdfe) {
+        
+      }
+    }
+    return classes;
+  }
+
+}

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java Tue Apr 19 13:05:00 2011
@@ -20,8 +20,10 @@ package org.apache.aries.jpa.container.i
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Hashtable;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
@@ -77,7 +79,7 @@ public class EntityManagerFactoryManager
   /** The {@link PersistenceProvider} to use */
   private ServiceReference provider;
   /** The persistence units to manage */
-  private Collection<ManagedPersistenceUnitInfo> persistenceUnits;
+  private Collection<? extends ManagedPersistenceUnitInfo> persistenceUnits;
   /** The original parsed data */
   private Collection<ParsedPersistenceUnit> parsedData;
   /** A Map of created {@link EntityManagerFactory}s */
@@ -104,7 +106,7 @@ public class EntityManagerFactoryManager
    * @param ref 
    * @param parsedUnits 
    */
-  public EntityManagerFactoryManager(BundleContext containerCtx, Bundle b, Collection<ParsedPersistenceUnit> parsedUnits, ServiceReference ref, Collection<ManagedPersistenceUnitInfo> infos) {
+  public EntityManagerFactoryManager(BundleContext containerCtx, Bundle b, Collection<ParsedPersistenceUnit> parsedUnits, ServiceReference ref, Collection<? extends ManagedPersistenceUnitInfo> infos) {
     containerContext = containerCtx;
     bundle = b;
     provider = ref;
@@ -211,15 +213,15 @@ public class EntityManagerFactoryManager
       //Register each EMF
       for(Entry<String, ? extends EntityManagerFactory> entry : emfs.entrySet())
       {
-        Properties props = new Properties();
+        Hashtable<String,Object> props = new Hashtable<String, Object>();
         String unitName = entry.getKey();
           
         props.put(PersistenceUnitConstants.OSGI_UNIT_NAME, unitName);
         if(providerName != null)
           props.put(PersistenceUnitConstants.OSGI_UNIT_PROVIDER, providerName);
-        props.put(PersistenceUnitConstants.OSGI_UNIT_VERSION, provider.getBundle().getVersion());
-        props.put(PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT, Boolean.TRUE);
-        props.put(PersistenceUnitConstants.EMPTY_PERSISTENCE_UNIT_NAME, "".equals(unitName));
+          props.put(PersistenceUnitConstants.OSGI_UNIT_VERSION, provider.getBundle().getVersion());
+          props.put(PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT, Boolean.TRUE);
+          props.put(PersistenceUnitConstants.EMPTY_PERSISTENCE_UNIT_NAME, "".equals(unitName));
         try {
           registrations.put(unitName, bundle.getBundleContext().registerService(EntityManagerFactory.class.getCanonicalName(), entry.getValue(), props));
         } catch (Exception e) {
@@ -278,7 +280,7 @@ public class EntityManagerFactoryManager
    * @param infos The {@link PersistenceUnitInfo}s defined by our bundle
    */
   public synchronized void manage(ServiceReference ref,
-      Collection<ManagedPersistenceUnitInfo> infos)  throws IllegalStateException{
+      Collection<? extends ManagedPersistenceUnitInfo> infos)  throws IllegalStateException{
     provider = ref;
     persistenceUnits = infos;
   }
@@ -294,7 +296,7 @@ public class EntityManagerFactoryManager
    * @param infos The {@link PersistenceUnitInfo}s defined by our bundle
    */
   public synchronized void manage(Collection<ParsedPersistenceUnit> parsedUnits, ServiceReference ref,
-      Collection<ManagedPersistenceUnitInfo> infos)  throws IllegalStateException{
+      Collection<? extends ManagedPersistenceUnitInfo> infos)  throws IllegalStateException{
     parsedData = parsedUnits;
     provider = ref;
     persistenceUnits = infos;

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java Tue Apr 19 13:05:00 2011
@@ -119,7 +119,8 @@ public class PersistenceBundleManager im
     
     if(className != null) {
       try {
-        Class<? extends ManagedPersistenceUnitInfoFactory> clazz = ctx.getBundle().loadClass(className);
+        Class<? extends ManagedPersistenceUnitInfoFactory> clazz = 
+          (Class<? extends ManagedPersistenceUnitInfoFactory>) ctx.getBundle().loadClass(className);
         persistenceUnitFactory = clazz.newInstance();
       } catch (Exception e) {
         _logger.error("There was a problem creating the custom ManagedPersistenceUnitInfoFactory " + className 
@@ -183,7 +184,7 @@ public class PersistenceBundleManager im
         : managersToManage.entrySet()) {
       EntityManagerFactoryManager mgr = entry.getKey();
       ServiceReference reference = entry.getValue();
-      Collection<ManagedPersistenceUnitInfo> infos = null;
+      Collection<? extends ManagedPersistenceUnitInfo> infos = null;
       try {
          infos = persistenceUnitFactory.createManagedPersistenceUnitMetadata(
              ctx, mgr.getBundle(), reference, mgr.getParsedPersistenceUnits());
@@ -360,7 +361,7 @@ public class PersistenceBundleManager im
         
         ServiceReference ref = getProviderServiceReference(pUnits);
         //If we found a provider then create the ManagedPersistenceUnitInfo objects
-        Collection<ManagedPersistenceUnitInfo> infos = null;
+        Collection<? extends ManagedPersistenceUnitInfo> infos = null;
         if(ref != null) {  
           infos = persistenceUnitFactory.
               createManagedPersistenceUnitMetadata(ctx, bundle, ref, pUnits);

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceDescriptorParserImpl.java Tue Apr 19 13:05:00 2011
@@ -19,7 +19,6 @@
 
 package org.apache.aries.jpa.container.parsing.impl;
 
-import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -183,7 +182,7 @@ public class PersistenceDescriptorParser
   /* (non-Javadoc)
    * @see org.apache.aries.jpa.container.parsing.impl.PersistenceDescriptorParser#parse(org.osgi.framework.Bundle, org.apache.aries.jpa.container.parsing.PersistenceDescriptor)
    */
-  public Collection<ParsedPersistenceUnit> parse(Bundle b, PersistenceDescriptor descriptor) throws PersistenceDescriptorParserException {
+  public Collection<? extends ParsedPersistenceUnit> parse(Bundle b, PersistenceDescriptor descriptor) throws PersistenceDescriptorParserException {
     Collection<ParsedPersistenceUnit> persistenceUnits = new ArrayList<ParsedPersistenceUnit>();
     SAXParserFactory parserFactory = SAXParserFactory.newInstance();
     InputStream is = null;

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java Tue Apr 19 13:05:00 2011
@@ -20,6 +20,9 @@ package org.apache.aries.jpa.container.u
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
 import org.apache.aries.jpa.container.ManagedPersistenceUnitInfoFactory;
@@ -31,101 +34,36 @@ import org.osgi.framework.ServiceReferen
 public class ManagedPersistenceUnitInfoFactoryImpl implements
     ManagedPersistenceUnitInfoFactory {
 
-  public Collection<ManagedPersistenceUnitInfo> createManagedPersistenceUnitMetadata(
+  private ConcurrentMap<Bundle, Collection<ManagedPersistenceUnitInfoImpl>> persistenceUnits = 
+      new ConcurrentHashMap<Bundle, Collection<ManagedPersistenceUnitInfoImpl>>();
+  
+  public Collection<? extends ManagedPersistenceUnitInfo> createManagedPersistenceUnitMetadata(
       BundleContext containerContext, Bundle persistenceBundle,
       ServiceReference providerReference,
       Collection<ParsedPersistenceUnit> persistenceMetadata) {
     
-    //TODO add support for provider bundle imports (e.g. for weaving) here
-    
-    Collection<ManagedPersistenceUnitInfo> managedUnits = new ArrayList<ManagedPersistenceUnitInfo>();
+    Collection<ManagedPersistenceUnitInfoImpl> managedUnits = new ArrayList<ManagedPersistenceUnitInfoImpl>();
     
     for(ParsedPersistenceUnit unit : persistenceMetadata)
       managedUnits.add(new ManagedPersistenceUnitInfoImpl(persistenceBundle, unit, providerReference));
     
-    return managedUnits;
+    Collection<?> existing = persistenceUnits.putIfAbsent(persistenceBundle, managedUnits);
+    if(existing != null)
+      throw new IllegalStateException("Previous units were detected that have not been destroyed");
+    return Collections.unmodifiableCollection(managedUnits);
   }
 
   public void destroyPersistenceBundle(BundleContext containerContext, Bundle bundle) {
-
+    Collection<ManagedPersistenceUnitInfoImpl> mpus = persistenceUnits.remove(bundle);
+    if(mpus == null)
+      throw new IllegalStateException("No persistence units defined for bundle " +
+          bundle.getSymbolicName() + "_" + bundle.getVersion());
+    for(ManagedPersistenceUnitInfoImpl impl : mpus) {
+      impl.destroy();
+    }
   }
 
   public String getDefaultProviderClassName() {
     return null;
   }
-
-  //Code that can be used to attach a fragment for provider wiring
-  
-////If we can't find a provider then bomb out
-//if (providerRef != null)
-//{
-//  try 
-//    FragmentBuilder builder = new FragmentBuilder(b, ".jpa.fragment");
-//    builder.addImportsFromExports(providerRef.getBundle());
-//    fragment = builder.install(ctx);
-//  
-//    
-//    hostToFragmentMap.put(b, fragment);
-//    // If we successfully got a fragment then
-//    // set the provider reference and register the units
-//    Set<ServiceRegistration> registrations = new HashSet<ServiceRegistration>();
-//    Hashtable<String, Object> props = new Hashtable<String, Object>();
-//    
-//    props.put(PersistenceUnitInfoService.PERSISTENCE_BUNDLE_SYMBOLIC_NAME, b.getSymbolicName());
-//    props.put(PersistenceUnitInfoService.PERSISTENCE_BUNDLE_VERSION, b.getVersion());
-//    
-//    for(PersistenceUnitImpl unit : parsedPersistenceUnits){
-//      Hashtable<String, Object> serviceProps = new Hashtable<String, Object>(props);
-//      
-//      String unitName = (String) unit.getPersistenceXmlMetadata().get(PersistenceUnitInfoService.UNIT_NAME);
-//      if(unitName != null)
-//        serviceProps.put(PersistenceUnitInfoService.PERSISTENCE_UNIT_NAME, unitName);
-//      
-//      unit.setProviderReference(providerRef);
-//      registrations.add(ctx.registerService(PersistenceUnitInfoService.class.getName(), unit, serviceProps));
-//    }
-//    hostToPersistenceUnitMap.put(b, registrations);
-//  }
-//  catch (IOException e)
-//  {
-//    // TODO Fragment generation failed, log the error
-//    // No clean up because we didn't register the bundle yet
-//    e.printStackTrace();
-//  }
-//  catch (BundleException be) {
-//    //TODO log the failure to install the fragment, but return null
-//    // to show we didn't get a fragment installed
-//    // No clean up because we didn't register the bundle yet
-//  }
-//}
-//}
-//}
-  
-  //Code that can be used to clear up a persistence unit
-  
-///**
-// * If we have generated a resources for the supplied bundle, then
-// * tidy them  up.
-// * @param host
-// */
-//private void tidyUpPersistenceBundle(Bundle host)
-//{
-//  
-//  Bundle fragment = hostToFragmentMap.remove(host);
-//  Set<ServiceRegistration> services = hostToPersistenceUnitMap.remove(host);
-//  
-//  if(services != null) {
-//    for(ServiceRegistration reg : services)
-//      reg.unregister();
-//  }
-//  
-//  if(fragment != null){
-//    try {
-//      fragment.uninstall();
-//    } catch (BundleException be) {
-//      //TODO log this error, then hope that we don't try to
-//      //recreate the fragment before restarting the framework!
-//    }
-//  }
-//}
 }

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoImpl.java?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoImpl.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoImpl.java Tue Apr 19 13:05:00 2011
@@ -31,7 +31,7 @@ import org.osgi.framework.ServiceReferen
 public class ManagedPersistenceUnitInfoImpl implements
     ManagedPersistenceUnitInfo {
 
-  private final PersistenceUnitInfo info;
+  private final PersistenceUnitInfoImpl info;
   
   public ManagedPersistenceUnitInfoImpl(Bundle persistenceBundle,
       ParsedPersistenceUnit unit,
@@ -47,5 +47,7 @@ public class ManagedPersistenceUnitInfoI
     return info;
   }
 
-
+  public void destroy() {
+    info.clearUp();
+  }
 }

Modified: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java?rev=1095075&r1=1095074&r2=1095075&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java (original)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java Tue Apr 19 13:05:00 2011
@@ -31,7 +31,11 @@ import javax.persistence.spi.Persistence
 import javax.persistence.spi.PersistenceUnitTransactionType;
 import javax.sql.DataSource;
 
+import org.apache.aries.jpa.container.annotation.impl.AnnotationScanner;
+import org.apache.aries.jpa.container.annotation.impl.AnnotationScannerFactory;
 import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
+import org.apache.aries.jpa.container.weaving.impl.TransformerRegistry;
+import org.apache.aries.jpa.container.weaving.impl.TransformerRegistryFactory;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
@@ -47,6 +51,8 @@ public class PersistenceUnitInfoImpl imp
   
   private final ServiceReference providerRef;
   
+  private ClassTransformer transformer;
+  
   /** Logger */
   private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.jpa.container");
   
@@ -58,14 +64,22 @@ public class PersistenceUnitInfoImpl imp
     cl = new BundleDelegatingClassLoader(b);
   }
   
-  public void addTransformer(ClassTransformer arg0) {
-    // TODO Add support for class transformation from this method
+  public synchronized void addTransformer(ClassTransformer arg0) {
+    TransformerRegistry reg = TransformerRegistryFactory.getTransformerRegistry();
+    if(reg != null) {
+      reg.addTransformer(bundle, arg0, providerRef);
+      transformer = arg0;
+    }
   }
 
-  public boolean excludeUnlistedClasses() {
+  public boolean internalExcludeUnlistedClasses() {
     Boolean result = (Boolean) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.EXCLUDE_UNLISTED_CLASSES);
     return (result == null) ? false : result;
   }
+  
+  public boolean excludeUnlistedClasses() {
+    return true;
+  }
 
   public ClassLoader getClassLoader() {
     return cl;
@@ -104,6 +118,11 @@ public class PersistenceUnitInfoImpl imp
     List<String> classes = (List<String>) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.MANAGED_CLASSES);
     if(classes == null)
       classes = new ArrayList<String>();
+    if(!!!internalExcludeUnlistedClasses()) {
+      AnnotationScanner scanner = AnnotationScannerFactory.getAnnotationScanner();
+      if(scanner != null)
+        classes.addAll(scanner.findJPAAnnotatedClasses(bundle));
+    }
     
     return Collections.unmodifiableList(classes);
   }
@@ -179,5 +198,13 @@ public class PersistenceUnitInfoImpl imp
       return ValidationMode.valueOf(s);
 
   }
+
+  public synchronized void clearUp() {
+    if(transformer != null) {
+      TransformerRegistry reg = TransformerRegistryFactory.getTransformerRegistry();
+      reg.removeTransformer(bundle, transformer);
+      transformer = null;
+    }
+  }
   
 }
\ No newline at end of file

Added: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java?rev=1095075&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java (added)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/JPAWeavingHook.java Tue Apr 19 13:05:00 2011
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jpa.container.weaving.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.persistence.spi.ClassTransformer;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.hooks.weaving.WeavingException;
+import org.osgi.framework.hooks.weaving.WeavingHook;
+import org.osgi.framework.hooks.weaving.WovenClass;
+import org.osgi.framework.wiring.BundleWiring;
+
+/**
+ * This weaving hook delegates to any registered {@link ClassTransformer} instances
+ * for a given bundle
+ */
+public class JPAWeavingHook implements WeavingHook, TransformerRegistry {
+
+  /**
+   * This constructor should not be called directly, the {@link JPAWeavingHookFactory} 
+   * should be used to ensure that Weaving support is available.
+   */
+  JPAWeavingHook() { }
+  
+  /** 
+   * With luck we will only have one persistence unit per bundle, but
+   * if we don't we'll need to call them until one of them does a transform
+   * or we run out.
+   */
+  private final ConcurrentMap<Bundle, LinkedHashSet<WrappingTransformer>> registeredTransformers
+      = new ConcurrentHashMap<Bundle, LinkedHashSet<WrappingTransformer>>();
+  
+  public void weave(WovenClass wovenClass) {
+    
+    BundleWiring wiring = wovenClass.getBundleWiring();
+    
+    Collection<WrappingTransformer> transformers = registeredTransformers.get(
+        wiring.getBundle());
+    
+    if(transformers != null) {
+      Collection<WrappingTransformer> transformersToTry;
+      synchronized (transformers) {
+        transformersToTry = new ArrayList<WrappingTransformer>(transformers);
+      }
+      for(WrappingTransformer transformer : transformersToTry) {
+        try {
+          byte[] result = transformer.transform(wiring.getClassLoader(), 
+              wovenClass.getClassName(), wovenClass.getDefinedClass(), 
+              wovenClass.getProtectionDomain(), wovenClass.getBytes());
+          if(result != null) {
+            wovenClass.setBytes(result);
+            wovenClass.getDynamicImports().addAll(transformer.getPackagesToAdd());
+            break;
+          }
+        } catch (Throwable t) {
+          if(t instanceof ThreadDeath)
+            throw (ThreadDeath)t;
+          else if (t instanceof OutOfMemoryError)
+            throw (OutOfMemoryError) t;
+          else throw new WeavingException("There was an error attempting to weave " +
+              wovenClass.getClassName() + " using transformer " + transformer.toString()
+              , t);
+        }
+      }
+    }
+  }
+  
+  public void addTransformer(Bundle pBundle, ClassTransformer transformer, ServiceReference<?> provider) {
+    
+    //Optimised for single adds
+    
+    LinkedHashSet<WrappingTransformer> set = new LinkedHashSet<WrappingTransformer>();
+    WrappingTransformer wt = new WrappingTransformer(transformer, provider);
+    set.add(wt);
+    
+    LinkedHashSet<WrappingTransformer> existingSet = registeredTransformers.putIfAbsent(pBundle, set);
+    
+    if(existingSet != null) {
+      synchronized (existingSet) {
+        existingSet.add(wt);
+      }
+    }
+  }
+   
+  public void removeTransformer(Bundle pBundle, ClassTransformer transformer) {
+    LinkedHashSet<WrappingTransformer> set = registeredTransformers.get(pBundle);
+    
+    if(set == null || !!!safeRemove(set, transformer))
+      throw new IllegalStateException("The transformer " + transformer + " is not registered");
+    
+    if(set.isEmpty())
+      registeredTransformers.remove(pBundle);
+  }
+
+  /**
+   * Perform a remove on the collection while synchronized on it
+   * @param set
+   * @param t
+   * @return
+   */
+  private boolean safeRemove(Collection<WrappingTransformer> set, ClassTransformer t) {
+    synchronized(set) {
+        return set.remove(new WrappingTransformer(t));
+      }
+  }
+}

Added: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistry.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistry.java?rev=1095075&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistry.java (added)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistry.java Tue Apr 19 13:05:00 2011
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jpa.container.weaving.impl;
+
+import javax.persistence.spi.ClassTransformer;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * {@link ClassTransformer} instances should be registered with the
+ * instance of this interface returned by {@link TransformerRegistryFactory#getTransformerRegistry()}
+ */
+public interface TransformerRegistry {
+
+  /**
+   * Register a new transformer with the WeavingHook
+   * 
+   * @param pBundle  The persistence bundle to weave
+   * @param transformer  The transformer to weave with
+   * @param provider The provider to provide packages from
+   */
+  public void addTransformer(Bundle pBundle, ClassTransformer transformer, ServiceReference<?> provider);
+  
+  
+  /**
+   * Remove a given transformer from this weaving hook. This must be 
+   * @param pBundle
+   * @param transformer
+   */
+  public void removeTransformer(Bundle pBundle, ClassTransformer transformer);
+}

Added: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistryFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistryFactory.java?rev=1095075&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistryFactory.java (added)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/TransformerRegistryFactory.java Tue Apr 19 13:05:00 2011
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jpa.container.weaving.impl;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.FrameworkUtil;
+
+/**
+ * This class is used to get hold of the active {@link TransformerRegistry}
+ * for this bundle. 
+ */
+public class TransformerRegistryFactory {
+  private static final TransformerRegistry _instance;
+  private static final int mask = Bundle.ACTIVE | Bundle.STARTING | Bundle.STOPPING;
+  
+  static {
+    TransformerRegistry tr = null;
+    try {
+      tr = (TransformerRegistry) Class.forName("org.apache.aries.jpa.container.weaving.impl.JPAWeavingHook").newInstance();
+      Bundle b = FrameworkUtil.getBundle(tr.getClass());
+      if(b != null && (b.getState() & mask) != 0)
+        b.getBundleContext().registerService(
+            "org.osgi.framework.hooks.weaving.WeavingHook", tr, null);
+    } catch (NoClassDefFoundError ncdfe) {
+      //TODO log this
+    } catch (Exception e) {
+      throw new RuntimeException(e);
+    } 
+    _instance = tr;
+  }
+  
+  /**
+   * @return the active {@link TransformerRegistry} or null if no transformation
+   * support is available
+   */
+  public static TransformerRegistry getTransformerRegistry() {
+    return _instance;
+  }
+}

Added: aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java?rev=1095075&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java (added)
+++ aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/weaving/impl/WrappingTransformer.java Tue Apr 19 13:05:00 2011
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.jpa.container.weaving.impl;
+
+import java.lang.instrument.IllegalClassFormatException;
+import java.security.ProtectionDomain;
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.persistence.spi.ClassTransformer;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.framework.wiring.BundleWiring;
+
+class WrappingTransformer implements ClassTransformer {
+  private final ClassTransformer delegate;
+  private final Collection<String> packageImportsToAdd = new HashSet<String>();
+  
+  public WrappingTransformer(ClassTransformer delegate,
+      ServiceReference<?> persistenceProvider) {
+
+    if(delegate == null) 
+      throw new NullPointerException("Delegate transformer must not be null");
+    
+    if(persistenceProvider == null) {
+      throw new NullPointerException("Persistence Provider must not be null");
+    }
+    
+    this.delegate = delegate;
+    
+    Object packages = persistenceProvider.getProperty("org.apache.aries.jpa.container.weaving.packages");
+    
+    Bundle provider = persistenceProvider.getBundle();
+    String suffix = ";" + Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE + "=" +
+    provider.getSymbolicName() + ";" + Constants.BUNDLE_VERSION_ATTRIBUTE 
+    + "=" + provider.getVersion();
+    
+    if(packages instanceof String[]) {
+      for(String s : (String[]) packages) {
+        packageImportsToAdd.add(s + suffix);
+      }
+    } else {
+      BundleRevision br = provider.adapt(BundleWiring.class).getRevision();
+      for(BundleCapability bc : br.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE)) {
+        packageImportsToAdd.add(bc.getAttributes().get(BundleRevision.PACKAGE_NAMESPACE) + suffix);
+      }
+    }
+  }
+
+  public WrappingTransformer(ClassTransformer transformer) {
+    delegate = transformer;
+  }
+
+  public byte[] transform(ClassLoader arg0, String arg1, Class<?> arg2,
+      ProtectionDomain arg3, byte[] arg4) throws IllegalClassFormatException {
+    return delegate.transform(arg0, arg1, arg2, arg3, arg4);
+  }
+  
+  public Collection<String> getPackagesToAdd() {
+    return packageImportsToAdd;
+  }
+  
+  public int hashCode() {
+    return delegate.hashCode();
+  }
+  
+  public boolean equals(Object o) {
+    if(o instanceof WrappingTransformer)
+      return delegate == ((WrappingTransformer) o).delegate;
+
+    return false;
+  }
+  
+  public String toString() {
+    return "Transformer: " + delegate.toString() + " Packages to add: " + packageImportsToAdd;
+  }
+}
\ No newline at end of file



Mime
View raw message