You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ti...@apache.org on 2010/01/18 12:26:56 UTC

svn commit: r900347 - in /incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container: PersistenceUnitConstants.java impl/EntityManagerFactoryManager.java

Author: timothyjward
Date: Mon Jan 18 11:26:56 2010
New Revision: 900347

URL: http://svn.apache.org/viewvc?rev=900347&view=rev
Log:
ARIES-118 : Add support for container managed persistence contexts

Added:
    incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/PersistenceUnitConstants.java
Modified:
    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/PersistenceUnitConstants.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/PersistenceUnitConstants.java?rev=900347&view=auto
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/PersistenceUnitConstants.java (added)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/PersistenceUnitConstants.java Mon Jan 18 11:26:56 2010
@@ -0,0 +1,34 @@
+/*
+ * 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.PersistenceProvider;
+
+/**
+ * Constants used when registering Persistence Units in the service registry
+ */
+public interface PersistenceUnitConstants {
+  /** The service property key mapped to the persistence unit name */
+  public static final String OSGI_UNIT_NAME = "osgi.unit.name";
+  /** The service property key mapped to the {@link PersistenceProvider} implementation class name */
+  public static final String OSGI_UNIT_PROVIDER = "osgi.unit.provider";
+  /** The service property key mapped to a Boolean indicating whether this persistence unit is container managed */ 
+  public static final String CONTAINER_MANAGED_PERSISTENCE_UNIT = "org.apache.aries.jpa.container.managed";
+
+}

Modified: 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=900347&r1=900346&r2=900347&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java (original)
+++ incubator/aries/trunk/jpa/jpa-container/src/main/java/org/apache/aries/jpa/container/impl/EntityManagerFactoryManager.java Mon Jan 18 11:26:56 2010
@@ -30,6 +30,7 @@
 import javax.persistence.spi.PersistenceUnitInfo;
 
 import org.apache.aries.jpa.container.ManagedPersistenceUnitInfo;
+import org.apache.aries.jpa.container.PersistenceUnitConstants;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -177,9 +178,9 @@
           throw new InvalidPersistenceUnitException();
         }
           
-        props.put("osgi.unit.name", unitName);
-        props.put("osgi.unit.provider", providerName);
-        props.put("org.apache.aries.jpa.container.managed", Boolean.TRUE);
+        props.put(PersistenceUnitConstants.OSGI_UNIT_NAME, unitName);
+        props.put(PersistenceUnitConstants.OSGI_UNIT_PROVIDER, providerName);
+        props.put(PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT, Boolean.TRUE);
         try {
           registrations.add(bundle.getBundleContext().registerService(EntityManagerFactory.class.getCanonicalName(), entry.getValue(), props));
         } catch (Exception e) {