From geronimo-cvs-return-3625-apmail-incubator-geronimo-cvs-archive=incubator.apache.org@incubator.apache.org Thu May 06 03:58:27 2004 Return-Path: Delivered-To: apmail-incubator-geronimo-cvs-archive@www.apache.org Received: (qmail 14303 invoked from network); 6 May 2004 03:58:27 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 6 May 2004 03:58:27 -0000 Received: (qmail 24069 invoked by uid 500); 6 May 2004 03:58:05 -0000 Delivered-To: apmail-incubator-geronimo-cvs-archive@incubator.apache.org Received: (qmail 23914 invoked by uid 500); 6 May 2004 03:58:04 -0000 Mailing-List: contact geronimo-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: geronimo-dev@incubator.apache.org Delivered-To: mailing list geronimo-cvs@incubator.apache.org Received: (qmail 23891 invoked from network); 6 May 2004 03:58:03 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 6 May 2004 03:58:03 -0000 Received: (qmail 14139 invoked by uid 1712); 6 May 2004 03:58:23 -0000 Date: 6 May 2004 03:58:23 -0000 Message-ID: <20040506035823.14136.qmail@minotaur.apache.org> From: djencks@apache.org To: incubator-geronimo-cvs@apache.org Subject: cvs commit: incubator-geronimo/modules/connector/src/schema geronimo-connector_1_5.xsd X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N djencks 2004/05/05 20:58:23 Modified: modules/connector/src/java/org/apache/geronimo/connector/deployment AbstractRARConfigBuilder.java RAR_1_0ConfigBuilder.java RAR_1_5ConfigBuilder.java modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean ConnectionDefinitionInstance.java modules/connector/src/java/org/apache/geronimo/connector/outbound LocalXAResource.java MCFConnectionInterceptor.java MultiPoolConnectionInterceptor.java SinglePoolConnectionInterceptor.java TransactionCachingInterceptor.java modules/connector/src/schema geronimo-connector_1_5.xsd Added: modules/connector/src/java/org/apache/geronimo/connector/outbound AbstractConnectionManager.java ConnectionInterceptorSource.java GenericConnectionManager.java SinglePoolMatchAllConnectionInterceptor.java modules/connector/src/java/org/apache/geronimo/connector/outbound/connectionmanagerconfig LocalTransactions.java NoPool.java NoTransactions.java PartitionedPool.java PoolingSupport.java SinglePool.java TransactionLog.java TransactionSupport.java XATransactions.java modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog JDBCLog.java LogXAResource.java LogXAResourceInsertionInterceptor.java Removed: modules/connector/src/java/org/apache/geronimo/connector/outbound ConnectionManagerDeployment.java Log: revamp connection manager configuration to only allow valid choices and provide better indication of related choices. Implement theoretically valid last-resource one-phase commit optimization for local-tx jdbc using an explicit database-table-based xid log (idea based on discussions with Jeremy Boynes) Revision Changes Path 1.16 +99 -1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/AbstractRARConfigBuilder.java Index: AbstractRARConfigBuilder.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/AbstractRARConfigBuilder.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- AbstractRARConfigBuilder.java 23 Apr 2004 03:08:28 -0000 1.15 +++ AbstractRARConfigBuilder.java 6 May 2004 03:58:22 -0000 1.16 @@ -32,6 +32,8 @@ import java.util.jar.JarInputStream; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; +import java.util.Collections; + import javax.management.MalformedObjectNameException; import javax.management.ObjectName; @@ -45,12 +47,26 @@ import org.apache.geronimo.gbean.GBeanInfoFactory; import org.apache.geronimo.gbean.GConstructorInfo; import org.apache.geronimo.gbean.GReferenceInfo; +import org.apache.geronimo.gbean.InvalidConfigurationException; +import org.apache.geronimo.gbean.jmx.GBeanMBean; import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.repository.Repository; import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument; import org.apache.geronimo.xbeans.geronimo.GerConnectorType; import org.apache.geronimo.xbeans.geronimo.GerGbeanType; import org.apache.geronimo.xbeans.geronimo.GerDependencyType; +import org.apache.geronimo.xbeans.geronimo.GerConnectiondefinitionInstanceType; +import org.apache.geronimo.xbeans.geronimo.GerConnectionmanagerType; +import org.apache.geronimo.connector.outbound.GenericConnectionManager; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoTransactions; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionLog; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoPool; import org.apache.xmlbeans.SchemaType; import org.apache.xmlbeans.SchemaTypeLoader; import org.apache.xmlbeans.XmlBeans; @@ -232,6 +248,88 @@ } } return uri; + } + + protected ObjectName configureConnectionManager(GerConnectiondefinitionInstanceType connectionfactoryInstance, DeploymentContext context) throws DeploymentException { + if (connectionfactoryInstance.getConnectionmanagerRef() != null) { + //we don't configure anything, just use the supplied gbean + try { + return ObjectName.getInstance(connectionfactoryInstance.getConnectionmanagerRef()); + } catch (MalformedObjectNameException e) { + throw new DeploymentException("Invalid ObjectName string supplied for ConnectionManager reference", e); + } + } + //we configure our connection manager + GerConnectionmanagerType connectionManager = connectionfactoryInstance.getConnectionmanager(); + GBeanInfo connectionManagerGBeanInfo; + try { + connectionManagerGBeanInfo = GBeanInfo.getGBeanInfo(GenericConnectionManager.class.getName(), GenericConnectionManager.class.getClassLoader()); + } catch (InvalidConfigurationException e) { + throw new DeploymentException("Unable to get GBeanInfo from ConnectionManagerDeployment", e); + } + + GBeanMBean connectionManagerGBean; + try { + connectionManagerGBean = new GBeanMBean(connectionManagerGBeanInfo, GenericConnectionManager.class.getClassLoader()); + } catch (InvalidConfigurationException e) { + throw new DeploymentException("Unable to create GMBean", e); + } + TransactionSupport transactionSupport = null; + if (connectionManager.getNoTransaction() != null) { + transactionSupport = NoTransactions.INSTANCE; + } else if (connectionManager.getLocalTransaction() != null) { + transactionSupport = LocalTransactions.INSTANCE; + } else if (connectionManager.getTransactionLog() != null) { + transactionSupport = TransactionLog.INSTANCE; + } else if (connectionManager.getXaTransaction() != null) { + transactionSupport = new XATransactions( + connectionManager.getXaTransaction().getTransactionCaching() != null, + connectionManager.getXaTransaction().getThreadCaching() != null + ); + } else { + throw new DeploymentException("Unexpected transaction support element"); + } + PoolingSupport pooling = null; + if (connectionManager.getSinglePool() != null) { + pooling = new SinglePool(connectionManager.getSinglePool().getMaxSize(), + connectionManager.getSinglePool().getBlockingTimeoutMilliseconds(), + connectionManager.getSinglePool().getMatchOne() != null, + connectionManager.getSinglePool().getMatchAll() != null, + connectionManager.getSinglePool().getSelectOneAssumeMatch() != null + ); + } else if (connectionManager.getPartitionedPool() != null) { + pooling = new PartitionedPool(connectionManager.getPartitionedPool().getPartitionByConnectionrequestinfo() != null, + connectionManager.getPartitionedPool().getPartitionBySubject() != null, + connectionManager.getPartitionedPool().getMaxSize(), + connectionManager.getPartitionedPool().getBlockingTimeoutMilliseconds(), + connectionManager.getPartitionedPool().getMatchOne() != null, + connectionManager.getPartitionedPool().getMatchAll() != null, + connectionManager.getPartitionedPool().getSelectOneAssumeMatch() != null + ); + } else if (connectionManager.getNoPool() != null) { + pooling = new NoPool(); + } else { + throw new DeploymentException("Unexpected pooling support element"); + } + try { + connectionManagerGBean.setAttribute("Name", connectionfactoryInstance.getName()); + connectionManagerGBean.setAttribute("TransactionSupport", transactionSupport); + connectionManagerGBean.setAttribute("Pooling", pooling); + connectionManagerGBean.setReferencePatterns("ConnectionTracker", Collections.singleton(connectionTrackerNamePattern)); + if (connectionManager.getRealmBridge() != null) { + connectionManagerGBean.setReferencePatterns("RealmBridge", Collections.singleton(ObjectName.getInstance(BASE_REALM_BRIDGE_NAME + connectionManager.getRealmBridge()))); + } + } catch (Exception e) { + throw new DeploymentException("Problem setting up ConnectionManager", e); + } + ObjectName connectionManagerFactoryObjectName = null; + try { + connectionManagerFactoryObjectName = ObjectName.getInstance(BASE_CONNECTION_MANAGER_FACTORY_NAME + connectionfactoryInstance.getName()); + } catch (MalformedObjectNameException e) { + throw new DeploymentException("Could not name ConnectionManager", e); + } + context.addGBean(connectionManagerFactoryObjectName, connectionManagerGBean); + return connectionManagerFactoryObjectName; } public static final GBeanInfo GBEAN_INFO; 1.7 +14 -50 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilder.java Index: RAR_1_0ConfigBuilder.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilder.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- RAR_1_0ConfigBuilder.java 12 Mar 2004 17:58:45 -0000 1.6 +++ RAR_1_0ConfigBuilder.java 6 May 2004 03:58:22 -0000 1.7 @@ -33,7 +33,6 @@ import javax.resource.spi.security.PasswordCredential; import org.apache.geronimo.common.propertyeditor.PropertyEditors; -import org.apache.geronimo.connector.outbound.ConnectionManagerDeployment; import org.apache.geronimo.connector.outbound.ManagedConnectionFactoryWrapper; import org.apache.geronimo.connector.outbound.security.PasswordCredentialRealm; import org.apache.geronimo.deployment.DeploymentContext; @@ -46,10 +45,10 @@ import org.apache.geronimo.gbean.jmx.GBeanMBean; import org.apache.geronimo.kernel.Kernel; import org.apache.geronimo.kernel.repository.Repository; +import org.apache.geronimo.naming.jmx.JMXReferenceFactory; import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType; import org.apache.geronimo.xbeans.geronimo.GerConnectionDefinitionType; import org.apache.geronimo.xbeans.geronimo.GerConnectiondefinitionInstanceType; -import org.apache.geronimo.xbeans.geronimo.GerConnectionmanagerType; import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument; import org.apache.geronimo.xbeans.geronimo.GerConnectorType; import org.apache.geronimo.xbeans.geronimo.GerResourceadapterType; @@ -57,7 +56,6 @@ import org.apache.geronimo.xbeans.j2ee.connector_1_0.ConfigPropertyType; import org.apache.geronimo.xbeans.j2ee.connector_1_0.ConnectorDocument; import org.apache.geronimo.xbeans.j2ee.connector_1_0.ResourceadapterType; -import org.apache.geronimo.naming.jmx.JMXReferenceFactory; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlOptions; @@ -99,69 +97,35 @@ for (int i = 0; i < geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray().length; i++) { GerConnectionDefinitionType geronimoConnectionDefinition = geronimoResourceAdapter.getOutboundResourceadapter().getConnectionDefinitionArray(i); assert geronimoConnectionDefinition != null: "Null GeronimoConnectionDefinition"; - //ConnectionManagerFactory + for (int j = 0; j < geronimoConnectionDefinition.getConnectiondefinitionInstanceArray().length; j++) { - GerConnectiondefinitionInstanceType gerConnectionfactoryInstance = geronimoConnectionDefinition.getConnectiondefinitionInstanceArray()[j]; + GerConnectiondefinitionInstanceType connectionfactoryInstance = geronimoConnectionDefinition.getConnectiondefinitionInstanceArray()[j]; - GerConnectionmanagerType connectionManagerFactory = gerConnectionfactoryInstance.getConnectionmanager(); - GBeanInfo connectionManagerFactoryGBeanInfo; - try { - connectionManagerFactoryGBeanInfo = GBeanInfo.getGBeanInfo(ConnectionManagerDeployment.class.getName(), ConnectionManagerDeployment.class.getClassLoader()); - } catch (InvalidConfigurationException e) { - throw new DeploymentException("Unable to get GBeanInfo from ConnectionManagerDeployment", e); - } + //ConnectionManager + ObjectName connectionManagerObjectName = configureConnectionManager(connectionfactoryInstance, context); - GBeanMBean connectionManagerFactoryGBean; - try { - connectionManagerFactoryGBean = new GBeanMBean(connectionManagerFactoryGBeanInfo, ConnectionManagerDeployment.class.getClassLoader()); - } catch (InvalidConfigurationException e) { - throw new DeploymentException("Unable to create GMBean", e); - } - try { - connectionManagerFactoryGBean.setAttribute("Name", gerConnectionfactoryInstance.getName()); - connectionManagerFactoryGBean.setAttribute("BlockingTimeout", new Integer(connectionManagerFactory.getBlockingTimeout().intValue())); - connectionManagerFactoryGBean.setAttribute("MaxSize", new Integer(connectionManagerFactory.getMaxSize().intValue())); - connectionManagerFactoryGBean.setAttribute("UseTransactions", Boolean.valueOf(connectionManagerFactory.getUseTransactions())); - connectionManagerFactoryGBean.setAttribute("UseLocalTransactions", Boolean.valueOf(connectionManagerFactory.getUseLocalTransactions())); - connectionManagerFactoryGBean.setAttribute("UseTransactionCaching", Boolean.valueOf(connectionManagerFactory.getUseTransactionCaching())); - connectionManagerFactoryGBean.setAttribute("UseConnectionRequestInfo", Boolean.valueOf(connectionManagerFactory.getUseConnectionRequestInfo())); - connectionManagerFactoryGBean.setAttribute("UseSubject", Boolean.valueOf(connectionManagerFactory.getUseSubject())); - connectionManagerFactoryGBean.setReferencePatterns("ConnectionTracker", Collections.singleton(connectionTrackerNamePattern)); - if (connectionManagerFactory.getRealmBridge() != null) { - connectionManagerFactoryGBean.setReferencePatterns("RealmBridge", Collections.singleton(ObjectName.getInstance(BASE_REALM_BRIDGE_NAME + connectionManagerFactory.getRealmBridge()))); - } - } catch (Exception e) { - throw new DeploymentException("Problem setting up ConnectionManagerFactory", e); - } - ObjectName connectionManagerFactoryObjectName = null; - try { - connectionManagerFactoryObjectName = ObjectName.getInstance(BASE_CONNECTION_MANAGER_FACTORY_NAME + gerConnectionfactoryInstance.getName()); - } catch (MalformedObjectNameException e) { - throw new DeploymentException("Could not name ConnectionManagerFactory", e); - } - context.addGBean(connectionManagerFactoryObjectName, connectionManagerFactoryGBean); //ManagedConnectionFactory ObjectName managedConnectionFactoryObjectName = null; try { - managedConnectionFactoryObjectName = ObjectName.getInstance(JMXReferenceFactory.BASE_MANAGED_CONNECTION_FACTORY_NAME + gerConnectionfactoryInstance.getName()); + managedConnectionFactoryObjectName = ObjectName.getInstance(JMXReferenceFactory.BASE_MANAGED_CONNECTION_FACTORY_NAME + connectionfactoryInstance.getName()); } catch (MalformedObjectNameException e) { throw new DeploymentException("Could not construct ManagedConnectionFactory object name", e); } GBeanInfoFactory managedConnectionFactoryInfoFactory = new GBeanInfoFactory(ManagedConnectionFactoryWrapper.class.getName(), ManagedConnectionFactoryWrapper.getGBeanInfo()); - GBeanMBean managedConnectionFactoryGBean = setUpDynamicGBean(managedConnectionFactoryInfoFactory, resourceAdapter.getConfigPropertyArray(), gerConnectionfactoryInstance.getConfigPropertySettingArray()); + GBeanMBean managedConnectionFactoryGBean = setUpDynamicGBean(managedConnectionFactoryInfoFactory, resourceAdapter.getConfigPropertyArray(), connectionfactoryInstance.getConfigPropertySettingArray()); try { managedConnectionFactoryGBean.setAttribute("ManagedConnectionFactoryClass", cl.loadClass(resourceAdapter.getManagedconnectionfactoryClass().getStringValue())); managedConnectionFactoryGBean.setAttribute("ConnectionFactoryInterface", cl.loadClass(resourceAdapter.getConnectionfactoryInterface().getStringValue())); managedConnectionFactoryGBean.setAttribute("ConnectionFactoryImplClass", cl.loadClass(resourceAdapter.getConnectionfactoryImplClass().getStringValue())); managedConnectionFactoryGBean.setAttribute("ConnectionInterface", cl.loadClass(resourceAdapter.getConnectionInterface().getStringValue())); managedConnectionFactoryGBean.setAttribute("ConnectionImplClass", cl.loadClass(resourceAdapter.getConnectionImplClass().getStringValue())); - managedConnectionFactoryGBean.setAttribute("GlobalJNDIName", gerConnectionfactoryInstance.getGlobalJndiName()); - managedConnectionFactoryGBean.setReferencePatterns("ConnectionManagerFactory", Collections.singleton(connectionManagerFactoryObjectName)); - if (gerConnectionfactoryInstance.getCredentialInterface() != null && PasswordCredential.class.getName().equals(gerConnectionfactoryInstance.getCredentialInterface().getStringValue())) { + managedConnectionFactoryGBean.setAttribute("GlobalJNDIName", connectionfactoryInstance.getGlobalJndiName()); + managedConnectionFactoryGBean.setReferencePatterns("ConnectionManagerFactory", Collections.singleton(connectionManagerObjectName)); + if (connectionfactoryInstance.getCredentialInterface() != null && PasswordCredential.class.getName().equals(connectionfactoryInstance.getCredentialInterface().getStringValue())) { GBeanMBean realmGBean = new GBeanMBean(PasswordCredentialRealm.class.getName()); - realmGBean.setAttribute("RealmName", BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME + gerConnectionfactoryInstance.getName()); - context.addGBean(ObjectName.getInstance(BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME + gerConnectionfactoryInstance.getName()), realmGBean); - managedConnectionFactoryGBean.setReferencePatterns("ManagedConnectionFactoryListener", Collections.singleton(ObjectName.getInstance(BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME + gerConnectionfactoryInstance.getName()))); + realmGBean.setAttribute("RealmName", BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME + connectionfactoryInstance.getName()); + context.addGBean(ObjectName.getInstance(BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME + connectionfactoryInstance.getName()), realmGBean); + managedConnectionFactoryGBean.setReferencePatterns("ManagedConnectionFactoryListener", Collections.singleton(ObjectName.getInstance(BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME + connectionfactoryInstance.getName()))); } managedConnectionFactoryGBean.setReferencePatterns("Kernel", Collections.singleton(Kernel.KERNEL)); managedConnectionFactoryGBean.setAttribute("SelfName", managedConnectionFactoryObjectName); 1.11 +14 -40 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilder.java Index: RAR_1_5ConfigBuilder.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/RAR_1_5ConfigBuilder.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- RAR_1_5ConfigBuilder.java 12 Apr 2004 21:54:19 -0000 1.10 +++ RAR_1_5ConfigBuilder.java 6 May 2004 03:58:22 -0000 1.11 @@ -37,8 +37,17 @@ import org.apache.geronimo.common.propertyeditor.PropertyEditors; import org.apache.geronimo.connector.AdminObjectWrapper; import org.apache.geronimo.connector.ResourceAdapterWrapper; -import org.apache.geronimo.connector.outbound.ConnectionManagerDeployment; +import org.apache.geronimo.connector.outbound.GenericConnectionManager; import org.apache.geronimo.connector.outbound.ManagedConnectionFactoryWrapper; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoTransactions; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionLog; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoPool; import org.apache.geronimo.connector.outbound.security.PasswordCredentialRealm; import org.apache.geronimo.deployment.DeploymentContext; import org.apache.geronimo.deployment.DeploymentException; @@ -151,44 +160,9 @@ for (int j = 0; j < geronimoConnectionDefinition.getConnectiondefinitionInstanceArray().length; j++) { GerConnectiondefinitionInstanceType connectionfactoryInstance = geronimoConnectionDefinition.getConnectiondefinitionInstanceArray()[j]; - //ConnectionManagerFactory - GerConnectionmanagerType connectionManagerFactory = connectionfactoryInstance.getConnectionmanager(); - GBeanInfo connectionManagerFactoryGBeanInfo; - try { - connectionManagerFactoryGBeanInfo = GBeanInfo.getGBeanInfo(ConnectionManagerDeployment.class.getName(), ConnectionManagerDeployment.class.getClassLoader()); - } catch (InvalidConfigurationException e) { - throw new DeploymentException("Unable to get GBeanInfo from ConnectionManagerDeployment", e); - } + //ConnectionManager + ObjectName connectionManagerObjectName = configureConnectionManager(connectionfactoryInstance, context); - GBeanMBean connectionManagerFactoryGBean; - try { - connectionManagerFactoryGBean = new GBeanMBean(connectionManagerFactoryGBeanInfo, ConnectionManagerDeployment.class.getClassLoader()); - } catch (InvalidConfigurationException e) { - throw new DeploymentException("Unable to create GMBean", e); - } - try { - connectionManagerFactoryGBean.setAttribute("Name", connectionfactoryInstance.getName()); - connectionManagerFactoryGBean.setAttribute("BlockingTimeout", new Integer(connectionManagerFactory.getBlockingTimeout().intValue())); - connectionManagerFactoryGBean.setAttribute("MaxSize", new Integer(connectionManagerFactory.getMaxSize().intValue())); - connectionManagerFactoryGBean.setAttribute("UseTransactions", Boolean.valueOf(connectionManagerFactory.getUseTransactions())); - connectionManagerFactoryGBean.setAttribute("UseLocalTransactions", Boolean.valueOf(connectionManagerFactory.getUseLocalTransactions())); - connectionManagerFactoryGBean.setAttribute("UseTransactionCaching", Boolean.valueOf(connectionManagerFactory.getUseTransactionCaching())); - connectionManagerFactoryGBean.setAttribute("UseConnectionRequestInfo", Boolean.valueOf(connectionManagerFactory.getUseConnectionRequestInfo())); - connectionManagerFactoryGBean.setAttribute("UseSubject", Boolean.valueOf(connectionManagerFactory.getUseSubject())); - connectionManagerFactoryGBean.setReferencePatterns("ConnectionTracker", Collections.singleton(connectionTrackerNamePattern)); - if (connectionManagerFactory.getRealmBridge() != null) { - connectionManagerFactoryGBean.setReferencePatterns("RealmBridge", Collections.singleton(ObjectName.getInstance(BASE_REALM_BRIDGE_NAME + connectionManagerFactory.getRealmBridge()))); - } - } catch (Exception e) { - throw new DeploymentException("Problem setting up ConnectionManagerFactory", e); - } - ObjectName connectionManagerFactoryObjectName = null; - try { - connectionManagerFactoryObjectName = ObjectName.getInstance(BASE_CONNECTION_MANAGER_FACTORY_NAME + connectionfactoryInstance.getName()); - } catch (MalformedObjectNameException e) { - throw new DeploymentException("Could not name ConnectionManagerFactory", e); - } - context.addGBean(connectionManagerFactoryObjectName, connectionManagerFactoryGBean); //ManagedConnectionFactory ObjectName managedConnectionFactoryObjectName = null; @@ -209,7 +183,7 @@ if (resourceAdapterClassName != null) { managedConnectionFactoryGBean.setReferencePatterns("ResourceAdapterWrapper", Collections.singleton(resourceAdapterObjectName)); } - managedConnectionFactoryGBean.setReferencePatterns("ConnectionManagerFactory", Collections.singleton(connectionManagerFactoryObjectName)); + managedConnectionFactoryGBean.setReferencePatterns("ConnectionManagerFactory", Collections.singleton(connectionManagerObjectName)); if (connectionfactoryInstance.getCredentialInterface() != null && PasswordCredential.class.getName().equals(connectionfactoryInstance.getCredentialInterface().getStringValue())) { GBeanMBean realmGBean = new GBeanMBean(PasswordCredentialRealm.getGBeanInfo()); realmGBean.setAttribute("RealmName", BASE_PASSWORD_CREDENTIAL_LOGIN_MODULE_NAME + connectionfactoryInstance.getName()); 1.9 +72 -72 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ConnectionDefinitionInstance.java Index: ConnectionDefinitionInstance.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/dconfigbean/ConnectionDefinitionInstance.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ConnectionDefinitionInstance.java 10 Mar 2004 09:58:31 -0000 1.8 +++ ConnectionDefinitionInstance.java 6 May 2004 03:58:22 -0000 1.9 @@ -129,77 +129,77 @@ pcs.firePropertyChange("globalJNDIName", old, globalJNDIName); } - public boolean isUseConnectionRequestInfo() { - return getConnectionManager().getUseConnectionRequestInfo(); - } - - public void setUseConnectionRequestInfo(boolean useConnectionRequestInfo) { - boolean old = isUseConnectionRequestInfo(); - getConnectionManager().setUseConnectionRequestInfo(useConnectionRequestInfo); - pcs.firePropertyChange("useConnectionRequestInfo", old, useConnectionRequestInfo); - } - - public boolean isUseSubject() { - return getConnectionManager().getUseSubject(); - } - - public void setUseSubject(boolean useSubject) { - boolean old = isUseSubject(); - getConnectionManager().setUseSubject(useSubject); - pcs.firePropertyChange("useSubject", old, useSubject); - } - - public boolean isUseTransactionCaching() { - return getConnectionManager().getUseTransactionCaching(); - } - - public void setUseTransactionCaching(boolean useTransactionCaching) { - boolean old = isUseTransactionCaching(); - getConnectionManager().setUseTransactionCaching(useTransactionCaching); - pcs.firePropertyChange("useTransactionCaching", old, useTransactionCaching); - } - - public boolean isUseLocalTransactions() { - return getConnectionManager().getUseLocalTransactions(); - } - - public void setUseLocalTransactions(boolean useLocalTransactions) { - boolean old = isUseLocalTransactions(); - getConnectionManager().setUseLocalTransactions(useLocalTransactions); - pcs.firePropertyChange("useLocalTransactions", old, useLocalTransactions); - } - - public boolean isUseTransactions() { - return getConnectionManager().getUseTransactions(); - } - - public void setUseTransactions(boolean useTransactions) { - boolean old = isUseTransactions(); - getConnectionManager().setUseTransactions(useTransactions); - pcs.firePropertyChange("useTransactions", old, useTransactions); - } - - public int getMaxSize() { - BigInteger test = getConnectionManager().getMaxSize(); - return test == null ? 0 : test.intValue(); - } - - public void setMaxSize(int maxSize) { - int old = getMaxSize(); - getConnectionManager().setMaxSize(BigInteger.valueOf(maxSize)); - pcs.firePropertyChange("maxSize", old, maxSize); - } - - public int getBlockingTimeout() { - BigInteger test = getConnectionManager().getBlockingTimeout(); - return test == null ? 0 : test.intValue(); - } - - public void setBlockingTimeout(int blockingTimeout) { - int old = getBlockingTimeout(); - getConnectionManager().setBlockingTimeout(BigInteger.valueOf(blockingTimeout)); - pcs.firePropertyChange("blockingTimeout", old, blockingTimeout); - } +// public boolean isUseConnectionRequestInfo() { +// return getConnectionManager().getUseConnectionRequestInfo(); +// } +// +// public void setUseConnectionRequestInfo(boolean useConnectionRequestInfo) { +// boolean old = isUseConnectionRequestInfo(); +// getConnectionManager().setUseConnectionRequestInfo(useConnectionRequestInfo); +// pcs.firePropertyChange("useConnectionRequestInfo", old, useConnectionRequestInfo); +// } +// +// public boolean isUseSubject() { +// return getConnectionManager().getUseSubject(); +// } +// +// public void setUseSubject(boolean useSubject) { +// boolean old = isUseSubject(); +// getConnectionManager().setUseSubject(useSubject); +// pcs.firePropertyChange("useSubject", old, useSubject); +// } +// +// public boolean isUseTransactionCaching() { +// return getConnectionManager().getUseTransactionCaching(); +// } +// +// public void setUseTransactionCaching(boolean useTransactionCaching) { +// boolean old = isUseTransactionCaching(); +// getConnectionManager().setUseTransactionCaching(useTransactionCaching); +// pcs.firePropertyChange("useTransactionCaching", old, useTransactionCaching); +// } +// +// public boolean isUseLocalTransactions() { +// return getConnectionManager().getUseLocalTransactions(); +// } +// +// public void setUseLocalTransactions(boolean useLocalTransactions) { +// boolean old = isUseLocalTransactions(); +// getConnectionManager().setUseLocalTransactions(useLocalTransactions); +// pcs.firePropertyChange("useLocalTransactions", old, useLocalTransactions); +// } +// +// public boolean isUseTransactions() { +// return getConnectionManager().getUseTransactions(); +// } +// +// public void setUseTransactions(boolean useTransactions) { +// boolean old = isUseTransactions(); +// getConnectionManager().setUseTransactions(useTransactions); +// pcs.firePropertyChange("useTransactions", old, useTransactions); +// } +// +// public int getMaxSize() { +// BigInteger test = getConnectionManager().getMaxSize(); +// return test == null ? 0 : test.intValue(); +// } +// +// public void setMaxSize(int maxSize) { +// int old = getMaxSize(); +// getConnectionManager().setMaxSize(BigInteger.valueOf(maxSize)); +// pcs.firePropertyChange("maxSize", old, maxSize); +// } +// +// public int getBlockingTimeout() { +// BigInteger test = getConnectionManager().getBlockingTimeout(); +// return test == null ? 0 : test.intValue(); +// } +// +// public void setBlockingTimeout(int blockingTimeout) { +// int old = getBlockingTimeout(); +// getConnectionManager().setBlockingTimeout(BigInteger.valueOf(blockingTimeout)); +// pcs.firePropertyChange("blockingTimeout", old, blockingTimeout); +// } public String getRealmBridgeName() { return getConnectionManager().getRealmBridge(); 1.4 +4 -8 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/LocalXAResource.java Index: LocalXAResource.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/LocalXAResource.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- LocalXAResource.java 10 Mar 2004 09:58:32 -0000 1.3 +++ LocalXAResource.java 6 May 2004 03:58:22 -0000 1.4 @@ -51,10 +51,8 @@ try { localTransaction.commit(); } catch (ResourceException e) { - XAException xae = new XAException(); - //xae.setLinkedException(e); - throw xae; - } finally { + throw (XAException)new XAException().initCause(e); + } finally { this.xid = null; } @@ -83,9 +81,7 @@ try { localTransaction.rollback(); } catch (ResourceException e) { - XAException xae = new XAException(); - //xae.setLinkedException(e); - throw xae; + throw (XAException)new XAException().initCause(e); } finally { this.xid = null; } 1.5 +8 -5 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/MCFConnectionInterceptor.java Index: MCFConnectionInterceptor.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/MCFConnectionInterceptor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- MCFConnectionInterceptor.java 7 Apr 2004 22:37:10 -0000 1.4 +++ MCFConnectionInterceptor.java 6 May 2004 03:58:22 -0000 1.5 @@ -28,10 +28,9 @@ */ public class MCFConnectionInterceptor implements ConnectionInterceptor { - private final ConnectionManagerDeployment head; + private ConnectionInterceptor stack; - public MCFConnectionInterceptor(ConnectionManagerDeployment head) { - this.head = head; + public MCFConnectionInterceptor() { } public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { @@ -41,7 +40,7 @@ mci.getSubject(), mci.getConnectionRequestInfo()); mci.setManagedConnection(mc); - GeronimoConnectionEventListener listener = new GeronimoConnectionEventListener(head.getStack(), mci); + GeronimoConnectionEventListener listener = new GeronimoConnectionEventListener(stack, mci); mci.setConnectionEventListener(listener); mc.addConnectionEventListener(listener); } @@ -60,6 +59,10 @@ } catch (Throwable t) { //log and forget } + } + + public void setStack(ConnectionInterceptor stack) { + this.stack = stack; } } 1.4 +17 -22 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/MultiPoolConnectionInterceptor.java Index: MultiPoolConnectionInterceptor.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/MultiPoolConnectionInterceptor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MultiPoolConnectionInterceptor.java 10 Mar 2004 09:58:32 -0000 1.3 +++ MultiPoolConnectionInterceptor.java 6 May 2004 03:58:22 -0000 1.4 @@ -25,21 +25,21 @@ import javax.resource.spi.ConnectionRequestInfo; import javax.security.auth.Subject; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport; + /** - * MultiPoolConnectionInterceptor.java - * + * MultiPoolConnectionInterceptor maps the provided subject and connection request info to a + * "SinglePool". This can be used to make sure all matches will succeed, avoiding synchronization + * slowdowns. * * Created: Fri Oct 10 12:53:11 2003 * - * @version 1.0 + * @version $Revision$ $Date$ */ public class MultiPoolConnectionInterceptor implements ConnectionInterceptor { private final ConnectionInterceptor next; - - private int maxSize; - - private int blockingTimeout; + private final PoolingSupport singlePoolFactory; private final boolean useSubject; @@ -49,13 +49,11 @@ public MultiPoolConnectionInterceptor( final ConnectionInterceptor next, - int maxSize, - int blockingTimeout, + PoolingSupport singlePoolFactory, final boolean useSubject, final boolean useCRI) { this.next = next; - this.maxSize = maxSize; - this.blockingTimeout = blockingTimeout; + this.singlePoolFactory = singlePoolFactory; this.useSubject = useSubject; this.useCRI = useCRI; } @@ -66,20 +64,13 @@ new SubjectCRIKey( useSubject ? mci.getSubject() : null, useCRI ? mci.getConnectionRequestInfo() : null); - SinglePoolConnectionInterceptor poolInterceptor = null; + ConnectionInterceptor poolInterceptor = null; synchronized (pools) { - poolInterceptor = (SinglePoolConnectionInterceptor) pools.get(key); + poolInterceptor = (ConnectionInterceptor) pools.get(key); if (poolInterceptor == null) { - poolInterceptor = - new SinglePoolConnectionInterceptor( - next, - mci.getSubject(), - mci.getConnectionRequestInfo(), - maxSize, - blockingTimeout); + poolInterceptor = singlePoolFactory.addPoolingInterceptors(next); pools.put(key, poolInterceptor); - } // end of if () - + } } mci.setPoolInterceptor(poolInterceptor); poolInterceptor.getConnection(connectionInfo); @@ -106,6 +97,10 @@ this.hashcode = (subject == null ? 17 : subject.hashCode() * 17) ^ (cri == null ? 1 : cri.hashCode()); + } + + public int hashCode() { + return hashcode; } public boolean equals(Object other) { 1.5 +23 -22 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java Index: SinglePoolConnectionInterceptor.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- SinglePoolConnectionInterceptor.java 7 Apr 2004 22:37:10 -0000 1.4 +++ SinglePoolConnectionInterceptor.java 6 May 2004 03:58:22 -0000 1.5 @@ -18,24 +18,25 @@ package org.apache.geronimo.connector.outbound; import java.util.Collections; + import javax.resource.ResourceException; -import javax.resource.spi.ConnectionRequestInfo; import javax.resource.spi.ManagedConnection; -import javax.security.auth.Subject; +import EDU.oswego.cs.dl.util.concurrent.FIFOSemaphore; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import EDU.oswego.cs.dl.util.concurrent.FIFOSemaphore; - /** - * SinglePoolConnectionInterceptor.java - * + * SinglePoolConnectionInterceptor chooses a single connection from the pool. If selectOneAssumeMatch + * is true, it simply returns the selected connection. + * THIS SHOULD BE USED ONLY IF MAXIMUM SPEED IS ESSENTIAL AND YOU HAVE THOROUGLY CHECKED THAT + * MATCHING WOULD SUCCEED ON THE SELECTED CONNECTION. (i.e., read the docs on your connector + * to find out how matching works) + * If selectOneAssumeMatch is false, it checks with the ManagedConnectionFactory that the + * selected connection does match before returning it: if not it throws an exception. * - * Created: Thu Oct 9 12:49:18 2003 + * @version $Revision$ $Date$ * - * @author David Jencks - * @version 1.0 */ public class SinglePoolConnectionInterceptor implements ConnectionInterceptor { @@ -48,27 +49,19 @@ private PoolDeque pool; - private final Subject defaultSubject; - - private final ConnectionRequestInfo defaultCRI; - - private int maxSize; - private int blockingTimeout; + private boolean selectOneAssumeMatch; public SinglePoolConnectionInterceptor( final ConnectionInterceptor next, - final Subject defaultSubject, - final ConnectionRequestInfo defaultCRI, int maxSize, - int blockingTimeout) { + int blockingTimeout, + boolean selectOneAssumeMatch) { this.next = next; - this.defaultSubject = defaultSubject; - this.defaultCRI = defaultCRI; - this.maxSize = maxSize; this.blockingTimeout = blockingTimeout; permits = new FIFOSemaphore(maxSize); pool = new PoolDeque(maxSize); + this.selectOneAssumeMatch = selectOneAssumeMatch; } public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { @@ -85,9 +78,17 @@ return; } else { newMCI = pool.removeLast(); - } // end of else + } + if (selectOneAssumeMatch) { + connectionInfo.setManagedConnectionInfo(newMCI); + if (log.isTraceEnabled()) { + log.trace("Returning pooled connection without checking matching " + connectionInfo.getManagedConnectionInfo()); + } + return; + } try { ManagedConnection matchedMC = +// newMCI.getManagedConnection(); newMCI .getManagedConnectionFactory() .matchManagedConnections( 1.6 +1 -3 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java Index: TransactionCachingInterceptor.java =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- TransactionCachingInterceptor.java 6 Apr 2004 00:21:21 -0000 1.5 +++ TransactionCachingInterceptor.java 6 May 2004 03:58:22 -0000 1.6 @@ -46,11 +46,9 @@ public class TransactionCachingInterceptor implements ConnectionInterceptor, ConnectionReleaser { private final ConnectionInterceptor next; - private final ConnectionTracker connectionTracker; - public TransactionCachingInterceptor(final ConnectionInterceptor next, final ConnectionTracker connectionTracker) { + public TransactionCachingInterceptor(final ConnectionInterceptor next) { this.next = next; - this.connectionTracker = connectionTracker; } public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java Index: AbstractConnectionManager.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed 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.outbound; import javax.resource.ResourceException; import javax.resource.spi.ConnectionManager; import javax.resource.spi.ConnectionRequestInfo; import javax.resource.spi.LazyAssociatableConnectionManager; import javax.resource.spi.ManagedConnectionFactory; import org.apache.geronimo.gbean.GBean; import org.apache.geronimo.gbean.GBeanContext; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoFactory; import org.apache.geronimo.gbean.WaitingException; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ * * */ public abstract class AbstractConnectionManager implements ConnectionManagerFactory, GBean, ConnectionManager, LazyAssociatableConnectionManager { protected ConnectionInterceptor stack; public AbstractConnectionManager() { } public void setGBeanContext(GBeanContext context) { } public void doStart() throws WaitingException, Exception{ setUpConnectionManager(); } protected abstract void setUpConnectionManager() throws IllegalStateException; public void doStop() { stack = null; } public void doFail() { } public Object createConnectionFactory(ManagedConnectionFactory mcf) throws ResourceException { return mcf.createConnectionFactory(this); } /** * in: mcf != null, is a deployed mcf * out: useable connection object. * @param managedConnectionFactory * @param connectionRequestInfo * @return * @throws javax.resource.ResourceException */ public Object allocateConnection( ManagedConnectionFactory managedConnectionFactory, ConnectionRequestInfo connectionRequestInfo) throws ResourceException { ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, connectionRequestInfo); ConnectionInfo ci = new ConnectionInfo(mci); stack.getConnection(ci); return ci.getConnectionHandle(); } /** * in: non-null connection object, from non-null mcf. * connection object is not associated with a managed connection * out: supplied connection object is assiciated with a non-null ManagedConnection from mcf. * @param connection * @param managedConnectionFactory * @param connectionRequestInfo * @throws javax.resource.ResourceException */ public void associateConnection( Object connection, ManagedConnectionFactory managedConnectionFactory, ConnectionRequestInfo connectionRequestInfo) throws ResourceException { ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, connectionRequestInfo); ConnectionInfo ci = new ConnectionInfo(mci); ci.setConnectionHandle(connection); stack.getConnection(ci); } ConnectionInterceptor getConnectionInterceptor() { return stack; } protected static final GBeanInfo GBEAN_INFO; static { GBeanInfoFactory infoFactory = new GBeanInfoFactory(AbstractConnectionManager.class.getName()); infoFactory.addOperation("createConnectionFactory", new Class[]{ManagedConnectionFactory.class}); GBEAN_INFO = infoFactory.getBeanInfo(); } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/ConnectionInterceptorSource.java Index: ConnectionInterceptorSource.java =================================================================== package org.apache.geronimo.connector.outbound; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ * * */ public interface ConnectionInterceptorSource { ConnectionInterceptor getConnectionInterceptor(); } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java Index: GenericConnectionManager.java =================================================================== /** * * Copyright 2003-2004 The Apache Software Foundation * * Licensed 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.outbound; import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool; import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport; import org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions; import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport; import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool; import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoFactory; import org.apache.geronimo.security.bridge.RealmBridge; /** * GenericConnectionManager sets up a connection manager stack according to the * policies described in the attributes. * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ * */ public class GenericConnectionManager extends AbstractConnectionManager { //connection manager configuration choices private TransactionSupport transactionSupport; private PoolingSupport pooling; /** * Identifying string used by unshareable resource detection */ private String name; //dependencies protected RealmBridge realmBridge; protected ConnectionTracker connectionTracker; //default constructor for use as endpoint public GenericConnectionManager() { } public GenericConnectionManager(TransactionSupport transactionSupport, PoolingSupport pooling, String name, RealmBridge realmBridge, ConnectionTracker connectionTracker) { this.transactionSupport = transactionSupport; this.pooling = pooling; this.name = name; this.realmBridge = realmBridge; this.connectionTracker = connectionTracker; } /** * Order of constructed interceptors: * * ConnectionTrackingInterceptor (connectionTracker != null) * ConnectionHandleInterceptor * TransactionCachingInterceptor (useTransactions & useTransactionCaching) * TransactionEnlistingInterceptor (useTransactions) * SubjectInterceptor (realmBridge != null) * SinglePoolConnectionInterceptor or MultiPoolConnectionInterceptor * LocalXAResourceInsertionInterceptor or XAResourceInsertionInterceptor (useTransactions (&localTransactions)) * MCFConnectionInterceptor */ protected void setUpConnectionManager() throws IllegalStateException { //check for consistency between attributes if (realmBridge == null && pooling instanceof PartitionedPool && ((PartitionedPool)pooling).isPartitionBySubject()) { throw new IllegalStateException("To use Subject in pooling, you need a SecurityDomain"); } //Set up the interceptor stack MCFConnectionInterceptor tail = new MCFConnectionInterceptor(); ConnectionInterceptor stack = tail; stack = transactionSupport.addXAResourceInsertionInterceptor(stack); stack = pooling.addPoolingInterceptors(stack); //experimental threadlocal caching if (transactionSupport instanceof XATransactions && ((XATransactions)transactionSupport).isUseThreadCaching()) { stack = new ThreadLocalCachingConnectionInterceptor(stack, false); } if (realmBridge != null) { stack = new SubjectInterceptor(stack, realmBridge); } stack = transactionSupport.addTransactionInterceptors(stack); stack = new ConnectionHandleInterceptor(stack); if (connectionTracker != null) { stack = new ConnectionTrackingInterceptor( stack, getName(), connectionTracker, realmBridge); } tail.setStack(stack); this.stack = stack; } public TransactionSupport getTransactionSupport() { return transactionSupport; } public void setTransactionSupport(TransactionSupport transactionSupport) { this.transactionSupport = transactionSupport; } public PoolingSupport getPooling() { return pooling; } public void setPooling(PoolingSupport pooling) { this.pooling = pooling; } public String getName() { return name; } public void setName(String name) { this.name = name; } public RealmBridge getRealmBridge() { return realmBridge; } public void setRealmBridge(RealmBridge realmBridge) { this.realmBridge = realmBridge; } public ConnectionTracker getConnectionTracker() { return connectionTracker; } public void setConnectionTracker(ConnectionTracker connectionTracker) { this.connectionTracker = connectionTracker; } public static final GBeanInfo GBEAN_INFO; static { GBeanInfoFactory infoFactory = new GBeanInfoFactory(GenericConnectionManager.class.getName(), AbstractConnectionManager.GBEAN_INFO); infoFactory.addAttribute("Name", true); infoFactory.addAttribute("TransactionSupport", true); infoFactory.addAttribute("Pooling", true); infoFactory.addReference("ConnectionTracker", ConnectionTracker.class); infoFactory.addReference("RealmBridge", RealmBridge.class); infoFactory.setConstructor( new String[]{"TransactionSupport", "Pooling", "Name", "RealmBridge", "ConnectionTracker"}, new Class[]{TransactionSupport.class, PoolingSupport.class, String.class, RealmBridge.class, ConnectionTracker.class}); GBEAN_INFO = infoFactory.getBeanInfo(); } public static GBeanInfo getGBeanInfo() { return GenericConnectionManager.GBEAN_INFO; } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/SinglePoolMatchAllConnectionInterceptor.java Index: SinglePoolMatchAllConnectionInterceptor.java =================================================================== /** * * Copyright 2003-2004 The Apache Software Foundation * * Licensed 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.outbound; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import javax.resource.ResourceException; import javax.resource.spi.ManagedConnection; import javax.resource.spi.ManagedConnectionFactory; import EDU.oswego.cs.dl.util.concurrent.FIFOSemaphore; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * This pool is the most spec-compliant pool. It can be used by itself with no partitioning. * It is apt to be the slowest pool. * For each connection request, it synchronizes access to the pool and asks the * ManagedConnectionFactory for a match from among all managed connections. If none is found, * it may discard a random existing connection, and creates a new connection. * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ */ public class SinglePoolMatchAllConnectionInterceptor implements ConnectionInterceptor { private static Log log = LogFactory.getLog(SinglePoolMatchAllConnectionInterceptor.class.getName()); private final ConnectionInterceptor next; private FIFOSemaphore permits; private HashMap pool; private int maxSize; private int blockingTimeout; private int actualConnections = 0; public SinglePoolMatchAllConnectionInterceptor( final ConnectionInterceptor next, int maxSize, int blockingTimeout) { this.next = next; this.maxSize = maxSize; this.blockingTimeout = blockingTimeout; permits = new FIFOSemaphore(maxSize); pool = new HashMap(maxSize); } public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); ManagedConnectionFactory managedConnectionFactory = mci.getManagedConnectionFactory(); try { if (permits.attempt(blockingTimeout)) { synchronized (pool) { try { if (!pool.isEmpty()) { ManagedConnection matchedMC = managedConnectionFactory .matchManagedConnections( pool.keySet(), mci.getSubject(), mci.getConnectionRequestInfo()); if (matchedMC != null) { connectionInfo.setManagedConnectionInfo((ManagedConnectionInfo) pool.get(matchedMC)); if (log.isTraceEnabled()) { log.trace("Returning pooled connection " + connectionInfo.getManagedConnectionInfo()); } return; } //matching failed or pool is empty //if pool is at maximum size, pick a cx to kill if (actualConnections == maxSize) { Iterator iterator = pool.entrySet().iterator(); ManagedConnectionInfo kill = (ManagedConnectionInfo) ((Map.Entry) iterator.next()).getValue(); iterator.remove(); ConnectionInfo killInfo = new ConnectionInfo(kill); returnConnection(killInfo, ConnectionReturnAction.DESTROY); } next.getConnection(connectionInfo); actualConnections++; if (log.isTraceEnabled()) { log.trace("Returning new connection " + connectionInfo.getManagedConnectionInfo()); } return; } } catch (ResourceException e) { //something is wrong: rethrow, release permit permits.release(); throw e; } } } else { throw new ResourceException( "No ManagedConnections available " + "within configured blocking timeout ( " + blockingTimeout + " [ms] )"); } // end of else } catch (InterruptedException ie) { throw new ResourceException("Interrupted while requesting permit!"); } // end of try-catch } public void returnConnection( ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) { if (log.isTraceEnabled()) { log.trace("returning connection" + connectionInfo.getConnectionHandle()); } boolean wasInPool = false; ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); if (connectionReturnAction == ConnectionReturnAction.DESTROY) { synchronized (pool) { wasInPool = (pool.remove(mci.getManagedConnection()) != null); } } else { if (mci.hasConnectionHandles()) { return; } } // end of else ManagedConnection mc = mci.getManagedConnection(); try { mc.cleanup(); } catch (ResourceException e) { connectionReturnAction = ConnectionReturnAction.DESTROY; } if (connectionReturnAction == ConnectionReturnAction.DESTROY) { actualConnections--; next.returnConnection(connectionInfo, connectionReturnAction); } else { synchronized (pool) { mci.setLastUsed(System.currentTimeMillis()); pool.put(mci.getManagedConnection(), mci); } } if (!wasInPool) { permits.release(); } } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectionmanagerconfig/LocalTransactions.java Index: LocalTransactions.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed 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.outbound.connectionmanagerconfig; import org.apache.geronimo.connector.outbound.ConnectionInterceptor; import org.apache.geronimo.connector.outbound.LocalXAResourceInsertionInterceptor; import org.apache.geronimo.connector.outbound.TransactionEnlistingInterceptor; import org.apache.geronimo.connector.outbound.TransactionCachingInterceptor; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ * * */ public class LocalTransactions extends TransactionSupport { public static final TransactionSupport INSTANCE = new LocalTransactions(); private LocalTransactions() { } public ConnectionInterceptor addXAResourceInsertionInterceptor(ConnectionInterceptor stack) { return new LocalXAResourceInsertionInterceptor(stack); } public ConnectionInterceptor addTransactionInterceptors(ConnectionInterceptor stack) { stack = new TransactionEnlistingInterceptor(stack); return new TransactionCachingInterceptor(stack); } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectionmanagerconfig/NoPool.java Index: NoPool.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed 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.outbound.connectionmanagerconfig; import org.apache.geronimo.connector.outbound.ConnectionInterceptor; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ * * */ public class NoPool extends PoolingSupport { public ConnectionInterceptor addPoolingInterceptors(ConnectionInterceptor tail) { return tail; } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectionmanagerconfig/NoTransactions.java Index: NoTransactions.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed 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.outbound.connectionmanagerconfig; import org.apache.geronimo.connector.outbound.ConnectionInterceptor; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ * * */ public class NoTransactions extends TransactionSupport { public static final TransactionSupport INSTANCE = new NoTransactions(); private NoTransactions() { } public ConnectionInterceptor addXAResourceInsertionInterceptor(ConnectionInterceptor stack) { return stack; } public ConnectionInterceptor addTransactionInterceptors(ConnectionInterceptor stack) { return stack; } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectionmanagerconfig/PartitionedPool.java Index: PartitionedPool.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed 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.outbound.connectionmanagerconfig; import org.apache.geronimo.connector.outbound.ConnectionInterceptor; import org.apache.geronimo.connector.outbound.MultiPoolConnectionInterceptor; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ * * */ public class PartitionedPool extends PoolingSupport { private boolean partitionByConnectionRequestInfo; private boolean partitionBySubject; private final SinglePool singlePool; public PartitionedPool(boolean partitionByConnectionRequestInfo, boolean partitionBySubject, int maxSize, int blockingTimeoutMilliseconds, boolean matchOne, boolean matchAll, boolean selectOneAssumeMatch) { singlePool = new SinglePool(maxSize, blockingTimeoutMilliseconds, matchOne, matchAll, selectOneAssumeMatch); this.partitionByConnectionRequestInfo = partitionByConnectionRequestInfo; this.partitionBySubject = partitionBySubject; } public boolean isPartitionByConnectionRequestInfo() { return partitionByConnectionRequestInfo; } public void setPartitionByConnectionRequestInfo(boolean partitionByConnectionRequestInfo) { this.partitionByConnectionRequestInfo = partitionByConnectionRequestInfo; } public boolean isPartitionBySubject() { return partitionBySubject; } public void setPartitionBySubject(boolean partitionBySubject) { this.partitionBySubject = partitionBySubject; } public int getMaxSize() { return singlePool.getMaxSize(); } public void setMaxSize(int maxSize) { singlePool.setMaxSize(maxSize); } public int getBlockingTimeoutMilliseconds() { return singlePool.getBlockingTimeoutMilliseconds(); } public void setBlockingTimeoutMilliseconds(int blockingTimeoutMilliseconds) { singlePool.setBlockingTimeoutMilliseconds(blockingTimeoutMilliseconds); } public boolean isMatchOne() { return singlePool.isMatchOne(); } public void setMatchOne(boolean matchOne) { singlePool.setMatchOne(matchOne); } public boolean isMatchAll() { return singlePool.isMatchAll(); } public void setMatchAll(boolean matchAll) { singlePool.setMatchAll(matchAll); } public boolean isSelectOneAssumeMatch() { return singlePool.isSelectOneAssumeMatch(); } public void setSelectOneAssumeMatch(boolean selectOneAssumeMatch) { singlePool.setSelectOneAssumeMatch(selectOneAssumeMatch); } public ConnectionInterceptor addPoolingInterceptors(ConnectionInterceptor tail) { return new MultiPoolConnectionInterceptor( tail, singlePool, isPartitionBySubject(), isPartitionByConnectionRequestInfo()); } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectionmanagerconfig/PoolingSupport.java Index: PoolingSupport.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed 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.outbound.connectionmanagerconfig; import java.io.Serializable; import org.apache.geronimo.connector.outbound.ConnectionInterceptor; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ * * */ public abstract class PoolingSupport implements Serializable { public abstract ConnectionInterceptor addPoolingInterceptors(ConnectionInterceptor tail); } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectionmanagerconfig/SinglePool.java Index: SinglePool.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed 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.outbound.connectionmanagerconfig; import org.apache.geronimo.connector.outbound.ConnectionInterceptor; import org.apache.geronimo.connector.outbound.SinglePoolConnectionInterceptor; import org.apache.geronimo.connector.outbound.SinglePoolMatchAllConnectionInterceptor; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ * * */ public class SinglePool extends PoolingSupport { private int maxSize; private int blockingTimeoutMilliseconds; private boolean matchOne; private boolean matchAll; private boolean selectOneAssumeMatch; public SinglePool(int maxSize, int blockingTimeoutMilliseconds, boolean matchOne, boolean matchAll, boolean selectOneAssumeMatch) { this.maxSize = maxSize; this.blockingTimeoutMilliseconds = blockingTimeoutMilliseconds; this.matchOne = matchOne; this.matchAll = matchAll; this.selectOneAssumeMatch = selectOneAssumeMatch; } public int getMaxSize() { return maxSize; } public void setMaxSize(int maxSize) { this.maxSize = maxSize; } public int getBlockingTimeoutMilliseconds() { return blockingTimeoutMilliseconds; } public void setBlockingTimeoutMilliseconds(int blockingTimeoutMilliseconds) { this.blockingTimeoutMilliseconds = blockingTimeoutMilliseconds; } public boolean isMatchOne() { return matchOne; } public void setMatchOne(boolean matchOne) { this.matchOne = matchOne; } public boolean isMatchAll() { return matchAll; } public void setMatchAll(boolean matchAll) { this.matchAll = matchAll; } public boolean isSelectOneAssumeMatch() { return selectOneAssumeMatch; } public void setSelectOneAssumeMatch(boolean selectOneAssumeMatch) { this.selectOneAssumeMatch = selectOneAssumeMatch; } public ConnectionInterceptor addPoolingInterceptors(ConnectionInterceptor tail) { if (isMatchAll()) { return new SinglePoolMatchAllConnectionInterceptor( tail, getMaxSize(), getBlockingTimeoutMilliseconds()); } else { return new SinglePoolConnectionInterceptor( tail, getMaxSize(), getBlockingTimeoutMilliseconds(), isSelectOneAssumeMatch()); } } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectionmanagerconfig/TransactionLog.java Index: TransactionLog.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed 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.outbound.connectionmanagerconfig; import org.apache.geronimo.connector.outbound.ConnectionInterceptor; import org.apache.geronimo.connector.outbound.TransactionEnlistingInterceptor; import org.apache.geronimo.connector.outbound.TransactionCachingInterceptor; import org.apache.geronimo.connector.outbound.transactionlog.LogXAResourceInsertionInterceptor; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ * * */ public class TransactionLog extends TransactionSupport { public static final TransactionSupport INSTANCE = new TransactionLog(); private TransactionLog() { } public ConnectionInterceptor addXAResourceInsertionInterceptor(ConnectionInterceptor stack) { return new LogXAResourceInsertionInterceptor(stack); } public ConnectionInterceptor addTransactionInterceptors(ConnectionInterceptor stack) { stack = new TransactionEnlistingInterceptor(stack); return new TransactionCachingInterceptor(stack); } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectionmanagerconfig/TransactionSupport.java Index: TransactionSupport.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed 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.outbound.connectionmanagerconfig; import java.io.Serializable; import org.apache.geronimo.connector.outbound.ConnectionInterceptor; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ * * */ public abstract class TransactionSupport implements Serializable { public abstract ConnectionInterceptor addXAResourceInsertionInterceptor(ConnectionInterceptor stack); public abstract ConnectionInterceptor addTransactionInterceptors(ConnectionInterceptor stack); } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectionmanagerconfig/XATransactions.java Index: XATransactions.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed 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.outbound.connectionmanagerconfig; import org.apache.geronimo.connector.outbound.ConnectionInterceptor; import org.apache.geronimo.connector.outbound.XAResourceInsertionInterceptor; import org.apache.geronimo.connector.outbound.TransactionEnlistingInterceptor; import org.apache.geronimo.connector.outbound.TransactionCachingInterceptor; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:22 $ * * */ public class XATransactions extends TransactionSupport { private boolean useTransactionCaching; private boolean useThreadCaching; public XATransactions(boolean useTransactionCaching, boolean useThreadCaching) { this.useTransactionCaching = useTransactionCaching; this.useThreadCaching = useThreadCaching; } public boolean isUseTransactionCaching() { return useTransactionCaching; } public void setUseTransactionCaching(boolean useTransactionCaching) { this.useTransactionCaching = useTransactionCaching; } public boolean isUseThreadCaching() { return useThreadCaching; } public void setUseThreadCaching(boolean useThreadCaching) { this.useThreadCaching = useThreadCaching; } public ConnectionInterceptor addXAResourceInsertionInterceptor(ConnectionInterceptor stack) { return new XAResourceInsertionInterceptor(stack); } public ConnectionInterceptor addTransactionInterceptors(ConnectionInterceptor stack) { stack = new TransactionEnlistingInterceptor(stack); if (isUseTransactionCaching()) { stack = new TransactionCachingInterceptor(stack); } return stack; } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/JDBCLog.java Index: JDBCLog.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed 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.outbound.transactionlog; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import javax.sql.DataSource; import javax.transaction.xa.Xid; import org.apache.geronimo.gbean.GBeanInfo; import org.apache.geronimo.gbean.GBeanInfoFactory; import org.apache.geronimo.gbean.GBean; import org.apache.geronimo.gbean.GBeanContext; import org.apache.geronimo.gbean.WaitingException; import org.apache.geronimo.transaction.manager.LogException; import org.apache.geronimo.transaction.manager.TransactionLog; import org.apache.geronimo.transaction.manager.XidImpl; import org.apache.geronimo.connector.outbound.ManagedConnectionFactoryWrapper; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:23 $ * * */ public class JDBCLog implements TransactionLog, GBean { private final static String INSERT_XID = "INSERT INTO TXLOG (SYSTEMID, FORMATID, GLOBALID, BRANCHID) VALUES (?, ?, ?, ?)"; private final static String DELETE_XID = "DELETE FROM TXLOG WHERE SYSTEMID = ? AND FORMATID = ? AND GLOBALID = ? BRANCHID = ?"; private final static String RECOVER = "SELECT FORMATID, GLOBALID, BRANCHID FROM TXLOG WHERE SYSTEMID = ?"; private DataSource dataSource; private final String systemId; private final ManagedConnectionFactoryWrapper managedConnectionFactoryWrapper; public JDBCLog(String systemId, ManagedConnectionFactoryWrapper managedConnectionFactoryWrapper) { this.systemId = systemId; this.managedConnectionFactoryWrapper = managedConnectionFactoryWrapper; } public void setGBeanContext(GBeanContext context) { } public void doStart() throws WaitingException, Exception { dataSource = (DataSource)managedConnectionFactoryWrapper.getProxy(); } public void doStop() throws WaitingException, Exception { dataSource = null; } public void doFail() { } public void begin(Xid xid) throws LogException { } public void prepare(Xid xid) throws LogException { xidOperation(xid, INSERT_XID); } private void xidOperation(Xid xid, String sql) throws LogException { try { Connection connection = dataSource.getConnection(); try { PreparedStatement ps = connection.prepareStatement(sql); try { ps.setString(0, systemId); ps.setInt(1, xid.getFormatId()); ps.setBytes(2, xid.getGlobalTransactionId()); ps.setBytes(3, xid.getBranchQualifier()); ps.execute(); } finally { ps.close(); } if (!connection.getAutoCommit()) { connection.commit(); } } finally { connection.close(); } } catch (SQLException e) { throw new LogException("Failure during prepare or commit", e); } } public void commit(Xid xid) throws LogException { xidOperation(xid, DELETE_XID); } public void rollback(Xid xid) throws LogException { throw new LogException("JDBCLog does not support rollback of prepared transactions. Use it only on servers that do not import transactions"); } public List recover() throws LogException { try { Connection connection = dataSource.getConnection(); try { List xids = new ArrayList(); PreparedStatement ps = connection.prepareStatement(RECOVER); ps.setString(0, systemId); ResultSet rs = ps.executeQuery(); while (rs.next()) { int formatId = rs.getInt(0); byte[] globalId = rs.getBytes(1); byte[] branchId = rs.getBytes(2); Xid xid = new XidImpl(formatId, globalId, branchId); xids.add(xid); } return xids; } finally { connection.close(); } } catch (SQLException e) { throw new LogException("Recover failure", e); } } public String getXMLStats() { return null; } public int getAverageForceTime() { return 0; } public int getAverageBytesPerForce() { return 0; } public static final GBeanInfo GBEAN_INFO; static { GBeanInfoFactory infoFactory = new GBeanInfoFactory(JDBCLog.class.getName()); infoFactory.addAttribute("SystemId", true); infoFactory.addInterface(TransactionLog.class); infoFactory.addReference("ManagedConnectionFactoryWrapper", ManagedConnectionFactoryWrapper.class); infoFactory.setConstructor( new String[]{"SystemId", "DataSource"}, new Class[]{String.class, DataSource.class}); GBEAN_INFO = infoFactory.getBeanInfo(); } public static GBeanInfo getGBeanInfo() { return GBEAN_INFO; } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/LogXAResource.java Index: LogXAResource.java =================================================================== /** * * Copyright 2004 The Apache Software Foundation * * Licensed 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.outbound.transactionlog; import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; import javax.transaction.xa.XAException; import javax.resource.ResourceException; import javax.resource.spi.LocalTransaction; /** * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:23 $ * * */ public class LogXAResource implements XAResource { final LocalTransaction localTransaction; private Xid xid; public LogXAResource(LocalTransaction localTransaction) { this.localTransaction = localTransaction; } public void commit(Xid xid, boolean onePhase) throws XAException { } public void end(Xid xid, int flags) throws XAException { } public void forget(Xid xid) throws XAException { } public int getTransactionTimeout() throws XAException { return 0; } public boolean isSameRM(XAResource xaResource) throws XAException { return this == xaResource; } public int prepare(Xid xid) throws XAException { return 0; } public Xid[] recover(int flag) throws XAException { return new Xid[0]; } public void rollback(Xid xid) throws XAException { if (this.xid == null || !this.xid.equals(xid)) { throw new XAException(); } try { localTransaction.rollback(); } catch (ResourceException e) { throw (XAException)new XAException().initCause(e); } finally { this.xid = null; } } public boolean setTransactionTimeout(int seconds) throws XAException { return false; } public void start(Xid xid, int flag) throws XAException { if (flag == XAResource.TMNOFLAGS) { // first time in this transaction if (this.xid != null) { throw new XAException("already enlisted"); } this.xid = xid; try { localTransaction.begin(); } catch (ResourceException e) { throw (XAException) new XAException("could not start local tx").initCause(e); } } else if (flag == XAResource.TMRESUME) { if (xid != this.xid) { throw new XAException("attempting to resume in different transaction"); } } else { throw new XAException("unknown state"); } } } 1.1 incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/transactionlog/LogXAResourceInsertionInterceptor.java Index: LogXAResourceInsertionInterceptor.java =================================================================== /** * * Copyright 2003-2004 The Apache Software Foundation * * Licensed 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.outbound.transactionlog; import javax.resource.ResourceException; import org.apache.geronimo.connector.outbound.ConnectionInfo; import org.apache.geronimo.connector.outbound.ConnectionInterceptor; import org.apache.geronimo.connector.outbound.ConnectionReturnAction; import org.apache.geronimo.connector.outbound.ManagedConnectionInfo; /** * LocalXAResourceInsertionInterceptor.java * * * @version $Revision: 1.1 $ $Date: 2004/05/06 03:58:23 $ */ public class LogXAResourceInsertionInterceptor implements ConnectionInterceptor { private final ConnectionInterceptor next; public LogXAResourceInsertionInterceptor(final ConnectionInterceptor next) { this.next = next; } public void getConnection(ConnectionInfo connectionInfo) throws ResourceException { next.getConnection(connectionInfo); ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo(); mci.setXAResource( new LogXAResource( mci.getManagedConnection().getLocalTransaction())); } public void returnConnection( ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) { next.returnConnection(connectionInfo, connectionReturnAction); } } 1.13 +48 -21 incubator-geronimo/modules/connector/src/schema/geronimo-connector_1_5.xsd Index: geronimo-connector_1_5.xsd =================================================================== RCS file: /home/cvs/incubator-geronimo/modules/connector/src/schema/geronimo-connector_1_5.xsd,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- geronimo-connector_1_5.xsd 14 Apr 2004 04:01:25 -0000 1.12 +++ geronimo-connector_1_5.xsd 6 May 2004 03:58:23 -0000 1.13 @@ -222,9 +222,12 @@ type="ger:config-property-settingType" minOccurs="0" maxOccurs="unbounded"/> - - + + + + + - - Specification of factory that will construct the ConnectionManager for us. + The ConnectionManager configuration. @@ -251,23 +253,50 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -359,8 +388,6 @@ -