geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1079603 - in /geronimo/sandbox/djencks/txmanager: ./ geronimo-connector-builder-1_6/ geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/da...
Date Tue, 08 Mar 2011 23:45:11 GMT
Author: djencks
Date: Tue Mar  8 23:45:10 2011
New Revision: 1079603

URL: http://svn.apache.org/viewvc?rev=1079603&view=rev
Log:
add support for @DataSource annotations, untested.  Some support added to tranql

Added:
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/datasource/
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/datasource/DataSourceWrapper.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/DataSourceInfo.java
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/pom.xml   (with props)
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/java/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/java/org/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/java/org/apache/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/java/org/apache/geronimo/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/java/org/apache/geronimo/connector/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/java/org/apache/geronimo/connector/datasource/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/java/org/apache/geronimo/connector/datasource/tranql/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/java/org/apache/geronimo/connector/datasource/tranql/TranqlDataSourceWrapper.java
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/test/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/test/java/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/test/java/org/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/test/java/org/apache/
    geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/test/java/org/apache/geronimo/
Removed:
    geronimo/sandbox/djencks/txmanager/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/RARConfiguration.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/RARConfigurer.java
Modified:
    geronimo/sandbox/djencks/txmanager/geronimo-connector-builder-1_6/pom.xml
    geronimo/sandbox/djencks/txmanager/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/AssemblerImpl.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/ConnectorExtender.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/Container.java
    geronimo/sandbox/djencks/txmanager/pom.xml

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector-builder-1_6/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector-builder-1_6/pom.xml?rev=1079603&r1=1079602&r2=1079603&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector-builder-1_6/pom.xml (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector-builder-1_6/pom.xml Tue Mar  8 23:45:10
2011
@@ -294,19 +294,6 @@
                 <version>2.3.2</version>
                 <configuration>
                     <compilerArgument>${bootClassPath}</compilerArgument>
-                    <includes>
-                        <include>org/apache/geronimo/connector/deployment/plan/*</include>
-                        <include>org/apache/geronimo/connector/deployment/*.java</include>
-                        <!--<include>org/apache/geronimo/connector/deployment/AnnotationProcessor.java</include>-->
-                        <!--<include>org/apache/geronimo/connector/deployment/InfoBuilder.java</include>-->
-                        <!--<include>org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java</include>-->
-                    </includes>
-                    <excludes>
-                        <!--<exclude>org/apache/geronimo/connector/deployment/AdminObjectRefBuilder.java</exclude>-->
-                        <exclude>org/apache/geronimo/connector/deployment/RARConfiguration.java</exclude>
-                        <exclude>org/apache/geronimo/connector/deployment/RARConfigurer.java</exclude>
-                        <!--<exclude>org/apache/geronimo/connector/deployment/ResourceRefBuilder.java</exclude>-->
-                    </excludes>
                     <testIncludes>
                         <!--<include>org/apache/geronimo/connector/deployment/InfoBuilderTest.java</include>-->
                     </testIncludes>

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java?rev=1079603&r1=1079602&r2=1079603&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java
Tue Mar  8 23:45:10 2011
@@ -17,6 +17,9 @@
 
 package org.apache.geronimo.datasource.deployment;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
 import java.sql.Connection;
 import java.util.Collection;
 import java.util.Collections;
@@ -28,8 +31,9 @@ import javax.annotation.sql.DataSourceDe
 import javax.annotation.sql.DataSourceDefinitions;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.connector.deployment.ConnectorModuleBuilder;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.connector.model.DataSourceInfo;
+import org.apache.geronimo.connector.model.ManagedConnectionFactoryInfo;
+import org.apache.geronimo.connector.model.ResourceAdapterModuleInfo;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.apache.geronimo.gbean.annotation.ParamSpecial;
@@ -121,62 +125,52 @@ public class DataSourceBuilder extends A
         // step 2: bind all defined data sources into jndi
         Collection<DataSource> dataSources = specDD.getDataSource();
         if (dataSources != null) {
+            ResourceAdapterModuleInfo moduleInfo = new ResourceAdapterModuleInfo();
             for (DataSource dataSource: dataSources) {
                 try {
-                    addDataSourceGBean(module, sharedContext, dataSource);
+                    addDataSourceGBean(moduleInfo, module, sharedContext, dataSource);
                 } catch (GBeanAlreadyExistsException e) {
                     throw new DeploymentException("Error creating DataSource gbean", e);
                 }
             }
-        }        
+            try {
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                ObjectOutputStream out = new ObjectOutputStream(baos);
+                out.writeObject(moduleInfo);
+                out.flush();
+                out.close();
+                module.getEarContext().addFile(ConnectorModuleBuilder.PLAN_LOCATION, baos.toByteArray());
+            } catch (IOException e) {
+                throw new DeploymentException(e);
+            }
+        }
     }
 
-    private void addDataSourceGBean(Module module, Map<EARContext.Key, Object> sharedContext,
DataSource ds)
+    private void addDataSourceGBean(ResourceAdapterModuleInfo resourceAdapterModuleInfo,
Module module, Map<EARContext.Key, Object> sharedContext, DataSource ds)
         throws GBeanAlreadyExistsException {
                         
         String jndiName = ds.getKey();
         
-        if (lookupJndiContextMap(module, jndiName) != null) {
-            return;
-        }
+//        if (lookupJndiContextMap(module, jndiName) != null) {
+//            return;
+//        }
         
         String name = jndiName;
         if (name.startsWith("java:")) {
             name = name.substring(5);
         }
-                
-        EARContext earContext = module.getEarContext();
-                       
-        AbstractName dataSourceAbstractName = earContext.getNaming().createChildName(module.getModuleName(),
name, "GBean");
 
-        GBeanData dataSourceGBean = new GBeanData(dataSourceAbstractName, DataSourceGBean.class);
-        
-        DataSourceDescription dsDescription = createDataSourceDescription(ds);
-        dataSourceGBean.setAttribute("dataSourceDescription", dsDescription);
-        
-        dataSourceGBean.setAttribute("defaultMaxSize", defaultMaxSize);
-        dataSourceGBean.setAttribute("defaultMinSize", defaultMinSize);
-        dataSourceGBean.setAttribute("defaultBlockingTimeoutMilliseconds", defaultBlockingTimeoutMilliseconds);
-        dataSourceGBean.setAttribute("defaultIdleTimeoutMinutes", defaultIdleTimeoutMinutes);
-        
-        dataSourceGBean.setAttribute("defaultXATransactionCaching", defaultXATransactionCaching);
-        dataSourceGBean.setAttribute("defaultXAThreadCaching", defaultXAThreadCaching);
-        
-        dataSourceGBean.setReferencePattern("ConnectionTracker", earContext.getConnectionTrackerName());
-        dataSourceGBean.setReferencePattern("TransactionManager", earContext.getTransactionManagerName());
+        DataSourceInfo dsDescription = createDataSourceDescription(ds);
+        String osgiJndiName = name;
+//        if (dsDescription.getProperties() != null) {
+//            osgiJndiName = dsDescription.getProperties().get(ConnectorModuleBuilder.OSGI_JNDI_SERVICE_NAME);
+//        }
+//        if (osgiJndiName == null) {
+//            osgiJndiName = module.getEarContext().getNaming().toOsgiJndiName(dataSourceAbstractName);
+//        }
+        dsDescription.serviceProperties.put(ConnectorModuleBuilder.OSGI_JNDI_SERVICE_NAME,
osgiJndiName);
+        resourceAdapterModuleInfo.managedConnectionFactoryInfos.add(dsDescription);
 
-        dataSourceGBean.setServiceInterfaces(new String[] { javax.sql.DataSource.class.getName()
});
-        String osgiJndiName = null;
-        if (dsDescription.getProperties() != null) {
-            osgiJndiName = dsDescription.getProperties().get(ConnectorModuleBuilder.OSGI_JNDI_SERVICE_NAME);
-        }
-        if (osgiJndiName == null) {
-            osgiJndiName = module.getEarContext().getNaming().toOsgiJndiName(dataSourceAbstractName);
-        }
-        dataSourceGBean.getServiceProperties().put(ConnectorModuleBuilder.OSGI_JNDI_SERVICE_NAME,
osgiJndiName);
-        
-        earContext.addGBean(dataSourceGBean);
-                
         Object ref = new JndiReference("aries:services/" + osgiJndiName);
         put(jndiName, ref, module.getJndiContext(), Collections.<InjectionTarget>emptyList(),
sharedContext);
     }
@@ -288,42 +282,42 @@ public class DataSourceBuilder extends A
         return null;        
     }
     
-    private DataSourceDescription createDataSourceDescription(DataSource ds) {
-        DataSourceDescription dsDescription = new DataSourceDescription();
+    private DataSourceInfo createDataSourceDescription(DataSource ds) {
+        DataSourceInfo dsDescription = new DataSourceInfo();
         
-        dsDescription.setName(ds.getName());
-        dsDescription.setClassName(ds.getClassName());
+        dsDescription.name  = ds.getName();
+        dsDescription.dataSourceClass = ds.getClassName();
         
-        if (ds.getDescription() != null) {
-            dsDescription.setDescription(ds.getDescription().trim());
-        }
+//        if (ds.getDescription() != null) {
+//            dsDescription.setDescription(ds.getDescription().trim());
+//        }
         
         if (ds.getUrl() != null) {
-            dsDescription.setUrl(ds.getUrl().trim());
+            dsDescription.configProperties.put("Url", ds.getUrl().trim());
         }
         
         if (ds.getUser() != null) {
-            dsDescription.setUser(ds.getUser().trim());
+            dsDescription.configProperties.put("User", ds.getUser().trim());
         }
         
         if (ds.getPassword() != null) {
-            dsDescription.setPassword(ds.getPassword().trim());
+            dsDescription.configProperties.put("Password", ds.getPassword().trim());
         }
         
         if (ds.getDatabaseName() != null) {
-            dsDescription.setDatabaseName(ds.getDatabaseName().trim());
+            dsDescription.configProperties.put("DatabaseName", ds.getDatabaseName().trim());
         }
         
         if (ds.getServerName() != null) {
-            dsDescription.setServerName(ds.getServerName().trim());
+            dsDescription.configProperties.put("ServerName", ds.getServerName().trim());
         }
         
         if (ds.getPortNumber() != null) {
-            dsDescription.setPortNumber(ds.getPortNumber());
+            dsDescription.configProperties.put("PortNumber", ds.getPortNumber());
         }
                 
         if (ds.getLoginTimeout() != null) {
-            dsDescription.setLoginTimeout(ds.getLoginTimeout());
+            dsDescription.configProperties.put("LoginTimeout", ds.getLoginTimeout());
         }
         
         List<Property> props = ds.getProperty();
@@ -333,52 +327,56 @@ public class DataSourceBuilder extends A
                 properties.put(prop.getName().trim(),
                                prop.getValue().trim());
             }
-            dsDescription.setProperties(properties);
+            dsDescription.configProperties.putAll(properties);
         }
         
         // transaction properties
         
         if (ds.getTransactional()) {
-            dsDescription.setTransactional(ds.getTransactional());
+            dsDescription.transactionSupport = ManagedConnectionFactoryInfo.TransactionSupport.xaTxCached;
+        } else {
+            dsDescription.transactionSupport = ManagedConnectionFactoryInfo.TransactionSupport.none;
         }
         
         if (ds.getIsolationLevel() != null) {
             switch (ds.getIsolationLevel()) {
             case TRANSACTION_READ_COMMITTED:
-                dsDescription.setIsolationLevel(Connection.TRANSACTION_READ_COMMITTED);
+                dsDescription.configProperties.put("IsolationLevel", Connection.TRANSACTION_READ_COMMITTED);
                 break;
             case TRANSACTION_READ_UNCOMMITTED:
-                dsDescription.setIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED);
+                dsDescription.configProperties.put("IsolationLevel", Connection.TRANSACTION_READ_UNCOMMITTED);
                 break;
             case TRANSACTION_REPEATABLE_READ:
-                dsDescription.setIsolationLevel(Connection.TRANSACTION_REPEATABLE_READ);
+                dsDescription.configProperties.put("IsolationLevel", Connection.TRANSACTION_REPEATABLE_READ);
                 break;
             case TRANSACTION_SERIALIZABLE:
-                dsDescription.setIsolationLevel(Connection.TRANSACTION_SERIALIZABLE);
+                dsDescription.configProperties.put("IsolationLevel", Connection.TRANSACTION_SERIALIZABLE);
                 break;
             }
         }
         
         // pool properties
         
-        if (ds.getInitialPoolSize() != null) {
-            dsDescription.setInitialPoolSize(ds.getInitialPoolSize());
-        }
+//        if (ds.getInitialPoolSize() != null) {
+//            dsDescription.setInitialPoolSize(ds.getInitialPoolSize());
+//        }
         
         if (ds.getMaxPoolSize() != null) {
-            dsDescription.setMaxPoolSize(ds.getMaxPoolSize());
+            dsDescription.maxPoolSize = ds.getMaxPoolSize();
         }
         
         if (ds.getMinPoolSize() != null) {
-            dsDescription.setMinPoolSize(ds.getMinPoolSize());
-        }
-        
-        if (ds.getMaxStatements() != null) {
-            dsDescription.setMaxStatements(ds.getMaxStatements());
+            dsDescription.minPoolSize = ds.getMinPoolSize();
         }
+
+        //TODO support this??
+//        if (ds.getMaxStatements() != null) {
+//            dsDescription.setMaxStatements(ds.getMaxStatements());
+//        }
         
         if (ds.getMaxIdleTime() != null) {
-            dsDescription.setMaxIdleTime(ds.getMaxIdleTime());
+            //todo time unit
+            dsDescription.idleTimeoutMinutes = ds.getMaxIdleTime();
         }
         
         return dsDescription;

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml?rev=1079603&r1=1079602&r2=1079603&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml Tue Mar  8 23:45:10 2011
@@ -128,7 +128,11 @@
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
                     <instructions>
-                        <Export-Package>org.apache.geronimo.connector,org.apache.geronimo.connector.model;version=3.0</Export-Package>
+                        <Export-Package>
+                            org.apache.geronimo.connector;version=4.0,
+                            org.apache.geronimo.connector.model;version=4.0,
+                            org.apache.geronimo.connector.datasource;version=4.0
+                        </Export-Package>
                     </instructions>
                 </configuration>
             </plugin>

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/AssemblerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/AssemblerImpl.java?rev=1079603&r1=1079602&r2=1079603&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/AssemblerImpl.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/AssemblerImpl.java
Tue Mar  8 23:45:10 2011
@@ -23,18 +23,23 @@ package org.apache.geronimo.connector.as
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.resource.spi.ResourceAdapter;
 import javax.resource.spi.ResourceAdapterAssociation;
+import javax.sql.XADataSource;
 import org.apache.geronimo.connector.ConnectionTracker;
 import org.apache.geronimo.connector.SubjectSource;
 import org.apache.geronimo.connector.assembler.Assembler;
 import org.apache.geronimo.connector.assembler.AssemblyListener;
+import org.apache.geronimo.connector.datasource.DataSourceWrapper;
 import org.apache.geronimo.connector.model.AdminObjectInfo;
+import org.apache.geronimo.connector.model.DataSourceInfo;
 import org.apache.geronimo.connector.model.ManagedConnectionFactoryInfo;
 import org.apache.geronimo.connector.model.ResourceAdapterInfo;
 import org.apache.geronimo.connector.model.ResourceAdapterModuleInfo;
@@ -58,6 +63,14 @@ import org.osgi.framework.Bundle;
 public class AssemblerImpl implements Assembler {
 
     private final List<AssemblyListener> listeners = new ArrayList<AssemblyListener>();
+    private DataSourceWrapper dataSourceWrapper;
+
+    public AssemblerImpl() {
+    }
+
+    public AssemblerImpl(DataSourceWrapper dataSourceWrapper) {
+        this.dataSourceWrapper = dataSourceWrapper;
+    }
 
     public void addListener(AssemblyListener listener) {
         listeners.add(listener);
@@ -98,7 +111,12 @@ public class AssemblerImpl implements As
     }
 
     private void assembleManagedConnectionFactory(ManagedConnectionFactoryInfo managedConnectionFactoryInfo,
Bundle bundle, ResourceAdapter resourceAdapter, ClassLoader threadClassLoader, SubjectSource
subjectSource, ConnectionTracker connectionTracker, RecoverableTransactionManager transactionManager)
throws ResourceException {
-        ManagedConnectionFactory managedConnectionFactory = load(ManagedConnectionFactory.class,
managedConnectionFactoryInfo.managedConnectionFactoryClass, managedConnectionFactoryInfo.configProperties,
bundle);
+        ManagedConnectionFactory managedConnectionFactory;
+        if (managedConnectionFactoryInfo instanceof DataSourceInfo) {
+            managedConnectionFactory = load((DataSourceInfo)managedConnectionFactoryInfo,
bundle);
+        } else {
+            managedConnectionFactory = load(ManagedConnectionFactory.class, managedConnectionFactoryInfo.managedConnectionFactoryClass,
managedConnectionFactoryInfo.configProperties, bundle);
+        }
         if (resourceAdapter != null & managedConnectionFactory instanceof ResourceAdapterAssociation)
{
             ((ResourceAdapterAssociation)managedConnectionFactory).setResourceAdapter(resourceAdapter);
         }
@@ -214,6 +232,68 @@ public class AssemblerImpl implements As
             throw new ResourceException(e);
         }
     }
+    private ManagedConnectionFactory load(DataSourceInfo dataSourceInfo, Bundle bundle) throws
ResourceException {
+        try {
+            Class<?> dataSourceClass = bundle.loadClass(dataSourceInfo.dataSourceClass);
+            Object dataSource = dataSourceClass.newInstance();
+            Set<String> foundNames = new HashSet<String>();
+            for (Map.Entry<String, Object> entry: dataSourceInfo.configProperties.entrySet())
{
+                String propertyName = entry.getKey();
+                Object propertyValue = entry.getValue();
+                Method setter;
+                try {
+                    setter = dataSourceClass.getMethod("set" + propertyName, propertyValue.getClass());
+                } catch (NoSuchMethodException e) {
+                    try {
+                        setter = dataSourceClass.getMethod("set" + swapCase(propertyName),
propertyValue.getClass());
+                    } catch (NoSuchMethodException e1) {
+                        continue;
+                    }
+                }
+                foundNames.add(propertyName);
+                setter.invoke(dataSource, propertyValue);
+            }
+
+            if (dataSourceInfo.transactionSupport != ManagedConnectionFactoryInfo.TransactionSupport.none)
{
+                if (dataSource instanceof XADataSource) {
+                     dataSourceInfo.transactionSupport = ManagedConnectionFactoryInfo.TransactionSupport.xaTxCached;
+                } else {
+                    dataSourceInfo.transactionSupport = ManagedConnectionFactoryInfo.TransactionSupport.local;
+                }
+            }
+
+            ManagedConnectionFactory result = dataSourceWrapper.wrapDataSource(dataSourceInfo.managedConnectionFactoryClass,
dataSource);
+            Class<?> resultClass = result.getClass();
+            for (Map.Entry<String, Object> entry: dataSourceInfo.configProperties.entrySet())
{
+                String propertyName = entry.getKey();
+                Object propertyValue = entry.getValue();
+                Method setter;
+                try {
+                    setter = resultClass.getMethod("set" + propertyName, propertyValue.getClass());
+                } catch (NoSuchMethodException e) {
+                    try {
+                        setter = resultClass.getMethod("set" + swapCase(propertyName), propertyValue.getClass());
+                    } catch (NoSuchMethodException e1) {
+                        continue;
+                    }
+                }
+                foundNames.add(propertyName);
+                setter.invoke(result, propertyValue);
+            }
+            if (foundNames.size() < dataSourceInfo.configProperties.size()) {
+                throw new ResourceException("Some config params could not be set on the datasource
or the wrapper: " + new HashSet(dataSourceInfo.configProperties.keySet()).removeAll(foundNames));
+            }
+            return result;
+        } catch (ClassNotFoundException e) {
+            throw new ResourceException(e);
+        } catch (InstantiationException e) {
+            throw new ResourceException(e);
+        } catch (IllegalAccessException e) {
+            throw new ResourceException(e);
+        } catch (InvocationTargetException e) {
+            throw new ResourceException(e);
+        }
+    }
 
     private String swapCase(String propertyName) {
         return propertyName;

Added: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/datasource/DataSourceWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/datasource/DataSourceWrapper.java?rev=1079603&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/datasource/DataSourceWrapper.java
(added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/datasource/DataSourceWrapper.java
Tue Mar  8 23:45:10 2011
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+
+package org.apache.geronimo.connector.datasource;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ManagedConnectionFactory;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public interface DataSourceWrapper {
+
+    ManagedConnectionFactory wrapDataSource(String wrapperClass, Object dataSource) throws
ResourceException;
+
+}

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/ConnectorExtender.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/ConnectorExtender.java?rev=1079603&r1=1079602&r2=1079603&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/ConnectorExtender.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/ConnectorExtender.java
Tue Mar  8 23:45:10 2011
@@ -31,6 +31,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.geronimo.connector.datasource.DataSourceWrapper;
 import org.apache.geronimo.connector.model.ResourceAdapterModuleInfo;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -52,6 +53,9 @@ public class ConnectorExtender {
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY, target = "(component.factory=org.apache.geronimo.connector.outbound.DSFactoryConnectionManager)")
     private ComponentFactory cmFactory;
 
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY)
+    private DataSourceWrapper dataSourceWrapper;
+
     private BundleTracker bt;
 
     @Activate
@@ -116,7 +120,7 @@ public class ConnectorExtender {
             } catch (IOException e) {
             }
             if (moduleInfo != null) {
-                Container container = new Container(bundle, moduleInfo, cmFactory);
+                Container container = new Container(bundle, moduleInfo, cmFactory, dataSourceWrapper);
                 //TODO use an executor
                 container.run();
                 return container;
@@ -141,4 +145,15 @@ public class ConnectorExtender {
     public void unsetCmFactory(ComponentFactory cmFactory) {
         this.cmFactory = null;
     }
+
+    public void bindDataSourceWrapper(DataSourceWrapper dataSourceWrapper) {
+        this.dataSourceWrapper = dataSourceWrapper;
+    }
+
+    public void unbindDataSourceWrapper(DataSourceWrapper dataSourceWrapper) {
+        if (this.dataSourceWrapper == dataSourceWrapper) {
+            this.dataSourceWrapper = null;
+        }
+    }
+
 }

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/Container.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/Container.java?rev=1079603&r1=1079602&r2=1079603&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/Container.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/Container.java
Tue Mar  8 23:45:10 2011
@@ -30,6 +30,7 @@ import javax.resource.spi.ManagedConnect
 import javax.resource.spi.ResourceAdapter;
 import org.apache.geronimo.connector.assembler.AssemblyListener;
 import org.apache.geronimo.connector.assembler.impl.AssemblerImpl;
+import org.apache.geronimo.connector.datasource.DataSourceWrapper;
 import org.apache.geronimo.connector.model.ResourceAdapterModuleInfo;
 import org.apache.geronimo.connector.outbound.BaseConnectionManager;
 import org.apache.geronimo.connector.outbound.DSFactoryConnectionManager;
@@ -46,19 +47,21 @@ public class Container implements Assemb
     private final Bundle bundle;
     private final ResourceAdapterModuleInfo moduleInfo;
     private final ComponentFactory cmFactory;
+    private final DataSourceWrapper dataSourceWrapper;
     private final List<ServiceRegistration> serviceRegistrations = new ArrayList<ServiceRegistration>();
     private final List<ComponentInstance> componentInstances = new ArrayList<ComponentInstance>();
 
 
-    public Container(Bundle bundle, ResourceAdapterModuleInfo moduleInfo, ComponentFactory
cmFactory) {
+    public Container(Bundle bundle, ResourceAdapterModuleInfo moduleInfo, ComponentFactory
cmFactory, DataSourceWrapper dataSourceWrapper) {
         this.bundle = bundle;
         this.moduleInfo = moduleInfo;
         this.cmFactory = cmFactory;
+        this.dataSourceWrapper = dataSourceWrapper;
     }
 
     @Override
     public void run() {
-        AssemblerImpl assembler = new AssemblerImpl();
+        AssemblerImpl assembler = new AssemblerImpl(dataSourceWrapper);
         assembler.addListener(this);
         ClassLoader cl = null;
         try {

Added: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/DataSourceInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/DataSourceInfo.java?rev=1079603&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/DataSourceInfo.java
(added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/DataSourceInfo.java
Tue Mar  8 23:45:10 2011
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+
+package org.apache.geronimo.connector.model;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class DataSourceInfo extends ManagedConnectionFactoryInfo {
+
+    public String dataSourceClass;
+
+}

Added: geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/pom.xml?rev=1079603&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/pom.xml (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/pom.xml Tue Mar  8 23:45:10
2011
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>geronimo-txmanager-parent</artifactId>
+        <groupId>org.apache.geronimo.components</groupId>
+        <version>3.99.99-SNAPSHOT</version>
+    </parent>
+    <groupId>org.apache.geronimo.components</groupId>
+    <artifactId>geronimo-tranql-wrapper</artifactId>
+    <packaging>bundle</packaging>
+    <name>geronimo-tranql-wrapper</name>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.components</groupId>
+            <artifactId>geronimo-connector</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.tranql</groupId>
+            <artifactId>tranql-connector</artifactId>
+            <version>1.8-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Private-Package>org.apache.geronimo.connector.*</Private-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Propchange: geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/java/org/apache/geronimo/connector/datasource/tranql/TranqlDataSourceWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/java/org/apache/geronimo/connector/datasource/tranql/TranqlDataSourceWrapper.java?rev=1079603&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/java/org/apache/geronimo/connector/datasource/tranql/TranqlDataSourceWrapper.java
(added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-tranql-wrapper/src/main/java/org/apache/geronimo/connector/datasource/tranql/TranqlDataSourceWrapper.java
Tue Mar  8 23:45:10 2011
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+
+package org.apache.geronimo.connector.datasource.tranql;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.sql.ConnectionPoolDataSource;
+import javax.sql.DataSource;
+import javax.sql.XADataSource;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.geronimo.connector.datasource.DataSourceWrapper;
+import org.tranql.connector.jdbc.ConnectionPoolDataSourceWrapper;
+import org.tranql.connector.jdbc.LocalDataSourceWrapper;
+import org.tranql.connector.jdbc.XADataSourceWrapper;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+
+@Component
+@Service
+public class TranqlDataSourceWrapper implements DataSourceWrapper {
+    @Override
+    public ManagedConnectionFactory wrapDataSource(String wrapperClass, Object dataSource)
throws ResourceException {
+        if (XADataSourceWrapper.class.getName().equals(wrapperClass)) {
+            return new XADataSourceWrapper((XADataSource) dataSource);
+        }
+        if (ConnectionPoolDataSourceWrapper.class.getName().equals(wrapperClass)) {
+            return new ConnectionPoolDataSourceWrapper((ConnectionPoolDataSource)dataSource);
+        }
+        if (LocalDataSourceWrapper.class.getName().equals(wrapperClass)) {
+            return new LocalDataSourceWrapper((DataSource)dataSource);
+        }
+        throw new ResourceException("Unknown data source wrapper class: " + wrapperClass);
+    }
+}

Modified: geronimo/sandbox/djencks/txmanager/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/pom.xml?rev=1079603&r1=1079602&r2=1079603&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/pom.xml (original)
+++ geronimo/sandbox/djencks/txmanager/pom.xml Tue Mar  8 23:45:10 2011
@@ -14,8 +14,7 @@
     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.
---><!-- $Rev$ $Date$ -->
-<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/maven-v4_0_0.xsd">
+--><!-- $Rev$ $Date$ --><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/maven-v4_0_0.xsd">
 
     <modelVersion>4.0.0</modelVersion>
 
@@ -271,7 +270,6 @@
                         <instructions>
                             <_versionpolicy-impl>[$(version;==;$(@)),$(version;=+;$(@)))</_versionpolicy-impl>
                             <_versionpolicy-uses>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy-uses>
-                            <!--<_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>-->
                         </instructions>
                     </configuration>
                 </plugin>
@@ -305,6 +303,7 @@
     <modules>
         <module>geronimo-transaction</module>
         <module>geronimo-connector</module>
+        <module>geronimo-tranql-wrapper</module>
         <module>geronimo-connector-builder-1_6</module>
         <module>org.apache.geronimo.transaction</module>
         <module>org.apache.geronimo.transaction.kar</module>



Mime
View raw message