aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1751615 - in /aries/trunk/tx-control: tx-control-provider-jdbc-local/ tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/ tx-control-provider-jdbc-xa/ tx-control-provider-jdbc-xa/src/main/java/org/apac...
Date Wed, 06 Jul 2016 07:47:43 GMT
Author: timothyjward
Date: Wed Jul  6 07:47:42 2016
New Revision: 1751615

URL: http://svn.apache.org/viewvc?rev=1751615&view=rev
Log:
[tx-control] Improvements for the Local and XA JDBC ResourceProviders:
 * Add Metatypes
 * Avoid publishing "." properties
 * Ensure that tracked services are DataSourceFactories

Added:
    aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/Config.java
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/Config.java
Modified:
    aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml
    aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/ManagedServiceFactoryImpl.java
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/pom.xml
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java

Modified: aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml?rev=1751615&r1=1751614&r2=1751615&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml Wed Jul  6 07:47:42 2016
@@ -79,6 +79,10 @@
 			<groupId>org.osgi</groupId>
 			<artifactId>org.osgi.service.jdbc</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.service.metatype.annotations</artifactId>
+		</dependency>
 
 		<!-- Hikari CP dependency -->
 		<dependency>

Added: aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/Config.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/Config.java?rev=1751615&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/Config.java
(added)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/Config.java
Wed Jul  6 07:47:42 2016
@@ -0,0 +1,90 @@
+package org.apache.aries.tx.control.jdbc.local.impl;
+
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_DATABASE_NAME;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_DATASOURCE_NAME;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_DESCRIPTION;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_NETWORK_PROTOCOL;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_PASSWORD;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_PORT_NUMBER;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_ROLE_NAME;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_SERVER_NAME;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_URL;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_USER;
+
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.AttributeType;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+
+@ObjectClassDefinition(factoryPid="org.apache.aries.tx.control.jdbc.local", description="Aries
Transaction Control Factory for Local JDBCResourceProvider Services")
+public @interface Config {
+
+	// Most commonly used properties declared first so that they go into the metatype first
+	
+	@AttributeDefinition(required=false, 
+			description="The name of the driver class for the DataSourceFactory service. This property
need not be defined if aries.dsf.target.filter is defined.")
+	String osgi_jdbc_driver_class();
+
+	@AttributeDefinition(required=false, description="The JDBC URL to pass to the DataSourceFactory")
+	String url();
+	
+	@AttributeDefinition(required=false, description="The userid to pass to the DataSourceFactory")
+	String user();
+	
+	@AttributeDefinition(type=AttributeType.PASSWORD, required=false, 
+			description="The password to pass to the DataSourceFactory (not visible as a service property)")
+	String password();
+	
+	// Pool configuration properties
+	
+	@AttributeDefinition(required=false, description="Is connection pooling enabled for this
JDBCResourceProvider")
+	boolean osgi_connection_pooling_enabled() default true;
+	
+	@AttributeDefinition(required=false, description="The maximum number of connections in the
pool")
+	int osgi_connection_max() default 10;
+
+	@AttributeDefinition(required=false, description="The minimum number of connections in the
pool")
+	int osgi_connection_min() default 10;
+	
+	@AttributeDefinition(required=false, description="The maximum time (in ms) that the pool
will wait for a connection before failing")
+	long osgi_connection_timeout() default 30000;
+	
+	@AttributeDefinition(required=false, description="The minimum time (in ms) a connection
will be idle before being reclaimed by the pool")
+	long osgi_idle_timeout() default 180000;
+	
+	@AttributeDefinition(required=false, description="The maximum time (in ms) that a connection
will stay in the pool before being discarded")
+	long osgi_connection_lifetime() default 10800000;
+	
+	// Detailed Configuration
+	
+	@AttributeDefinition(required=false, description="The filter to use when finding the DataSourceFactory
service. This property need not be defined if osgi.jdbc.driver.class is defined.")
+	String aries_dsf_target_filter();
+	
+	@AttributeDefinition(required=false, description="The names of the properties from this
configuration that should be passed to the DataSourceFactory")
+	String[] aries_jdbc_property_names() default {JDBC_DATABASE_NAME, JDBC_DATASOURCE_NAME,
+			JDBC_DESCRIPTION, JDBC_NETWORK_PROTOCOL, JDBC_PASSWORD, JDBC_PORT_NUMBER, JDBC_ROLE_NAME,
JDBC_SERVER_NAME,
+			JDBC_URL, JDBC_USER};
+	
+
+	//Raw JDBC configuration
+	
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	String databaseName();
+	
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	String dataSourceName();
+
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	String description();
+
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	String networkProtocol();
+
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	int portNumber();
+
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	String roleName();
+
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	String serverName();
+}

Modified: aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/ManagedServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/ManagedServiceFactoryImpl.java?rev=1751615&r1=1751614&r2=1751615&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/ManagedServiceFactoryImpl.java
(original)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/ManagedServiceFactoryImpl.java
Wed Jul  6 07:47:42 2016
@@ -166,7 +166,7 @@ public class ManagedServiceFactoryImpl i
 					throw new ConfigurationException(OSGI_JDBC_DRIVER_CLASS,
 							"The configuration must specify either a target filter or a JDBC driver class");
 				}
-				targetFilter = "(" + OSGI_JDBC_DRIVER_CLASS + "=" + driver + ")";
+				targetFilter = "(&(" + OBJECTCLASS + "=" + DataSourceFactory.class.getName() + ")("
+ OSGI_JDBC_DRIVER_CLASS + "=" + driver + "))";
 			}
 
 			targetFilter = "(&(" + OBJECTCLASS + "=" + DataSourceFactory.class.getName() + ")"
+ targetFilter + ")";
@@ -214,7 +214,9 @@ public class ManagedServiceFactoryImpl i
 
 		private Dictionary<String, ?> getServiceProperties() {
 			Hashtable<String, Object> props = new Hashtable<>();
-			providerProperties.keySet().stream().filter(s -> !JDBC_PASSWORD.equals(s))
+			providerProperties.keySet().stream()
+					.filter(s -> !s.startsWith("."))
+					.filter(s -> !JDBC_PASSWORD.equals(s))
 					.forEach(s -> props.put(s, providerProperties.get(s)));
 			return props;
 		}

Modified: aries/trunk/tx-control/tx-control-provider-jdbc-xa/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-xa/pom.xml?rev=1751615&r1=1751614&r2=1751615&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-xa/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-xa/pom.xml Wed Jul  6 07:47:42 2016
@@ -78,6 +78,10 @@
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.service.jdbc</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.service.metatype.annotations</artifactId>
+        </dependency>
 
         <!-- Hikari CP dependency -->
         <dependency>

Added: aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/Config.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/Config.java?rev=1751615&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/Config.java
(added)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/Config.java
Wed Jul  6 07:47:42 2016
@@ -0,0 +1,98 @@
+package org.apache.aries.tx.control.jdbc.xa.impl;
+
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_DATABASE_NAME;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_DATASOURCE_NAME;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_DESCRIPTION;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_NETWORK_PROTOCOL;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_PASSWORD;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_PORT_NUMBER;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_ROLE_NAME;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_SERVER_NAME;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_URL;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_USER;
+
+import org.osgi.service.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.AttributeType;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+
+@ObjectClassDefinition(factoryPid="org.apache.aries.tx.control.jdbc.xa", description="Aries
Transaction Control Factory for XA enabled JDBCResourceProvider Services")
+public @interface Config {
+
+	// Most commonly used properties declared first so that they go into the metatype first
+	
+	@AttributeDefinition(required=false, 
+			description="The name of the driver class for the DataSourceFactory service. This property
need not be defined if aries.dsf.target.filter is defined.")
+	String osgi_jdbc_driver_class();
+
+	@AttributeDefinition(required=false, description="The JDBC URL to pass to the DataSourceFactory")
+	String url();
+	
+	@AttributeDefinition(required=false, description="The userid to pass to the DataSourceFactory")
+	String user();
+	
+	@AttributeDefinition(type=AttributeType.PASSWORD, required=false, 
+			description="The password to pass to the DataSourceFactory (not visible as a service property)")
+	String password();
+	
+	// Pool configuration properties
+	
+	@AttributeDefinition(required=false, description="Is connection pooling enabled for this
JDBCResourceProvider")
+	boolean osgi_connection_pooling_enabled() default true;
+	
+	@AttributeDefinition(required=false, description="The maximum number of connections in the
pool")
+	int osgi_connection_max() default 10;
+
+	@AttributeDefinition(required=false, description="The minimum number of connections in the
pool")
+	int osgi_connection_min() default 10;
+	
+	@AttributeDefinition(required=false, description="The maximum time (in ms) that the pool
will wait for a connection before failing")
+	long osgi_connection_timeout() default 30000;
+	
+	@AttributeDefinition(required=false, description="The minimum time (in ms) a connection
will be idle before being reclaimed by the pool")
+	long osgi_idle_timeout() default 180000;
+	
+	@AttributeDefinition(required=false, description="The maximum time (in ms) that a connection
will stay in the pool before being discarded")
+	long osgi_connection_lifetime() default 10800000;
+	
+	// Transaction integration configuration
+	
+	@AttributeDefinition(required=false, description="Should this Resource participate in transactions
using XA")
+	boolean osgi_xa_enabled() default true;
+
+	@AttributeDefinition(required=false, description="Should this Resource participate as a
Local Resource if XA is not available")
+	boolean osgi_local_enabled() default true;
+
+	// Detailed Configuration
+	
+	@AttributeDefinition(required=false, description="The filter to use when finding the DataSourceFactory
service. This property need not be defined if osgi.jdbc.driver.class is defined.")
+	String aries_dsf_target_filter();
+	
+	@AttributeDefinition(required=false, description="The names of the properties from this
configuration that should be passed to the DataSourceFactory")
+	String[] aries_jdbc_property_names() default {JDBC_DATABASE_NAME, JDBC_DATASOURCE_NAME,
+			JDBC_DESCRIPTION, JDBC_NETWORK_PROTOCOL, JDBC_PASSWORD, JDBC_PORT_NUMBER, JDBC_ROLE_NAME,
JDBC_SERVER_NAME,
+			JDBC_URL, JDBC_USER};
+	
+
+	//Raw JDBC configuration
+	
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	String databaseName();
+	
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	String dataSourceName();
+
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	String description();
+
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	String networkProtocol();
+
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	int portNumber();
+
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	String roleName();
+
+	@AttributeDefinition(required=false, description="JDBC configuration property")
+	String serverName();
+}

Modified: aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java?rev=1751615&r1=1751614&r2=1751615&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java
(original)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java
Wed Jul  6 07:47:42 2016
@@ -166,7 +166,7 @@ public class ManagedServiceFactoryImpl i
 					throw new ConfigurationException(OSGI_JDBC_DRIVER_CLASS,
 							"The configuration must specify either a target filter or a JDBC driver class");
 				}
-				targetFilter = "(" + OSGI_JDBC_DRIVER_CLASS + "=" + driver + ")";
+				targetFilter = "(&(" + OBJECTCLASS + "=" + DataSourceFactory.class.getName() + ")("
+ OSGI_JDBC_DRIVER_CLASS + "=" + driver + "))";
 			}
 
 			targetFilter = "(&(" + OBJECTCLASS + "=" + DataSourceFactory.class.getName() + ")"
+ targetFilter + ")";
@@ -214,7 +214,9 @@ public class ManagedServiceFactoryImpl i
 
 		private Dictionary<String, ?> getServiceProperties() {
 			Hashtable<String, Object> props = new Hashtable<>();
-			providerProperties.keySet().stream().filter(s -> !JDBC_PASSWORD.equals(s))
+			providerProperties.keySet().stream()
+					.filter(s -> !s.startsWith("."))
+					.filter(s -> !JDBC_PASSWORD.equals(s))
 					.forEach(s -> props.put(s, providerProperties.get(s)));
 			return props;
 		}



Mime
View raw message