incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r897874 - in /incubator/aries/trunk/jpa/jpa-container: ./ src/main/java/org/apache/aries/jpa/container/ src/main/java/org/apache/aries/jpa/container/impl/ src/main/java/org/apache/aries/jpa/container/parsing/ src/main/java/org/apache/aries/...
Date Mon, 11 Jan 2010 14:21:47 GMT
Author: timothyjward
Date: Mon Jan 11 14:21:47 2010
New Revision: 897874

URL: http://svn.apache.org/viewvc?rev=897874&view=rev
Log:
ARIES-79: Create and manage EntityManagerFactory services for persistence units

Added:
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfo.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfoFactory.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidPersistenceUnitException.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidRangeCombination.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoImpl.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java
    incubator/aries/trunk/jpa/jpa-container/src/main/resources/OSGI-INF/
    incubator/aries/trunk/jpa/jpa-container/src/main/resources/OSGI-INF/blueprint/
    incubator/aries/trunk/jpa/jpa-container/src/main/resources/OSGI-INF/blueprint/jpa.xml
Modified:
    incubator/aries/trunk/jpa/jpa-container/pom.xml
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/ParsedPersistenceUnit.java
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java

Modified: incubator/aries/trunk/jpa/jpa-container/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/pom.xml?rev=897874&r1=897873&r2=897874&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/pom.xml (original)
+++ incubator/aries/trunk/jpa/jpa-container/pom.xml Mon Jan 11 14:21:47 2010
@@ -22,6 +22,22 @@
       <scope>provided</scope>
     </dependency>
     <dependency>
+      <artifactId>org.apache.aries.application.api</artifactId>
+      <groupId>org.apache.aries.application</groupId>
+      <version>1.0.0-incubating-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <artifactId>org.apache.aries.application.utils</artifactId>
+      <groupId>org.apache.aries.application</groupId>
+      <version>1.0.0-incubating-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-jpa_2.0_spec</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency> 
+    
+    <dependency>
       <groupId>org.apache.aries.testsupport</groupId>
       <artifactId>org.apache.aries.testsupport.unit</artifactId>
       <scope>test</scope>
@@ -36,6 +52,16 @@
   
   
       <build>
+       <resources>
+            <resource>
+                <targetPath>OSGI-INF/blueprint</targetPath>
+                <filtering>false</filtering>
+                <directory>${basedir}/src/main/resources/OSGI-INF/blueprint</directory>
+                <includes>
+                    <include>*.xml</include>
+                </includes>
+            </resource>
+        </resources>
         <plugins>
             <plugin>
                 <groupId>org.apache.felix</groupId>
@@ -45,7 +71,8 @@
                     <instructions>
                         <Bundle-SymbolicName>${pom.groupId}.container</Bundle-SymbolicName>
                         <Export-Package>
-                            org.apache.aries.jpa.container.parsing;version="${pom.version}", 
+                            org.apache.aries.jpa.container.parsing;version="${pom.version}",
+                            org.apache.aries.jpa.container;version="${pom.version}"
                         </Export-Package>
                         <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
                         <_removeheaders>Ignore-Package,Include-Resource,Private-Package,Bundle-DocURL</_removeheaders>

Added: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfo.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfo.java?rev=897874&view=auto
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfo.java (added)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfo.java Mon Jan 11 14:21:47 2010
@@ -0,0 +1,13 @@
+package org.apache.aries.jpa.container;
+
+import java.util.Map;
+
+import javax.persistence.spi.PersistenceUnitInfo;
+
+public interface ManagedPersistenceUnitInfo {
+
+  PersistenceUnitInfo getPersistenceUnitInfo();
+  
+  Map<String, Object> getContainerProperties();
+  
+}

Added: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfoFactory.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfoFactory.java?rev=897874&view=auto
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfoFactory.java (added)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/ManagedPersistenceUnitInfoFactory.java Mon Jan 11 14:21:47 2010
@@ -0,0 +1,17 @@
+package org.apache.aries.jpa.container;
+
+import java.util.Collection;
+
+import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+public interface ManagedPersistenceUnitInfoFactory {
+
+  Collection<ManagedPersistenceUnitInfo> createManagedPersistenceUnitMetadata(BundleContext containerContext, Bundle persistenceBundle, ServiceReference providerReference, Collection<ParsedPersistenceUnit> persistenceMetadata);
+  
+  String getDefaultProviderClassName();
+
+  void destroyPersistenceBundle(Bundle bundle);
+}

Added: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java?rev=897874&view=auto
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java (added)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java Mon Jan 11 14:21:47 2010
@@ -0,0 +1,186 @@
+package org.apache.aries.jpa.container.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Map.Entry;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.PersistenceProvider;
+import javax.persistence.spi.PersistenceUnitInfo;
+
+import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+public class EntityManagerFactoryManager {
+
+  private final BundleContext containerContext;
+  
+  private final Bundle bundle;
+  
+  private ServiceReference provider;
+  
+  private Collection<ManagedPersistenceUnitInfo> persistenceUnits;
+  
+  private Map<String, EntityManagerFactory> emfs = null;
+  
+  private Collection<ServiceRegistration> registrations = null;
+
+  /**
+   * Create an {@link EntityManagerFactoryManager} for
+   * the supplied persistence bundle.
+   * 
+   * This constructor should only be used by a 
+   * {@link PersistenceBundleManager} that is synchronized
+   * on itself, and the resulting manager should be immediately
+   * stored in the bundleToManager Map
+   * 
+   * @param b
+   * @param infos 
+   * @param ref 
+   */
+  public EntityManagerFactoryManager(BundleContext containerCtx, Bundle b, ServiceReference ref, Collection<ManagedPersistenceUnitInfo> infos) {
+    containerContext = containerCtx;
+    bundle = b;
+    provider = ref;
+    persistenceUnits = infos;
+  }
+
+  public synchronized boolean providerRemoved(ServiceReference ref) {
+    
+    boolean toReturn = ref == provider;
+    
+    if(toReturn)
+      destroy();
+    
+    return toReturn;
+  }
+
+  public synchronized void bundleStateChange() throws InvalidPersistenceUnitException {
+    
+    switch(bundle.getState()) {
+      case Bundle.RESOLVED :
+        createEntityManagerFactories();
+        break;
+      case Bundle.STARTING :
+      case Bundle.ACTIVE :
+        registerEntityManagerFactories();
+        break;
+      case Bundle.STOPPING :
+        unregisterEntityManagerFactories();
+        break;
+    }
+  }
+
+  private void unregisterEntityManagerFactories() {
+    if(registrations != null) {
+      for(ServiceRegistration reg : registrations) {
+        try {
+          reg.unregister();
+        } catch (Exception e) {
+          //TODO log this
+        }
+      }
+      registrations = null;
+    }
+  }
+
+  private void registerEntityManagerFactories() throws InvalidPersistenceUnitException {
+    if(provider != null) {
+      if(emfs == null)
+        createEntityManagerFactories();
+      
+      registrations = new ArrayList<ServiceRegistration>();
+      String providerName = (String) provider.getProperty("javax.persistence.provider");
+      
+      for(Entry<String, EntityManagerFactory> entry : emfs.entrySet())
+      {
+        Properties props = new Properties();
+        String unitName = entry.getKey();
+        props.put("osgi.unit.name", unitName);
+        props.put("osgi.unit.provider", providerName);
+        props.put("org.apache.aries.jpa.container.managed", Boolean.TRUE);
+        try {
+          registrations.add(bundle.getBundleContext().registerService(EntityManagerFactory.class.getCanonicalName(), entry.getValue(), props));
+        } catch (Exception e) {
+          //TODO log
+          throw new InvalidPersistenceUnitException(e);
+        }
+      }
+    }
+  }
+
+  private void createEntityManagerFactories() throws InvalidPersistenceUnitException {
+    if(provider != null) {
+      if(emfs == null) {
+        try {
+          emfs = new HashMap<String, EntityManagerFactory>();
+        
+          PersistenceProvider providerService = (PersistenceProvider) containerContext.getService(provider);
+
+          if(providerService == null) throw new InvalidPersistenceUnitException();
+      
+          for(ManagedPersistenceUnitInfo info : persistenceUnits){
+            PersistenceUnitInfo pUnitInfo = info.getPersistenceUnitInfo();
+        
+            emfs.put(pUnitInfo.getPersistenceUnitName(), 
+                providerService.createContainerEntityManagerFactory(
+                    pUnitInfo, info.getContainerProperties()));
+          }
+        } finally {
+          containerContext.ungetService(provider);
+        }
+      }
+    }
+  }
+
+  /**
+   * Manage the EntityManagerFactories for the following
+   * provider and {@link PersistenceUnitInfo}s
+   * 
+   * This method should only be called when not holding any locks
+   * 
+   * @param ref The {@link PersistenceProvider} {@link ServiceReference}
+   * @param infos The {@link PersistenceUnitInfo}s defined by our bundle
+   */
+  public synchronized void manage(ServiceReference ref,
+      Collection<ManagedPersistenceUnitInfo> infos)  throws IllegalStateException{
+    provider = ref;
+    persistenceUnits = infos;
+  }
+
+  /**
+   * Stop managing any {@link EntityManagerFactory}s 
+   * 
+   * This method should only be called when not holding any locks
+   */
+  public synchronized void destroy() {
+    unregisterEntityManagerFactories();
+    destroyEntityManagerFactories();
+    
+    provider = null;
+    persistenceUnits = null;
+  }
+
+  private void destroyEntityManagerFactories() {
+    if(registrations != null)
+      unregisterEntityManagerFactories();
+    if(emfs != null) {
+      for(Entry<String, EntityManagerFactory> entry : emfs.entrySet()) {
+        try {
+          entry.getValue().close();
+        } catch (Exception e) {
+          //TODO log this error
+        }
+      }
+    }
+    emfs = null;
+  }
+
+
+}

Added: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidPersistenceUnitException.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidPersistenceUnitException.java?rev=897874&view=auto
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidPersistenceUnitException.java (added)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidPersistenceUnitException.java Mon Jan 11 14:21:47 2010
@@ -0,0 +1,13 @@
+package org.apache.aries.jpa.container.impl;
+
+public class InvalidPersistenceUnitException extends Exception {
+
+  public InvalidPersistenceUnitException(Exception e) {
+    super(e);
+  }
+
+  public InvalidPersistenceUnitException() {
+    // TODO Auto-generated constructor stub
+  }
+
+}

Added: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidRangeCombination.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidRangeCombination.java?rev=897874&view=auto
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidRangeCombination.java (added)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/InvalidRangeCombination.java Mon Jan 11 14:21:47 2010
@@ -0,0 +1,12 @@
+package org.apache.aries.jpa.container.impl;
+
+import org.osgi.framework.Version;
+
+public class InvalidRangeCombination extends Exception {
+
+  public InvalidRangeCombination(Version minVersion, boolean minExclusive,
+      Version maxVersion, boolean maxExclusive) {
+    // TODO Auto-generated constructor stub
+  }
+
+}

Modified: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java?rev=897874&r1=897873&r2=897874&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java (original)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/PersistenceBundleManager.java Mon Jan 11 14:21:47 2010
@@ -19,12 +19,34 @@
 
 package org.apache.aries.jpa.container.impl;
 
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
 import java.util.Collection;
-
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.apache.aries.application.VersionRange;
+import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
+import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
+import org.apache.aries.jpa.container.ManagedPersistenceUnitInfoFactory;
+import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
 import org.apache.aries.jpa.container.parsing.PersistenceDescriptor;
+import org.apache.aries.jpa.container.parsing.PersistenceDescriptorParser;
+import org.apache.aries.jpa.container.parsing.PersistenceDescriptorParserException;
+import org.apache.aries.jpa.container.unit.impl.ManagedPersistenceUnitInfoFactoryImpl;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
 import org.osgi.util.tracker.BundleTracker;
 
 
@@ -35,14 +57,24 @@
 {
   /** The bundle context for this bundle */
   private BundleContext ctx = null;
-  /** A map of bundles to generated fragments */
-//  private final ConcurrentMap<Bundle, Bundle> hostToFragmentMap = new ConcurrentHashMap<Bundle, Bundle>();
-//  /** A map of persistence bundles to sets of persistence metadata */
-//  private final ConcurrentMap<Bundle, Set<ServiceRegistration>> hostToPersistenceUnitMap = new ConcurrentHashMap<Bundle, Set<ServiceRegistration>>();
-  //TODO pull this from config
-  /** The default JPA provider to use */
-  public static final String DEFAULT_JPA_PROVIDER ="org.apache.openjpa.persistence.PersistenceProviderImpl";
+  /** 
+   * A map of providers to persistence bundles this is used to guarantee that 
+   * when a provider service is removed we can access all of the bundles that
+   * might possibly be using it. The map should only ever be accessed when
+   * synchronized on {@code this}.
+   */
+  private final Map<Bundle, EntityManagerFactoryManager> bundleToManagerMap = new HashMap<Bundle, EntityManagerFactoryManager>();
+  /** The PersistenceProviders.  */
+  private Set<ServiceReference> persistenceProviders = new HashSet<ServiceReference>();
+  /** Plug-point for persistence unit providers */
+  private ManagedPersistenceUnitInfoFactory persistenceUnitFactory; 
+  /** Configuration for this extender */
+  private Properties config;
 
+  private static final String DEFAULT_PU_INFO_FACTORY = "";
+  
+  private static final String DEFAULT_PU_INFO_FACTORY_KEY = "org.apache.aries.jpa.container.PersistenceUnitInfoFactory";
+  
   /**
    * Create the extender. Note that it will not start tracking 
    * until the {@code open()} method is called
@@ -55,6 +87,28 @@
     this.ctx = ctx;
   }
   
+  @Override
+  public void open() {
+    String className = (String) config.get(DEFAULT_PU_INFO_FACTORY_KEY);
+    Class<? extends ManagedPersistenceUnitInfoFactory> clazz = null;
+    
+    if(className != null) {
+      try {
+        clazz = ctx.getBundle().loadClass(className);
+        persistenceUnitFactory = clazz.newInstance();
+      } catch (Exception e) {
+        // TODO Log the error
+        e.printStackTrace();
+        //clazz = default;
+      }
+    }
+    
+    if(persistenceUnitFactory == null)
+      persistenceUnitFactory = new ManagedPersistenceUnitInfoFactoryImpl();
+
+    
+    super.open();
+  }
 //  /**
 //   * If we have generated a resources for the supplied bundle, then
 //   * tidy them  up.
@@ -88,23 +142,89 @@
     if(bundle.getState() == Bundle.ACTIVE) {
       //TODO LOG WARNING HERE
     }
+    EntityManagerFactoryManager mgr = null;
+    mgr = setupManager(bundle, mgr);
+    return mgr;
+  }
 
-    Collection <PersistenceDescriptor> persistenceXmls = PersistenceBundleHelper.findPersistenceXmlFiles(bundle);
+  private EntityManagerFactoryManager setupManager(Bundle bundle,
+    EntityManagerFactoryManager mgr) {
+  Collection <PersistenceDescriptor> persistenceXmls = PersistenceBundleHelper.findPersistenceXmlFiles(bundle);
 
     //If we have no persistence units then our job is done
     if (!!!persistenceXmls.isEmpty()) {
-      //TODO parse these
+      Collection<ParsedPersistenceUnit> pUnits = new ArrayList<ParsedPersistenceUnit>();
+      
+      for(PersistenceDescriptor descriptor : persistenceXmls) {
+        try {
+          pUnits.addAll(PersistenceDescriptorParser.parse(bundle, descriptor));
+        } catch (PersistenceDescriptorParserException e) {
+          // TODO Auto-generated catch block
+          e.printStackTrace();
+        }
+      }
+      
+      if(!!!pUnits.isEmpty()) {
+        ServiceReference ref = getProviderServiceReference(pUnits);
+          
+        Collection<ManagedPersistenceUnitInfo> infos = persistenceUnitFactory.
+            createManagedPersistenceUnitMetadata(ctx, bundle, ref, pUnits);
+        if(mgr != null)
+          mgr.manage(ref, infos);
+        else {
+          synchronized (this) {
+            if(persistenceProviders.contains(ref)) {
+                mgr = new EntityManagerFactoryManager(ctx, bundle, ref, infos);
+                bundleToManagerMap.put(bundle, mgr);
+            }
+          }
+        }
+        try {
+          mgr.bundleStateChange();
+        } catch (InvalidPersistenceUnitException e) {
+          // TODO Log this error
+          mgr.destroy();
+        }
+      }
     }
-    return null;
+    return mgr;
+}
+  
+  public synchronized void addingProvider(ServiceReference ref)
+  {
+    persistenceProviders.add(ref);
   }
-//      //Get the persistence units defined, and a provider for them to use
-//      Collection<PersistenceUnitImpl> parsedPersistenceUnits = parseXmlFiles(persistenceXmls, b);
-//      ServiceReference providerRef = getProviderServiceReference(parsedPersistenceUnits);
-//      
+  
+  public void removingProvider(ServiceReference ref)
+  {
+    Map<Bundle, EntityManagerFactoryManager> mgrs;
+    synchronized (this) {
+      persistenceProviders.remove(ref);
+      mgrs = new HashMap<Bundle, EntityManagerFactoryManager>(bundleToManagerMap);
+    }
+    for(Entry<Bundle, EntityManagerFactoryManager> entry : mgrs.entrySet()) {
+      if(entry.getValue().providerRemoved(ref))
+        persistenceUnitFactory.destroyPersistenceBundle(entry.getKey());
+    }
+  }
+  
+  public void setConfig(Properties props) {
+    config = props;
+    URL u = ctx.getBundle().getResource("org.apache.aries.jpa.container.properties");
+    
+    if(u != null)
+      try {
+        config.load(u.openStream());
+      } catch (IOException e) {
+        // TODO Log this error
+        e.printStackTrace();
+      }
+  }
+     
 //      //If we can't find a provider then bomb out
 //      if (providerRef != null)
 //      {
-//        try {
+//        try 
 //          FragmentBuilder builder = new FragmentBuilder(b, ".jpa.fragment");
 //          builder.addImportsFromExports(providerRef.getBundle());
 //          fragment = builder.install(ctx);
@@ -148,13 +268,31 @@
 
 
   public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
-      // TODO Auto-generated method stub
-      
+
+    EntityManagerFactoryManager mgr = (EntityManagerFactoryManager) object;
+    
+    if(event != null && event.getType() == BundleEvent.UPDATED) {
+      mgr.destroy();
+      persistenceUnitFactory.destroyPersistenceBundle(bundle);
+      setupManager(bundle, mgr);
+    } else {
+      try {
+        mgr.bundleStateChange();
+      } catch (InvalidPersistenceUnitException e) {
+        // TODO log this
+        mgr.destroy();
+      }
+    }
   }
 
   public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
-      // TODO Auto-generated method stub
-      
+    EntityManagerFactoryManager mgr = (EntityManagerFactoryManager) object;   
+    mgr.destroy();
+    persistenceUnitFactory.destroyPersistenceBundle(bundle);
+    
+    synchronized (this) {
+      bundleToManagerMap.remove(bundle);
+    }
   }
   
 
@@ -164,161 +302,155 @@
    * @param parsedPersistenceUnits
    * @return A service reference or null if no suitable reference is available
    */
-//  private ServiceReference getProviderServiceReference(Collection<PersistenceUnitImpl> parsedPersistenceUnits)
-//  {
-//    Set<String> ppClassNames = new HashSet<String>();
-//    Set<Filter> versionFilters = new HashSet<Filter>();
-//    //Fill the set of class names and version Filters
-//    for(PersistenceUnitImpl unit : parsedPersistenceUnits)
-//    {
-//      Map<String, Object> metadata = unit.getPersistenceXmlMetadata();
-//      String provider = (String) metadata.get(PersistenceUnitInfoService.PROVIDER_CLASSNAME);
-//      //get providers specified in the persistence units
-//      if(provider != null && !!!provider.equals(""))
-//      {
-//        ppClassNames.add(provider);
-//        
-//        Properties props = (Properties) metadata.get(PersistenceUnitInfoService.PROPERTIES);
-//        
-//        if(props != null && props.containsKey(PersistenceUnitInfoService.JPA_PROVIDER_VERSION)) {
-//         
-//          try {
-//            Filter f = getFilter(props.getProperty(PersistenceUnitInfoService.JPA_PROVIDER_VERSION, "0.0.0"));
-//            versionFilters.add(f);
-//          } catch (InvalidSyntaxException e) {
-//            // TODO Log error and ignore, This should never happen
-//            e.printStackTrace();
-//          }
-//        }
-//      }
-//    }
-//    
-//    //If we have too many provider class names specified then blow up
-//    if(ppClassNames.size() > 1)
-//    {
-//      //TODO log this error (too many persistence providers specified)
-//    } else {
-//      //Get the best provider for the given filters
-//      String provider = (ppClassNames.isEmpty()) ?
-//          DEFAULT_JPA_PROVIDER : ppClassNames.iterator().next();
-//          return getBestProvider(provider, versionFilters);
-//    }
-//    return null;
-//  }
+  private ServiceReference getProviderServiceReference(Collection<ParsedPersistenceUnit> parsedPersistenceUnits)
+  {
+    Set<String> ppClassNames = new HashSet<String>();
+    List<VersionRange> versionRanges = new ArrayList<VersionRange>();
+    //Fill the set of class names and version Filters
+    for(ParsedPersistenceUnit unit : parsedPersistenceUnits)
+    {
+      Map<String, Object> metadata = unit.getPersistenceXmlMetadata();
+      String provider = (String) metadata.get(ParsedPersistenceUnit.PROVIDER_CLASSNAME);
+      //get providers specified in the persistence units
+      if(provider != null && !!!provider.equals(""))
+      {
+        ppClassNames.add(provider);
+        
+        Properties props = (Properties) metadata.get(ParsedPersistenceUnit.PROPERTIES);
+        
+        if(props != null && props.containsKey(ParsedPersistenceUnit.JPA_PROVIDER_VERSION)) {
+         
+          try {
+            String versionRangeString = props.getProperty(ParsedPersistenceUnit.JPA_PROVIDER_VERSION, "0.0.0");
+            versionRanges.add(ManifestHeaderProcessor.parseVersionRange(versionRangeString));
+          } catch (IllegalArgumentException e) {
+            // TODO Log error. This is an invalid range and will be ignored.
+            e.printStackTrace();
+          }
+        }
+      }
+    }
+    //If we have too many provider class names or incompatible version ranges specified then blow up
+    
+    VersionRange range;
+    try {
+      range = combineVersionRanges(versionRanges);
+    } catch (InvalidRangeCombination e) {
+      // TODO Log this error
+      e.printStackTrace();
+      return null;
+    }
+    
+    if(ppClassNames.size() > 1)
+    {
+      //TODO log this error then(too many persistence providers specified)
+      return null;
+    } else {
+      //Get the best provider for the given filters
+      String provider = (ppClassNames.isEmpty()) ?
+          persistenceUnitFactory.getDefaultProviderClassName() : ppClassNames.iterator().next();
+          return getBestProvider(provider, range);
+    }
+  }
  
-//  /**
-//   * Locate the best provider for the given criteria
-//   * @param providerClass
-//   * @param matchingCriteria
-//   * @return
-//   */
-//  private ServiceReference getBestProvider(String providerClass, Set<Filter> matchingCriteria)
-//  {
-//    ServiceReference[] array = null;
-//    try {
-//      array = ctx.getAllServiceReferences(providerClass, null);
-//    } catch (InvalidSyntaxException e) {
-//      //TODO this can never happen
-//    }
-//    
-//    if(array != null) {
-//      //A linked list is faster for large numbers of ServiceReferences
-//      //Note we cannot use Arrays.asList() as we need to remove items
-//      //via an iterator, and this would throw UnsupportedOperationException.
-//      List<ServiceReference> refs = new LinkedList<ServiceReference>();
-//      
-//      for(ServiceReference reference : array)
-//        refs.add(reference);
-//      
-//      Iterator<ServiceReference> it = refs.iterator();
-//      
-//      //Remove anything that doesn't match the filter
-//      while(it.hasNext())
-//      {
-//        ServiceReference ref = it.next();
-//        for(Filter f : matchingCriteria)
-//        {
-//          if(!!!f.match(ref)) {
-//            it.remove();
-//            break;
-//          }
-//        }
-//      }
-//      
-//      if(!!!refs.isEmpty()) {
-//        //Sort the list in DESCENDING ORDER
-//        Collections.sort(refs, new Comparator<ServiceReference>() {
-//
-//          //TODO we may wish to use Ranking, then versions for equal ranks
-//          public int compare(ServiceReference object1, ServiceReference object2)
-//          {
-//            Version v1 = object1.getBundle().getVersion();
-//            Version v2 = object2.getBundle().getVersion();
-//            return v2.compareTo(v1);
-//          }
-//        });
-//        return refs.get(0);
-//      } else {
-//        //TODO no matching providers for matching criteria
-//      }
-//    } else {
-//      //TODO log no matching Providers for impl class
-//    }
-//    
-//    return null;
-//  }
-//  
-//  /**
-//   * Create a filter for the supplied version range string
-//   * @param providerVersion
-//   * @return
-//   * @throws InvalidSyntaxException
-//   */
-//  private Filter getFilter(String providerVersion)
-//      throws InvalidSyntaxException
-//  {
-//    String toReturn = null;
-//    
-//    //TODO NLS enable the messages in the exceptions below (Invalid version range specified...)
-//    //Create a filter to match the required provider version range
-//    if(providerVersion != null) {
-//      if(!!!providerVersion.contains(","))
-//        toReturn = ("(osgi.jpa.provider.version>=" + providerVersion + ")");
-//      else {
-//        String[] versionArray = providerVersion.split(",");
-//        
-//        if(versionArray.length == 2) {
-//          
-//          versionArray[0] = versionArray[0].trim();
-//          versionArray[1] = versionArray[1].trim();
-//          
-//          char bracket1 = versionArray[0].charAt(0);
-//          char bracket2 = versionArray[1].charAt(versionArray[1].length() - 1);
-//          
-//          String version1 = versionArray[0].substring(1);
-//          String version2 = versionArray[1].substring(0, versionArray[1].length() -1);
-//
-//          if(version1.compareTo(version2) > 0)
-//            throw new InvalidSyntaxException("Invalid version range specified. " + providerVersion, providerVersion);
-//          
-//          String compare1 = "(osgi.jpa.provider.version>=" + version1 + ")";
-//          String compare2 = "(osgi.jpa.provider.version<=" + version2 + ")";
-//          
-//          if('(' == bracket1)
-//             compare1 = compare1 + "(!(osgi.jpa.provider.version=" + version1 + "))";
-//          else if('[' != bracket1) throw new InvalidSyntaxException("Invalid version range specified. " + providerVersion, providerVersion);
-//          
-//
-//          if(')' == bracket2)
-//            compare2 = compare2 + "(!(osgi.jpa.provider.version=" + version2 + "))";
-//          else if(']' != bracket2) throw new InvalidSyntaxException("Invalid version range specified. " + providerVersion, providerVersion);
-//         
-//         
-//          toReturn = "(&" + compare1 + compare2 + ")";
-//        } else throw new InvalidSyntaxException("Invalid version range specified. " + providerVersion, providerVersion);
-//        
-//      }
-//    }
-//    return FrameworkUtil.createFilter(toReturn);
-//  }
+  private VersionRange combineVersionRanges(List<VersionRange> versionRanges) throws InvalidRangeCombination {
+
+    Version minVersion = new Version(0,0,0);
+    Version maxVersion = null;
+    boolean minExclusive = false;
+    boolean maxExclusive = false;
+    
+    for(VersionRange range : versionRanges) {
+      int minComparison = minVersion.compareTo(range.getMinimumVersion());
+      //If minVersion is smaller then we have a new, larger, minimum
+      if(minComparison < 0) {
+        minVersion = range.getMinimumVersion();
+        minExclusive = range.isMinimumExclusive();
+      }
+      //Only update if it is the same version but more restrictive
+      else if(minComparison == 0 && range.isMaximumExclusive())
+        minExclusive = true;
+    
+      if(range.isMaximumUnbounded())
+        continue;
+      else if (maxVersion == null) {
+        maxVersion = range.getMaximumVersion();
+        maxExclusive = range.isMaximumExclusive();
+      } else {
+        int maxComparison = maxVersion.compareTo(range.getMaximumVersion());
+        
+        //We have a new, lower maximum
+        if(maxComparison > 0) {
+          maxVersion = range.getMaximumVersion();
+          maxExclusive = range.isMaximumExclusive();
+          //If the maximum is the same then make sure we set the exclusivity properly
+        } else if (maxComparison == 0 && range.isMaximumExclusive())
+          maxExclusive = true;
+      }
+    }
+    
+    //Now check that we have valid values
+    int check = minVersion.compareTo(maxVersion);
+    //If min is greater than max, or min is equal to max and one of the exclusive
+    //flags is set then we have a problem!
+    if(check > 0 || (check == 0 && (minExclusive || maxExclusive))) {
+      throw new InvalidRangeCombination(minVersion, minExclusive, maxVersion, maxExclusive);
+    }
+    
+    StringBuilder rangeString = new StringBuilder();
+    rangeString.append(minVersion);
+    
+    if(maxVersion != null) {
+      rangeString.insert(0, minExclusive ? "(" : "[");
+      rangeString.append(",");
+      rangeString.append(maxVersion);
+      rangeString.append(maxExclusive ? ")" : "[");
+    }
+    
+    return ManifestHeaderProcessor.parseVersionRange(rangeString.toString());
+  }
+
+  /**
+   * Locate the best provider for the given criteria
+   * @param providerClass
+   * @param matchingCriteria
+   * @return
+   */
+  private synchronized ServiceReference getBestProvider(String providerClass, VersionRange matchingCriteria)
+  {
+    if(!!!persistenceProviders.isEmpty()) {
+
+      List<ServiceReference> refs = new ArrayList<ServiceReference>();
+      
+      for(ServiceReference reference : persistenceProviders) {
+        
+        if(providerClass != null && !!!providerClass.equals(
+            reference.getProperty("javax.persistence.provider")))
+          continue;
+          
+        if(matchingCriteria.matches(reference.getBundle().getVersion()))
+          refs.add(reference);
+      }
+      
+      if(!!!refs.isEmpty()) {
+        //Sort the list in DESCENDING ORDER
+        Collections.sort(refs, new Comparator<ServiceReference>() {
+
+          //TODO we may wish to use Ranking, then versions for equal ranks
+          public int compare(ServiceReference object1, ServiceReference object2)
+          {
+            Version v1 = object1.getBundle().getVersion();
+            Version v2 = object2.getBundle().getVersion();
+            return v2.compareTo(v1);
+          }
+        });
+        return refs.get(0);
+      } else {
+        //TODO no matching providers for matching criteria
+      }
+    } else {
+      //TODO log no matching Providers for impl class
+    }
+    return null;
+  }
 }

Modified: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/ParsedPersistenceUnit.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/ParsedPersistenceUnit.java?rev=897874&r1=897873&r2=897874&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/ParsedPersistenceUnit.java (original)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/ParsedPersistenceUnit.java Mon Jan 11 14:21:47 2010
@@ -54,6 +54,11 @@
   public static final String NON_JTA_DATASOURCE = "org.apache.aries.jpa.non.jta.datasource";
   /** A Boolean indicating whether unlisted classes should be excluded */
   public static final String EXCLUDE_UNLISTED_CLASSES = "org.apache.aries.jpa.exclude.unlisted";
+  
+  /* End of Map keys */
+  
+  /** This property is used in the JPA properties to indicate a provider version range */
+  public static final String JPA_PROVIDER_VERSION = "org.apache.aries.jpa.provider.version";
 
   /**
    * Return the bundle that defines the persistence unit

Modified: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java?rev=897874&r1=897873&r2=897874&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java (original)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/parsing/impl/PersistenceUnitImpl.java Mon Jan 11 14:21:47 2010
@@ -67,13 +67,11 @@
   }
   
   
-  @Override
   public Bundle getDefiningBundle()
   {
     return bundle;
   }
 
-  @Override
   public Map<String, Object> getPersistenceXmlMetadata()
   {
     Map<String, Object> data = new HashMap<String, Object>(metadata);

Added: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java?rev=897874&view=auto
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java (added)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoFactoryImpl.java Mon Jan 11 14:21:47 2010
@@ -0,0 +1,38 @@
+package org.apache.aries.jpa.container.unit.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
+import org.apache.aries.jpa.container.ManagedPersistenceUnitInfoFactory;
+import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+public class ManagedPersistenceUnitInfoFactoryImpl implements
+    ManagedPersistenceUnitInfoFactory {
+
+  public Collection<ManagedPersistenceUnitInfo> createManagedPersistenceUnitMetadata(
+      BundleContext containerContext, Bundle persistenceBundle,
+      ServiceReference providerReference,
+      Collection<ParsedPersistenceUnit> persistenceMetadata) {
+    
+    Collection<ManagedPersistenceUnitInfo> managedUnits = new ArrayList<ManagedPersistenceUnitInfo>();
+    
+    for(ParsedPersistenceUnit unit : persistenceMetadata)
+      managedUnits.add(new ManagedPersistenceUnitInfoImpl(persistenceBundle, unit));
+    
+    return managedUnits;
+  }
+
+  public void destroyPersistenceBundle(Bundle bundle) {
+    // TODO Auto-generated method stub
+
+  }
+
+  public String getDefaultProviderClassName() {
+    return null;
+  }
+
+}

Added: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoImpl.java?rev=897874&view=auto
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoImpl.java (added)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/ManagedPersistenceUnitInfoImpl.java Mon Jan 11 14:21:47 2010
@@ -0,0 +1,29 @@
+package org.apache.aries.jpa.container.unit.impl;
+
+import java.util.Map;
+
+import javax.persistence.spi.PersistenceUnitInfo;
+
+import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
+import org.apache.aries.jpa.container.parsing.ParsedPersistenceUnit;
+import org.osgi.framework.Bundle;
+
+public class ManagedPersistenceUnitInfoImpl implements
+    ManagedPersistenceUnitInfo {
+
+  private final PersistenceUnitInfo info;
+  public ManagedPersistenceUnitInfoImpl(Bundle persistenceBundle,
+      ParsedPersistenceUnit unit) {
+    info = new PersistenceUnitInfoImpl(persistenceBundle, unit);
+  }
+
+  public Map<String, Object> getContainerProperties() {
+    return null;
+  }
+
+  public PersistenceUnitInfo getPersistenceUnitInfo() {
+    return info;
+  }
+
+
+}

Added: incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java?rev=897874&view=auto
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java (added)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/unit/impl/PersistenceUnitInfoImpl.java Mon Jan 11 14:21:47 2010
@@ -0,0 +1,134 @@
+package org.apache.aries.jpa.container.unit.impl;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+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.parsing.ParsedPersistenceUnit;
+import org.osgi.framework.Bundle;
+
+public class PersistenceUnitInfoImpl implements PersistenceUnitInfo {
+  
+  private final Bundle bundle;
+
+  private final ParsedPersistenceUnit unit;
+  
+  public PersistenceUnitInfoImpl (Bundle b, ParsedPersistenceUnit parsedData)
+  {
+    bundle = b;
+    unit = parsedData;
+  }
+  
+  public void addTransformer(ClassTransformer arg0) {
+    // TODO Auto-generated method stub
+  }
+
+  public boolean excludeUnlistedClasses() {
+    Boolean result = (Boolean) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.EXCLUDE_UNLISTED_CLASSES);
+    return (result == null) ? false : result;
+  }
+
+  public ClassLoader getClassLoader() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @SuppressWarnings("unchecked")
+  public List<URL> getJarFileUrls() {
+    List<String> jarFiles = (List<String>) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.JAR_FILES);
+    List<URL> urls = new ArrayList<URL>();
+    
+    for(String jarFile : jarFiles)
+      urls.add(bundle.getResource(jarFile));
+    
+    return urls;
+  }
+
+  public DataSource getJtaDataSource() {
+    String jndiString = (String) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.NON_JTA_DATASOURCE);
+    DataSource toReturn = null;
+    try {
+      InitialContext ctx = new InitialContext();
+      toReturn = (DataSource) ctx.lookup(jndiString);
+    } catch (NamingException e) {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+    return toReturn;
+  }
+
+  @SuppressWarnings("unchecked")
+  public List<String> getManagedClassNames() {
+    return (List<String>) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.MANAGED_CLASSES);
+  }
+
+  @SuppressWarnings("unchecked")
+  public List<String> getMappingFileNames() {
+    return (List<String>) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.MAPPING_FILES);
+  }
+
+  public ClassLoader getNewTempClassLoader() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  public DataSource getNonJtaDataSource() {
+    
+    String jndiString = (String) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.NON_JTA_DATASOURCE);
+    DataSource toReturn = null;
+    try {
+      InitialContext ctx = new InitialContext();
+      toReturn = (DataSource) ctx.lookup(jndiString);
+    } catch (NamingException e) {
+      // TODO Auto-generated catch block
+      e.printStackTrace();
+    }
+    return toReturn;
+  }
+
+  public String getPersistenceProviderClassName() {
+    return (String) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.PROVIDER_CLASSNAME);
+  }
+
+  public String getPersistenceUnitName() {
+    return (String) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.UNIT_NAME);
+  }
+
+  public URL getPersistenceUnitRootUrl() {
+    return bundle.getResource("");
+  }
+
+  public String getPersistenceXMLSchemaVersion() {
+    return (String) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.SCHEMA_VERSION);
+  }
+
+  public Properties getProperties() {
+    return (Properties) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.PROPERTIES);
+  }
+
+  public SharedCacheMode getSharedCacheMode() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  public PersistenceUnitTransactionType getTransactionType() {
+    return PersistenceUnitTransactionType.valueOf(
+        (String) unit.getPersistenceXmlMetadata().get(ParsedPersistenceUnit.TRANSACTION_TYPE));
+  }
+
+  public ValidationMode getValidationMode() {
+    // TODO Auto-generated method stub
+    return null;
+  }
+  
+}
\ No newline at end of file

Added: incubator/aries/trunk/jpa/jpa-container/src/main/resources/OSGI-INF/blueprint/jpa.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/resources/OSGI-INF/blueprint/jpa.xml?rev=897874&view=auto
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/resources/OSGI-INF/blueprint/jpa.xml (added)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/resources/OSGI-INF/blueprint/jpa.xml Mon Jan 11 14:21:47 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="container"  class="org.apache.aries.jpa.container.impl.PersistenceBundleManager" init-method="open">
+      <argument ref="blueprintBundleContext"/>
+    </bean>
+
+	<reference-list interface="javax.persistence.spi.PersistenceProvider">
+	  <reference-listener ref="container" bind-method="addingProvider" unbind-method="removingProvider"/>
+	</reference-list>
+    
+</blueprint>



Mime
View raw message