aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1764109 - in /aries/trunk/tx-control: ./ tx-control-provider-jpa-common/ tx-control-provider-jpa-common/src/ tx-control-provider-jpa-common/src/main/ tx-control-provider-jpa-common/src/main/java/ tx-control-provider-jpa-common/src/main/jav...
Date Mon, 10 Oct 2016 14:47:05 GMT
Author: timothyjward
Date: Mon Oct 10 14:47:04 2016
New Revision: 1764109

URL: http://svn.apache.org/viewvc?rev=1764109&view=rev
Log:
ARIES-1616 Factor out JPA resource provider common code from Local JPA

Added:
    aries/trunk/tx-control/tx-control-provider-jpa-common/
    aries/trunk/tx-control/tx-control-provider-jpa-common/pom.xml
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/AbstractJPAEntityManagerProvider.java
      - copied, changed from r1764108, aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/AbstractJPAEntityManagerProvider.java
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/EntityManagerWrapper.java
      - copied, changed from r1764108, aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/EntityManagerWrapper.java
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/InternalJPAEntityManagerProviderFactory.java
      - copied, changed from r1764108, aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/InternalJPAEntityManagerProviderFactory.java
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/JPAResourceActivator.java
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ResourceTrackingJPAEntityManagerProviderFactory.java
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ScopedEntityManagerWrapper.java
      - copied, changed from r1764108, aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ScopedEntityManagerWrapper.java
    aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/TxEntityManagerWrapper.java
      - copied, changed from r1764108, aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/TxEntityManagerWrapper.java
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/DriverDataSource.java
      - copied, changed from r1764108, aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/DriverDataSource.java
Removed:
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/AbstractJPAEntityManagerProvider.java
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/DriverDataSource.java
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/EntityManagerWrapper.java
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/InternalJPAEntityManagerProviderFactory.java
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/JPAEntityManagerProviderFactoryServiceFactory.java
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ResourceTrackingJPAEntityManagerProviderFactory.java
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ScopedEntityManagerWrapper.java
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/TxEntityManagerWrapper.java
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/LifecycleAware.java
Modified:
    aries/trunk/tx-control/pom.xml
    aries/trunk/tx-control/tx-control-provider-jpa-local/bnd.bnd
    aries/trunk/tx-control/tx-control-provider-jpa-local/pom.xml
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/Activator.java
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedJPADataSourceSetup.java
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedJPAEMFLocator.java
    aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedServiceFactoryImpl.java

Modified: aries/trunk/tx-control/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/pom.xml?rev=1764109&r1=1764108&r2=1764109&view=diff
==============================================================================
--- aries/trunk/tx-control/pom.xml (original)
+++ aries/trunk/tx-control/pom.xml Mon Oct 10 14:47:04 2016
@@ -58,6 +58,7 @@
 				<module>tx-control-provider-jdbc-common</module>
 				<module>tx-control-provider-jdbc-local</module>
 				<module>tx-control-provider-jdbc-xa</module>
+				<module>tx-control-provider-jpa-common</module>
 				<module>tx-control-provider-jpa-local</module>
 				<module>tx-control-provider-jpa-xa</module>
 				<module>tx-control-itests</module>

Added: aries/trunk/tx-control/tx-control-provider-jpa-common/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-common/pom.xml?rev=1764109&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jpa-common/pom.xml (added)
+++ aries/trunk/tx-control/tx-control-provider-jpa-common/pom.xml Mon Oct 10 14:47:04 2016
@@ -0,0 +1,98 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.tx-control</groupId>
+        <artifactId>tx-control</artifactId>
+        <version>0.0.2-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <groupId>org.apache.aries.tx-control</groupId>
+    <artifactId>tx-control-provider-jpa-common</artifactId>
+    <packaging>jar</packaging>
+    <name>OSGi Transaction Control JPA Resource Provider - Common Code</name>
+    <version>0.0.2-SNAPSHOT</version>
+
+    <description>
+        This jar contains a common code for building OSGi Transaction Control JPAEntityManagerProvider

+        implementations. It is not complete and should not be deployed at runtime, instead
it should 
+        be repackaged inside a complete implementation.
+    </description>
+
+    <scm>
+        <connection>
+            scm:svn:http://svn.apache.org/repos/asf/aries/trunk/tx-control/tx-control-provider-jpa-common
+        </connection>
+        <developerConnection>
+            scm:svn:https://svn.apache.org/repos/asf/aries/trunk/tx-control/tx-control-provider-jpa-common
+        </developerConnection>
+        <url>
+            http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-common
+        </url>
+    </scm>
+
+    <dependencies>
+        <!-- Internal Aries project dependencies -->
+        <dependency>
+            <groupId>org.apache.aries.tx-control</groupId>
+            <artifactId>tx-control-api</artifactId>
+            <version>0.0.2-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.tx-control</groupId>
+            <artifactId>tx-control-provider-common</artifactId>
+            <version>0.0.2-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        
+        <!-- OSGi dependencies -->
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.util.tracker</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.service.cm</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.service.jdbc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.service.jpa</artifactId>
+        </dependency>
+        
+        <!-- JPA API dependency -->
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jpa_2.1_spec</artifactId>
+        </dependency>
+        
+        <!-- Hikari CP dependency -->
+        <dependency>
+            <groupId>com.zaxxer</groupId>
+            <artifactId>HikariCP</artifactId>
+        </dependency>
+        
+        <!-- Logging dependencies -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+        <!-- Test dependencies -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

Copied: aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/AbstractJPAEntityManagerProvider.java
(from r1764108, aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/AbstractJPAEntityManagerProvider.java)
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/AbstractJPAEntityManagerProvider.java?p2=aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/AbstractJPAEntityManagerProvider.java&p1=aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/AbstractJPAEntityManagerProvider.java&r1=1764108&r2=1764109&rev=1764109&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/AbstractJPAEntityManagerProvider.java
(original)
+++ aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/AbstractJPAEntityManagerProvider.java
Mon Oct 10 14:47:04 2016
@@ -27,7 +27,7 @@ import org.osgi.service.transaction.cont
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public abstract class AbstractJPAEntityManagerProvider implements JPAEntityManagerProvider
{
+public abstract class AbstractJPAEntityManagerProvider implements JPAEntityManagerProvider,
AutoCloseable {
 
 	private static final Logger LOG = LoggerFactory.getLogger(AbstractJPAEntityManagerProvider.class);
 	

Copied: aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/EntityManagerWrapper.java
(from r1764108, aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/EntityManagerWrapper.java)
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/EntityManagerWrapper.java?p2=aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/EntityManagerWrapper.java&p1=aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/EntityManagerWrapper.java&r1=1764108&r2=1764109&rev=1764109&view=diff
==============================================================================
    (empty)

Copied: aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/InternalJPAEntityManagerProviderFactory.java
(from r1764108, aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/InternalJPAEntityManagerProviderFactory.java)
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/InternalJPAEntityManagerProviderFactory.java?p2=aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/InternalJPAEntityManagerProviderFactory.java&p1=aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/InternalJPAEntityManagerProviderFactory.java&r1=1764108&r2=1764109&rev=1764109&view=diff
==============================================================================
    (empty)

Added: aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/JPAResourceActivator.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/JPAResourceActivator.java?rev=1764109&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/JPAResourceActivator.java
(added)
+++ aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/JPAResourceActivator.java
Mon Oct 10 14:47:04 2016
@@ -0,0 +1,58 @@
+/*
+ * 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.tx.control.jpa.common.impl;
+
+import org.apache.aries.tx.control.resource.common.impl.ResourceActivator;
+import org.apache.geronimo.specs.jpa.PersistenceActivator;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.transaction.control.jpa.JPAEntityManagerProviderFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class JPAResourceActivator extends
+	ResourceActivator<AbstractJPAEntityManagerProvider, ResourceTrackingJPAEntityManagerProviderFactory>{
+
+	private static final Logger LOG = LoggerFactory.getLogger(JPAResourceActivator.class);
+	
+	private final BundleActivator geronimoActivator = new PersistenceActivator();
+	
+	@Override
+	public void start(BundleContext context) throws Exception {
+		LOG.debug("Starting JPA API trackers");
+		geronimoActivator.start(context);
+		super.start(context);
+	}
+
+	@Override
+	public void stop(BundleContext context) throws Exception {
+		try {
+			super.stop(context);
+		} finally {
+			LOG.debug("Stopping JPA API trackers");
+			geronimoActivator.stop(context);
+		}
+	}
+
+
+	@Override
+	protected Class<JPAEntityManagerProviderFactory> getAdvertisedInterface() {
+		return JPAEntityManagerProviderFactory.class;
+	}
+}

Added: aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ResourceTrackingJPAEntityManagerProviderFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ResourceTrackingJPAEntityManagerProviderFactory.java?rev=1764109&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ResourceTrackingJPAEntityManagerProviderFactory.java
(added)
+++ aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ResourceTrackingJPAEntityManagerProviderFactory.java
Mon Oct 10 14:47:04 2016
@@ -0,0 +1,34 @@
+package org.apache.aries.tx.control.jpa.common.impl;
+
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.aries.tx.control.resource.common.impl.TrackingResourceProviderFactory;
+import org.osgi.service.jpa.EntityManagerFactoryBuilder;
+import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider;
+import org.osgi.service.transaction.control.jpa.JPAEntityManagerProviderFactory;
+
+public class ResourceTrackingJPAEntityManagerProviderFactory extends 
+	TrackingResourceProviderFactory<AbstractJPAEntityManagerProvider> implements 
+	JPAEntityManagerProviderFactory {
+
+	private final InternalJPAEntityManagerProviderFactory factory;
+	
+	public ResourceTrackingJPAEntityManagerProviderFactory(InternalJPAEntityManagerProviderFactory
factory) {
+		this.factory = factory;
+	}
+
+	@Override
+	public JPAEntityManagerProvider getProviderFor(EntityManagerFactoryBuilder emfb, Map<String,
Object> jpaProperties,
+			Map<String, Object> resourceProviderProperties) {
+		return doGetResult(() -> factory.getProviderFor(emfb, 
+				jpaProperties, resourceProviderProperties));
+	}
+
+	@Override
+	public JPAEntityManagerProvider getProviderFor(EntityManagerFactory emf, Map<String,
Object> resourceProviderProperties) {
+		return doGetResult(() -> factory.getProviderFor(emf, 
+				resourceProviderProperties));
+	}
+}
\ No newline at end of file

Copied: aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ScopedEntityManagerWrapper.java
(from r1764108, aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ScopedEntityManagerWrapper.java)
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ScopedEntityManagerWrapper.java?p2=aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ScopedEntityManagerWrapper.java&p1=aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/ScopedEntityManagerWrapper.java&r1=1764108&r2=1764109&rev=1764109&view=diff
==============================================================================
    (empty)

Copied: aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/TxEntityManagerWrapper.java
(from r1764108, aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/TxEntityManagerWrapper.java)
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/TxEntityManagerWrapper.java?p2=aries/trunk/tx-control/tx-control-provider-jpa-common/src/main/java/org/apache/aries/tx/control/jpa/common/impl/TxEntityManagerWrapper.java&p1=aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/TxEntityManagerWrapper.java&r1=1764108&r2=1764109&rev=1764109&view=diff
==============================================================================
    (empty)

Modified: aries/trunk/tx-control/tx-control-provider-jpa-local/bnd.bnd
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-local/bnd.bnd?rev=1764109&r1=1764108&r2=1764109&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jpa-local/bnd.bnd (original)
+++ aries/trunk/tx-control/tx-control-provider-jpa-local/bnd.bnd Mon Oct 10 14:47:04 2016
@@ -39,6 +39,7 @@ Export-Package: org.osgi.service.transac
 # to avoid dependency fanout
 
 Private-Package: org.apache.aries.tx.control.jpa.*, \
+                 org.apache.aries.tx.control.resource.common.impl, \
                  org.apache.geronimo.osgi.locator, \
                  org.apache.geronimo.specs.jpa, \
                  com.zaxxer.hikari, \

Modified: aries/trunk/tx-control/tx-control-provider-jpa-local/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-local/pom.xml?rev=1764109&r1=1764108&r2=1764109&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jpa-local/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-provider-jpa-local/pom.xml Mon Oct 10 14:47:04 2016
@@ -47,8 +47,6 @@
         </url>
 	</scm>
 
-
-
 	<dependencies>
 		<!-- Internal Aries project dependencies -->
 		<dependency>
@@ -57,6 +55,18 @@
 			<version>0.0.2-SNAPSHOT</version>
 			<scope>provided</scope>
 		</dependency>
+		<dependency>
+			<groupId>org.apache.aries.tx-control</groupId>
+			<artifactId>tx-control-provider-common</artifactId>
+			<version>0.0.2-SNAPSHOT</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.aries.tx-control</groupId>
+			<artifactId>tx-control-provider-jpa-common</artifactId>
+			<version>0.0.2-SNAPSHOT</version>
+			<scope>provided</scope>
+		</dependency>
 
 		<!-- OSGi API dependencies -->
 		<dependency>

Modified: aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/Activator.java?rev=1764109&r1=1764108&r2=1764109&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/Activator.java
(original)
+++ aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/Activator.java
Mon Oct 10 14:47:04 2016
@@ -18,89 +18,49 @@
  */
 package org.apache.aries.tx.control.jpa.local.impl;
 
-import static org.osgi.framework.Constants.SERVICE_PID;
-
 import java.util.Dictionary;
 import java.util.Hashtable;
 
+import org.apache.aries.tx.control.jpa.common.impl.AbstractJPAEntityManagerProvider;
 import org.apache.aries.tx.control.jpa.common.impl.InternalJPAEntityManagerProviderFactory;
-import org.apache.aries.tx.control.jpa.common.impl.JPAEntityManagerProviderFactoryServiceFactory;
-import org.apache.geronimo.specs.jpa.PersistenceActivator;
-import org.osgi.framework.BundleActivator;
+import org.apache.aries.tx.control.jpa.common.impl.JPAResourceActivator;
+import org.apache.aries.tx.control.jpa.common.impl.ResourceTrackingJPAEntityManagerProviderFactory;
+import org.apache.aries.tx.control.resource.common.impl.ConfigurationDefinedResourceFactory;
+import org.apache.aries.tx.control.resource.common.impl.ResourceProviderFactoryServiceFactory;
+import org.apache.aries.tx.control.resource.common.impl.TrackingResourceProviderFactory;
 import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.ManagedServiceFactory;
-import org.osgi.service.transaction.control.jpa.JPAEntityManagerProviderFactory;
-
-public class Activator implements BundleActivator {
-
-	private final BundleActivator geronimoActivator;
-	
-	private JPAEntityManagerProviderFactoryServiceFactory service;
-	private ManagedServiceFactoryImpl msf;
-	
-	private ServiceRegistration<?> reg;
-	private ServiceRegistration<ManagedServiceFactory> factoryReg;
-	
-	public Activator() {
-		geronimoActivator = new PersistenceActivator();
-	}
-	
+
+public class Activator extends JPAResourceActivator {
+
 	@Override
-	public void start(BundleContext context) throws Exception {
-		geronimoActivator.start(context);
+	protected ResourceProviderFactoryServiceFactory<AbstractJPAEntityManagerProvider, ResourceTrackingJPAEntityManagerProviderFactory>
getServiceFactory(
+			BundleContext context) {
 		
 		InternalJPAEntityManagerProviderFactory ijempf = new JPAEntityManagerProviderFactoryImpl();
-		
-		service = new JPAEntityManagerProviderFactoryServiceFactory() {
+		return new ResourceProviderFactoryServiceFactory<AbstractJPAEntityManagerProvider, ResourceTrackingJPAEntityManagerProviderFactory>()
{
 			@Override
-			protected InternalJPAEntityManagerProviderFactory getInternalJPAEntityManagerProviderFactory()
{
-				return ijempf;
+			protected TrackingResourceProviderFactory<AbstractJPAEntityManagerProvider> getTrackingResourceManagerProviderFactory()
{
+				return new ResourceTrackingJPAEntityManagerProviderFactory(ijempf);
 			}
+			
 		};
-		reg = context.registerService(JPAEntityManagerProviderFactory.class.getName(), 
-				service, getProperties());
-		
-		msf  = new ManagedServiceFactoryImpl(context);
-		factoryReg = context.registerService(ManagedServiceFactory.class, 
-				msf, getMSFProperties());
 	}
 
 	@Override
-	public void stop(BundleContext context) throws Exception {
-		safeUnregister(reg);
-		safeUnregister(factoryReg);
-		try {
-			msf.stop();
-		} catch (Exception e) {
-			// TODO log this
-		}
-		try {
-			service.close();
-		} catch (Exception e) {
-			// TODO log this
-		}
-		geronimoActivator.stop(context);
-	}
-
-	private void safeUnregister(ServiceRegistration<?> reg) {
-		try {
-			reg.unregister();
-		} catch (IllegalStateException ise) {
-			// Ignore this
-		}
-	}
-
-	private Dictionary<String, Object> getProperties() {
+	protected Dictionary<String, Object> getServiceProperties() {
 		Dictionary<String, Object> props = new Hashtable<>();
 		props.put("osgi.local.enabled", Boolean.TRUE);
 		return props;
 	}
 
-	private Dictionary<String, ?> getMSFProperties() {
-		Dictionary<String, Object> props = new Hashtable<>();
-		props.put(SERVICE_PID, "org.apache.aries.tx.control.jpa.local");
-		return props;
+	@Override
+	protected ConfigurationDefinedResourceFactory getConfigurationDefinedResourceFactory(BundleContext
context) {
+		return new ManagedServiceFactoryImpl(context);
+	}
+
+	@Override
+	protected String getMSFPid() {
+		return "org.apache.aries.tx.control.jpa.local";
 	}
 
 }

Copied: aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/DriverDataSource.java
(from r1764108, aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/DriverDataSource.java)
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/DriverDataSource.java?p2=aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/DriverDataSource.java&p1=aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/DriverDataSource.java&r1=1764108&r2=1764109&rev=1764109&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/common/impl/DriverDataSource.java
(original)
+++ aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/DriverDataSource.java
Mon Oct 10 14:47:04 2016
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.aries.tx.control.jpa.common.impl;
+package org.apache.aries.tx.control.jpa.local.impl;
 
 import java.io.PrintWriter;
 import java.sql.Connection;

Modified: aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedJPADataSourceSetup.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedJPADataSourceSetup.java?rev=1764109&r1=1764108&r2=1764109&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedJPADataSourceSetup.java
(original)
+++ aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedJPADataSourceSetup.java
Mon Oct 10 14:47:04 2016
@@ -42,7 +42,7 @@ import java.util.concurrent.atomic.Atomi
 
 import javax.sql.DataSource;
 
-import org.apache.aries.tx.control.jpa.common.impl.DriverDataSource;
+import org.apache.aries.tx.control.resource.common.impl.LifecycleAware;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;

Modified: aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedJPAEMFLocator.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedJPAEMFLocator.java?rev=1764109&r1=1764108&r2=1764109&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedJPAEMFLocator.java
(original)
+++ aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedJPAEMFLocator.java
Mon Oct 10 14:47:04 2016
@@ -29,6 +29,7 @@ import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.aries.tx.control.jpa.common.impl.AbstractJPAEntityManagerProvider;
+import org.apache.aries.tx.control.resource.common.impl.LifecycleAware;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;

Modified: aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedServiceFactoryImpl.java?rev=1764109&r1=1764108&r2=1764109&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedServiceFactoryImpl.java
(original)
+++ aries/trunk/tx-control/tx-control-provider-jpa-local/src/main/java/org/apache/aries/tx/control/jpa/local/impl/ManagedServiceFactoryImpl.java
Mon Oct 10 14:47:04 2016
@@ -20,7 +20,6 @@ package org.apache.aries.tx.control.jpa.
 
 import static java.lang.Integer.MAX_VALUE;
 import static java.util.Arrays.asList;
-import static java.util.Optional.ofNullable;
 import static java.util.function.Function.identity;
 import static java.util.stream.Collectors.toMap;
 import static javax.persistence.spi.PersistenceUnitTransactionType.RESOURCE_LOCAL;
@@ -38,23 +37,20 @@ import static org.osgi.service.jdbc.Data
 
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.aries.tx.control.resource.common.impl.ConfigurationDefinedResourceFactory;
+import org.apache.aries.tx.control.resource.common.impl.LifecycleAware;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedServiceFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ManagedServiceFactoryImpl implements ManagedServiceFactory {
+public class ManagedServiceFactoryImpl extends ConfigurationDefinedResourceFactory {
 
 	static final Logger LOG = LoggerFactory.getLogger(ManagedServiceFactoryImpl.class);
 	
@@ -66,12 +62,8 @@ public class ManagedServiceFactoryImpl i
 			JDBC_URL, JDBC_USER);
 	static final String JPA_PROP_NAMES = "aries.jpa.property.names";
 
-	private final Map<String, LifecycleAware> managedInstances = new ConcurrentHashMap<>();
-
-	private final BundleContext context;
-
 	public ManagedServiceFactoryImpl(BundleContext context) {
-		this.context = context;
+		super(context);
 	}
 
 	@Override
@@ -80,43 +72,32 @@ public class ManagedServiceFactoryImpl i
 	}
 
 	@Override
-	public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException
{
+	protected LifecycleAware getConfigurationDrivenResource(BundleContext context, String pid,
+			Map<String, Object> properties) throws Exception {
 
-		Map<String, Object> propsMap = new HashMap<>();
-
-		Enumeration<String> keys = properties.keys();
-		while (keys.hasMoreElements()) {
-			String key = keys.nextElement();
-			propsMap.put(key, properties.get(key));
-		}
 
-		Properties jdbcProps = getJdbcProps(pid, propsMap);
-		Map<String, Object> jpaProps = getJPAProps(pid, propsMap);
+		Properties jdbcProps = getJdbcProps(pid, properties);
+		Map<String, Object> jpaProps = getJPAProps(pid, properties);
 
 		try {
 			LifecycleAware worker;
-			if(propsMap.containsKey(OSGI_JDBC_DRIVER_CLASS) ||
-					propsMap.containsKey(DSF_TARGET_FILTER)) {
-				worker = new ManagedJPADataSourceSetup(context, pid, jdbcProps, jpaProps, propsMap);
+			if(properties.containsKey(OSGI_JDBC_DRIVER_CLASS) ||
+					properties.containsKey(DSF_TARGET_FILTER)) {
+				worker = new ManagedJPADataSourceSetup(context, pid, jdbcProps, jpaProps, properties);
 			} else {
 				if(!jdbcProps.isEmpty()) {
 					LOG.warn("The configuration {} contains raw JDBC configuration, but no osgi.jdbc.driver.class
or aries.dsf.target.filter properties. No DataSourceFactory will be used byt this bundle,
so the JPA provider must be able to directly create the datasource, and these configuration
properties will likely be ignored. {}",
 								pid, jdbcProps.stringPropertyNames());
 				}
-				worker = new ManagedJPAEMFLocator(context, pid, jpaProps, propsMap, null);
+				worker = new ManagedJPAEMFLocator(context, pid, jpaProps, properties, null);
 			}
-			ofNullable(managedInstances.put(pid, worker)).ifPresent(LifecycleAware::stop);
-			worker.start();
+			return worker;
 		} catch (InvalidSyntaxException e) {
 			LOG.error("The configuration {} contained an invalid target filter {}", pid, e.getFilter());
 			throw new ConfigurationException(DSF_TARGET_FILTER, "The target filter was invalid", e);
 		}
 	}
 
-	public void stop() {
-		managedInstances.values().forEach(LifecycleAware::stop);
-	}
-
 	@SuppressWarnings("unchecked")
 	private Properties getJdbcProps(String pid, Map<String, Object> properties) throws
ConfigurationException {
 
@@ -168,11 +149,6 @@ public class ManagedServiceFactoryImpl i
 		return result;
 	}
 
-	@Override
-	public void deleted(String pid) {
-		ofNullable(managedInstances.remove(pid))
-			.ifPresent(LifecycleAware::stop);
-	}
 	
 	private static class AllCollection implements Collection<String> {
 



Mime
View raw message