geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r931658 - in /geronimo/server/trunk/plugins/connector-1_6: geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/ geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/
Date Wed, 07 Apr 2010 19:52:28 GMT
Author: gawor
Date: Wed Apr  7 19:52:27 2010
New Revision: 931658

URL: http://svn.apache.org/viewvc?rev=931658&view=rev
Log:
GERONIMO-5113: Support (or at least try to support) transaction isolation level & url
properties

Modified:
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceDescription.java
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBean.java
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceDescription.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceDescription.java?rev=931658&r1=931657&r2=931658&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceDescription.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceDescription.java
Wed Apr  7 19:52:27 2010
@@ -40,6 +40,7 @@ public class DataSourceDescription imple
     
     // transaction settings
     private boolean transactional = true;
+    private int isolationLevel = -1;
   
     // pool settings
     private int initialPoolSize = -1;
@@ -136,6 +137,14 @@ public class DataSourceDescription imple
         this.transactional = transactional;
     }
 
+    public int getIsolationLevel() {
+        return isolationLevel;
+    }
+
+    public void setIsolationLevel(int isolationLevel) {
+        this.isolationLevel = isolationLevel;
+    }
+
     public Map<String, String> getProperties() {
         return properties;
     }
@@ -184,6 +193,14 @@ public class DataSourceDescription imple
         this.maxStatements = maxStatements;
     }
     
+    public boolean hasStandardProperties() {
+        return (databaseName != null
+                || password != null
+                || user != null
+                || portNumber != -1
+                || !(serverName != null && serverName.equals("localhost")));
+    }
+    
     public boolean hasPoolingProperties() {
         return (maxPoolSize != -1
                 || minPoolSize != -1
@@ -191,5 +208,5 @@ public class DataSourceDescription imple
                 || initialPoolSize != -1
                 || maxStatements != -1);
     }
-  
+          
 }

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBean.java?rev=931658&r1=931657&r2=931658&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBean.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/datasource/DataSourceGBean.java
Wed Apr  7 19:52:27 2010
@@ -17,13 +17,16 @@
 
 package org.apache.geronimo.datasource;
 
+import java.sql.SQLException;
 import java.util.HashMap;
 import java.util.Map;
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ManagedConnectionFactory;
+import javax.security.auth.Subject;
 import javax.sql.ConnectionPoolDataSource;
 import javax.sql.DataSource;
+import javax.sql.XAConnection;
 import javax.sql.XADataSource;
 
 import org.apache.geronimo.connector.outbound.GenericConnectionManager;
@@ -50,6 +53,7 @@ import org.apache.xbean.recipe.Option;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.tranql.connector.CredentialExtractor;
 import org.tranql.connector.NoExceptionsAreFatalSorter;
 import org.tranql.connector.jdbc.AbstractLocalDataSourceMCF;
 import org.tranql.connector.jdbc.AbstractPooledConnectionDataSourceMCF;
@@ -87,6 +91,7 @@ public class DataSourceGBean implements 
         
         String dsName = dataSourceDescription.getName();
         String dsClass = dataSourceDescription.getClassName();
+        String dsJndiName = getOsgiJndiName();
         
         TransactionSupport transactionSupport;
         PoolingSupport pooling;
@@ -137,7 +142,7 @@ public class DataSourceGBean implements 
         connectionRegistration = new ConnectionFactoryRegistration(connectionManager, 
                                                                    bundleContext, 
                                                                    abstractName, 
-                                                                   getOsgiJndiName(), 
+                                                                   dsJndiName, 
                                                                    new String [] { DataSource.class.getName()
});
     }
     
@@ -147,19 +152,27 @@ public class DataSourceGBean implements 
             
         Map<String, Object> properties = new HashMap<String, Object>();
             
-        // TODO: handle "url" property somehow
-        // TODO: handle "isolationType" property somehow
-        
         // standard settings
         setProperty(properties, "description", dataSourceDescription.getDescription());
         setProperty(properties, "user", dataSourceDescription.getUser());
         setProperty(properties, "password", dataSourceDescription.getPassword());
         setProperty(properties, "databaseName", dataSourceDescription.getDatabaseName());
+        setProperty(properties, "serverName", dataSourceDescription.getServerName());
         if (dataSourceDescription.getPortNumber() != -1) {
             setProperty(properties, "portNumber", dataSourceDescription.getPortNumber());
-        }
-        setProperty(properties, "serverName", dataSourceDescription.getServerName());
+        }        
         setProperty(properties, "loginTimeout", dataSourceDescription.getLoginTimeout());
+        
+        /*
+         * XXX: Not really sure how deal with url property.
+         *      We can't really parse it so pass it as a property to data source.
+         */
+        
+        // set url property if no specific properties are set
+        if (dataSourceDescription.hasStandardProperties()) {
+            setProperty(properties, "url", dataSourceDescription.getUrl());
+        }
+        
         // other properties
         if (dataSourceDescription.getProperties() != null) {
             properties.putAll(dataSourceDescription.getProperties());
@@ -253,6 +266,21 @@ public class DataSourceGBean implements 
         public String getUserName() {
             return dataSourceDescription.getUser();
         }
+        
+        @Override
+        protected XAConnection getPhysicalConnection(Subject subject, CredentialExtractor
credentialExtractor) 
+            throws ResourceException {
+            XAConnection connection = super.getPhysicalConnection(subject, credentialExtractor);
+            int isolationLevel = dataSourceDescription.getIsolationLevel();
+            if (isolationLevel != -1) {
+                try {
+                    connection.getConnection().setTransactionIsolation(isolationLevel);
+                } catch (SQLException e) {
+                    throw new ResourceException("Error setting transaction isolation level
for ", dataSourceDescription.getName());
+                }
+            }
+            return connection;
+        }
     }
     
     private class LocalDataSourceMCF extends AbstractLocalDataSourceMCF {

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java?rev=931658&r1=931657&r2=931658&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/datasource/deployment/DataSourceBuilder.java
Wed Apr  7 19:52:27 2010
@@ -17,6 +17,7 @@
 
 package org.apache.geronimo.datasource.deployment;
 
+import java.sql.Connection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -332,7 +333,20 @@ public class DataSourceBuilder extends A
         }
         
         if (ds.isSetIsolationLevel()) {
-            // dsDefinition.setIsolationLevel(ds.getIsolationLevel().intValue());
+            switch (ds.getIsolationLevel().intValue()) {
+            case IsolationLevelType.INT_TRANSACTION_READ_COMMITTED:
+                dsDescription.setIsolationLevel(Connection.TRANSACTION_READ_COMMITTED);
+                break;
+            case IsolationLevelType.INT_TRANSACTION_READ_UNCOMMITTED:
+                dsDescription.setIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED);
+                break;
+            case IsolationLevelType.INT_TRANSACTION_REPEATABLE_READ:
+                dsDescription.setIsolationLevel(Connection.TRANSACTION_REPEATABLE_READ);
+                break;
+            case IsolationLevelType.INT_TRANSACTION_SERIALIZABLE:
+                dsDescription.setIsolationLevel(Connection.TRANSACTION_SERIALIZABLE);
+                break;
+            }
         }
         
         // pool properties



Mime
View raw message