aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eji...@apache.org
Subject svn commit: r1342638 - in /aries/trunk/jpa: jpa-api/src/main/java/org/apache/aries/jpa/container/ jpa-container/src/main/java/org/apache/aries/jpa/container/impl/ jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ jpa-container/src/m...
Date Fri, 25 May 2012 14:30:05 GMT
Author: ejiang
Date: Fri May 25 14:30:04 2012
New Revision: 1342638

URL: http://svn.apache.org/viewvc?rev=1342638&view=rev
Log:
ARIES-832: JPA load-time enhamcement fails for a WAB - Patch from Brian DePradine 

Added:
    aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/PersistenceUnitInfo.java
Modified:
    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/unit/impl/PersistenceUnitInfoImpl.java
    aries/trunk/jpa/jpa-container/src/main/resources/org/apache/aries/jpa/container/nls/jpaContainerMessages.properties
    aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/PersistenceBundleLifecycleTest.java

Added: aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/PersistenceUnitInfo.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/PersistenceUnitInfo.java?rev=1342638&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/PersistenceUnitInfo.java (added)
+++ aries/trunk/jpa/jpa-api/src/main/java/org/apache/aries/jpa/container/PersistenceUnitInfo.java Fri May 25 14:30:04 2012
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+import javax.persistence.spi.ClassTransformer;
+
+
+/**
+ * Extend the {@link javax.persistence.spi.PersistenceUnitInfo} to allow access
+ * to setup from the persistence provider
+ */
+public interface PersistenceUnitInfo extends
+        javax.persistence.spi.PersistenceUnitInfo {
+
+    /**
+     * Retrieve the {@link ClassTransformer} set by the persistence provider
+     * 
+     * @return an instance of {@link ClassTransformer}
+     */
+    public ClassTransformer getTransformer();
+}

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=1342638&r1=1342637&r2=1342638&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 Fri May 25 14:30:04 2012
@@ -31,11 +31,12 @@ import java.util.concurrent.ConcurrentHa
 import java.util.concurrent.ConcurrentMap;
 
 import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.ClassTransformer;
 import javax.persistence.spi.PersistenceProvider;
-import javax.persistence.spi.PersistenceUnitInfo;
 
 import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
 import org.apache.aries.jpa.container.PersistenceUnitConstants;
+import org.apache.aries.jpa.container.PersistenceUnitInfo;
 import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
 import org.apache.aries.util.AriesFrameworkUtil;
 import org.osgi.framework.Bundle;
@@ -89,16 +90,16 @@ public class EntityManagerFactoryManager
   private ConcurrentMap<String, ServiceRegistration> registrations = null;
   /** Quiesce this Manager */
   private boolean quiesce = false;
-  
+
   private volatile ServiceTracker tracker; 
-  
+
   /** DataSourceFactories in use by persistence units in this bundle - class name key to collection of unit values */
   private final ConcurrentMap<String, Collection<String>> dataSourceFactories = 
-         new ConcurrentHashMap<String, Collection<String>>();
+    new ConcurrentHashMap<String, Collection<String>>();
 
   /** Logger */
   private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.jpa.container");
-  
+
   /**
    * Create an {@link EntityManagerFactoryManager} for
    * the supplied persistence bundle.
@@ -146,12 +147,12 @@ public class EntityManagerFactoryManager
    * @return true if the the provider is being used by this manager
    */
   public synchronized boolean providerRemoved(ServiceReference ref) {
-    
+
     boolean toReturn = provider.equals(ref);
-    
+
     if(toReturn)
       destroy();
-    
+
     return toReturn;
   }
 
@@ -165,16 +166,17 @@ public class EntityManagerFactoryManager
    *                                         should be destroyed
    */
   public synchronized void bundleStateChange() throws InvalidPersistenceUnitException {
-    
+
     switch(bundle.getState()) {
       case Bundle.RESOLVED :
         //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 :
-        //Create the EMF objects if necessary
         createEntityManagerFactories();
       case Bundle.ACTIVE :
         if(tracker == null) {
@@ -236,31 +238,31 @@ public class EntityManagerFactoryManager
     if(registrations == null) {
       registrations = new ConcurrentHashMap<String, ServiceRegistration>();
     }
-    
+
     if(provider != null && !quiesce) {
       //Make sure the EntityManagerFactories are instantiated
       createEntityManagerFactories();
-      
+
       String providerName = (String) provider.getProperty("javax.persistence.provider");
       if(providerName == null) {
         _logger.warn( NLS.MESSAGES.getMessage("no.provider.specified", 
-                      bundle.getSymbolicName() + '/' + bundle.getVersion(), 
-                      PersistenceUnitConstants.OSGI_UNIT_PROVIDER, provider));
+            bundle.getSymbolicName() + '/' + bundle.getVersion(), 
+            PersistenceUnitConstants.OSGI_UNIT_PROVIDER, provider));
       }
       //Register each EMF
       for(Entry<String, ? extends EntityManagerFactory> entry : emfs.entrySet())
       {
-        
+
         Hashtable<String,Object> props = new Hashtable<String, Object>();
         String unitName = entry.getKey();
-        
+
         if(registrations.containsKey(unitName) || !!!availableDataSourceFactory(unitName))
           continue;
-        
+
         props.put(PersistenceUnitConstants.OSGI_UNIT_NAME, unitName);
         if(providerName != null)
           props.put(PersistenceUnitConstants.OSGI_UNIT_PROVIDER, providerName);
-        
+
         props.put(PersistenceUnitConstants.OSGI_UNIT_VERSION, bundle.getVersion());
         props.put(PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT, Boolean.TRUE);
         props.put(PersistenceUnitConstants.EMPTY_PERSISTENCE_UNIT_NAME, "".equals(unitName));
@@ -277,15 +279,15 @@ public class EntityManagerFactoryManager
 
   private boolean availableDataSourceFactory(String unitName) {
     ManagedPersistenceUnitInfo mpui = persistenceUnits.get(unitName);
-        
+
     String driver = (String) mpui.getPersistenceUnitInfo().getProperties().
     get(PersistenceUnitConstants.DATA_SOURCE_FACTORY_CLASS_NAME);
-    
+
     //True if the property is not "true" and the jdbc driver is set
     if(Boolean.parseBoolean((String)mpui.getContainerProperties().
         get(PersistenceUnitConstants.USE_DATA_SOURCE_FACTORY)) &&
         driver != null) {
-      
+
       if(dataSourceFactories.containsKey(driver)) {
         dataSourceFactories.get(driver).add(unitName);
         if(_logger.isDebugEnabled())
@@ -314,7 +316,7 @@ public class EntityManagerFactoryManager
       if(emfs == null && !quiesce) {
         try {
           emfs = new HashMap<String, CountingEntityManagerFactory>();
-        
+
           //Get hold of the provider
           PersistenceProvider providerService = (PersistenceProvider) containerContext.getService(provider);
 
@@ -324,13 +326,33 @@ public class EntityManagerFactoryManager
           }
 
           for(Entry<String, ? extends ManagedPersistenceUnitInfo> entry : 
-               persistenceUnits.entrySet()){
+            persistenceUnits.entrySet()){
             ManagedPersistenceUnitInfo mpui = entry.getValue();
             emfs.put(entry.getKey(), new CountingEntityManagerFactory(
                 providerService.createContainerEntityManagerFactory(
                     mpui.getPersistenceUnitInfo(), mpui.getContainerProperties()), entry.getKey()));
           }
         } finally {
+          //Make sure that we have ClassTransformers, required for JPA entity enhancement to work,
+          //before proceeding. If not, tear everything down so that we can try again later.
+          for(Entry<String, ? extends ManagedPersistenceUnitInfo> entry : 
+            persistenceUnits.entrySet()){
+            ManagedPersistenceUnitInfo mpui = entry.getValue();
+            Object object = mpui.getPersistenceUnitInfo();
+
+            if (object instanceof PersistenceUnitInfo) {
+              PersistenceUnitInfo pui = (PersistenceUnitInfo) object;
+              ClassTransformer transformer = pui.getTransformer();
+
+              if (transformer == null) {
+                if (_logger.isDebugEnabled())
+                  _logger.debug(NLS.MESSAGES.getMessage("no.classtransformer.available"), entry.getKey());
+                destroyEntityManagerFactories();
+                break;
+              }
+            }
+          }
+
           //Remember to unget the provider
           containerContext.ungetService(provider);
         }
@@ -352,7 +374,7 @@ public class EntityManagerFactoryManager
     provider = ref;
     persistenceUnits = getInfoMap(infos);
   }
-  
+
   /**
    * Manage the EntityManagerFactories for the following
    * provider, updated persistence xmls and {@link PersistenceUnitInfo}s
@@ -377,7 +399,7 @@ public class EntityManagerFactoryManager
    */
   public synchronized void destroy() {
     destroyEntityManagerFactories();
-    
+
     provider = null;
     persistenceUnits = null;
     if(tracker != null) {
@@ -414,7 +436,7 @@ public class EntityManagerFactoryManager
   }
   /** 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>();
     Collection<String> names = new ArrayList<String>();
@@ -432,7 +454,7 @@ public class EntityManagerFactoryManager
     if(entries.isEmpty())
       countdown.callback();
     else {
-    NamedCallback callback = new NamedCallback(names, countdown);
+      NamedCallback callback = new NamedCallback(names, countdown);
       for(Entry<CountingEntityManagerFactory, ServiceRegistration> entry : entries.entrySet()) {
         CountingEntityManagerFactory emf = entry.getKey();
         emf.quiesce(callback, entry.getValue());
@@ -444,7 +466,7 @@ public class EntityManagerFactoryManager
   public StringBuffer addingService(ServiceReference reference) {
     //Use String.valueOf to save us from nulls
     StringBuffer sb = new StringBuffer(String.valueOf(reference.getProperty("osgi.jdbc.driver.class")));
-    
+
     //Only notify of a potential change if a new data source class is available
     if(dataSourceFactories.putIfAbsent(sb.toString(), new ArrayList<String>()) == null) {
       if(_logger.isDebugEnabled())
@@ -455,7 +477,7 @@ public class EntityManagerFactoryManager
       } catch (InvalidPersistenceUnitException e) {
         //Not much we can do here unfortunately
         _logger.warn(NLS.MESSAGES.getMessage("new.datasourcefactory.error", sb.toString(), 
-          bundle.getSymbolicName(), bundle.getVersion()), e);
+            bundle.getSymbolicName(), bundle.getVersion()), e);
       }
     }
     return sb;
@@ -465,11 +487,11 @@ public class EntityManagerFactoryManager
   public void modifiedService(ServiceReference reference, Object service) {
     //Updates only matter if they change the value of the driver class
     if(!!!service.toString().equals(reference.getProperty("osgi.jdbc.driver.class"))) {
-      
+
       if(_logger.isDebugEnabled())
         _logger.debug(NLS.MESSAGES.getMessage("changed.datasourcefactory.available", service.toString(), 
             reference.getProperty("osgi.jdbc.driver.class"), bundle.getSymbolicName(), bundle.getVersion()));
-      
+
       //Remove the service
       removedService(reference, service);
       //Clear the old driver class
@@ -482,11 +504,11 @@ public class EntityManagerFactoryManager
 
   @Override
   public void removedService(ServiceReference reference, Object service) {
-    
+
     if(_logger.isDebugEnabled())
       _logger.debug(NLS.MESSAGES.getMessage("datasourcefactory.unavailable", service.toString(), 
           bundle.getSymbolicName(), bundle.getVersion()));
-    
+
     Object[] objects = tracker.getServices();
 
     boolean gone = true;

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=1342638&r1=1342637&r2=1342638&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 Fri May 25 14:30:04 2012
@@ -28,11 +28,11 @@ import java.util.concurrent.atomic.Atomi
 import javax.persistence.SharedCacheMode;
 import javax.persistence.ValidationMode;
 import javax.persistence.spi.ClassTransformer;
-import javax.persistence.spi.PersistenceUnitInfo;
 import javax.persistence.spi.PersistenceUnitTransactionType;
 import javax.sql.DataSource;
 
 import org.apache.aries.jpa.container.PersistenceUnitConstants;
+import org.apache.aries.jpa.container.PersistenceUnitInfo;
 import org.apache.aries.jpa.container.annotation.impl.AnnotationScanner;
 import org.apache.aries.jpa.container.annotation.impl.AnnotationScannerFactory;
 import org.apache.aries.jpa.container.impl.NLS;
@@ -90,6 +90,10 @@ public class PersistenceUnitInfoImpl imp
     }
   }
 
+  public synchronized ClassTransformer getTransformer() {
+    return transformer;
+  }
+
   public boolean internalExcludeUnlistedClasses() {
     Boolean result = (Boolean) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.EXCLUDE_UNLISTED_CLASSES);
     return (result == null) ? false : result;

Modified: aries/trunk/jpa/jpa-container/src/main/resources/org/apache/aries/jpa/container/nls/jpaContainerMessages.properties
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/main/resources/org/apache/aries/jpa/container/nls/jpaContainerMessages.properties?rev=1342638&r1=1342637&r2=1342638&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/main/resources/org/apache/aries/jpa/container/nls/jpaContainerMessages.properties (original)
+++ aries/trunk/jpa/jpa-container/src/main/resources/org/apache/aries/jpa/container/nls/jpaContainerMessages.properties Fri May 25 14:30:04 2012
@@ -1,204 +1,206 @@
-#
-# 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.
-#
-
-# {0} The bundle identity
-# {1} OSGi unit provider
-# {2} The persistence provider service
-no.provider.specified=The PersistenceProvider for bundle {0} did not specify a provider name in the \
- "javax.persistence.provider" service property. As a result EntityManagerFactory objects will not \
- be registered with the {1} property. The Persistence Provider service is {2}.
-# {0} A unit test
-# {1} Bundle identity
-cannot.register.persistence.unit=There was an error registering the persistence unit {0} defined by \
- the bundle {1}.
-# {0} The bundle identity
-persistence.provider.gone.awol=The PersistenceProvider service hosting persistence units in bundle {0} \
- is no longer available. Persistence units defined by the bundle will not be available until the bundle is refreshed.
-# {0} A property key
-# {1} The bundle identity
-could.not.close.persistence.unit=There was an exception when closing the EntityManagerFactory for persistence unit \
- {0} in bundle {1}.
-# {0} The combined version range
-no.overlap.for.version.range=There was no overlap between the specified version ranges. The combined version range \
- string would have been {0}.
-# {0} The bundle identity
-# {1} The Web-ContextPath header
-# {2} The Meta-Persistence header
-# {3} The locations
-wab.without.meta.persistence.header=The bundle {0} specifies the {1} header; it does not specify the {2} header. \
- This bundle will be scanned for persistence descriptors in the locations: {3} using the rules defined by the \
- JPA specification for finding persistence descriptors for web applications.
-# {0} The bundle identity
-# {1} The Web-ContextPath header
-# {2} The Meta-Persistence header
-# {3} The locations
-ejb.without.meta.persistence.header=The bundle {0} specifies the {1} header; it does not specify the {2} header. \
- This bundle will be scanned for persistence descriptors in the locations: {3} using the rules defined by the \
- JPA specification for finding persistence descriptors for ejb applications.
-# {0} The location
-# {1} The bundle identity
-exception.while.locating.descriptor=There was an exception while locating the persistence descriptor at location \
- {0} in bundle {1}. No persistence descriptors will be processed for this bundle.
-# {0} The bundle identity
-# {1} The locations
-no.persistence.descriptor=No persistence descriptors could be located in the bundle {0}. The following locations were searched: \
- {1}.
-
-# {0} The name of the ManagedPersistenceUnitInfoFactory class.
-unable.to.create.mpuif=There was a problem creating the custom ManagedPersistenceUnitInfoFactory {0}. The default \
- ManagedPersistenceUnitInfo factory will be used instead.
-# {0} The bundle symbolic name.
-# {1} The bundle version.
-unable.to.manage.pu=An error occurred trying to manage persistence units for bundle {0}/{1}.
-# {0} The file that was found.
-# {1} The bundle symbolic name.
-# {2} The bundle version.
-# {3} The properties that are being overridden.
-aries.jpa.config.file.found=A {0} file was found in bundle {1}/{2}. The default properties {3} will be overridden."
-# {0} The file that was being read.
-# {1} The bundle symbolic name.
-# {2} The bundle version.
-aries.jpa.config.file.read.error=There was an error reading from file {0} in bundle {1}/{2}.
-# {0} The file that could not be found
-# {1} The bundle symbolic name.
-# {2} The bundle version.
-# {3} The default properties.
-aries.jpa.config.file.not.found=The file {0} was not found in bundle {1}/{2}. The default properties {3} will be used.
-# {0} The bundle symbolic name.
-# {1} The bundle version.
-jpa.bundle.active=The bundle {0}/{1} is already active, it may not be possible to create managed persistence units for it.
-# {0} The file that could not be parsed.
-# {1} The bundle symbolic name.
-# {2} The bundle version.
-persistence.description.parse.error=There was an error while parsing the persistence descriptor {0} in the bundle {1}/{2}. \
- No persistence units will be managed for this bundle.
-# {0} The invalid version range.
-# {1} The persistent unit name.
-version.range.parse.failure=There was an error parsing the version range string {0} for persistence unit {1}. It will be ignored.
-# {0} The bundle symbolic name.
-# {1} The bundle version.
-invalid.provider.version.ranges=The bundle {0}/{1} specified an invalid combination of provider version ranges.
-# {0} The bundle symbolic name.
-# {1} The bundle version.
-# {2} Persistence providers specified.
-multiple.persistence.providers.specified=The bundle {0}/{1} specified more than one persistence provider: {2}. \
- This is not supported, so no persistence units will be created for this bundle.
-# {0} The provider class name
-# {1} The version range
-# {2} The bundle symbolic name.
-# {3} The bundle version.
-no.suitable.jpa.providers=There are no suitable providers for the provider class name {0} and version range {1} to \
- support the bundle {2}/{3}.
-no.jpa.providers=There are no providers available.
-# {0} The bundle symbolic name.
-# {1} The bundle version.
-pu.has.becomd.invalid=The persistence units for bundle {0}/{1} became invalid and will be destroyed.
-quiesce.manager.not.there=No quiesce support is available, so managed persistence units will not participate in quiesce operations.
-# {0} The bundle symbolic name.
-# {1} The bundle version.
-persistence.bundle.not.active=The bundle {0}/{1} is not started.
-# {0} The datasource JNDI name
-# {1} The bundle symbolic name.
-# {2} The bundle version.
-no.data.source.found=The DataSource {0} required by bundle {1}/{2} could not be found.
-# {0} The persistence unit name
-# {1} The bundle symbolic name.
-# {2} The bundle version.
-# {3} The jar name.
-pu.not.found=The persistence unit {0} in bundle {1}/{2} listed the jar file {3}, but {3} could not be found in the bundle.
-# {0} The persistence descriptor location.
-# {1} The bundle symbolic name.
-# {2} The bundle version.
-persistence.descriptor.schema.not.found=A schema could be located for the persistence descriptor {0} in bundle {1}/{2}.
-# {0} The bundle symbolic name.
-# {1} The bundle version.
-previous.pus.have.not.been.destroyed=Unable to create persistence units for the bundle {0}/{1} as previous persistence units already exist.
-# {0} The bundle symbolic name.
-# {1} The bundle version.
-no.persistence.units.for.bundle=No persistence units defined for bundle {0}/{1}.
-# {0} The class that could not be weaved.
-# {1} The bundle symbolic name.
-# {2} The bundle version.
-# {3} The transformer that threw an exception.
-jpa.weaving.failure=There was an error attempting to weave the class {0} in the bundle {1}/{2} using the transformer {3}.
-# {0} The transformer that was not registered.
-jpa.weaving.transformer.not.registered=The transformer {0} cannot be unregistered because it has not been registered.
-jpa.weaving.null.transformer=The delegate transformer must not be null.
-jpa.weaving.null.provider=The persistence provider must not be null.
-# {0} The new JDBC class name that is available.
-# {1} The symbolic name of the persistence bundle.
-# {2} The version of the persistence bundle.
-new.datasourcefactory.available=A DataSourceFactory service for {0} is now available for use by persistence bundle {1}/{2}.
-# {0} The new JDBC class name that is available.
-# {1} The symbolic name of the persistence bundle.
-# {2} The version of the persistence bundle.
-new.datasourcefactory.error=There was an error updating the persistence units in bundle {1}/{2} when a DataSourceFactory service for {0} became available.
-# {0} The old JDBC class name that is no longer available.
-# {1} The new JDBC class name that is becoming available.
-# {2} The symbolic name of the persistence bundle.
-# {3} The version of the persistence bundle.
-changed.datasourcefactory.available=A DataSourceFactory service for {0} was modified so that it now provides DataSources for {1}. This may affect the running persistence bundle {2}/{3}.
-# {0} The JDBC class name that is no longer available.
-# {1} The symbolic name of the persistence bundle.
-# {2} The version of the persistence bundle.
-# {3} The persistence units that will be unregistered
-in.use.datasourcefactory.unavailable=No DataSourceFactory services for {0} are available from persistence bundle {1}/{2}. The persistence units {3} will now be unregistered.
-# {0} The JDBC class name that going away.
-# {1} The symbolic name of the persistence bundle.
-# {2} The version of the persistence bundle.
-datasourcefactory.unavailable=A DataSourceFactory service for {0} has been unregistered and is no longer available for use by persistence bundle {1}/{2}.
-# {0} The name of the persistence unit.
-# {1} The symbolic name of the persistence bundle.
-# {2} The version of the persistence bundle.
-# {3} The name of the JDBC driver class
-datasourcefactory.found=The persistence unit {0} in bundle {1}/{2} will now be registered and use JDBC driver {3}.
-# {0} The name of the persistence unit.
-# {1} The symbolic name of the persistence bundle.
-# {2} The version of the persistence bundle.
-# {3} The name of the JDBC driver class
-datasourcefactory.not.found=The persistence unit {0} in bundle {1}/{2} cannot be registered because no DataSourceFactory service for JDBC driver {3} exists.
-# {0} The datasourcefactory class
-# {1} The datasource creation properties
-# {2} The bundle symbolic name.
-# {3} The bundle version.
-datasourcefactory.sql.exception=The DataSourceFactory {0} threw an exception when creating a datasource with the properties {1}. This datasource was required by bundle {2}/{3}.
-no.datasourcefactory.integration=The org.osgi.service.jdbc package is unavailable. As a result the Aries JPA container will not offer any DataSourceFactory integration.
-# {0} The name of the persistence unit.
-# {1} The symbolic name of the persistence bundle.
-# {2} The version of the persistence bundle.
-using.datasource.factory=The persistence unit {0} in bundle {1}/{2} will use a DataSourceFactory service when creating its database connections.
-# {0} The datasourcefactory class
-# {1} The bundle symbolic name.
-# {2} The bundle version.
-no.datasource.factory=No DataSourceFactory service is available for the JDBC driver class {0}. Persistence bundle {1}/{2} is trying to create that DataSource and cannot. One or more persistence units will be unusable until this DataSourceFactory is available.
-datasource.enlised.commit=This datasource is enrolled in a JTA transaction and can only be committed by the JTA transaction manager.
-datasource.enlised.rollback=This datasource is enrolled in a JTA transaction and can only be rolledback by the JTA transaction manager.
-datasource.enlised.savepoint=This datasource is enrolled in a JTA transaction and does not support savepoint.
-unable.to.get.tx=An error occurred while getting the current transaction.
-unable.to.get.tx.mgr=No TransactionManager is currently available.
-# {0} The name of the persistence unit.
-# {1} The symbolic name of the persistence bundle.
-# {2} The version of the persistence bundle.
-# {3} The jndi name of the datasource
-xa.datasource.non.tx=The persistence unit {0} in persistence bundle {1}/{2} uses a JNDI name {3} that looks up an XADataSource. The persistence unit is not JTA integrated so an XADataSource cannot be used. 
-# {0} The name of the persistence unit.
-# {1} The symbolic name of the persistence bundle.
-# {2} The version of the persistence bundle.
-# {3} The jndi name of the datasource
+#
+# 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.
+#
+
+# {0} The bundle identity
+# {1} OSGi unit provider
+# {2} The persistence provider service
+no.provider.specified=The PersistenceProvider for bundle {0} did not specify a provider name in the \
+ "javax.persistence.provider" service property. As a result EntityManagerFactory objects will not \
+ be registered with the {1} property. The Persistence Provider service is {2}.
+# {0} A unit test
+# {1} Bundle identity
+cannot.register.persistence.unit=There was an error registering the persistence unit {0} defined by \
+ the bundle {1}.
+# {0} The bundle identity
+persistence.provider.gone.awol=The PersistenceProvider service hosting persistence units in bundle {0} \
+ is no longer available. Persistence units defined by the bundle will not be available until the bundle is refreshed.
+no.classtransformer.available=A ClassTransformer was not provided by the PersistenceProvider for the persistence unit {0}. \
+In order to fix this problem, the EntityManagerFactories will be removed and a later retry will occur.
+# {0} A property key
+# {1} The bundle identity
+could.not.close.persistence.unit=There was an exception when closing the EntityManagerFactory for persistence unit \
+ {0} in bundle {1}.
+# {0} The combined version range
+no.overlap.for.version.range=There was no overlap between the specified version ranges. The combined version range \
+ string would have been {0}.
+# {0} The bundle identity
+# {1} The Web-ContextPath header
+# {2} The Meta-Persistence header
+# {3} The locations
+wab.without.meta.persistence.header=The bundle {0} specifies the {1} header; it does not specify the {2} header. \
+ This bundle will be scanned for persistence descriptors in the locations: {3} using the rules defined by the \
+ JPA specification for finding persistence descriptors for web applications.
+# {0} The bundle identity
+# {1} The Web-ContextPath header
+# {2} The Meta-Persistence header
+# {3} The locations
+ejb.without.meta.persistence.header=The bundle {0} specifies the {1} header; it does not specify the {2} header. \
+ This bundle will be scanned for persistence descriptors in the locations: {3} using the rules defined by the \
+ JPA specification for finding persistence descriptors for ejb applications.
+# {0} The location
+# {1} The bundle identity
+exception.while.locating.descriptor=There was an exception while locating the persistence descriptor at location \
+ {0} in bundle {1}. No persistence descriptors will be processed for this bundle.
+# {0} The bundle identity
+# {1} The locations
+no.persistence.descriptor=No persistence descriptors could be located in the bundle {0}. The following locations were searched: \
+ {1}.
+
+# {0} The name of the ManagedPersistenceUnitInfoFactory class.
+unable.to.create.mpuif=There was a problem creating the custom ManagedPersistenceUnitInfoFactory {0}. The default \
+ ManagedPersistenceUnitInfo factory will be used instead.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+unable.to.manage.pu=An error occurred trying to manage persistence units for bundle {0}/{1}.
+# {0} The file that was found.
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+# {3} The properties that are being overridden.
+aries.jpa.config.file.found=A {0} file was found in bundle {1}/{2}. The default properties {3} will be overridden."
+# {0} The file that was being read.
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+aries.jpa.config.file.read.error=There was an error reading from file {0} in bundle {1}/{2}.
+# {0} The file that could not be found
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+# {3} The default properties.
+aries.jpa.config.file.not.found=The file {0} was not found in bundle {1}/{2}. The default properties {3} will be used.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+jpa.bundle.active=The bundle {0}/{1} is already active, it may not be possible to create managed persistence units for it.
+# {0} The file that could not be parsed.
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+persistence.description.parse.error=There was an error while parsing the persistence descriptor {0} in the bundle {1}/{2}. \
+ No persistence units will be managed for this bundle.
+# {0} The invalid version range.
+# {1} The persistent unit name.
+version.range.parse.failure=There was an error parsing the version range string {0} for persistence unit {1}. It will be ignored.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+invalid.provider.version.ranges=The bundle {0}/{1} specified an invalid combination of provider version ranges.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+# {2} Persistence providers specified.
+multiple.persistence.providers.specified=The bundle {0}/{1} specified more than one persistence provider: {2}. \
+ This is not supported, so no persistence units will be created for this bundle.
+# {0} The provider class name
+# {1} The version range
+# {2} The bundle symbolic name.
+# {3} The bundle version.
+no.suitable.jpa.providers=There are no suitable providers for the provider class name {0} and version range {1} to \
+ support the bundle {2}/{3}.
+no.jpa.providers=There are no providers available.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+pu.has.becomd.invalid=The persistence units for bundle {0}/{1} became invalid and will be destroyed.
+quiesce.manager.not.there=No quiesce support is available, so managed persistence units will not participate in quiesce operations.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+persistence.bundle.not.active=The bundle {0}/{1} is not started.
+# {0} The datasource JNDI name
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+no.data.source.found=The DataSource {0} required by bundle {1}/{2} could not be found.
+# {0} The persistence unit name
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+# {3} The jar name.
+pu.not.found=The persistence unit {0} in bundle {1}/{2} listed the jar file {3}, but {3} could not be found in the bundle.
+# {0} The persistence descriptor location.
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+persistence.descriptor.schema.not.found=A schema could be located for the persistence descriptor {0} in bundle {1}/{2}.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+previous.pus.have.not.been.destroyed=Unable to create persistence units for the bundle {0}/{1} as previous persistence units already exist.
+# {0} The bundle symbolic name.
+# {1} The bundle version.
+no.persistence.units.for.bundle=No persistence units defined for bundle {0}/{1}.
+# {0} The class that could not be weaved.
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+# {3} The transformer that threw an exception.
+jpa.weaving.failure=There was an error attempting to weave the class {0} in the bundle {1}/{2} using the transformer {3}.
+# {0} The transformer that was not registered.
+jpa.weaving.transformer.not.registered=The transformer {0} cannot be unregistered because it has not been registered.
+jpa.weaving.null.transformer=The delegate transformer must not be null.
+jpa.weaving.null.provider=The persistence provider must not be null.
+# {0} The new JDBC class name that is available.
+# {1} The symbolic name of the persistence bundle.
+# {2} The version of the persistence bundle.
+new.datasourcefactory.available=A DataSourceFactory service for {0} is now available for use by persistence bundle {1}/{2}.
+# {0} The new JDBC class name that is available.
+# {1} The symbolic name of the persistence bundle.
+# {2} The version of the persistence bundle.
+new.datasourcefactory.error=There was an error updating the persistence units in bundle {1}/{2} when a DataSourceFactory service for {0} became available.
+# {0} The old JDBC class name that is no longer available.
+# {1} The new JDBC class name that is becoming available.
+# {2} The symbolic name of the persistence bundle.
+# {3} The version of the persistence bundle.
+changed.datasourcefactory.available=A DataSourceFactory service for {0} was modified so that it now provides DataSources for {1}. This may affect the running persistence bundle {2}/{3}.
+# {0} The JDBC class name that is no longer available.
+# {1} The symbolic name of the persistence bundle.
+# {2} The version of the persistence bundle.
+# {3} The persistence units that will be unregistered
+in.use.datasourcefactory.unavailable=No DataSourceFactory services for {0} are available from persistence bundle {1}/{2}. The persistence units {3} will now be unregistered.
+# {0} The JDBC class name that going away.
+# {1} The symbolic name of the persistence bundle.
+# {2} The version of the persistence bundle.
+datasourcefactory.unavailable=A DataSourceFactory service for {0} has been unregistered and is no longer available for use by persistence bundle {1}/{2}.
+# {0} The name of the persistence unit.
+# {1} The symbolic name of the persistence bundle.
+# {2} The version of the persistence bundle.
+# {3} The name of the JDBC driver class
+datasourcefactory.found=The persistence unit {0} in bundle {1}/{2} will now be registered and use JDBC driver {3}.
+# {0} The name of the persistence unit.
+# {1} The symbolic name of the persistence bundle.
+# {2} The version of the persistence bundle.
+# {3} The name of the JDBC driver class
+datasourcefactory.not.found=The persistence unit {0} in bundle {1}/{2} cannot be registered because no DataSourceFactory service for JDBC driver {3} exists.
+# {0} The datasourcefactory class
+# {1} The datasource creation properties
+# {2} The bundle symbolic name.
+# {3} The bundle version.
+datasourcefactory.sql.exception=The DataSourceFactory {0} threw an exception when creating a datasource with the properties {1}. This datasource was required by bundle {2}/{3}.
+no.datasourcefactory.integration=The org.osgi.service.jdbc package is unavailable. As a result the Aries JPA container will not offer any DataSourceFactory integration.
+# {0} The name of the persistence unit.
+# {1} The symbolic name of the persistence bundle.
+# {2} The version of the persistence bundle.
+using.datasource.factory=The persistence unit {0} in bundle {1}/{2} will use a DataSourceFactory service when creating its database connections.
+# {0} The datasourcefactory class
+# {1} The bundle symbolic name.
+# {2} The bundle version.
+no.datasource.factory=No DataSourceFactory service is available for the JDBC driver class {0}. Persistence bundle {1}/{2} is trying to create that DataSource and cannot. One or more persistence units will be unusable until this DataSourceFactory is available.
+datasource.enlised.commit=This datasource is enrolled in a JTA transaction and can only be committed by the JTA transaction manager.
+datasource.enlised.rollback=This datasource is enrolled in a JTA transaction and can only be rolledback by the JTA transaction manager.
+datasource.enlised.savepoint=This datasource is enrolled in a JTA transaction and does not support savepoint.
+unable.to.get.tx=An error occurred while getting the current transaction.
+unable.to.get.tx.mgr=No TransactionManager is currently available.
+# {0} The name of the persistence unit.
+# {1} The symbolic name of the persistence bundle.
+# {2} The version of the persistence bundle.
+# {3} The jndi name of the datasource
+xa.datasource.non.tx=The persistence unit {0} in persistence bundle {1}/{2} uses a JNDI name {3} that looks up an XADataSource. The persistence unit is not JTA integrated so an XADataSource cannot be used. 
+# {0} The name of the persistence unit.
+# {1} The symbolic name of the persistence bundle.
+# {2} The version of the persistence bundle.
+# {3} The jndi name of the datasource
 not.a.datasource=The persistence unit {0} in persistence bundle {1}/{2} uses a JNDI name {3} that looks up an Objet that is not a DataSource or XADataSource. 
\ No newline at end of file

Modified: aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/PersistenceBundleLifecycleTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/PersistenceBundleLifecycleTest.java?rev=1342638&r1=1342637&r2=1342638&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/PersistenceBundleLifecycleTest.java (original)
+++ aries/trunk/jpa/jpa-container/src/test/java/org/apache/aries/jpa/container/PersistenceBundleLifecycleTest.java Fri May 25 14:30:04 2012
@@ -45,6 +45,7 @@ import java.util.zip.ZipEntry;
 
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.ClassTransformer;
 import javax.persistence.spi.PersistenceProvider;
 import javax.persistence.spi.PersistenceUnitInfo;
 
@@ -55,7 +56,9 @@ import org.apache.aries.mocks.BundleCont
 import org.apache.aries.mocks.BundleMock;
 import org.apache.aries.quiesce.manager.QuiesceCallback;
 import org.apache.aries.quiesce.participant.QuiesceParticipant;
+import org.apache.aries.unittest.mocks.DefaultInvocationHandler;
 import org.apache.aries.unittest.mocks.MethodCall;
+import org.apache.aries.unittest.mocks.MethodCallHandler;
 import org.apache.aries.unittest.mocks.Skeleton;
 import org.junit.After;
 import org.junit.Before;
@@ -72,6 +75,10 @@ import org.osgi.service.jdbc.DataSourceF
 
 public class PersistenceBundleLifecycleTest
 {
+  private static final String JPA_WEAVING_PACKAGES = "org.apache.aries.jpa.container.weaving.packages";
+  private static final String[] JPA_PACKAGES = new String[] { "org.apache.openjpa.enhance", "org.apache.openjpa.util" };
+
+  private MethodCall call;
   private Bundle persistenceBundle;
   private BundleContext persistenceBundleContext;
   
@@ -90,16 +97,38 @@ public class PersistenceBundleLifecycleT
   private PersistenceBundleManager mgr;
   private PersistenceProvider pp;
   
+  private class MethodCallHandlerImpl implements MethodCallHandler {
+      private Skeleton skel;
+      
+      public MethodCallHandlerImpl(Skeleton skel) {
+          this.skel = skel;
+      }
+
+      @Override
+      public Object handle(MethodCall methodCall, Skeleton parent) throws Exception {
+          ClassTransformer ct = Skeleton.newMock(ClassTransformer.class);
+          PersistenceUnitInfo pui = (PersistenceUnitInfo) methodCall.getArguments()[0];
+
+          if (pui != null)
+              pui.addTransformer(ct);
+
+          return (new DefaultInvocationHandler(skel)).createProxy(EntityManagerFactory.class);
+      }      
+  }
+ 
   @Before
   public void setUp() throws Exception
   {
     persistenceBundle = Skeleton.newMock(new BundleMock("scooby.doo", new Hashtable<String, Object>()), Bundle.class);
     persistenceBundleContext = persistenceBundle.getBundleContext();
     
+    call = new MethodCall(PersistenceProvider.class, "createContainerEntityManagerFactory", PersistenceUnitInfo.class, Map.class);
     pp = Skeleton.newMock(PersistenceProvider.class);
+    Skeleton skel = Skeleton.getSkeleton(pp);
+    skel.registerMethodCallHandler(call, new MethodCallHandlerImpl(skel));
     
     providerBundleP100 = Skeleton.newMock(new BundleMock("no.such.Provider", new Hashtable<String, Object>()), Bundle.class);
-    Skeleton skel = Skeleton.getSkeleton(providerBundleP100);
+    skel = Skeleton.getSkeleton(providerBundleP100);
     skel.setReturnValue(new MethodCall(Bundle.class, "getVersion"), new Version("1.0.0"));
 
     providerBundleP101 = Skeleton.newMock(new BundleMock("no.such.Provider", new Hashtable<String, Object>()), Bundle.class);
@@ -187,6 +216,7 @@ public class PersistenceBundleLifecycleT
     Hashtable<String,Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
     hash1.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     ServiceReference ref = reg.getReference();
@@ -210,8 +240,9 @@ public class PersistenceBundleLifecycleT
     
     BundleContext extenderContext = preExistingBundleSetup();
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     
@@ -233,8 +264,9 @@ public class PersistenceBundleLifecycleT
     
     BundleContext extenderContext = preExistingBundleSetup();
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     
@@ -255,8 +287,9 @@ public class PersistenceBundleLifecycleT
   {
     BundleContext extenderContext = preExistingBundleSetup();
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     ServiceReference ref = reg.getReference();
@@ -291,8 +324,9 @@ public class PersistenceBundleLifecycleT
     BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
     assertNotNull("We should have an EntityManagerFactoryManager", getTrackedObject());
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     ServiceReference ref = reg.getReference();
@@ -320,8 +354,9 @@ public class PersistenceBundleLifecycleT
     BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
     assertNotNull("We should have an EntityManagerFactoryManager", getTrackedObject());
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     ServiceReference ref = reg.getReference();
@@ -331,9 +366,10 @@ public class PersistenceBundleLifecycleT
     testSuccessfulCreationEvent(ref, extenderContext, 1);
     testSuccessfulRegistrationEvent(ref, extenderContext, 1);
     
-    Hashtable<String,String> hash2 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash2 = new Hashtable<String, Object>();
     hash2.put("javax.persistence.provider", "no.such.Provider");
     hash2.put("key", "value");
+    hash2.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg2 = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash2 );
     ServiceReference ref2 = reg2.getReference();
@@ -377,8 +413,9 @@ public class PersistenceBundleLifecycleT
     mgr = new PersistenceBundleManager();
     mgr.start(extenderContext);
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName(), "no.such.Provider"} ,
         pp, hash1 );
     ServiceReference ref = reg.getReference();
@@ -406,6 +443,8 @@ public class PersistenceBundleLifecycleT
     //Now try Resolving
     Skeleton.getSkeleton(persistenceBundle).setReturnValue(new MethodCall(Bundle.class, "getState"), Bundle.RESOLVED);
     mgr.modifiedBundle(persistenceBundle, new BundleEvent(BundleEvent.RESOLVED, persistenceBundle), o);
+    
+    testSuccessfulCreationEvent(ref, extenderContext, 1);
     BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
     
     
@@ -454,8 +493,9 @@ public class PersistenceBundleLifecycleT
     setupPersistenceBundle("file4", "");
     BundleContext extenderContext = preExistingBundleSetup();
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName(), "no.such.Provider"} ,
         pp, hash1 );
     
@@ -487,6 +527,7 @@ public class PersistenceBundleLifecycleT
     mgr.modifiedBundle(persistenceBundle, new BundleEvent(BundleEvent.RESOLVED, persistenceBundle), getTrackedObject());
     
     //We will have created the EMF a total of 2 times
+    testSuccessfulCreationEvent(ref, extenderContext, 2);
     BundleContextMock.assertNoServiceExists(EntityManagerFactory.class.getName());
   }
   
@@ -496,8 +537,9 @@ public class PersistenceBundleLifecycleT
     setupPersistenceBundle("file4", "");
     BundleContext extenderContext = preExistingBundleSetup();
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName(), "no.such.Provider"} ,
         pp, hash1 );
     
@@ -529,8 +571,9 @@ public class PersistenceBundleLifecycleT
   {
     BundleContext extenderContext = preExistingBundleSetup();
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     ServiceReference ref = reg.getReference();
@@ -557,8 +600,9 @@ public class PersistenceBundleLifecycleT
     
     mgr = new PersistenceBundleManager();
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     ServiceReference ref = reg.getReference();
@@ -583,6 +627,7 @@ public class PersistenceBundleLifecycleT
     Hashtable<String,Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "use.this.Provider");
     hash1.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     ServiceReference ppRef = reg.getReference();
@@ -612,6 +657,7 @@ public class PersistenceBundleLifecycleT
     Hashtable<String,Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "use.this.Provider");
     hash1.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     ServiceReference ppRef = reg.getReference();
@@ -644,8 +690,9 @@ public class PersistenceBundleLifecycleT
   {
     BundleContext extenderContext = preExistingBundleSetup();
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     ServiceReference ref = reg.getReference();
@@ -678,8 +725,9 @@ public class PersistenceBundleLifecycleT
     
     BundleContext extenderContext = preExistingBundleSetup();
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     ServiceReference ref = reg.getReference();
@@ -711,8 +759,9 @@ public class PersistenceBundleLifecycleT
     
     BundleContext extenderContext = preExistingBundleSetup();
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     ServiceReference ref = reg.getReference();
@@ -936,8 +985,9 @@ public class PersistenceBundleLifecycleT
     //Check we correctly parse and register EMFactories according to the Meta-Persistence Header
     BundleContext extenderContext = preExistingBundleSetup();
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     
@@ -1211,8 +1261,9 @@ public class PersistenceBundleLifecycleT
     //Basic startup
     BundleContext extenderContext = preExistingBundleSetup();
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     ServiceRegistration reg = persistenceBundle.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()} ,
         pp, hash1 );
     ServiceReference ref = reg.getReference();
@@ -1231,7 +1282,7 @@ public class PersistenceBundleLifecycleT
     testSuccessfulRegistrationEvent(ref, extenderContext, 0);
     
     //Register the DSF for alpha and it should appear
-    hash1 = new Hashtable<String, String>();
+    hash1 = new Hashtable<String, Object>();
     hash1.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, "alpha.db.class");
     reg = persistenceBundle.getBundleContext().registerService(new String[] {DataSourceFactory.class.getName()} ,
         Skeleton.newMock(DataSourceFactory.class), hash1 );
@@ -1239,7 +1290,7 @@ public class PersistenceBundleLifecycleT
     testSuccessfulRegistrationEvent(ref, extenderContext, 1, "alpha");
     
     //Register the other DSF
-    hash1 = new Hashtable<String, String>();
+    hash1 = new Hashtable<String, Object>();
     hash1.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, "shared.db.class");
     persistenceBundle.getBundleContext().registerService(new String[] {DataSourceFactory.class.getName()} ,
         Skeleton.newMock(DataSourceFactory.class), hash1 );
@@ -1398,14 +1449,26 @@ public class PersistenceBundleLifecycleT
   private void registerVersionedPersistenceProviders() {
     
     providerP100 = Skeleton.newMock(PersistenceProvider.class);
+    Skeleton skel = Skeleton.getSkeleton(providerP100);
+    skel.registerMethodCallHandler(call, new MethodCallHandlerImpl(skel));
+
     providerP101 = Skeleton.newMock(PersistenceProvider.class);
+    skel = Skeleton.getSkeleton(providerP101);
+    skel.registerMethodCallHandler(call, new MethodCallHandlerImpl(skel));
+    
     providerP110 = Skeleton.newMock(PersistenceProvider.class);
+    skel = Skeleton.getSkeleton(providerP110);
+    skel.registerMethodCallHandler(call, new MethodCallHandlerImpl(skel));
+    
     providerP111 = Skeleton.newMock(PersistenceProvider.class);
+    skel = Skeleton.getSkeleton(providerP111);
+    skel.registerMethodCallHandler(call, new MethodCallHandlerImpl(skel));
     
     ServiceRegistration reg;
     
-    Hashtable<String,String> hash1 = new Hashtable<String, String>();
+    Hashtable<String, Object> hash1 = new Hashtable<String, Object>();
     hash1.put("javax.persistence.provider", "no.such.Provider");
+    hash1.put(JPA_WEAVING_PACKAGES, JPA_PACKAGES);
     reg = providerBundleP100.getBundleContext().registerService(new String[] {PersistenceProvider.class.getName()},
             providerP100, hash1 );
     



Mime
View raw message