[jboss-cvs] JBossAS SVN: r64057 - in projects: jboss-jca and 108 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Jul 14 07:34:26 EDT 2007
Author: vicky.kak at jboss.com
Date: 2007-07-14 07:34:26 -0400 (Sat, 14 Jul 2007)
New Revision: 64057
Added:
projects/jboss-jca/
projects/jboss-jca/adapter/
projects/jboss-jca/adapter/pom.xml
projects/jboss-jca/adapter/src/
projects/jboss-jca/adapter/src/etc/
projects/jboss-jca/adapter/src/etc/conf/
projects/jboss-jca/adapter/src/etc/conf/log4j.properties
projects/jboss-jca/adapter/src/etc/default.mf
projects/jboss-jca/adapter/src/main/
projects/jboss-jca/adapter/src/main/org/
projects/jboss-jca/adapter/src/main/org/jboss/
projects/jboss-jca/adapter/src/main/org/jboss/rars/
projects/jboss-jca/adapter/src/main/org/jboss/rars/advice/
projects/jboss-jca/adapter/src/main/org/jboss/rars/advice/AbstractRARInterceptor.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/advice/TraceAdvice.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/
projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/pooling/
projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/pooling/PoolingConnectionEventListener.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/pooling/PoolingConnectionManager.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/simple/
projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/simple/SimpleConnectionEventListener.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/simple/SimpleConnectionManager.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cf/
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cf/ConnectionFactoryAdvice.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cf/GenericConnectionFactory.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/NoConnectionRequestInfo.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/SubjectCRIRequestID.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/UserPasswordConnectionRequestInfo.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/GenericManagedConnection.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/GenericManagedConnectionFactory.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/ReflectionUtil.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/DirectConnectionFactory.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/DirectGenericConnectionFactory.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/DirectGenericManagedConnectionFactory.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/AbstractRealConnection.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectConnection.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectConnectionAdvice.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectConnectionFactory.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectGenericConnection.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectGenericConnectionFactory.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectGenericManagedConnectionFactory.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/RealConnection.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jdbc/
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jdbc/JDBCManagedConnectionFactory.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jdbc/local/
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jdbc/local/LocalJDBCManagedConnectionFactory.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jms/
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jms/JMSManagedConnectionFactory.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jms/JMSRealConnection.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/ra/
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/ra/GenericResourceAdapter.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/ra/ResourceErrorHandler.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/ClosedAdvice.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericChild.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericConnection.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericHandle.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericWrapper.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/ParentChildAdvice.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/WrappedObject.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/WrapperAdvice.java
projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/WrapperErrorAdvice.java
projects/jboss-jca/adapter/src/resources/
projects/jboss-jca/adapter/src/resources/tests/
projects/jboss-jca/adapter/src/resources/tests/org/
projects/jboss-jca/adapter/src/resources/tests/org/jboss/
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/JBossMQUnitTestCase.xml
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jdbc/
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jdbc/local/
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jdbc/local/test/
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jdbc/local/test/JDBCUnitTestCase.xml
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jms/
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jms/test/
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jms/test/JMSUnitTestCase.xml
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/test/
projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/test/TestUnitTestCase.xml
projects/jboss-jca/adapter/src/tests/
projects/jboss-jca/adapter/src/tests/org/
projects/jboss-jca/adapter/src/tests/org/jboss/
projects/jboss-jca/adapter/src/tests/org/jboss/test/
projects/jboss-jca/adapter/src/tests/org/jboss/test/JBossMQUnitTestCase.java
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/RARAllTestSuite.java
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/RARTest.java
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jdbc/
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jdbc/local/
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jdbc/local/test/
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jdbc/local/test/JDBCUnitTestCase.java
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jms/
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jms/test/
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jms/test/JMSUnitTestCase.java
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestConnection.java
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestConnectionFactory.java
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestConnectionImpl.java
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestManagedConnectionFactory.java
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/test/
projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/test/TestUnitTestCase.java
projects/jboss-jca/core/
projects/jboss-jca/core/pom.xml
projects/jboss-jca/core/src/
projects/jboss-jca/core/src/etc/
projects/jboss-jca/core/src/etc/conf/
projects/jboss-jca/core/src/etc/conf/log4j.properties
projects/jboss-jca/core/src/etc/default.mf
projects/jboss-jca/core/src/main/
projects/jboss-jca/core/src/main/org/
projects/jboss-jca/core/src/main/org/jboss/
projects/jboss-jca/core/src/main/org/jboss/jca/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/advice/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/advice/AbstractJCAInterceptor.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/ConnectionManagerExceptionAdvice.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/ConnectionManagerFactory.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/TraceAdvice.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/listener/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/listener/ListenerAdvice.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/PoolAdvice.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/none/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/none/NoPoolFactory.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/simple/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/simple/SimplePool.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/simple/SimplePoolFactory.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/security/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/security/SecurityAdvice.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/Activation.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/POJOMessageEndpointAdvice.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/POJOMessageEndpointFactory.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/timer/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/timer/JDKTimerFactory.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/work/
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/work/JBossWorkManager.java
projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/work/WorkWrapper.java
projects/jboss-jca/core/src/main/org/jboss/jca/spi/
projects/jboss-jca/core/src/main/org/jboss/jca/spi/ResourceExceptionUtil.java
projects/jboss-jca/core/src/main/org/jboss/jca/spi/cm/
projects/jboss-jca/core/src/main/org/jboss/jca/spi/cm/ManagedConnectionContext.java
projects/jboss-jca/core/src/main/org/jboss/jca/spi/cm/ManagedConnectionContextManager.java
projects/jboss-jca/core/src/main/org/jboss/jca/spi/pool/
projects/jboss-jca/core/src/main/org/jboss/jca/spi/pool/ManagedConnectionContextPool.java
projects/jboss-jca/core/src/main/org/jboss/jca/spi/pool/ManagedConnectionContextPoolFactory.java
projects/jboss-jca/core/src/main/org/jboss/jca/spi/rar/
projects/jboss-jca/core/src/main/org/jboss/jca/spi/rar/BootstrapContextFactory.java
projects/jboss-jca/core/src/main/org/jboss/jca/spi/rar/TimerFactory.java
projects/jboss-jca/core/src/resources/
projects/jboss-jca/core/src/resources/tests/
projects/jboss-jca/core/src/resources/tests/org/
projects/jboss-jca/core/src/resources/tests/org/jboss/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/inflow/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/inflow/test/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/inflow/test/InflowUnitTestCase.xml
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/notx/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/notx/test/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/notx/test/NoTxUnitTestCase.xml
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/timer/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/timer/test/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/timer/test/TimerUnitTestCase.xml
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/txinflow/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/txinflow/test/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/txinflow/test/TxInflowUnitTestCase.xml
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/work/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/work/test/
projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/work/test/WorkManagerUnitTestCase.xml
projects/jboss-jca/core/src/tests/
projects/jboss-jca/core/src/tests/org/
projects/jboss-jca/core/src/tests/org/jboss/
projects/jboss-jca/core/src/tests/org/jboss/test/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/JCAAllTestSuite.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/JCATest.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/JCATestSuite.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/inflow/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/inflow/test/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/inflow/test/InflowTestSuite.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/inflow/test/InflowUnitTestCase.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/notx/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/notx/test/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/notx/test/NoTxTestSuite.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/notx/test/NoTxUnitTestCase.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestActivationSpec.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnection.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionFactory.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionFactoryImpl.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionImpl.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionRequestInfo.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestManagedConnection.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestManagedConnectionFactory.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestManagedConnectionMetaData.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestMessage.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestMessageListener.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestMessageListenerImpl.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestResourceAdapter.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/timer/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/timer/test/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/timer/test/TimerTestSuite.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/timer/test/TimerUnitTestCase.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/txinflow/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/txinflow/test/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/txinflow/test/TxInflowTestSuite.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/txinflow/test/TxInflowUnitTestCase.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/work/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/work/test/
projects/jboss-jca/core/src/tests/org/jboss/test/jca/work/test/WorkManagerTestSuite.java
projects/jboss-jca/core/src/tests/org/jboss/test/jca/work/test/WorkManagerUnitTestCase.java
projects/jboss-jca/pom.xml
Log:
jboss-jca Initial checkin.
Added: projects/jboss-jca/adapter/pom.xml
===================================================================
--- projects/jboss-jca/adapter/pom.xml (rev 0)
+++ projects/jboss-jca/adapter/pom.xml 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,168 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-adapter</artifactId>
+ <packaging>jar</packaging>
+ <version>0.1.SNAPSHOT</version>
+ <name>JBoss JCA</name>
+ <url>http://www.jboss.org</url>
+ <description>This would contain the Jboss RA classes independent of the JbossAS</description>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <url>http://repository.jboss.com/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+ <organization>
+ <name>JBoss, a division of Red Hat, Inc.</name>
+ <url>http://www.jboss.org</url>
+ </organization>
+
+ <repositories>
+ <repository>
+ <id>jboss</id>
+ <name>JBoss Inc. Repository</name>
+ <layout>default</layout>
+ <url>http://repository.jboss.com/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <layout>default</layout>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ <repository>
+ <id>jboss</id>
+ <name>Central Maven Repository</name>
+ <layout>default</layout>
+ <url>http://repo1.maven.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-jca/trunk/</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-jca/trunk/</developerConnection>
+ <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-jca/trunk/</url>
+ </scm>
+
+ <build>
+ <sourceDirectory>src/main</sourceDirectory>
+ <testSourceDirectory>src/tests</testSourceDirectory>
+ <outputDirectory>output</outputDirectory>
+ <testOutputDirectory>output</testOutputDirectory>
+
+ <testResources>
+ <testResource>
+ <directory>src/resources/tests</directory>
+ </testResource>
+ </testResources>
+
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <optimize>true</optimize>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <includes>
+ <include>org/jboss/test/**/*TestCase.java</include>
+ </includes>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.0.2.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-aop</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-transaction</artifactId>
+ <version>5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>1.0.3.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-aop-mc-int</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.7</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
Added: projects/jboss-jca/adapter/src/etc/conf/log4j.properties
===================================================================
--- projects/jboss-jca/adapter/src/etc/conf/log4j.properties (rev 0)
+++ projects/jboss-jca/adapter/src/etc/conf/log4j.properties 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,15 @@
+### ====================================================================== ###
+## ##
+## JBoss Bootstrap Log4j Configuration ##
+## ##
+### ====================================================================== ###
+
+### $Id: log4j.properties,v 1.1.1.1 2006/02/04 14:37:17 adrian Exp $ ###
+
+log4j.rootCategory=DEBUG, CONSOLE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=INFO
+log4j.appender.CONSOLE.Target=System.out
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
Added: projects/jboss-jca/adapter/src/etc/default.mf
===================================================================
--- projects/jboss-jca/adapter/src/etc/default.mf (rev 0)
+++ projects/jboss-jca/adapter/src/etc/default.mf 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: @java.vm.version@ (@java.vm.vendor@)
+Specification-Title: @specification.title@
+Specification-Version: @specification.version@
+Specification-Vendor: @specification.vendor@
+Implementation-Title: @implementation.title@
+Implementation-URL: @implementation.url@
+Implementation-Version: @implementation.version@
+Implementation-Vendor: @implementation.vendor@
+Implementation-Vendor-Id: @implementation.vendor.id@
\ No newline at end of file
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/advice/AbstractRARInterceptor.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/advice/AbstractRARInterceptor.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/advice/AbstractRARInterceptor.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,78 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.advice;
+
+import java.lang.reflect.Method;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.logging.Logger;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * AbstractRARInterceptor.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public abstract class AbstractRARInterceptor implements Interceptor
+{
+ /** The log */
+ protected final Logger log = Logger.getLogger(getClass());
+
+ public String getName()
+ {
+ return getClass().getName();
+ }
+
+ protected static String format(Invocation invocation)
+ {
+ JBossStringBuilder buffer = new JBossStringBuilder();
+ format(buffer, invocation);
+ return buffer.toString();
+ }
+
+ protected static void format(JBossStringBuilder buffer, Invocation invocation)
+ {
+ if (invocation instanceof MethodInvocation)
+ {
+ MethodInvocation mi = (MethodInvocation) invocation;
+ Method method = mi.getMethod();
+ buffer.append("[method=").append(method.getDeclaringClass().getName());
+ buffer.append('.').append(method.getName());
+ buffer.append('(');
+ Class[] parameters = method.getParameterTypes();
+ for (int i = 0; i < parameters.length; ++i)
+ {
+ if (i > 0)
+ buffer.append(", ");
+ buffer.append(parameters[i].getName());
+ }
+ buffer.append(')');
+ buffer.append(" target=").append(mi.getTargetObject());
+ buffer.append(']');
+ }
+ else
+ buffer.append(invocation);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/advice/TraceAdvice.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/advice/TraceAdvice.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/advice/TraceAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,100 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.advice;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Trace advice.
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class TraceAdvice extends AbstractRARInterceptor
+{
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ boolean trace = log.isTraceEnabled();
+ long begin = 0;
+ if (trace)
+ {
+ begin = System.currentTimeMillis();
+ log.trace(format("BEFORE: ", invocation));
+ }
+ try
+ {
+ Object result = invocation.invokeNext();
+ if (trace)
+ {
+ long now = System.currentTimeMillis();
+ log.trace(format("AFTER: ", invocation, now-begin, result));
+ }
+ return result;
+ }
+ catch (Throwable t)
+ {
+ if (trace)
+ {
+ long now = System.currentTimeMillis();
+ log.trace(format("AFTER: ", invocation, now-begin), t);
+ }
+ throw t;
+ }
+ }
+
+ protected static void format(JBossStringBuilder buffer, String context, Invocation invocation)
+ {
+ buffer.append(context);
+ format(buffer, invocation);
+ }
+
+ protected static void format(JBossStringBuilder buffer, String context, Invocation invocation, long time)
+ {
+ if (time > 10)
+ buffer.append("-------> ");
+ format(buffer, context, invocation);
+ buffer.append(" time=").append(time).append("ms");
+ }
+
+ protected static JBossStringBuilder format(String context, Invocation invocation)
+ {
+ JBossStringBuilder buffer = new JBossStringBuilder();
+ format(buffer, context, invocation);
+ return buffer;
+ }
+
+ protected static JBossStringBuilder format(String context, Invocation invocation, long time)
+ {
+ JBossStringBuilder buffer = new JBossStringBuilder();
+ format(buffer, context, invocation, time);
+ return buffer;
+ }
+
+ protected static JBossStringBuilder format(String context, Invocation invocation, long time, Object result)
+ {
+ JBossStringBuilder buffer = new JBossStringBuilder();
+ format(buffer, context, invocation, time);
+ buffer.append(" RESULT=").append(result);
+ return buffer;
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/pooling/PoolingConnectionEventListener.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/pooling/PoolingConnectionEventListener.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/pooling/PoolingConnectionEventListener.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,112 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.cm.pooling;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ManagedConnection;
+
+import org.jboss.logging.Logger;
+
+/**
+ * PoolingConnectionEventListener.
+ *
+ * @todo handle counting
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class PoolingConnectionEventListener implements ConnectionEventListener
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(PoolingConnectionEventListener.class);
+
+ /** The connection manager */
+ private PoolingConnectionManager cm;
+
+ /** The managed connection */
+ private ManagedConnection mc;
+
+ /**
+ * Create a new PoolingConnectionEventListener.
+ *
+ * @param mc the managed connection
+ */
+ public PoolingConnectionEventListener(PoolingConnectionManager cm, ManagedConnection mc)
+ {
+ this.cm = cm;
+ this.mc = mc;
+ }
+
+ public void connectionClosed(ConnectionEvent event)
+ {
+ if (mc != null)
+ {
+ try
+ {
+ mc.cleanup();
+ cm.returnManagedConnection(mc);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error closing connection", t);
+ close();
+ }
+ }
+ }
+
+ public void connectionErrorOccurred(ConnectionEvent event)
+ {
+ log.warn("Connection Error occurred for " + mc, event.getException());
+ close();
+ }
+
+ public void localTransactionStarted(ConnectionEvent event)
+ {
+ }
+
+ public void localTransactionCommitted(ConnectionEvent event)
+ {
+ }
+
+ public void localTransactionRolledback(ConnectionEvent event)
+ {
+ }
+
+ private void close()
+ {
+ ManagedConnection managedConnection = mc;
+ mc = null;
+ try
+ {
+ if (managedConnection != null)
+ {
+ cm.removeManagedConnection(mc);
+ managedConnection.destroy();
+ }
+ }
+ catch (ResourceException ignored)
+ {
+ log.trace("Ignored", ignored);
+ }
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/pooling/PoolingConnectionManager.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/pooling/PoolingConnectionManager.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/pooling/PoolingConnectionManager.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,162 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.cm.pooling;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.security.auth.Subject;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.collection.CollectionsFactory;
+
+/**
+ * PoolingConnectionManager.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class PoolingConnectionManager implements ConnectionManager
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -411325259312495917L;
+
+ /** The log */
+ private static final Logger log = Logger.getLogger(PoolingConnectionManager.class);
+
+ /** The pool */
+ private Set pool = CollectionsFactory.createCopyOnWriteSet();
+
+ /** The checked out connectins */
+ private Set checkedOut = CollectionsFactory.createCopyOnWriteSet();
+
+ public Object allocateConnection(ManagedConnectionFactory mcf, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ Subject subject = null;
+ ManagedConnection mc = getManagedConnection(mcf, subject, cxRequestInfo);
+ checkedOut.add(mc);
+ try
+ {
+ return mc.getConnection(subject, cxRequestInfo);
+ }
+ catch (Throwable t)
+ {
+ checkedOut.remove(mc);
+ try
+ {
+ mc.destroy();
+ }
+ catch (Throwable ignored)
+ {
+ }
+ if (t instanceof ResourceException)
+ throw (ResourceException) t;
+ else
+ throw new ResourceAdapterInternalException("Unable to get connection handle", t);
+ }
+ }
+
+ protected void finalize() throws Throwable
+ {
+ stop();
+ }
+
+ public synchronized void stop()
+ {
+ if (pool.size() != 0)
+ {
+ for (Iterator i = pool.iterator(); i.hasNext();)
+ {
+ ManagedConnection mc = (ManagedConnection) i.next();
+ try
+ {
+ mc.destroy();
+ }
+ catch (Throwable ignored)
+ {
+ log.debug("Error stopping pool", ignored);
+ }
+ }
+ }
+ }
+
+ /**
+ * Get a managed connection
+ *
+ * @param mcf the managed connection factory
+ * @param subject the subject
+ * @param cri the connection request info
+ * @return the managed connection
+ */
+ protected synchronized ManagedConnection getManagedConnection(ManagedConnectionFactory mcf, Subject subject, ConnectionRequestInfo cri) throws ResourceException
+ {
+ boolean trace = log.isTraceEnabled();
+
+ // Try the pool
+ if (pool.size() != 0)
+ {
+ ManagedConnection mc = mcf.matchManagedConnections(pool, subject, cri);
+ if (mc != null)
+ {
+ pool.remove(mc);
+ checkedOut.add(mc);
+ if (trace)
+ log.trace("Got managed connection from pool " + mc);
+ return mc;
+ }
+ }
+
+ ManagedConnection mc = mcf.createManagedConnection(null, cri);
+ checkedOut.add(mc);
+ PoolingConnectionEventListener listener = new PoolingConnectionEventListener(this, mc);
+ mc.addConnectionEventListener(listener);
+ if (trace)
+ log.trace("Created new managed connection " + mc);
+ return mc;
+ }
+
+ protected synchronized void returnManagedConnection(ManagedConnection mc) throws ResourceException
+ {
+ pool.add(mc);
+ checkedOut.remove(mc);
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Return managed connection to the pool " + mc);
+ }
+
+ protected synchronized void removeManagedConnection(ManagedConnection mc)
+ {
+ boolean trace = log.isTraceEnabled();
+ boolean removed = pool.remove(mc);
+ if (trace && removed)
+ log.trace("Removed destroyed managed connection from the pool " + mc);
+ checkedOut.remove(mc);
+ if (trace && removed)
+ log.trace("Removed destroyed managed connection that was checked out " + mc);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/simple/SimpleConnectionEventListener.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/simple/SimpleConnectionEventListener.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/simple/SimpleConnectionEventListener.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,95 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.cm.simple;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ManagedConnection;
+
+import org.jboss.logging.Logger;
+
+/**
+ * SimpleConnectionEventListener.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class SimpleConnectionEventListener implements ConnectionEventListener
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(SimpleConnectionEventListener.class);
+
+ /** The managed connection */
+ private ManagedConnection mc;
+
+ /**
+ * Create a new SimpleConnectionEventListener.
+ *
+ * @param mc the managed connection
+ */
+ public SimpleConnectionEventListener(ManagedConnection mc)
+ {
+ this.mc = mc;
+ }
+
+ public void connectionClosed(ConnectionEvent event)
+ {
+ close();
+ }
+
+ public void connectionErrorOccurred(ConnectionEvent event)
+ {
+ log.warn("Connection Error occurred for " + mc, event.getException());
+ close();
+ }
+
+ public void localTransactionStarted(ConnectionEvent event)
+ {
+ }
+
+ public void localTransactionCommitted(ConnectionEvent event)
+ {
+ }
+
+ public void localTransactionRolledback(ConnectionEvent event)
+ {
+ }
+
+ /**
+ * Close the managed connection
+ */
+ protected void close()
+ {
+ ManagedConnection managedConnection = mc;
+ mc = null;
+ try
+ {
+ if (managedConnection != null)
+ managedConnection.destroy();
+ }
+ catch (ResourceException ignored)
+ {
+ log.trace("Ignored", ignored);
+ }
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/simple/SimpleConnectionManager.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/simple/SimpleConnectionManager.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/cm/simple/SimpleConnectionManager.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.cm.simple;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+
+/**
+ * SimpleConnectionManager.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class SimpleConnectionManager implements ConnectionManager
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -411325259312495917L;
+
+ public Object allocateConnection(ManagedConnectionFactory mcf, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ ManagedConnection mc = mcf.createManagedConnection(null, cxRequestInfo);
+ SimpleConnectionEventListener listener = new SimpleConnectionEventListener(mc);
+ mc.addConnectionEventListener(listener);
+ return mc.getConnection(null, cxRequestInfo);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cf/ConnectionFactoryAdvice.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cf/ConnectionFactoryAdvice.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cf/ConnectionFactoryAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.cf;
+
+import javax.resource.spi.ConnectionRequestInfo;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.rars.advice.AbstractRARInterceptor;
+
+/**
+ * ConnectionFactory advice.
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class ConnectionFactoryAdvice extends AbstractRARInterceptor
+{
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ MethodInvocation mi = (MethodInvocation) invocation;
+ GenericConnectionFactory cf = (GenericConnectionFactory) mi.getTargetObject();
+ ConnectionRequestInfo cri = cf.getConnectionRequestInfo(mi.getMethod(), mi.getArguments());
+ return cf.createConnection(cri);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cf/GenericConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cf/GenericConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cf/GenericConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,127 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.cf;
+
+import java.lang.reflect.Method;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+
+import org.jboss.rars.generic.mcf.GenericManagedConnectionFactory;
+import org.jboss.rars.generic.ra.ResourceErrorHandler;
+
+/**
+ * GenericConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public abstract class GenericConnectionFactory implements ResourceErrorHandler
+{
+ /** The managed connection factory */
+ private GenericManagedConnectionFactory mcf;
+
+ /** The delegate connection manager */
+ private ConnectionManager cm;
+
+ /**
+ * Create a new GenericConnectionFactory.
+ *
+ * @param mcf the managed connection factory
+ * @param cm the connection manager
+ */
+ public GenericConnectionFactory(GenericManagedConnectionFactory mcf, ConnectionManager cm)
+ {
+ this.mcf = mcf;
+ this.cm = cm;
+ }
+
+ /**
+ * Get the managed connection factory
+ *
+ * @return the managed connection factory
+ */
+ public GenericManagedConnectionFactory getManagedConnectionFactory()
+ {
+ return mcf;
+ }
+
+ /**
+ * Get the connection manager
+ *
+ * @return the connection manager
+ */
+ public ConnectionManager getConnectionManager()
+ {
+ return cm;
+ }
+
+ /**
+ * Get the connection request info
+ *
+ * @param method the method
+ * @param args the arguments
+ * @return the connection request info
+ * @throws ResourceException for any error
+ */
+ public ConnectionRequestInfo getConnectionRequestInfo(Method method, Object[] args) throws ResourceException
+ {
+ return mcf.getConnectionRequestInfo(this, method, args);
+ }
+
+ /**
+ * Allocate a connection
+ *
+ * @param cri the connection request info
+ * @return the connection
+ * @throws Exception for any error
+ */
+ public Object allocateConnection(ConnectionRequestInfo cri) throws ResourceException
+ {
+ ConnectionManager cm = getConnectionManager();
+ GenericManagedConnectionFactory mcf = getManagedConnectionFactory();
+ return cm.allocateConnection(mcf, cri);
+ }
+
+ /**
+ * Report a specific error
+ *
+ * @param context the context
+ * @param t the throwable
+ * @return never
+ * @throws the correct error
+ */
+ public Throwable throwError(Object context, Throwable t) throws Throwable
+ {
+ throw mcf.error(context, t);
+ }
+
+ /**
+ * Create a connection
+ *
+ * @param cri the connection request info
+ * @return the connection
+ * @throws Throwable for any error
+ */
+ public abstract Object createConnection(ConnectionRequestInfo cri) throws Throwable;
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/NoConnectionRequestInfo.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/NoConnectionRequestInfo.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/NoConnectionRequestInfo.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.cri;
+
+import javax.resource.spi.ConnectionRequestInfo;
+
+/**
+ * NoConnectionRequestInfo.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class NoConnectionRequestInfo implements ConnectionRequestInfo
+{
+ /** The singleton */
+ public static final NoConnectionRequestInfo NONE = new NoConnectionRequestInfo();
+
+ /**
+ * Create a new NoConnectionRequestInfo.
+ */
+ private NoConnectionRequestInfo()
+ {
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/SubjectCRIRequestID.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/SubjectCRIRequestID.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/SubjectCRIRequestID.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,90 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.cri;
+
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.security.auth.Subject;
+
+/**
+ * SubjectCRIRequestID.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class SubjectCRIRequestID
+{
+ /** The subject */
+ private Subject subject;
+
+ /** The connection request info */
+ private ConnectionRequestInfo cri;
+
+ /** The cached hashCode */
+ private int cachedHashCode = Integer.MIN_VALUE;
+
+ /**
+ * Create a new SubjectCRIRequestID.
+ *
+ * @param subject the subject
+ * @param cri the connection request info
+ */
+ public SubjectCRIRequestID(Subject subject, ConnectionRequestInfo cri)
+ {
+ this.subject = subject;
+ this.cri = cri;
+ }
+
+ public int hashCode()
+ {
+ if (cachedHashCode == Integer.MIN_VALUE)
+ {
+ int hashCode = 37;
+ if (subject != null)
+ hashCode = (37 + hashCode) * subject.hashCode();
+ if (cri != null)
+ hashCode = (37 + hashCode) * cri.hashCode();
+ }
+ return cachedHashCode;
+ }
+
+ public boolean equals(Object object)
+ {
+ if (this == object)
+ return true;
+ if (object == null || object instanceof SubjectCRIRequestID == false)
+ return false;
+
+ SubjectCRIRequestID other = (SubjectCRIRequestID) object;
+
+ if (this.subject == null && other.subject == null && this.cri == null && other.cri == null)
+ return true;
+ if (this.subject == null && other.subject != null)
+ return false;
+ if (this.subject != null && subject.equals(other) == false)
+ return false;
+ if (this.cri == null && other.cri != null)
+ return false;
+ if (this.cri != null && cri.equals(other.cri) == false)
+ return false;
+ return true;
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/UserPasswordConnectionRequestInfo.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/UserPasswordConnectionRequestInfo.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/cri/UserPasswordConnectionRequestInfo.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,124 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.cri;
+
+import javax.resource.spi.ConnectionRequestInfo;
+
+/**
+ * UserPasswordConnectionRequestInfo.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class UserPasswordConnectionRequestInfo implements ConnectionRequestInfo
+{
+ /** No user and password */
+ public static final UserPasswordConnectionRequestInfo NONE = new UserPasswordConnectionRequestInfo();
+
+ /** The user */
+ private String user;
+
+ /** The password */
+ private String password;
+
+ /** The hashCode */
+ private int cachedHashCode = Integer.MIN_VALUE;
+
+ /**
+ * Create a new UserPasswordConnectionRequestInfo.
+ */
+ public UserPasswordConnectionRequestInfo()
+ {
+ }
+
+ /**
+ * Create a new UserPasswordConnectionRequestInfo.
+ *
+ * @param user the user
+ * @param password the password
+ */
+ public UserPasswordConnectionRequestInfo(String user, String password)
+ {
+ this.user = user;
+ this.password = password;
+ }
+
+ /**
+ * Get the user.
+ *
+ * @return the user.
+ */
+ public String getUser()
+ {
+ return user;
+ }
+
+ /**
+ * Get the password.
+ *
+ * @return the password.
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public int hashCode()
+ {
+ if (cachedHashCode == Integer.MIN_VALUE)
+ {
+ int hashCode = 37;
+ if (user != null)
+ {
+ hashCode = (hashCode + 37) * user.hashCode();
+ // This is deliberate, we ignore the password if there is no user
+ if (password != null)
+ hashCode = (hashCode + 37) * password.hashCode();
+ }
+ cachedHashCode = hashCode;
+ }
+ return cachedHashCode;
+ }
+
+ public boolean equals(Object object)
+ {
+ if (this == object)
+ return true;
+ if (object == null || object instanceof UserPasswordConnectionRequestInfo == false)
+ return false;
+
+ UserPasswordConnectionRequestInfo other = (UserPasswordConnectionRequestInfo) object;
+
+ // This is deliberate, we ignore the password if there is no user
+ if (user == null && other.user == null)
+ return true;
+ if (user == null && other.user != null)
+ return false;
+ if (user.equals(other.user) == false)
+ return false;
+ if (password == null && other.password == null)
+ return true;
+ if (password == null && other.password != null)
+ return false;
+ return password.equals(other.password);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/GenericManagedConnection.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/GenericManagedConnection.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/GenericManagedConnection.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,408 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf;
+
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.LocalTransaction;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionMetaData;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.security.auth.Subject;
+import javax.transaction.xa.XAResource;
+
+import org.jboss.logging.Logger;
+import org.jboss.rars.generic.wrapper.GenericConnection;
+import org.jboss.rars.generic.wrapper.GenericHandle;
+import org.jboss.util.collection.CollectionsFactory;
+import org.jboss.util.JBossStringBuilder;
+import org.jboss.util.Strings;
+
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
+
+/**
+ * GenericManagedConnection.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class GenericManagedConnection implements ManagedConnection
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(GenericManagedConnection.class);
+
+ /** The writer */
+ private PrintWriter writer;
+
+ /** The managed connection factory */
+ private GenericManagedConnectionFactory mcf;
+
+ /** The connection */
+ private Object realConnection;
+
+ /** The request id */
+ private Object requestID;
+
+ /** Whether the managed connection is destroyed */
+ protected SynchronizedBoolean destroyed = new SynchronizedBoolean(false);
+
+ /** The associated connection handles */
+ private Set associated = CollectionsFactory.createCopyOnWriteSet();
+
+ /** The listeners */
+ private List listeners = CollectionsFactory.createCopyOnWriteList();
+
+ /** The connections by handle */
+ private Map connectionsByHandle = CollectionsFactory.createConcurrentReaderMap();
+
+ /**
+ * Create a new GenericManagedConnection.
+ *
+ * @param mcf the managed connection factory
+ * @param connection the real connection
+ * @param requestID the request id
+ */
+ protected GenericManagedConnection(GenericManagedConnectionFactory mcf, Object requestID)
+ {
+ this.mcf = mcf;
+ this.requestID = requestID;
+ log.debug(this + " CREATED");
+ }
+
+ /**
+ * Get the managed connection factory
+ *
+ * @return the managed connection factory
+ */
+ public GenericManagedConnectionFactory getManagedConnectionFactory()
+ {
+ return mcf;
+ }
+
+ /**
+ * Get the real connection.
+ *
+ * @return the connection.
+ */
+ public Object getRealConnection()
+ {
+ return realConnection;
+ }
+
+ protected void setRealConnection(Object connection)
+ {
+ if (realConnection != null)
+ throw new IllegalStateException("Connection is already set");
+ this.realConnection = connection;
+ }
+
+ public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ GenericConnection impl = mcf.createGenericConnection(this, subject, cxRequestInfo);
+ Class[] interfaces = mcf.getConnectionInterfaces(impl);
+ GenericHandle handle = impl.createHandle(interfaces);
+ connectionsByHandle.put(handle, impl);
+ associateConnection(impl);
+ return handle;
+ }
+
+ public void associateConnection(Object connection) throws ResourceException
+ {
+ GenericConnection wrapper = (GenericConnection) connectionsByHandle.get(connection);
+ if (wrapper == null)
+ throw new ResourceAdapterInternalException("Unknown connnection handle " + connection);
+ associateConnection(wrapper);
+ }
+
+ /**
+ * Associate a connection
+ *
+ * @param wrapper the connection
+ * @throws ResourceException for any error
+ */
+ protected void associateConnection(GenericConnection wrapper) throws ResourceException
+ {
+ wrapper.setManagedConnection(this);
+ associated.add(wrapper);
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace(this + " ASSOCIATE " + wrapper);
+ }
+
+ /**
+ * Disassociate a connection
+ *
+ * @param wrapper the connection
+ */
+ protected void disassociateConnection(GenericConnection wrapper)
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace(this + " DISASSOCIATE " + wrapper);
+ associated.remove(wrapper);
+ wrapper.setManagedConnection(null);
+ }
+
+ /**
+ * Close a wrapper
+ *
+ * @param wrapper the connection
+ */
+ public void close(GenericConnection wrapper)
+ {
+ if (destroyed.get())
+ return;
+ disassociateConnection(wrapper);
+ Object handle = wrapper.getProxy();
+ ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
+ event.setConnectionHandle(handle);
+ broadcastEvent(event);
+ connectionsByHandle.remove(handle);
+ }
+
+ public void cleanup() throws ResourceException
+ {
+ for (Iterator i = associated.iterator(); i.hasNext();)
+ {
+ GenericConnection wrapper = (GenericConnection) i.next();
+ disassociateConnection(wrapper);
+ }
+ }
+
+ public void safeDestroy()
+ {
+ try
+ {
+ destroy();
+ }
+ catch (Throwable ignored)
+ {
+ log.trace("Ignored", ignored);
+ }
+ }
+
+ public void destroy() throws ResourceException
+ {
+ log.debug(this + " DESTROY");
+ cleanup();
+ listeners.clear();
+ if (destroyed.set(true))
+ {
+ log.debug(this + " already destroyed");
+ return;
+ }
+ mcf.destroyRealConnection(this);
+ }
+
+ /**
+ * Test whether this managed connection matches the request
+ *
+ * @param requestID the request id
+ * @return true when it matches
+ */
+ protected boolean matches(Object requestID)
+ {
+ if (this.requestID == null && requestID == null)
+ return true;
+ if (this.requestID == null && requestID != null)
+ return false;
+ return this.requestID.equals(requestID);
+ }
+
+ public void addConnectionEventListener(ConnectionEventListener listener)
+ {
+ listeners.add(listener);
+ }
+
+ public void removeConnectionEventListener(ConnectionEventListener listener)
+ {
+ listeners.remove(listener);
+ }
+
+ /**
+ * Check whether an error is fatal
+ *
+ * @param t the error
+ */
+ public void checkFatal(Throwable t)
+ {
+ if (mcf.isFatal(t))
+ broadcastError(t);
+ }
+
+ /**
+ * Broadcast an error
+ *
+ * @param t the error
+ */
+ public void broadcastError(Throwable t)
+ {
+ Exception e;
+ if (t instanceof Exception)
+ e = (Exception) t;
+ else
+ e = new ResourceAdapterInternalException("Error ", t);
+
+ ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, e);
+ broadcastEvent(event);
+ safeDestroy();
+ }
+
+ /**
+ * Broadcast an event
+ *
+ * @param event the event
+ */
+ protected void broadcastEvent(ConnectionEvent event)
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ {
+ switch (event.getId())
+ {
+ case ConnectionEvent.CONNECTION_CLOSED:
+ {
+ log.trace(this + " CONNECTION_CLOSED " + event.getConnectionHandle());
+ break;
+ }
+ case ConnectionEvent.CONNECTION_ERROR_OCCURRED:
+ {
+ log.trace(this + " CONNECTION_ERROR", event.getException());
+ break;
+ }
+ case ConnectionEvent.LOCAL_TRANSACTION_STARTED:
+ {
+ log.trace(this + " LOCAL_TRANSACTION_STARTED");
+ break;
+ }
+ case ConnectionEvent.LOCAL_TRANSACTION_COMMITTED:
+ {
+ log.trace(this + " LOCAL_TRANSACTION_COMMITTED");
+ break;
+ }
+ case ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK:
+ {
+ log.trace(this + " LOCAL_TRANSACTION_ROLLEDBACK");
+ break;
+ }
+ }
+ }
+
+ if (listeners.size() == 0)
+ return;
+
+ for (Iterator i = listeners.iterator(); i.hasNext();)
+ {
+ ConnectionEventListener listener = (ConnectionEventListener) i.next();
+ try
+ {
+ switch (event.getId())
+ {
+ case ConnectionEvent.CONNECTION_CLOSED:
+ {
+ listener.connectionClosed(event);
+ break;
+ }
+ case ConnectionEvent.CONNECTION_ERROR_OCCURRED:
+ {
+ listener.connectionErrorOccurred(event);
+ break;
+ }
+ case ConnectionEvent.LOCAL_TRANSACTION_STARTED:
+ {
+ listener.localTransactionStarted(event);
+ break;
+ }
+ case ConnectionEvent.LOCAL_TRANSACTION_COMMITTED:
+ {
+ listener.localTransactionCommitted(event);
+ break;
+ }
+ case ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK:
+ {
+ listener.localTransactionRolledback(event);
+ break;
+ }
+ default:
+ throw new IllegalStateException("Illegal event id : " + event.getId());
+ }
+ }
+ catch (Throwable t)
+ {
+ log.warn("Ignored error from event listener " + listener + " event=" + event, t);
+ }
+ }
+ }
+
+ public LocalTransaction getLocalTransaction() throws ResourceException
+ {
+ // @todo getLocalTransaction
+ throw new org.jboss.util.NotImplementedException("getLocalTransaction");
+ }
+
+ public XAResource getXAResource() throws ResourceException
+ {
+ // @todo getXAResource
+ throw new org.jboss.util.NotImplementedException("getXAResource");
+ }
+
+ public ManagedConnectionMetaData getMetaData() throws ResourceException
+ {
+ // @todo getMetaData
+ throw new org.jboss.util.NotImplementedException("getMetaData");
+ }
+
+ public PrintWriter getLogWriter() throws ResourceException
+ {
+ return writer;
+ }
+
+ public void setLogWriter(PrintWriter out) throws ResourceException
+ {
+ this.writer = out;
+ }
+
+ protected void finalize() throws Throwable
+ {
+ if (destroyed.get() == false)
+ {
+ log.warn("Destroying undestroyed managed connection that is being garbage collection " + this);
+ safeDestroy();
+ }
+ }
+
+ public String toString()
+ {
+ JBossStringBuilder buffer = new JBossStringBuilder();
+ Strings.defaultToString(buffer, this);
+ buffer.append('[').append(getRealConnection()).append(']');
+ return buffer.toString();
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/GenericManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/GenericManagedConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/GenericManagedConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,584 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf;
+
+import java.io.PrintWriter;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterAssociation;
+import javax.security.auth.Subject;
+
+import org.jboss.aop.metadata.SimpleMetaData;
+import org.jboss.aop.proxy.container.AOPProxyFactory;
+import org.jboss.aop.proxy.container.AOPProxyFactoryParameters;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+import org.jboss.logging.Logger;
+import org.jboss.rars.cm.simple.SimpleConnectionManager;
+import org.jboss.rars.generic.cf.GenericConnectionFactory;
+import org.jboss.rars.generic.cri.NoConnectionRequestInfo;
+import org.jboss.rars.generic.cri.SubjectCRIRequestID;
+import org.jboss.rars.generic.ra.GenericResourceAdapter;
+import org.jboss.rars.generic.wrapper.GenericChild;
+import org.jboss.rars.generic.wrapper.GenericConnection;
+import org.jboss.rars.generic.wrapper.GenericHandle;
+import org.jboss.rars.generic.wrapper.GenericWrapper;
+import org.jboss.util.collection.CollectionsFactory;
+
+/**
+ * GenericManagedConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.7 $
+ */
+public abstract class GenericManagedConnectionFactory implements ManagedConnectionFactory, ResourceAdapterAssociation
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 8813394264813638739L;
+
+ /** The log */
+ private static final Logger log = Logger.getLogger(GenericManagedConnectionFactory.class);
+
+ /** The proxy factory */
+ private static final AOPProxyFactory proxyFactory = new GeneratedAOPProxyFactory();
+
+ /** No close method */
+ private static final Object NO_CLOSE_METHOD = new Object();
+
+ /** Cache of close methods Map<class name, method> */
+ private Map closeMethodCache = CollectionsFactory.createConcurrentReaderMap();
+
+ /** The writer */
+ private transient PrintWriter writer;
+
+ /** The resource adapter */
+ private transient GenericResourceAdapter ra;
+
+ /** The connection factory interfaces cache */
+ private transient Class[] connectionFactoryInterfaces;
+
+ /** The connection interfaces cache */
+ private transient Class[] connectionInterfaces;
+
+ /** The wrapped interfaces cache */
+ private transient Map wrappedInterfaces = CollectionsFactory.createConcurrentReaderMap();
+
+ public Object createConnectionFactory() throws ResourceException
+ {
+ ConnectionManager cxManager = new SimpleConnectionManager();
+ return createConnectionFactory(cxManager);
+ }
+
+ public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException
+ {
+ GenericConnectionFactory impl = createGenericConnectionFactory(cxManager);
+
+ Class[] interfaces = getConnectionFactoryInterfaces(impl);
+
+ Object connectionFactory = createProxy(interfaces, impl, null);
+ log.debug(this + " CREATED " + connectionFactory);
+ return connectionFactory;
+ }
+
+ /**
+ * Get the connection factory interfaces
+ *
+ * @param impl the implemetation
+ * @return the interfaces
+ * @throws ResourceException for any error
+ */
+ private Class[] getConnectionFactoryInterfaces(GenericConnectionFactory impl) throws ResourceException
+ {
+ if (connectionFactoryInterfaces == null)
+ {
+ Set interfaces = new HashSet();
+ addConnectionFactoryInterfaces(impl, interfaces);
+ addGenericConnectionFactoryInterfaces(impl, interfaces);
+ connectionFactoryInterfaces = (Class[]) interfaces.toArray(new Class[interfaces.size()]);
+ }
+ return connectionFactoryInterfaces;
+ }
+
+ /**
+ * Create a generic connection factory
+ *
+ * @param cxManager the connection manager
+ * @return the generic connection factory
+ * @throws ResourceException for any error
+ */
+ protected abstract GenericConnectionFactory createGenericConnectionFactory(ConnectionManager cxManager) throws ResourceException;
+
+ /**
+ * Get the connection factory interface
+ *
+ * @param impl the generic connection factory
+ * @param interfaces add the interfaces to this set
+ */
+ protected abstract void addConnectionFactoryInterfaces(GenericConnectionFactory impl, Set interfaces);
+
+ /**
+ * Add the generic connection factory interfaces
+ *
+ * @param impl the implementation
+ * @param interfaces add the interfaces to this set
+ * @throws ResourceException for any error
+ */
+ protected void addGenericConnectionFactoryInterfaces(GenericConnectionFactory impl, Set interfaces) throws ResourceException
+ {
+ Class clazz = impl.getClass();
+ addInterfaces(clazz, interfaces);
+ }
+
+ public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ Object requestID = getRequestID(subject, cxRequestInfo);
+ GenericManagedConnection mc = createManagedConnection(subject, cxRequestInfo, requestID);
+ Object connection = createRealConnection(mc, subject, cxRequestInfo, requestID);
+ mc.setRealConnection(connection);
+ return mc;
+ }
+
+ public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ if (connectionSet != null && connectionSet.size() >= 0)
+ {
+ Object requestID = getRequestID(subject, cxRequestInfo);
+ for (Iterator i = connectionSet.iterator(); i.hasNext();)
+ {
+ GenericManagedConnection managedConnection = (GenericManagedConnection) i.next();
+ if (managedConnection.matches(requestID))
+ return managedConnection;
+ }
+ }
+ return null;
+ }
+
+ public ResourceAdapter getResourceAdapter()
+ {
+ return ra;
+ }
+
+ public void setResourceAdapter(ResourceAdapter ra) throws ResourceException
+ {
+ this.ra = (GenericResourceAdapter) ra;
+ }
+
+ public PrintWriter getLogWriter() throws ResourceException
+ {
+ return writer;
+ }
+
+ public void setLogWriter(PrintWriter out) throws ResourceException
+ {
+ this.writer = out;
+ }
+
+ /**
+ * Is the method a close method
+ *
+ * @param method the method
+ * @return true when it is a close method
+ */
+ public boolean isCloseMethod(Method method)
+ {
+ return "close".equals(method.getName());
+ }
+
+ /**
+ * Find close method
+ *
+ * @param clazz the clazz
+ * @return the method or null when not found
+ */
+ protected Method findCloseMethod(Class clazz)
+ {
+ if (clazz.isInterface())
+ {
+ try
+ {
+ return clazz.getMethod("close", null);
+ }
+ catch (NoSuchMethodException ignored)
+ {
+ }
+ }
+ Class[] interfaces = clazz.getInterfaces();
+ for (int i = 0; i < interfaces.length; ++i)
+ {
+ Method method = findCloseMethod(interfaces[i]);
+ if (method != null)
+ return method;
+ }
+ return null;
+ }
+
+ /**
+ * Invoke close on an object
+ *
+ * @param wrapper the wrapper
+ * @param method @todo the method
+ * @param onProxy true for invoke close on the proxy
+ */
+ public void invokeClose(GenericWrapper wrapper, Method method, boolean onProxy)
+ {
+ Object object;
+ try
+ {
+ object = wrapper.getWrappedObject();
+ }
+ catch (Throwable t)
+ {
+ log.warn("Unable to get wrapped object to close " + wrapper, t);
+ return;
+ }
+
+ if (object == null)
+ {
+ log.warn("Wrapped object was null during close " + wrapper);
+ return;
+ }
+
+ Class clazz = object.getClass();
+ Object closeMethod = closeMethodCache.get(clazz.getName());
+ if (closeMethod == null)
+ {
+ if (method != null)
+ {
+ closeMethod = method;
+ }
+ else
+ {
+ closeMethod = findCloseMethod(clazz);
+ if (closeMethod == null)
+ {
+ log.trace("Unable to find close method " + wrapper);
+ closeMethod = NO_CLOSE_METHOD;
+ }
+ }
+ closeMethodCache.put(clazz.getName(), closeMethod);
+ }
+
+ if (method == null)
+ {
+ if (closeMethod == NO_CLOSE_METHOD)
+ {
+ if (onProxy)
+ wrapper.closeWrapper(null);
+ return;
+ }
+
+ method = (Method) closeMethod;
+ }
+
+ Object target = object;
+ if (onProxy)
+ target = wrapper.getProxy();
+ try
+ {
+ ReflectionUtil.invoke(target, method, null);
+ }
+ catch (Throwable t)
+ {
+ log.trace("Ignored error during close " + target, t);
+ }
+ }
+
+ /**
+ * Whether this result is the parent
+ *
+ * @param method the method
+ * @param parent the parent wrapper
+ * @param child the target child of the method
+ * @return true when result is parent
+ * @throws ResourceException for any error
+ */
+ public boolean isParent(Method method, GenericWrapper parentWrapper, GenericWrapper child) throws ResourceException
+ {
+ Class returnType = method.getReturnType();
+ Object parent = parentWrapper.getWrappedTarget();
+ return returnType.isInstance(parent);
+ }
+
+ /**
+ * Whether this result is a child
+ *
+ * @param method the method
+ * @param object the object
+ * @return true when a child
+ */
+ public boolean isChild(Method method, Object object)
+ {
+ Class returnType = method.getReturnType();
+ if (ignoreChild(method, object, returnType))
+ return false;
+ return isChild(method, object, returnType);
+ }
+
+ /**
+ * Whether we should ignore a child type
+ *
+ * @param method the method
+ * @param object the object
+ * @param type the type
+ * @return true when it should be ignored
+ */
+ protected boolean ignoreChild(Method method, Object object, Class type)
+ {
+ if (Collection.class.isAssignableFrom(type))
+ return true;
+ if (Map.class.isAssignableFrom(type))
+ return true;
+ if (Iterator.class.isAssignableFrom(type))
+ return true;
+ if (Enumeration.class.isAssignableFrom(type))
+ return true;
+ return false;
+ }
+
+ /**
+ * Whether we this is a child
+ *
+ * @param method the method
+ * @param object the object
+ * @param type the type
+ * @return true when it is a child
+ */
+ protected boolean isChild(Method method, Object object, Class type)
+ {
+ return type.isInterface();
+ }
+
+ /**
+ * Whether an error is fatal
+ *
+ * @param t the error
+ * @return true when the error is fatal
+ */
+ protected boolean isFatal(Throwable t)
+ {
+ if (t instanceof RuntimeException)
+ return true;
+ if (t instanceof Error)
+ return true;
+ return false;
+ }
+
+ /**
+ * Map an error
+ *
+ * @param context the context
+ * @param e the error
+ * @return the mapped error
+ */
+ public Throwable error(Object context, Throwable t)
+ {
+ return t;
+ }
+
+ /**
+ * Create a real connection
+ *
+ * @param mc the managed connection
+ * @param subject the subject
+ * @param cxRequestInfo the connection request info
+ * @param requestID the request id
+ * @return the connection
+ * @throws ResourceException for any error
+ */
+ protected abstract Object createRealConnection(GenericManagedConnection mc, Subject subject, ConnectionRequestInfo cxRequestInfo, Object requestID) throws ResourceException;
+
+ /**
+ * Destroy a real connection
+ *
+ * @param mc the managed connection
+ * @throws ResourceException for any error
+ */
+ protected abstract void destroyRealConnection(GenericManagedConnection mc) throws ResourceException;
+
+ /**
+ * Create a managed connection
+ *
+ * @param subject the subject
+ * @param cxRequestInfo the connection request info
+ * @param requestID the request id
+ * @return the managed connection
+ * @throws ResourceException for any error
+ */
+ protected GenericManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cxRequestInfo, Object requestID) throws ResourceException
+ {
+ return new GenericManagedConnection(this, requestID);
+ }
+
+ /**
+ * Get a connection request id
+ *
+ * @param subject the subject
+ * @param cxRequestInfo the request info
+ * @return the request id
+ * @throws ResourceException for any error
+ */
+ protected Object getRequestID(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ return new SubjectCRIRequestID(subject, cxRequestInfo);
+ }
+
+ /**
+ * Get the connection request info
+ *
+ * @param method the method
+ * @param args the arguments
+ * @return the connection request info
+ * @throws ResourceException for any error
+ */
+ public ConnectionRequestInfo getConnectionRequestInfo(GenericConnectionFactory cf, Method method, Object[] args) throws ResourceException
+ {
+ return NoConnectionRequestInfo.NONE;
+ }
+
+ /**
+ * Create the generic connection
+ *
+ * @param mc the managed connection
+ * @param subject the subject
+ * @param cri the connection request info
+ * @return the connection
+ * @throws ResourceException for any error
+ */
+ protected GenericConnection createGenericConnection(GenericManagedConnection mc, Subject subject, ConnectionRequestInfo cri) throws ResourceException
+ {
+ return new GenericConnection(mc);
+ }
+
+ /**
+ * Get the connection interfaces
+ *
+ * @param impl the implementation
+ * @return the interfaces
+ * @throws ResourceException for any error
+ */
+ protected Class[] getConnectionInterfaces(GenericConnection impl) throws ResourceException
+ {
+ if (connectionInterfaces == null)
+ {
+ Set interfaces = new HashSet();
+ addConnectionInterfaces(impl, interfaces);
+ interfaces.add(GenericHandle.class);
+ connectionInterfaces = (Class[]) interfaces.toArray(new Class[interfaces.size()]);
+ }
+ return connectionInterfaces;
+ }
+
+ /**
+ * Create a generic child
+ *
+ * @param impl the implementation
+ * @return the child
+ * @throws ResourceException for any error
+ */
+ public GenericWrapper createGenericChild(Object impl) throws ResourceException
+ {
+ return new GenericChild(this, impl);
+ }
+
+ /**
+ * Add the connection object's interfaces
+ *
+ * @param connection the connection
+ * @param interfaces add the interfaces to this set
+ * @throws ResourceException for any error
+ */
+ protected void addConnectionInterfaces(GenericConnection connection, Set interfaces) throws ResourceException
+ {
+ Object object = connection.getWrappedTarget();
+ Class clazz = object.getClass();
+ addInterfaces(clazz, interfaces);
+ }
+
+ /**
+ * Get the wrapped object's interfaces
+ *
+ * @param wrapper the wrapper
+ * @return the interfaces
+ * @throws ResourceException for any error
+ */
+ public Class[] getWrappedInterfaces(GenericWrapper wrapper) throws ResourceException
+ {
+ Object object = wrapper.getWrappedTarget();
+ Class clazz = object.getClass();
+ Class[] result = (Class[]) wrappedInterfaces.get(clazz);
+ if (result == null)
+ {
+ Set interfaces = new HashSet();
+ addInterfaces(clazz, interfaces);
+ interfaces.add(GenericHandle.class);
+ result = (Class[]) interfaces.toArray(new Class[interfaces.size()]);
+ wrappedInterfaces.put(clazz, result);
+ }
+ return result;
+ }
+
+ /**
+ * Add the implementation interfaces
+ *
+ * @param clazz the class
+ * @param interfaces add the interfaces to this set
+ * @throws ResourceException for any error
+ */
+ private void addInterfaces(Class clazz, Set interfaces) throws ResourceException
+ {
+ if (clazz == null)
+ return;
+ Class[] intfs = clazz.getInterfaces();
+ for (int i = 0; i < intfs.length; ++i)
+ interfaces.add(intfs[i]);
+ addInterfaces(clazz.getSuperclass(), interfaces);
+ }
+
+ /**
+ * Create a proxy
+ *
+ * @param interfaces the interfaces
+ * @param impl the implementation
+ * @return the proxy
+ */
+ public Object createProxy(Class[] interfaces, Object impl, SimpleMetaData metaData)
+ {
+ AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+ params.setObjectAsSuperClass(true);
+ params.setInterfaces(interfaces);
+ params.setSimpleMetaData(metaData);
+ params.setTarget(impl);
+
+ return proxyFactory.createAdvisedProxy(params);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/ReflectionUtil.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/ReflectionUtil.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/ReflectionUtil.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,136 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * ReflectionUtil.
+ *
+ * @todo move somewhere else
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+class ReflectionUtil
+{
+ /**
+ * Invoked on the target
+ *
+ * @param target the target
+ * @param method the method
+ * @param args the arguments
+ * @return the result
+ * @throws Throwable for any error
+ */
+ public static Object invoke(Object target, Method method, Object[] args) throws Throwable
+ {
+ try
+ {
+ return method.invoke(target, args);
+ }
+ catch (Throwable t)
+ {
+ throw handleErrors(target, method, args, t);
+ }
+ }
+
+ /**
+ * Handle invocation errors
+ *
+ * @param target the target
+ * @param method the method
+ * @param arguments the arguments
+ * @param t the error
+ * @return never
+ * @throws Throwable the throwable
+ */
+ public static Throwable handleErrors(Object target, Method method, Object[] arguments, Throwable t) throws Throwable
+ {
+ if (t instanceof IllegalArgumentException)
+ {
+ if (target == null)
+ throw new IllegalArgumentException("Null target for method " + method);
+ Class methodClass = method.getClass();
+ Class targetClass = target.getClass();
+ if (methodClass.isAssignableFrom(targetClass) == false)
+ throw new IllegalArgumentException("Wrong target. " + targetClass + " for " + method);
+ ArrayList expected = new ArrayList();
+ Class[] parameterTypes = method.getParameterTypes();
+ for (int i = 0; i < parameterTypes.length; ++i)
+ expected.add(parameterTypes[i].getName());
+ ArrayList actual = new ArrayList();
+ if (arguments != null)
+ {
+ for (int i = 0; i < arguments.length; ++i)
+ {
+ if (arguments[i] == null)
+ actual.add(null);
+ else
+ actual.add(arguments[i].getClass().getName());
+ }
+ }
+ throw new IllegalArgumentException("Wrong arguments. " + method.getName() + " expected=" + expected + " actual=" + actual);
+ }
+ else if (t instanceof InvocationTargetException)
+ {
+ throw ((InvocationTargetException) t).getTargetException();
+ }
+ throw t;
+ }
+
+ protected static void format(JBossStringBuilder buffer, String context, Method method, Object target)
+ {
+ buffer.append(context);
+ buffer.append("[method=").append(method.getDeclaringClass().getName());
+ buffer.append('.').append(method.getName());
+ buffer.append('(');
+ Class[] parameters = method.getParameterTypes();
+ for (int i = 0; i < parameters.length; ++i)
+ {
+ if (i > 0)
+ buffer.append(", ");
+ buffer.append(parameters[i].getName());
+ }
+ buffer.append(')');
+ buffer.append(" target=").append(target);
+ buffer.append(']');
+ }
+
+ protected static JBossStringBuilder format(String context, Method method, Object target)
+ {
+ JBossStringBuilder buffer = new JBossStringBuilder();
+ format(buffer, context, method, target);
+ return buffer;
+ }
+
+ protected static JBossStringBuilder format(String context, Method method, Object target, Object result)
+ {
+ JBossStringBuilder buffer = new JBossStringBuilder();
+ format(buffer, context, method, target);
+ buffer.append(" RESULT=").append(result);
+ return buffer;
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/DirectConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/DirectConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/DirectConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.direct;
+
+/**
+ * DirectConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public interface DirectConnectionFactory
+{
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/DirectGenericConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/DirectGenericConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/DirectGenericConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,47 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.direct;
+
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+
+import org.jboss.rars.generic.cf.GenericConnectionFactory;
+import org.jboss.rars.generic.mcf.GenericManagedConnectionFactory;
+
+public class DirectGenericConnectionFactory extends GenericConnectionFactory implements DirectConnectionFactory
+{
+ /**
+ * Create a new DirectGenericConnectionFactory.
+ *
+ * @param mcf the managed connection factory
+ * @param cm the connection manager
+ */
+ public DirectGenericConnectionFactory(GenericManagedConnectionFactory mcf, ConnectionManager cm)
+ {
+ super(mcf, cm);
+ }
+
+ public Object createConnection(ConnectionRequestInfo cri) throws Throwable
+ {
+ return allocateConnection(cri);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/DirectGenericManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/DirectGenericManagedConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/direct/DirectGenericManagedConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.direct;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+
+import org.jboss.rars.generic.cf.GenericConnectionFactory;
+import org.jboss.rars.generic.mcf.GenericManagedConnectionFactory;
+
+/**
+ * DirectGenericManagedConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public abstract class DirectGenericManagedConnectionFactory extends GenericManagedConnectionFactory
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 246264283973765682L;
+
+ protected GenericConnectionFactory createGenericConnectionFactory(ConnectionManager cxManager) throws ResourceException
+ {
+ return new DirectGenericConnectionFactory(this, cxManager);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/AbstractRealConnection.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/AbstractRealConnection.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/AbstractRealConnection.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,98 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.indirect;
+
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+
+import org.jboss.rars.generic.mcf.GenericManagedConnection;
+
+/**
+ * AbstractRealConnection.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public abstract class AbstractRealConnection implements RealConnection
+{
+ /** The managed connection */
+ private GenericManagedConnection mc;
+
+ /** The indirect connection */
+ private IndirectGenericConnection indirectConnection;
+
+ /**
+ * Create a new AbstractRealConnection.
+ *
+ * @param mc the managed connection
+ */
+ public AbstractRealConnection(GenericManagedConnection mc)
+ {
+ this.mc = mc;
+ RealConnectionEventListener listener = new RealConnectionEventListener();
+ mc.addConnectionEventListener(listener);
+ }
+
+ /**
+ * Get the managed connection
+ *
+ * @return the managed connection
+ */
+ public GenericManagedConnection getManagedConnection()
+ {
+ return mc;
+ }
+
+ public void setIndirectGenericConnection(IndirectGenericConnection indirectConnection)
+ {
+ if (indirectConnection == null)
+ throw new IllegalArgumentException("Null indirect connection");
+ if (this.indirectConnection != null)
+ throw new IllegalStateException("Already have an indirect connection");
+ this.indirectConnection = indirectConnection;
+ }
+
+ private class RealConnectionEventListener implements ConnectionEventListener
+ {
+ public void connectionClosed(ConnectionEvent event)
+ {
+ indirectConnection.realConnectionClosed(event.getConnectionHandle());
+ indirectConnection = null;
+ }
+
+ public void connectionErrorOccurred(ConnectionEvent event)
+ {
+ }
+
+ public void localTransactionStarted(ConnectionEvent event)
+ {
+ }
+
+ public void localTransactionCommitted(ConnectionEvent event)
+ {
+ }
+
+ public void localTransactionRolledback(ConnectionEvent event)
+ {
+ }
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectConnection.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectConnection.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectConnection.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.indirect;
+
+/**
+ * IndirectConnection.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public interface IndirectConnection
+{
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectConnectionAdvice.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectConnectionAdvice.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectConnectionAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.indirect;
+
+import javax.resource.spi.ConnectionRequestInfo;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.rars.advice.AbstractRARInterceptor;
+
+/**
+ * ConnectionFactory advice.
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class IndirectConnectionAdvice extends AbstractRARInterceptor
+{
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ MethodInvocation mi = (MethodInvocation) invocation;
+ IndirectGenericConnection c = (IndirectGenericConnection) mi.getTargetObject();
+ // @todo method and arguments
+ ConnectionRequestInfo cri = c.getConnectionRequestInfo();
+ return c.allocateConnection(cri);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.indirect;
+
+/**
+ * IndirectConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public interface IndirectConnectionFactory
+{
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectGenericConnection.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectGenericConnection.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectGenericConnection.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,139 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.indirect;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.IllegalStateException;
+
+import org.jboss.logging.Logger;
+import org.jboss.rars.generic.wrapper.GenericWrapper;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * IndirectGenericConnection.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class IndirectGenericConnection extends GenericWrapper
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(IndirectGenericConnection.class);
+
+ /** The connection request info */
+ private ConnectionRequestInfo cri;
+
+ /** The connection manager */
+ private ConnectionManager cm;
+
+ /** The real connection */
+ private RealConnection realConnection;
+
+ /**
+ * Create a new IndirectGenericConnection.
+ *
+ * @param mcf the managed connection factory
+ * @param cri the connection request info
+ */
+ public IndirectGenericConnection(IndirectGenericManagedConnectionFactory mcf, ConnectionManager cm, ConnectionRequestInfo cri)
+ {
+ super(mcf);
+ this.cm = cm;
+ this.cri = cri;
+ }
+
+ /**
+ * Get the connectionManager.
+ *
+ * @return the connectionManager.
+ */
+ public ConnectionManager getConnectionManager()
+ {
+ return cm;
+ }
+
+ /**
+ * Get the connectionRequestInfo.
+ *
+ * @return the connectionRequestInfo.
+ */
+ public ConnectionRequestInfo getConnectionRequestInfo()
+ {
+ return cri;
+ }
+
+ public Object allocateConnection(ConnectionRequestInfo cri) throws ResourceException
+ {
+ IndirectGenericManagedConnectionFactory mcf = (IndirectGenericManagedConnectionFactory) getManagedConnectionFactory();
+
+ if (realConnection != null)
+ throw new IllegalStateException(mcf.getSingletonError());
+
+ Object handle = cm.allocateConnection(mcf, cri);
+ if (handle instanceof RealConnection == false)
+ throw new IllegalStateException("Not a RealConnection " + handle + " interfaces=" + Arrays.asList(handle.getClass().getInterfaces()));
+ realConnection = (RealConnection) handle;
+ realConnection.setIndirectGenericConnection(this);
+ return realConnection;
+ }
+
+ public Object getWrappedObject() throws ResourceException
+ {
+ return this;
+ }
+
+ /**
+ * Notification that the real connection has been closed
+ *
+ * @param realConnection the real connection
+ */
+ public void realConnectionClosed(Object realConnection)
+ {
+ if (this.realConnection == realConnection)
+ this.realConnection = null;
+ }
+
+ protected void handleClose(Method method)
+ {
+ if (realConnection != null)
+ {
+ try
+ {
+ realConnection.closeFromIndirectConnection();
+ }
+ catch (Throwable ignored)
+ {
+ log.trace("Ignored error in close", ignored);
+ }
+ }
+ }
+
+ protected void toString(JBossStringBuilder buffer)
+ {
+ buffer.append(cri);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectGenericConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectGenericConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectGenericConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.indirect;
+
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+
+import org.jboss.rars.generic.cf.GenericConnectionFactory;
+
+/**
+ * IndirectGenericConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class IndirectGenericConnectionFactory extends GenericConnectionFactory implements IndirectConnectionFactory
+{
+ /**
+ * Create a new IndirectGenericConnectionFactory.
+ *
+ * @param mcf the managed connection factory
+ * @param cm the connection manager
+ */
+ public IndirectGenericConnectionFactory(IndirectGenericManagedConnectionFactory mcf, ConnectionManager cm)
+ {
+ super(mcf, cm);
+ }
+
+ public Object createConnection(ConnectionRequestInfo cri) throws Throwable
+ {
+ ConnectionManager cm = getConnectionManager();
+ IndirectGenericManagedConnectionFactory mcf = (IndirectGenericManagedConnectionFactory) getManagedConnectionFactory();
+ return mcf.createIndirectConnection(cm, cri);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectGenericManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectGenericManagedConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/IndirectGenericManagedConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,151 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.indirect;
+
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ResourceAdapterInternalException;
+
+import org.jboss.rars.generic.cf.GenericConnectionFactory;
+import org.jboss.rars.generic.mcf.GenericManagedConnection;
+import org.jboss.rars.generic.mcf.GenericManagedConnectionFactory;
+import org.jboss.rars.generic.wrapper.GenericConnection;
+
+/**
+ * DirectGenericManagedConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public abstract class IndirectGenericManagedConnectionFactory extends GenericManagedConnectionFactory
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -2214678871251343168L;
+
+ /** Our close method */
+ private static final Method CLOSE_FROM_INDIRECT_CONNECTION;
+
+ /** The indirect connection interfaces */
+ private Class[] indirectConnectionInterfaces;
+
+ static
+ {
+ try
+ {
+ CLOSE_FROM_INDIRECT_CONNECTION = RealConnection.class.getMethod("closeFromIndirectConnection", null);
+ }
+ catch (NoSuchMethodException e)
+ {
+ throw new ExceptionInInitializerError(e);
+ }
+ }
+
+ protected GenericConnectionFactory createGenericConnectionFactory(ConnectionManager cxManager) throws ResourceException
+ {
+ return new IndirectGenericConnectionFactory(this, cxManager);
+ }
+
+ /**
+ * Create the indirect connection
+ *
+ * @param cm the connecton manager
+ * @param cri the connection request info
+ * @return the indirect connection
+ * @throws Throwable for any error
+ */
+ public Object createIndirectConnection(ConnectionManager cm, ConnectionRequestInfo cri) throws Throwable
+ {
+ IndirectGenericConnection impl = new IndirectGenericConnection(this, cm, cri);
+
+ Class[] interfaces = getIndirectConnectionInterfaces(impl);
+ Object connection = impl.createProxy(interfaces, impl);
+ return connection;
+ }
+
+ /**
+ * Get the indirect connection interfaces
+ *
+ * @param impl the implemetation
+ * @return the interfaces
+ * @throws ResourceException for any error
+ */
+ private Class[] getIndirectConnectionInterfaces(IndirectGenericConnection impl) throws ResourceException
+ {
+ if (indirectConnectionInterfaces == null)
+ {
+ Set interfaces = new HashSet();
+ addIndirectConnectionInterfaces(impl, interfaces);
+ interfaces.add(IndirectConnection.class);
+ indirectConnectionInterfaces = (Class[]) interfaces.toArray(new Class[interfaces.size()]);
+ }
+ return indirectConnectionInterfaces;
+ }
+
+ /**
+ * Add the connection interfaces
+ *
+ * @param connection the connection
+ * @param interfaces the interfaces
+ */
+ protected abstract void addIndirectConnectionInterfaces(IndirectGenericConnection connection, Set interfaces);
+
+ protected void addConnectionInterfaces(GenericConnection connection, Set interfaces) throws ResourceException
+ {
+ interfaces.add(RealConnection.class);
+ super.addConnectionInterfaces(connection, interfaces);
+ }
+
+ public boolean isCloseMethod(Method method)
+ {
+ if (super.isCloseMethod(method))
+ return true;
+ return CLOSE_FROM_INDIRECT_CONNECTION.equals(method);
+ }
+
+ protected void destroyRealConnection(GenericManagedConnection mc) throws ResourceException
+ {
+ RealConnection connection = (RealConnection) mc.getRealConnection();
+ try
+ {
+ connection.closeFromIndirectConnection();
+ }
+ catch (Throwable t)
+ {
+ throw new ResourceAdapterInternalException("Error closing the connection", t);
+ }
+ }
+
+ /**
+ * Report the singleton error
+ *
+ * @return the single error
+ */
+ protected String getSingletonError()
+ {
+ return "You are only allowed to have one child object open at once";
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/RealConnection.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/RealConnection.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/indirect/RealConnection.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.indirect;
+
+/**
+ * RealConnection.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public interface RealConnection
+{
+ /**
+ * Set the indirect connection
+ *
+ * @param indirectConnection the indirect connection
+ */
+ void setIndirectGenericConnection(IndirectGenericConnection indirectConnection);
+
+ /**
+ * Close the connection
+ *
+ * @param indirectConnection the indirect connection
+ * @throws Exception for any error
+ */
+ void closeFromIndirectConnection() throws Exception;
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jdbc/JDBCManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jdbc/JDBCManagedConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jdbc/JDBCManagedConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.jdbc;
+
+import java.sql.SQLException;
+import java.util.Set;
+
+import javax.sql.DataSource;
+
+import org.jboss.rars.generic.cf.GenericConnectionFactory;
+import org.jboss.rars.generic.mcf.direct.DirectGenericManagedConnectionFactory;
+
+/**
+ * JDBCManagedConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public abstract class JDBCManagedConnectionFactory extends DirectGenericManagedConnectionFactory
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -710101414887209297L;
+
+ public Throwable error(Object context, Throwable t)
+ {
+ if (t instanceof SQLException)
+ return t;
+ SQLException e = new SQLException("Error during " + context);
+ e.initCause(t);
+ return e;
+ }
+
+ protected void addConnectionFactoryInterfaces(GenericConnectionFactory impl, Set interfaces)
+ {
+ interfaces.add(DataSource.class);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jdbc/local/LocalJDBCManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jdbc/local/LocalJDBCManagedConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jdbc/local/LocalJDBCManagedConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,349 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.jdbc.local;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.Properties;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.ResourceAllocationException;
+import javax.resource.spi.security.PasswordCredential;
+import javax.security.auth.Subject;
+
+import org.jboss.logging.Logger;
+import org.jboss.rars.generic.cf.GenericConnectionFactory;
+import org.jboss.rars.generic.cri.UserPasswordConnectionRequestInfo;
+import org.jboss.rars.generic.mcf.GenericManagedConnection;
+import org.jboss.rars.generic.mcf.jdbc.JDBCManagedConnectionFactory;
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * LocalJDBCManagedConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class LocalJDBCManagedConnectionFactory extends JDBCManagedConnectionFactory
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 29477823548495724L;
+
+ /** The log */
+ private static final Logger log = Logger.getLogger(LocalJDBCManagedConnectionFactory.class);
+
+ /** The user */
+ protected String user;
+
+ /** The password */
+ protected String password;
+
+ /** The connection url */
+ protected String connectionURL;
+
+ /** The driver class */
+ protected String driverClassName;
+
+ /** The connection properties as a string */
+ protected String connectionProperties;
+
+ /** The connection properties */
+ protected Properties connectionProps = new Properties();
+
+ /**
+ * Get the user.
+ *
+ * @return the user.
+ */
+ public String getUser()
+ {
+ return user;
+ }
+
+ /**
+ * Set the user.
+ *
+ * @param user the user.
+ */
+ public void setUser(String user)
+ {
+ this.user = user;
+ }
+
+ /**
+ * Get the password.
+ *
+ * @return the password.
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ /**
+ * Set the password.
+ *
+ * @param password the password.
+ */
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ /**
+ * Get the connectionURL.
+ *
+ * @return the connectionURL.
+ */
+ public String getConnectionURL()
+ {
+ return connectionURL;
+ }
+
+ /**
+ * Set the connectionURL.
+ *
+ * @param connectionURL the connectionURL.
+ */
+ public void setConnectionURL(String connectionURL)
+ {
+ this.connectionURL = connectionURL;
+ }
+
+ /**
+ * Get the driverClassName.
+ *
+ * @return the driverClassName.
+ */
+ public String getDriverClassName()
+ {
+ return driverClassName;
+ }
+
+ /**
+ * Set the driverClassName.
+ *
+ * @param driverClassName the driverClassName.
+ */
+ public void setDriverClassName(String driverClassName)
+ {
+ this.driverClassName = driverClassName;
+ }
+
+ /**
+ * Get the value of connectionProperties.
+ *
+ * @return value of connectionProperties.
+ */
+ public String getConnectionProperties()
+ {
+ return connectionProperties;
+ }
+
+ /**
+ * Set the value of connectionProperties.
+ *
+ * @param connectionProperties Value to assign to connectionProperties.
+ */
+ public void setConnectionProperties(String connectionProperties)
+ {
+ this.connectionProperties = connectionProperties;
+ connectionProps.clear();
+ if (connectionProperties != null)
+ {
+ // Map any \ to \\
+ connectionProperties = connectionProperties.replaceAll("\\\\", "\\\\\\\\");
+
+ InputStream is = new ByteArrayInputStream(connectionProperties.getBytes());
+ try
+ {
+ connectionProps.load(is);
+ }
+ catch (IOException ioe)
+ {
+ throw new NestedRuntimeException("Could not load connection properties", ioe);
+ }
+ }
+ }
+
+ public ConnectionRequestInfo getConnectionRequestInfo(GenericConnectionFactory cf, Method method, Object[] args) throws ResourceException
+ {
+ if (args == null || args.length != 2)
+ return UserPasswordConnectionRequestInfo.NONE;
+ else
+ {
+ String user = (String) args[0];
+ String password = (String) args[1];
+ return new UserPasswordConnectionRequestInfo(user, password);
+ }
+ }
+
+ /**
+ * Get the connection properties
+ *
+ * @param subject the subject
+ * @param cxRequestInfo the connection request info
+ * @return the properties
+ * @throws ResourceException for any error
+ */
+ protected Object getRequestID(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ Properties props = new Properties();
+ props.putAll(connectionProps);
+ if (subject != null)
+ {
+ if (SubjectActions.addMatchingProperties(subject, props, this) == true)
+ return props;
+ throw new ResourceAdapterInternalException("No matching credentials in Subject!");
+ }
+
+ if (cxRequestInfo != null && cxRequestInfo instanceof UserPasswordConnectionRequestInfo == false)
+ throw new ResourceAdapterInternalException("Wrong kind of ConnectionRequestInfo: " + cxRequestInfo.getClass());
+
+ UserPasswordConnectionRequestInfo cri = (UserPasswordConnectionRequestInfo) cxRequestInfo;
+ if (cri != null)
+ {
+ if (cri.getUser() != null)
+ {
+ props.setProperty("user", cri.getUser());
+ props.setProperty("password", (cri.getPassword() == null)? "": cri.getPassword());
+ return props;
+ }
+ }
+
+ if (user != null)
+ {
+ props.setProperty("user", user);
+ props.setProperty("password", (password == null) ? "" : password);
+ }
+
+ return props;
+ }
+
+ protected Object createRealConnection(GenericManagedConnection mc, Subject subject, ConnectionRequestInfo cxRequestInfo, Object requestID) throws ResourceException
+ {
+ Properties props = (Properties) requestID;
+
+ // Some friendly drivers (Oracle, you guessed right) modify the props you supply.
+ // Since we use our copy to identify compatibility in matchManagedConnection, we need
+ // a pristine copy for our own use. So give the friendly driver a copy.
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ {
+ // Make yet another copy to mask the password
+ Properties logCopy = props;
+ if (props.getProperty("password") != null)
+ {
+ logCopy = (Properties) props.clone();
+ logCopy.setProperty("password", "--hidden--");
+ }
+ log.trace("Using properties: " + logCopy);
+ }
+
+ try
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Class.forName(driverClassName, true, cl);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ResourceAdapterInternalException("Unable to load driver class " + driverClassName, e);
+ }
+
+ try
+ {
+ return DriverManager.getConnection(connectionURL, props);
+ }
+ catch (SQLException e)
+ {
+ throw new ResourceAllocationException("Unable to get connection url=" + connectionURL + " user=" + user, e);
+ }
+ }
+
+ protected void destroyRealConnection(GenericManagedConnection mc) throws ResourceException
+ {
+ Connection connection = (Connection) mc.getRealConnection();
+ try
+ {
+ connection.close();
+ }
+ catch (SQLException e)
+ {
+ throw new ResourceAdapterInternalException("Error closing the connection", e);
+ }
+ }
+
+ static class SubjectActions implements PrivilegedAction
+ {
+ Subject subject;
+
+ Properties props;
+
+ ManagedConnectionFactory mcf;
+
+ SubjectActions(Subject subject, Properties props, ManagedConnectionFactory mcf)
+ {
+ this.subject = subject;
+ this.props = props;
+ this.mcf = mcf;
+ }
+
+ public Object run()
+ {
+ Iterator i = subject.getPrivateCredentials().iterator();
+ while (i.hasNext())
+ {
+ Object o = i.next();
+ if (o instanceof PasswordCredential)
+ {
+ PasswordCredential cred = (PasswordCredential) o;
+ if (cred.getManagedConnectionFactory().equals(mcf))
+ {
+ props.setProperty("user", (cred.getUserName() == null) ? "" : cred.getUserName());
+ if( cred.getPassword() != null )
+ props.setProperty("password", new String(cred.getPassword()));
+ return Boolean.TRUE;
+ }
+ }
+ }
+ return Boolean.FALSE;
+ }
+
+ static boolean addMatchingProperties(Subject subject, Properties props, ManagedConnectionFactory mcf)
+ {
+ SubjectActions action = new SubjectActions(subject, props, mcf);
+ Boolean matched = (Boolean) AccessController.doPrivileged(action);
+ return matched.booleanValue();
+ }
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jms/JMSManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jms/JMSManagedConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jms/JMSManagedConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,227 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.jms;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.Set;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.ExceptionListener;
+import javax.jms.IllegalStateException;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.Session;
+import javax.jms.TopicConnection;
+import javax.jms.TopicConnectionFactory;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.security.auth.Subject;
+
+import org.jboss.rars.generic.cf.GenericConnectionFactory;
+import org.jboss.rars.generic.mcf.GenericManagedConnection;
+import org.jboss.rars.generic.mcf.indirect.IndirectGenericConnection;
+import org.jboss.rars.generic.mcf.indirect.IndirectGenericManagedConnectionFactory;
+
+/**
+ * JMSManagedConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class JMSManagedConnectionFactory extends IndirectGenericManagedConnectionFactory
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 8122176068763448640L;
+
+ /** The user */
+ protected String user;
+
+ /** The password */
+ protected String password;
+
+ /** The connection factory */
+ protected ConnectionFactory connectionFactory;
+
+ /**
+ * Get the user.
+ *
+ * @return the user.
+ */
+ public String getUser()
+ {
+ return user;
+ }
+
+ /**
+ * Set the user.
+ *
+ * @param user the user.
+ */
+ public void setUser(String user)
+ {
+ this.user = user;
+ }
+
+ /**
+ * Get the password.
+ *
+ * @return the password.
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ /**
+ * Set the password.
+ *
+ * @param password the password.
+ */
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
+
+ /**
+ * Get the connectionFactory.
+ *
+ * @return the connectionFactory.
+ */
+ public ConnectionFactory getConnectionFactory()
+ {
+ return connectionFactory;
+ }
+
+ /**
+ * Set the connectionFactory.
+ *
+ * @param connectionFactory the connectionFactory.
+ */
+ public void setConnectionFactory(ConnectionFactory connectionFactory)
+ {
+ this.connectionFactory = connectionFactory;
+ }
+
+ protected void addConnectionFactoryInterfaces(GenericConnectionFactory impl, Set interfaces)
+ {
+ interfaces.add(ConnectionFactory.class);
+ interfaces.add(QueueConnectionFactory.class);
+ interfaces.add(TopicConnectionFactory.class);
+ interfaces.add(Serializable.class);
+ }
+
+ protected void addIndirectConnectionInterfaces(IndirectGenericConnection connection, Set interfaces)
+ {
+ interfaces.add(Connection.class);
+ interfaces.add(QueueConnection.class);
+ interfaces.add(TopicConnection.class);
+ }
+
+ public Throwable error(Object context, Throwable t)
+ {
+ if (t instanceof JMSException)
+ return t;
+ JMSException e;
+ if (t instanceof javax.resource.spi.IllegalStateException)
+ e = new IllegalStateException("Error during " + context);
+ else
+ e = new JMSException("Error during " + context);
+ e.initCause(t);
+ return e;
+ }
+
+ protected Object createRealConnection(GenericManagedConnection mc, Subject subject, ConnectionRequestInfo cxRequestInfo, Object requestID) throws ResourceException
+ {
+ Connection connection;
+ try
+ {
+ // @todo user/password
+ connection = connectionFactory.createConnection();
+ }
+ catch (JMSException e)
+ {
+ throw new ResourceAdapterInternalException("Unable to create connection ", e);
+ }
+
+ try
+ {
+ // @todo client id
+ JMSRealConnection handle = new JMSRealConnection(mc, connection);
+ JMSExceptionListener exceptionListener = new JMSExceptionListener(mc);
+ connection.setExceptionListener(exceptionListener);
+ connection.start();
+
+ // @todo parameters and XASession
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ handle.setSession(session);
+ return handle;
+ }
+ catch (Throwable t)
+ {
+ try
+ {
+ connection.close();
+ }
+ catch (Throwable ignored)
+ {
+ }
+ throw new ResourceAdapterInternalException("Error initializing the connection", t);
+ }
+ }
+
+ protected boolean ignoreChild(Method method, Object object, Class type)
+ {
+ if (Message.class.isAssignableFrom(type))
+ return true;
+ return super.ignoreChild(method, object, type);
+ }
+
+ protected String getSingletonError()
+ {
+ return JMSRealConnection.DUPLICATE;
+ }
+
+ protected class JMSExceptionListener implements ExceptionListener
+ {
+ private GenericManagedConnection mc;
+
+ /**
+ * Create a new JMSExceptionListener.
+ *
+ * @param mc the managed connection
+ */
+ public JMSExceptionListener(GenericManagedConnection mc)
+ {
+ this.mc = mc;
+ }
+
+ public void onException(JMSException exception)
+ {
+ mc.broadcastError(exception);
+ }
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jms/JMSRealConnection.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jms/JMSRealConnection.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/mcf/jms/JMSRealConnection.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,89 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.mcf.jms;
+
+import javax.jms.Connection;
+import javax.jms.Session;
+
+import org.jboss.rars.generic.mcf.GenericManagedConnection;
+import org.jboss.rars.generic.mcf.indirect.AbstractRealConnection;
+import org.jboss.rars.generic.wrapper.WrappedObject;
+
+/**
+ * JMSRealConnection.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+class JMSRealConnection extends AbstractRealConnection implements WrappedObject
+{
+ /** Error message for strict behaviour */
+ static final String ISE = "This method is not applicable inside the application server. See the J2EE spec, e.g. J2EE1.4 Section 6.6";
+
+ /** Error message for multiple sessions */
+ static final String DUPLICATE = "Only one session is allowed per connection inside the application server. See the J2EE spec, e.g. J2EE1.4 Section 6.6";
+
+ /** The connection */
+ private Connection connection;
+
+ /** The session */
+ private Session session;
+
+ /**
+ * Create a new JMSRealConnection.
+ *
+ * @param mc the managed connection
+ * @param connection the connection
+ */
+ public JMSRealConnection(GenericManagedConnection mc, Connection connection)
+ {
+ super(mc);
+ this.connection = connection;
+ }
+
+ /**
+ * Set the session.
+ *
+ * @param session the session.
+ */
+ protected void setSession(Session session)
+ {
+ this.session = session;
+ }
+
+ public Object getWrappedObject()
+ {
+ return session;
+ }
+
+ public void closeFromIndirectConnection() throws Exception
+ {
+ connection.close();
+ }
+
+ public String toString()
+ {
+ if (session == null)
+ return super.toString();
+ return session.toString();
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/ra/GenericResourceAdapter.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/ra/GenericResourceAdapter.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/ra/GenericResourceAdapter.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,84 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.ra;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.transaction.xa.XAResource;
+
+/**
+ * GenericResourceAdapter.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class GenericResourceAdapter implements ResourceAdapter
+{
+ /** The bootstrap context */
+ private BootstrapContext ctx;
+
+ /**
+ * Get the bootstrap context
+ *
+ * @return the context
+ */
+ public BootstrapContext getBootstrapContext()
+ {
+ return ctx;
+ }
+
+ public void start(BootstrapContext ctx) throws ResourceAdapterInternalException
+ {
+ this.ctx = ctx;
+ // @todo start
+ }
+
+ public void stop()
+ {
+ // @todo stop
+ this.ctx = null;
+ }
+
+ public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException
+ {
+ // @todo endpointActivation
+ throw new org.jboss.util.NotImplementedException("endpointActivation");
+
+ }
+
+ public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec)
+ {
+ // @todo endpointDeactivation
+ throw new org.jboss.util.NotImplementedException("endpointDeactivation");
+
+ }
+
+ public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException
+ {
+ // @todo getXAResources
+ throw new org.jboss.util.NotImplementedException("getXAResources");
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/ra/ResourceErrorHandler.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/ra/ResourceErrorHandler.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/ra/ResourceErrorHandler.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.ra;
+
+/**
+ * ResourceErrorHandler.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public interface ResourceErrorHandler
+{
+ /**
+ * Report a specific error
+ *
+ * @param context the context
+ * @param t the throwable
+ * @return never
+ * @throws the correct error
+ */
+ Throwable throwError(Object context, Throwable t) throws Throwable;
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/ClosedAdvice.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/ClosedAdvice.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/ClosedAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.wrapper;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.rars.advice.AbstractRARInterceptor;
+
+/**
+ * Connection Close advice.
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class ClosedAdvice extends AbstractRARInterceptor
+{
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ MethodInvocation mi = (MethodInvocation) invocation;
+ GenericWrapper wrapper = (GenericWrapper) mi.getMetaData(GenericWrapper.METADATA_KEY, GenericWrapper.METADATA_KEY);
+
+ if (wrapper.isClosed())
+ throw wrapper.throwError(format(invocation), new Exception("Already closed"));
+ return invocation.invokeNext();
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericChild.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericChild.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericChild.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,79 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.wrapper;
+
+import java.lang.reflect.Method;
+
+import javax.resource.ResourceException;
+
+import org.jboss.logging.Logger;
+import org.jboss.rars.generic.mcf.GenericManagedConnectionFactory;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * GenericChild.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class GenericChild extends GenericWrapper implements GenericHandle
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(GenericChild.class);
+
+ /** Whether trace is enabled */
+ private boolean trace = log.isTraceEnabled();
+
+ /** The target */
+ protected Object target;
+
+ /**
+ * Create a new GenericChild.
+ *
+ * @param mcf the managed connection factory
+ * @param target the target
+ */
+ public GenericChild(GenericManagedConnectionFactory mcf, Object target)
+ {
+ super(mcf);
+ if (target == null)
+ throw new IllegalStateException("Null target");
+ this.target = target;
+ if (trace)
+ log.trace(this + " CREATED");
+ }
+
+ public Object getWrappedObject() throws ResourceException
+ {
+ return target;
+ }
+
+ protected void handleClose(Method method)
+ {
+ getManagedConnectionFactory().invokeClose(this, method, false);
+ }
+
+ protected void toString(JBossStringBuilder buffer)
+ {
+ buffer.append(target);
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericConnection.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericConnection.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericConnection.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,117 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.wrapper;
+
+import java.lang.reflect.Method;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ResourceAdapterInternalException;
+
+import org.jboss.logging.Logger;
+import org.jboss.rars.generic.mcf.GenericManagedConnection;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * GenericConnection.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class GenericConnection extends GenericWrapper implements GenericHandle
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(GenericConnection.class);
+
+ /** Whether trace is enabled */
+ private boolean trace = log.isTraceEnabled();
+
+ /** The managed connection */
+ private GenericManagedConnection managedConnection;
+
+ /**
+ * Create a new GenericConnection.
+ *
+ * @param managedConnection the managed connection
+ */
+ public GenericConnection(GenericManagedConnection managedConnection)
+ {
+ super(managedConnection.getManagedConnectionFactory());
+ setManagedConnection(managedConnection);
+ if (trace)
+ log.trace(this + " CREATED");
+ }
+
+ /**
+ * Get the managed connection
+ *
+ * @return the managed connection
+ */
+ protected GenericManagedConnection getManagedConnection()
+ {
+ return managedConnection;
+ }
+
+ /**
+ * Set the managed connection
+ *
+ * @param managedConnection the managed connection
+ */
+ public void setManagedConnection(GenericManagedConnection managedConnection)
+ {
+ this.managedConnection = managedConnection;
+ if (managedConnection != null)
+ setManagedConnectionFactory(managedConnection.getManagedConnectionFactory());
+ }
+
+ public Object getWrappedObject() throws ResourceException
+ {
+ GenericManagedConnection managedConnection = getManagedConnection();
+ if (managedConnection == null)
+ throw new ResourceAdapterInternalException("Connection is not associated with a managed connection");
+ return managedConnection.getRealConnection();
+ }
+
+ protected void checkFatal(Throwable t)
+ {
+ // Looks like it is already broken and handled
+ if (managedConnection == null)
+ return;
+ managedConnection.checkFatal(t);
+ }
+
+ protected void handleClose(Method method)
+ {
+ GenericManagedConnection managedConnection = getManagedConnection();
+ if (managedConnection == null)
+ return;
+ managedConnection.close(this);
+ }
+
+ protected void toString(JBossStringBuilder buffer)
+ {
+ GenericManagedConnection managedConnection = getManagedConnection();
+ if (managedConnection == null)
+ buffer.append("null");
+ else
+ buffer.append(managedConnection.getRealConnection());
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericHandle.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericHandle.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericHandle.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.wrapper;
+
+/**
+ * GenericHandle.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public interface GenericHandle
+{
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericWrapper.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericWrapper.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/GenericWrapper.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,388 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.wrapper;
+
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+
+import org.jboss.aop.metadata.SimpleMetaData;
+import org.jboss.logging.Logger;
+import org.jboss.rars.generic.mcf.GenericManagedConnectionFactory;
+import org.jboss.rars.generic.ra.ResourceErrorHandler;
+import org.jboss.util.collection.CollectionsFactory;
+import org.jboss.util.JBossStringBuilder;
+import org.jboss.util.Strings;
+
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
+
+/**
+ * GenericWrapper.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public abstract class GenericWrapper implements ResourceErrorHandler
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(GenericWrapper.class);
+
+ /** The metadata key */
+ public static final String METADATA_KEY = GenericWrapper.class.getName();
+
+ /** Whether trace is enabled */
+ private boolean trace = log.isTraceEnabled();
+
+ /** The managed connection factory */
+ private GenericManagedConnectionFactory mcf;
+
+ /** The proxy */
+ private Object proxy;
+
+ /** Whether we are closed */
+ private SynchronizedBoolean closed = new SynchronizedBoolean(false);
+
+ /** The parent */
+ private GenericWrapper parent;
+
+ /** The children */
+ private Set children = CollectionsFactory.createCopyOnWriteSet();
+
+ /**
+ * Create a new GenericWrapper.
+ *
+ * @param mcf the managed connection factory
+ */
+ protected GenericWrapper(GenericManagedConnectionFactory mcf)
+ {
+ this.mcf = mcf;
+ }
+
+ /**
+ * Get the managed connection factory
+ *
+ * @return the managed connection factory
+ */
+ public GenericManagedConnectionFactory getManagedConnectionFactory()
+ {
+ return mcf;
+ }
+
+ /**
+ * Set the managed connection factory
+ *
+ * @param mcf the managed connection factory
+ */
+ protected void setManagedConnectionFactory(GenericManagedConnectionFactory mcf)
+ {
+ this.mcf = mcf;
+ }
+
+ /**
+ * Get the proxy.
+ *
+ * @return the proxy.
+ */
+ public Object getProxy()
+ {
+ return proxy;
+ }
+
+ /**
+ * Set the proxy.
+ *
+ * @param proxy the proxy.
+ */
+ protected void setProxy(Object proxy)
+ {
+ this.proxy = proxy;
+ }
+
+ public GenericWrapper getWrapper(GenericManagedConnectionFactory mcf)
+ {
+ if (getManagedConnectionFactory() != mcf)
+ throw new SecurityException("Pass the correct managed connection factory");
+ return this;
+ }
+
+ /**
+ * Whether this is a close method
+ *
+ * @param method the method
+ * @return true when a close method
+ */
+ protected boolean isCloseMethod(Method method)
+ {
+ return getManagedConnectionFactory().isCloseMethod(method);
+ }
+
+ /**
+ * Whether the handle is closed
+ *
+ * @return true when already closed
+ */
+ protected boolean isClosed()
+ {
+ return closed.get();
+ }
+
+ /**
+ * Close the handle
+ *
+ * @param method the method
+ */
+ public void closeWrapper(Method method)
+ {
+ if (closed.set(true) == false)
+ {
+ if (trace)
+ log.trace(this + " CLOSED");
+ Set children = getChildren();
+ if (children != null && children.size() > 0)
+ {
+ for (Iterator i = children.iterator(); i.hasNext();)
+ {
+ GenericWrapper child = (GenericWrapper) i.next();
+ removeChild(child);
+ child.setParent(null);
+ child.invokeClose(null);
+ }
+ }
+ if (parent != null)
+ {
+ parent.removeChild(this);
+ setParent(null);
+ }
+ handleClose(method);
+ }
+ }
+
+ /**
+ * Invoke close
+ *
+ * @param method the method
+ */
+ protected void invokeClose(Method method)
+ {
+ getManagedConnectionFactory().invokeClose(this, method, true);
+ }
+
+ /**
+ * Handle the close operation
+ *
+ * @param method the method
+ */
+ protected abstract void handleClose(Method method);
+
+ /**
+ * Get the wrapped object
+ *
+ * @return the wrapped object
+ * @throws ResourceException for any error
+ */
+ public abstract Object getWrappedObject() throws ResourceException;
+
+ /**
+ * Get the wrapped target
+ *
+ * @return the wrapped target
+ * @throws ResourceException for any error
+ */
+ public Object getWrappedTarget() throws ResourceException
+ {
+ Object result = getWrappedObject();
+ if (result instanceof WrappedObject)
+ result = ((WrappedObject) result).getWrappedObject();
+ return result;
+ }
+
+ /**
+ * Check whether an error is fatal
+ *
+ * @param t the throwable
+ */
+ protected void checkFatal(Throwable t)
+ {
+ }
+
+ /**
+ * Report a specific error
+ *
+ * @param context the context
+ * @param t the throwable
+ * @return never
+ * @throws the correct error
+ */
+ public Throwable throwError(Object context, Throwable t) throws Throwable
+ {
+ throw getManagedConnectionFactory().error(context, t);
+ }
+
+ /**
+ * Get the parent
+ *
+ * @return the parent
+ */
+ protected GenericWrapper getParent()
+ {
+ return parent;
+ }
+
+ /**
+ * Set the parent
+ *
+ * @param parent the parent
+ */
+ protected void setParent(GenericWrapper parent)
+ {
+ this.parent = parent;
+ }
+
+ /**
+ * Add a child
+ *
+ * @param child the child
+ */
+ protected void addChild(GenericWrapper child)
+ {
+ if (trace)
+ log.trace(this + " ADDCHILD " + child);
+ children.add(child);
+ }
+
+ /**
+ * Remove a child
+ *
+ * @param child the child
+ */
+ protected void removeChild(GenericWrapper child)
+ {
+ if (trace)
+ log.trace(this + " REMOVECHILD " + child);
+ children.remove(child);
+ }
+
+ /**
+ * Get the children
+ *
+ * @return the children
+ */
+ protected Set getChildren()
+ {
+ return children;
+ }
+
+ /**
+ * Check for a parent
+ *
+ * @param method the method
+ * @return the parent result if it is the parent or null for not the parent
+ * @throws Throwable for any error
+ */
+ protected Object checkParent(Method method) throws Throwable
+ {
+ if (parent != null && getManagedConnectionFactory().isParent(method, parent, this))
+ return parent.getProxy();
+ return null;
+ }
+
+ /**
+ * Check for a child
+ *
+ * @param method the method
+ * @param result the result
+ * @return the child result
+ * @throws Throwable for any error
+ */
+ protected Object checkChild(Method method, Object result) throws Throwable
+ {
+ GenericManagedConnectionFactory mcf = getManagedConnectionFactory();
+ if (mcf.isChild(method, result))
+ {
+ GenericWrapper child = mcf.createGenericChild(result);
+ child.setParent(this);
+ addChild(child);
+ return child.createHandle();
+ }
+ return result;
+ }
+
+ /**
+ * Create a handle
+ *
+ * @param interfaces the interfaces
+ * @return the handle
+ * @throws ResourceException for any error
+ */
+ protected GenericHandle createHandle() throws ResourceException
+ {
+ Class[] interfaces = mcf.getWrappedInterfaces(this);
+ return createHandle(interfaces);
+ }
+
+ /**
+ * Create a handle
+ *
+ * @param interfaces the interfaces
+ * @return the handle
+ */
+ public GenericHandle createHandle(Class[] interfaces) throws ResourceException
+ {
+ return (GenericHandle) createProxy(interfaces, getWrappedObject());
+ }
+
+ /**
+ * Create a proxy
+ *
+ * @param interfaces the interfaces
+ * @param impl the implementation
+ * @return the proxy
+ */
+ public Object createProxy(Class[] interfaces, Object impl) throws ResourceException
+ {
+ SimpleMetaData metaData = new SimpleMetaData();
+ metaData.addMetaData(GenericWrapper.METADATA_KEY, GenericWrapper.METADATA_KEY, this);
+
+ Object proxy = mcf.createProxy(interfaces, impl, metaData);
+ setProxy(proxy);
+ return proxy;
+ }
+
+ public String toString()
+ {
+ JBossStringBuilder buffer = new JBossStringBuilder();
+ Strings.defaultToString(buffer, this);
+ buffer.append('[');
+ toString(buffer);
+ buffer.append(']');
+ return buffer.toString();
+ }
+
+ /**
+ * Fill in the state
+ *
+ * @param buffer the buffer
+ */
+ protected abstract void toString(JBossStringBuilder buffer);
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/ParentChildAdvice.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/ParentChildAdvice.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/ParentChildAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,66 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.wrapper;
+
+import java.lang.reflect.Method;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.rars.advice.AbstractRARInterceptor;
+
+/**
+ * ParentChild advice.
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class ParentChildAdvice extends AbstractRARInterceptor
+{
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ MethodInvocation mi = (MethodInvocation) invocation;
+ GenericWrapper wrapper = (GenericWrapper) mi.getMetaData(GenericWrapper.METADATA_KEY, GenericWrapper.METADATA_KEY);
+
+ Method method = mi.getMethod();
+ Class returnType = method.getReturnType();
+ boolean checkResult = (returnType != Void.class);
+
+ Object result;
+
+ // Check for retrieval of parent
+ if (checkResult)
+ {
+ result = wrapper.checkParent(method);
+ if (result != null)
+ return result;
+ }
+
+ // Do invocation
+ result = invocation.invokeNext();
+
+ // Check for child
+ if (checkResult && result != null && result instanceof GenericHandle == false)
+ result = wrapper.checkChild(method, result);
+
+ return result;
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/WrappedObject.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/WrappedObject.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/WrappedObject.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.wrapper;
+
+/**
+ * WrappedObject.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public interface WrappedObject
+{
+ /**
+ * Get the wrapped object
+ *
+ * @return the wrapped object
+ */
+ Object getWrappedObject();
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/WrapperAdvice.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/WrapperAdvice.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/WrapperAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,69 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.wrapper;
+
+import java.lang.reflect.Method;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.rars.advice.AbstractRARInterceptor;
+
+/**
+ * Wrapper advice.
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class WrapperAdvice extends AbstractRARInterceptor
+{
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ MethodInvocation mi = (MethodInvocation) invocation;
+ GenericWrapper wrapper = (GenericWrapper) mi.getMetaData(GenericWrapper.METADATA_KEY, GenericWrapper.METADATA_KEY);
+
+ Method method = mi.getMethod();
+ if (wrapper.isCloseMethod(method))
+ {
+ wrapper.closeWrapper(method);
+ return null;
+ }
+
+ // Is this a straight forward invocation?
+ Object target = mi.getTargetObject();
+ Class targetClass = target.getClass();
+ Class declaringClass = method.getDeclaringClass();
+ if (declaringClass.isAssignableFrom(targetClass))
+ return invocation.invokeNext();
+
+ // Try any wrapped target
+ Object wrappedObject = wrapper.getWrappedTarget();
+ mi.setTargetObject(wrappedObject);
+ try
+ {
+ return invocation.invokeNext();
+ }
+ finally
+ {
+ mi.setTargetObject(target);
+ }
+ }
+}
Added: projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/WrapperErrorAdvice.java
===================================================================
--- projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/WrapperErrorAdvice.java (rev 0)
+++ projects/jboss-jca/adapter/src/main/org/jboss/rars/generic/wrapper/WrapperErrorAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.rars.generic.wrapper;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.rars.advice.AbstractRARInterceptor;
+import org.jboss.rars.generic.ra.ResourceErrorHandler;
+
+/**
+ * Wrapper error advice.
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class WrapperErrorAdvice extends AbstractRARInterceptor
+{
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ try
+ {
+ return invocation.invokeNext();
+ }
+ catch (Throwable t)
+ {
+ MethodInvocation mi = (MethodInvocation) invocation;
+ Object target = mi.getTargetObject();
+ GenericWrapper wrapper = (GenericWrapper) mi.getMetaData(GenericWrapper.METADATA_KEY, GenericWrapper.METADATA_KEY);
+
+ // Check for a fatal error
+ if (wrapper != null)
+ {
+ target = wrapper;
+ wrapper.checkFatal(t);
+ }
+
+ // Rethrow as the correct type
+ if (target != null && target instanceof ResourceErrorHandler)
+ {
+ ResourceErrorHandler handler = (ResourceErrorHandler) target;
+ handler.throwError(format(mi), t);
+ }
+ throw t;
+ }
+ }
+}
Added: projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/JBossMQUnitTestCase.xml
===================================================================
--- projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/JBossMQUnitTestCase.xml (rev 0)
+++ projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/JBossMQUnitTestCase.xml 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="PersistenceManager" class="org.jboss.mq.pm.none.PersistenceManager"/>
+
+ <bean name="StateManager" class="org.jboss.mq.sm.none.NullStateManager"/>
+
+ <bean name="MessageCache" class="org.jboss.mq.kernel.MessageCache">
+ <property name="persistenceManager"><inject bean="PersistenceManager"/></property>
+ </bean>
+
+ <bean name="DestinationManager" class="org.jboss.mq.kernel.DestinationManager">
+ <property name="persistenceManagerInstance"><inject bean="PersistenceManager"/></property>
+ <property name="stateManagerInstance"><inject bean="StateManager"/></property>
+ <property name="messageCacheInstance"><inject bean="MessageCache"/></property>
+ </bean>
+
+ <bean name="JMSServer">
+ <constructor factoryMethod="getInterceptor">
+ <factory bean="DestinationManager"/>
+ </constructor>
+ </bean>
+
+ <bean name="Invoker" class="org.jboss.mq.server.JMSServerInvoker">
+ <property name="next"><inject bean="JMSServer"/></property>
+ </bean>
+
+ <bean name="ServerIL" class="org.jboss.mq.il.jvm.JVMServerIL">
+ <constructor>
+ <parameter><inject bean="Invoker"/></parameter>
+ </constructor>
+ </bean>
+
+ <bean name="GCF" class="org.jboss.mq.GenericConnectionFactory">
+ <constructor>
+ <parameter><inject bean="ServerIL"/></parameter>
+ <parameter>
+ ClientILService=org.jboss.mq.il.jvm.JVMClientILService
+ </parameter>
+ </constructor>
+ </bean>
+
+ <bean name="Queue" class="org.jboss.mq.SpyQueue">
+ <constructor>
+ <parameter>testQueue</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="RealQueue" class="org.jboss.mq.server.JMSQueue">
+ <constructor>
+ <parameter><inject bean="Queue"/></parameter>
+ <parameter><null/></parameter>
+ <parameter><inject bean="JMSServer"/></parameter>
+ <parameter><inject bean="JMSServer" property="parameters"/></parameter>
+ </constructor>
+ <install bean="JMSServer" method="addDestination">
+ <parameter><this/></parameter>
+ </install>
+ <uninstall bean="JMSServer" method="closeDestination">
+ <parameter><inject bean="Queue"/></parameter>
+ </uninstall>
+ </bean>
+
+ <bean name="ConnectionFactory" class="org.jboss.mq.SpyConnectionFactory">
+ <constructor>
+ <parameter class="org.jboss.mq.GenericConnectionFactory"><inject bean="GCF"/></parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added: projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jdbc/local/test/JDBCUnitTestCase.xml
===================================================================
--- projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jdbc/local/test/JDBCUnitTestCase.xml (rev 0)
+++ projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jdbc/local/test/JDBCUnitTestCase.xml 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="AspectManager">
+ <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+ </bean>
+
+ <beanfactory name="TraceAdvice" class="org.jboss.rars.advice.TraceAdvice"/>
+
+ <bean name="TraceAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="TraceAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <bean name="ManagedConnectionFactory" class="org.jboss.rars.generic.mcf.jdbc.local.LocalJDBCManagedConnectionFactory">
+ <property name="user">sa</property>
+ <property name="connectionURL">jdbc:hsqldb:.</property>
+ <property name="driverClassName">org.hsqldb.jdbcDriver</property>
+ </bean>
+
+ <beanfactory name="WrapperErrorAdvice" class="org.jboss.rars.generic.wrapper.WrapperErrorAdvice"/>
+
+ <bean name="WrapperErrorAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="WrapperErrorAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <beanfactory name="ConnectionFactoryAdvice" class="org.jboss.rars.generic.cf.ConnectionFactoryAdvice"/>
+
+ <bean name="ConnectionFactoryAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="ConnectionFactoryAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <bean name="ConnectionFactoryBinding" class="org.jboss.aop.microcontainer.beans.StackBinding">
+ <property name="pointcut">execution(* $instanceof{org.jboss.rars.generic.mcf.direct.DirectConnectionFactory}->*(..))</property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="advices">
+ <list>
+ <inject bean="TraceAspect" property="definition"/>
+ <inject bean="WrapperErrorAspect" property="definition"/>
+ <inject bean="ConnectionFactoryAspect" property="definition"/>
+ </list>
+ </property>
+ </bean>
+
+ <beanfactory name="WrapperAdvice" class="org.jboss.rars.generic.wrapper.WrapperAdvice"/>
+
+ <bean name="WrapperAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="WrapperAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <beanfactory name="ParentChildAdvice" class="org.jboss.rars.generic.wrapper.ParentChildAdvice"/>
+
+ <bean name="ParentChildAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="ParentChildAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <beanfactory name="ClosedAdvice" class="org.jboss.rars.generic.wrapper.ClosedAdvice"/>
+
+ <bean name="ClosedAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="ClosedAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <bean name="ConnectionBinding" class="org.jboss.aop.microcontainer.beans.StackBinding">
+ <property name="pointcut">execution(* $instanceof{org.jboss.rars.generic.wrapper.GenericHandle}->*(..))</property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="advices">
+ <list>
+ <inject bean="TraceAspect" property="definition"/>
+ <inject bean="WrapperErrorAspect" property="definition"/>
+ <inject bean="ClosedAspect" property="definition"/>
+ <inject bean="ParentChildAspect" property="definition"/>
+ <inject bean="WrapperAspect" property="definition"/>
+ </list>
+ </property>
+ </bean>
+
+ <bean name="ConnectionManager" class="org.jboss.rars.cm.pooling.PoolingConnectionManager"/>
+
+ <bean name="ConnectionFactory">
+ <constructor factoryMethod="createConnectionFactory">
+ <factory bean="ManagedConnectionFactory"/>
+ <parameter><inject bean="ConnectionManager"/></parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added: projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jms/test/JMSUnitTestCase.xml
===================================================================
--- projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jms/test/JMSUnitTestCase.xml (rev 0)
+++ projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/jms/test/JMSUnitTestCase.xml 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="PersistenceManager" class="org.jboss.mq.pm.none.PersistenceManager"/>
+
+ <bean name="StateManager" class="org.jboss.mq.sm.none.NullStateManager"/>
+
+ <bean name="MessageCache" class="org.jboss.mq.kernel.MessageCache">
+ <property name="persistenceManager"><inject bean="PersistenceManager"/></property>
+ </bean>
+
+ <bean name="DestinationManager" class="org.jboss.mq.kernel.DestinationManager">
+ <property name="persistenceManagerInstance"><inject bean="PersistenceManager"/></property>
+ <property name="stateManagerInstance"><inject bean="StateManager"/></property>
+ <property name="messageCacheInstance"><inject bean="MessageCache"/></property>
+ </bean>
+
+ <bean name="JMSServer">
+ <constructor factoryMethod="getInterceptor">
+ <factory bean="DestinationManager"/>
+ </constructor>
+ </bean>
+
+ <bean name="Invoker" class="org.jboss.mq.server.JMSServerInvoker">
+ <property name="next"><inject bean="JMSServer"/></property>
+ </bean>
+
+ <bean name="ServerIL" class="org.jboss.mq.il.jvm.JVMServerIL">
+ <constructor>
+ <parameter><inject bean="Invoker"/></parameter>
+ </constructor>
+ </bean>
+
+ <bean name="GCF" class="org.jboss.mq.GenericConnectionFactory">
+ <constructor>
+ <parameter><inject bean="ServerIL"/></parameter>
+ <parameter>
+ ClientILService=org.jboss.mq.il.jvm.JVMClientILService
+ </parameter>
+ </constructor>
+ </bean>
+
+ <bean name="Queue" class="org.jboss.mq.SpyQueue">
+ <constructor>
+ <parameter>testQueue</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="RealQueue" class="org.jboss.mq.server.JMSQueue">
+ <constructor>
+ <parameter><inject bean="Queue"/></parameter>
+ <parameter><null/></parameter>
+ <parameter><inject bean="JMSServer"/></parameter>
+ <parameter><inject bean="JMSServer" property="parameters"/></parameter>
+ </constructor>
+ <install bean="JMSServer" method="addDestination">
+ <parameter><this/></parameter>
+ </install>
+ <uninstall bean="JMSServer" method="closeDestination">
+ <parameter><inject bean="Queue"/></parameter>
+ </uninstall>
+ </bean>
+
+ <bean name="QueueConnectionFactory" class="org.jboss.mq.SpyConnectionFactory">
+ <constructor>
+ <parameter class="org.jboss.mq.GenericConnectionFactory"><inject bean="GCF"/></parameter>
+ </constructor>
+ </bean>
+
+ <bean name="ManagedConnectionFactory" class="org.jboss.rars.generic.mcf.jms.JMSManagedConnectionFactory">
+ <property name="user">guest</property>
+ <property name="password">guest</property>
+ <property name="connectionFactory"><inject bean="QueueConnectionFactory"/></property>
+ </bean>
+
+ <bean name="AspectManager">
+ <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+ </bean>
+
+ <beanfactory name="TraceAdvice" class="org.jboss.rars.advice.TraceAdvice"/>
+
+ <bean name="TraceAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="TraceAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <beanfactory name="WrapperErrorAdvice" class="org.jboss.rars.generic.wrapper.WrapperErrorAdvice"/>
+
+ <bean name="WrapperErrorAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="WrapperErrorAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <beanfactory name="ConnectionFactoryAdvice" class="org.jboss.rars.generic.cf.ConnectionFactoryAdvice"/>
+
+ <bean name="ConnectionFactoryAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="ConnectionFactoryAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <bean name="ConnectionFactoryBinding" class="org.jboss.aop.microcontainer.beans.StackBinding">
+ <property name="pointcut">execution(* $instanceof{org.jboss.rars.generic.mcf.indirect.IndirectConnectionFactory}->*(..))</property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="advices">
+ <list>
+ <inject bean="TraceAspect" property="definition"/>
+ <inject bean="WrapperErrorAspect" property="definition"/>
+ <inject bean="ConnectionFactoryAspect" property="definition"/>
+ </list>
+ </property>
+ </bean>
+
+ <beanfactory name="WrapperAdvice" class="org.jboss.rars.generic.wrapper.WrapperAdvice"/>
+
+ <bean name="WrapperAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="WrapperAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <beanfactory name="ParentChildAdvice" class="org.jboss.rars.generic.wrapper.ParentChildAdvice"/>
+
+ <bean name="ParentChildAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="ParentChildAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <beanfactory name="ClosedAdvice" class="org.jboss.rars.generic.wrapper.ClosedAdvice"/>
+
+ <bean name="ClosedAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="ClosedAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <beanfactory name="IndirectConnectionAdvice" class="org.jboss.rars.generic.mcf.indirect.IndirectConnectionAdvice"/>
+
+ <bean name="IndirectConnectionAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="IndirectConnectionAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <bean name="ConnectionBinding" class="org.jboss.aop.microcontainer.beans.StackBinding">
+ <property name="pointcut">execution(* $instanceof{org.jboss.rars.generic.mcf.indirect.IndirectConnection}->*(..))</property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="advices">
+ <list>
+ <inject bean="TraceAspect" property="definition"/>
+ <inject bean="WrapperErrorAspect" property="definition"/>
+ <inject bean="ClosedAspect" property="definition"/>
+ <inject bean="ParentChildAspect" property="definition"/>
+ <inject bean="WrapperAspect" property="definition"/>
+ <inject bean="IndirectConnectionAspect" property="definition"/>
+ </list>
+ </property>
+ </bean>
+
+ <bean name="WrapperBinding" class="org.jboss.aop.microcontainer.beans.StackBinding">
+ <property name="pointcut">execution(* $instanceof{org.jboss.rars.generic.wrapper.GenericHandle}->*(..))</property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="advices">
+ <list>
+ <inject bean="TraceAspect" property="definition"/>
+ <inject bean="WrapperErrorAspect" property="definition"/>
+ <inject bean="ClosedAspect" property="definition"/>
+ <inject bean="ParentChildAspect" property="definition"/>
+ <inject bean="WrapperAspect" property="definition"/>
+ </list>
+ </property>
+ </bean>
+
+ <bean name="ConnectionManager" class="org.jboss.rars.cm.pooling.PoolingConnectionManager"/>
+
+ <bean name="ConnectionFactory">
+ <constructor factoryMethod="createConnectionFactory">
+ <factory bean="ManagedConnectionFactory"/>
+ <parameter><inject bean="ConnectionManager"/></parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added: projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/test/TestUnitTestCase.xml
===================================================================
--- projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/test/TestUnitTestCase.xml (rev 0)
+++ projects/jboss-jca/adapter/src/resources/tests/org/jboss/test/rars/generic/mcf/test/TestUnitTestCase.xml 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+ <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+ </bean>
+
+ <beanfactory name="TraceAdvice" class="org.jboss.rars.advice.TraceAdvice"/>
+
+ <bean name="TraceAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="TraceAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <bean name="ManagedConnectionFactory" class="org.jboss.test.rars.generic.mcf.support.TestManagedConnectionFactory">
+ </bean>
+
+ <beanfactory name="ConnectionFactoryAdvice" class="org.jboss.rars.generic.cf.ConnectionFactoryAdvice"/>
+
+ <bean name="ConnectionFactoryAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="ConnectionFactoryAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <bean name="ConnectionFactoryBinding" class="org.jboss.aop.microcontainer.beans.StackBinding">
+ <property name="pointcut">execution(* $instanceof{org.jboss.rars.generic.mcf.direct.DirectConnectionFactory}->*(..))</property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="advices">
+ <list>
+ <inject bean="TraceAspect" property="definition"/>
+ <inject bean="ConnectionFactoryAspect" property="definition"/>
+ </list>
+ </property>
+ </bean>
+
+ <beanfactory name="WrapperAdvice" class="org.jboss.rars.generic.wrapper.WrapperAdvice"/>
+
+ <bean name="WrapperAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="WrapperAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <beanfactory name="ClosedAdvice" class="org.jboss.rars.generic.wrapper.ClosedAdvice"/>
+
+ <bean name="ClosedAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="ClosedAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <bean name="ConnectionBinding" class="org.jboss.aop.microcontainer.beans.StackBinding">
+ <property name="pointcut">execution(* $instanceof{org.jboss.rars.generic.wrapper.GenericHandle}->*(..))</property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="advices">
+ <list>
+ <inject bean="TraceAspect" property="definition"/>
+ <inject bean="ClosedAspect" property="definition"/>
+ <inject bean="WrapperAspect" property="definition"/>
+ </list>
+ </property>
+ </bean>
+
+ <bean name="ConnectionFactory" class="java.lang.Object">
+ <constructor factoryMethod="createConnectionFactory">
+ <factory bean="ManagedConnectionFactory"/>
+ </constructor>
+ </bean>
+
+</deployment>
Added: projects/jboss-jca/adapter/src/tests/org/jboss/test/JBossMQUnitTestCase.java
===================================================================
--- projects/jboss-jca/adapter/src/tests/org/jboss/test/JBossMQUnitTestCase.java (rev 0)
+++ projects/jboss-jca/adapter/src/tests/org/jboss/test/JBossMQUnitTestCase.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,77 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+
+import junit.framework.Test;
+
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+
+/**
+ * JMS Unit Tests
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class JBossMQUnitTestCase extends MicrocontainerTest
+{
+ public void testNoTx() throws Throwable
+ {
+ ConnectionFactory cf = (ConnectionFactory) getBean("ConnectionFactory");
+ Queue queue = (Queue) getBean("Queue");
+ Connection c = cf.createConnection();
+ try
+ {
+ c.start();
+ Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Message m = s.createTextMessage("hello");
+
+ MessageProducer p = s.createProducer(queue);
+ p.send(m);
+
+ MessageConsumer r = s.createConsumer(queue);
+ m = r.receiveNoWait();
+ getLog().info(m);
+ }
+ finally
+ {
+ c.close();
+ }
+ }
+
+ public static Test suite() throws Exception
+ {
+ return suite(JBossMQUnitTestCase.class);
+ }
+
+ public JBossMQUnitTestCase (String name)
+ {
+ super(name);
+ }
+}
Added: projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/RARAllTestSuite.java
===================================================================
--- projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/RARAllTestSuite.java (rev 0)
+++ projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/RARAllTestSuite.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.rars;
+
+import org.jboss.test.rars.generic.mcf.jdbc.local.test.JDBCUnitTestCase;
+import org.jboss.test.rars.generic.mcf.jms.test.JMSUnitTestCase;
+import org.jboss.test.rars.generic.mcf.test.TestUnitTestCase;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * All Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class RARAllTestSuite extends TestSuite
+{
+ public static void main(String[] args) throws Exception
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite("All Tests");
+
+ suite.addTest(TestUnitTestCase.suite());
+ suite.addTest(JDBCUnitTestCase.suite());
+ suite.addTest(JMSUnitTestCase.suite());
+
+ return suite;
+ }
+}
Added: projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/RARTest.java
===================================================================
--- projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/RARTest.java (rev 0)
+++ projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/RARTest.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.rars;
+
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+
+/**
+ * A RARTest.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class RARTest extends MicrocontainerTest
+{
+ /**
+ * Create a new RARTest.
+ *
+ * @param name the test name
+ */
+ public RARTest(String name)
+ {
+ super(name);
+ }
+
+ public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+ {
+ AbstractTestDelegate delegate = MicrocontainerTest.getDelegate(clazz);
+ //delegate.enableSecurity = true;
+ return delegate;
+ }
+
+ protected void configureLogging()
+ {
+ //enableTrace("org.jboss.rars");
+ }
+}
Added: projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jdbc/local/test/JDBCUnitTestCase.java
===================================================================
--- projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jdbc/local/test/JDBCUnitTestCase.java (rev 0)
+++ projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jdbc/local/test/JDBCUnitTestCase.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,83 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.rars.generic.mcf.jdbc.local.test;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.Statement;
+
+import javax.sql.DataSource;
+
+import junit.framework.Test;
+
+import org.jboss.test.rars.RARTest;
+
+/**
+ * JDBC Unit Tests
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class JDBCUnitTestCase extends RARTest
+{
+ public void testNoTx() throws Throwable
+ {
+ DataSource ds = (DataSource) getBean("ConnectionFactory");
+ Connection c = ds.getConnection();
+ assertNotNull("Should have a connection", c);
+ try
+ {
+ Statement s = c.createStatement();
+ s.execute("create table test (key varchar(10), value varchar(10))");
+ Connection c1 = s.getConnection();
+ assertTrue(c == c1);
+ Statement s1 = c.createStatement();
+ s1.executeQuery("select 1 from test");
+ s1.close();
+ }
+ finally
+ {
+ c.close();
+ }
+ c = ds.getConnection("sa", "");
+ assertNotNull("Should have a connection", c);
+ try
+ {
+ DatabaseMetaData m = c.getMetaData();
+ m.getCatalogs();
+ }
+ finally
+ {
+ c.close();
+ }
+ }
+
+ public static Test suite() throws Exception
+ {
+ return suite(JDBCUnitTestCase.class);
+ }
+
+ public JDBCUnitTestCase (String name)
+ {
+ super(name);
+ }
+}
Added: projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jms/test/JMSUnitTestCase.java
===================================================================
--- projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jms/test/JMSUnitTestCase.java (rev 0)
+++ projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/jms/test/JMSUnitTestCase.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,190 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.rars.generic.mcf.jms.test;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.IllegalStateException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+
+import junit.framework.Test;
+
+import org.jboss.test.rars.RARTest;
+
+/**
+ * JMS Unit Tests
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class JMSUnitTestCase extends RARTest
+{
+ int iterations = 100;
+
+ public void testNoTx() throws Throwable
+ {
+ ConnectionFactory cf = (ConnectionFactory) getBean("ConnectionFactory");
+ Queue queue = (Queue) getBean("Queue");
+ Connection c = cf.createConnection();
+ try
+ {
+ Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Message m = s.createTextMessage("hello");
+
+ MessageProducer p = s.createProducer(queue);
+ p.send(m);
+
+ MessageConsumer r = s.createConsumer(queue);
+ m = r.receiveNoWait();
+ s.close();
+
+ s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ s.close();
+ }
+ finally
+ {
+ c.close();
+ }
+
+ c = cf.createConnection();
+ try
+ {
+ Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ s.createTextMessage("goodbye");
+ }
+ finally
+ {
+ c.close();
+ }
+
+ c = cf.createConnection();
+ try
+ {
+ c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try
+ {
+ c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ fail("Should not be here!");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ }
+ finally
+ {
+ c.close();
+ }
+ }
+
+ public void testStress1() throws Exception
+ {
+ ConnectionFactory cf = (ConnectionFactory) getBean("QueueConnectionFactory");
+ for (int i = 0; i < iterations; ++i)
+ {
+ Connection c = cf.createConnection();
+ try
+ {
+ c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ }
+ finally
+ {
+ c.close();
+ }
+ }
+ }
+
+ public void testStress2() throws Exception
+ {
+ ConnectionFactory cf = (ConnectionFactory) getBean("ConnectionFactory");
+ for (int i = 0; i < iterations; ++i)
+ {
+ Connection c = cf.createConnection();
+ try
+ {
+ c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ }
+ finally
+ {
+ c.close();
+ }
+ }
+ }
+
+ public void testStress3() throws Exception
+ {
+ ConnectionFactory cf = (ConnectionFactory) getBean("QueueConnectionFactory");
+ Connection c = cf.createConnection();
+ try
+ {
+ for (int i = 0; i < iterations; ++i)
+ {
+ Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ s.close();
+ }
+ }
+ finally
+ {
+ c.close();
+ }
+ }
+
+ public void testStress4() throws Exception
+ {
+ ConnectionFactory cf = (ConnectionFactory) getBean("ConnectionFactory");
+ Connection c = cf.createConnection();
+ Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ s.close();
+ try
+ {
+ for (int i = 0; i < iterations; ++i)
+ {
+ s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ s.close();
+ }
+ }
+ finally
+ {
+ c.close();
+ }
+
+ }
+
+ protected void configureLogging()
+ {
+ //enableTrace("org.jboss.mq");
+ //enableTrace("org.jboss.rars");
+ }
+
+ public static Test suite() throws Exception
+ {
+ return suite(JMSUnitTestCase.class);
+ }
+
+ public JMSUnitTestCase (String name)
+ {
+ super(name);
+ }
+}
Added: projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestConnection.java
===================================================================
--- projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestConnection.java (rev 0)
+++ projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestConnection.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.rars.generic.mcf.support;
+
+/**
+ * TestConnection.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public interface TestConnection
+{
+ void close();
+}
Added: projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.rars.generic.mcf.support;
+
+/**
+ * TestConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public interface TestConnectionFactory
+{
+ /**
+ * Get a connection
+ *
+ * @return the connection
+ */
+ TestConnection getConnection();
+}
Added: projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestConnectionImpl.java
===================================================================
--- projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestConnectionImpl.java (rev 0)
+++ projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestConnectionImpl.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.rars.generic.mcf.support;
+
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
+
+/**
+ * TestConnectionImpl.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class TestConnectionImpl implements TestConnection
+{
+ private SynchronizedBoolean closed = new SynchronizedBoolean(false);
+
+ public void close()
+ {
+ closed.set(true);
+ }
+}
Added: projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestManagedConnectionFactory.java (rev 0)
+++ projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/support/TestManagedConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,62 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.rars.generic.mcf.support;
+
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.security.auth.Subject;
+
+import org.jboss.rars.generic.cf.GenericConnectionFactory;
+import org.jboss.rars.generic.mcf.GenericManagedConnection;
+import org.jboss.rars.generic.mcf.direct.DirectGenericManagedConnectionFactory;
+
+/**
+ * TestManagedConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class TestManagedConnectionFactory extends DirectGenericManagedConnectionFactory
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1155075489153266482L;
+
+ private static final Class CONNECTION_FACTORY_CLASS = TestConnectionFactory.class;
+
+ protected void addConnectionFactoryInterfaces(GenericConnectionFactory impl, Set interfaces)
+ {
+ interfaces.add(CONNECTION_FACTORY_CLASS);
+ }
+
+ protected Object createRealConnection(GenericManagedConnection mc, Subject subject, ConnectionRequestInfo cxRequestInfo, Object requestID) throws ResourceException
+ {
+ return new TestConnectionImpl();
+ }
+
+ protected void destroyRealConnection(GenericManagedConnection mc) throws ResourceException
+ {
+ TestConnectionImpl connection = (TestConnectionImpl) mc.getRealConnection();
+ connection.close();
+ }
+}
Added: projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/test/TestUnitTestCase.java
===================================================================
--- projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/test/TestUnitTestCase.java (rev 0)
+++ projects/jboss-jca/adapter/src/tests/org/jboss/test/rars/generic/mcf/test/TestUnitTestCase.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.rars.generic.mcf.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.rars.RARTest;
+import org.jboss.test.rars.generic.mcf.support.TestConnection;
+import org.jboss.test.rars.generic.mcf.support.TestConnectionFactory;
+
+/**
+ * NoTx Unit Tests
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public class TestUnitTestCase extends RARTest
+{
+ public TestUnitTestCase (String name)
+ {
+ super(name);
+ }
+
+ public void testNoTx() throws Throwable
+ {
+ TestConnectionFactory cf = (TestConnectionFactory) getBean("ConnectionFactory");
+ TestConnection c = cf.getConnection();
+ assertNotNull("Should have a connection", c);
+ c.close();
+ c = cf.getConnection();
+ assertNotNull("Should have a connection", c);
+ c.close();
+ }
+
+ public static Test suite() throws Exception
+ {
+ return suite(TestUnitTestCase.class);
+ }
+}
Added: projects/jboss-jca/core/pom.xml
===================================================================
--- projects/jboss-jca/core/pom.xml (rev 0)
+++ projects/jboss-jca/core/pom.xml 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,163 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>jboss</groupId>
+ <artifactId>jca-core</artifactId>
+ <packaging>jar</packaging>
+ <version>0.1.SNAPSHOT</version>
+ <name>JBoss JCA Core</name>
+ <url>http://www.jboss.org</url>
+ <description>This would contain the core JBoss JCA classes</description>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <url>http://repository.jboss.com/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+ <organization>
+ <name>JBoss, a division of Red Hat, Inc.</name>
+ <url>http://www.jboss.org</url>
+ </organization>
+
+ <repositories>
+ <repository>
+ <id>jboss</id>
+ <name>JBoss Inc. Repository</name>
+ <layout>default</layout>
+ <url>http://repository.jboss.com/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <layout>default</layout>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-jca/trunk/</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-jca/trunk/</developerConnection>
+ <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-jca/trunk/</url>
+ </scm>
+
+ <build>
+ <sourceDirectory>src/main</sourceDirectory>
+ <testSourceDirectory>src/tests</testSourceDirectory>
+ <outputDirectory>output</outputDirectory>
+ <testOutputDirectory>output</testOutputDirectory>
+
+ <testResources>
+ <testResource>
+ <directory>src/resources/tests</directory>
+ </testResource>
+ </testResources>
+
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <optimize>true</optimize>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <includes>
+ <include>org/jboss/test/**/*TestCase.java</include>
+ </includes>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.0.2.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-aop</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-transaction</artifactId>
+ <version>5.0-SNAPSHOT</version>
+ <!-- scope>runtime</scope -->
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-test</artifactId>
+ <version>1.0.3.GA</version>
+ </dependency>
+ <!-- This is AS dependency and should go off -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ <version>5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-aop-mc-int</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
\ No newline at end of file
Added: projects/jboss-jca/core/src/etc/conf/log4j.properties
===================================================================
--- projects/jboss-jca/core/src/etc/conf/log4j.properties (rev 0)
+++ projects/jboss-jca/core/src/etc/conf/log4j.properties 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,15 @@
+### ====================================================================== ###
+## ##
+## JBoss Bootstrap Log4j Configuration ##
+## ##
+### ====================================================================== ###
+
+### $Id: log4j.properties,v 1.1.1.1 2005/10/06 19:30:02 adrian Exp $ ###
+
+log4j.rootCategory=DEBUG, CONSOLE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=INFO
+log4j.appender.CONSOLE.Target=System.out
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
Added: projects/jboss-jca/core/src/etc/default.mf
===================================================================
--- projects/jboss-jca/core/src/etc/default.mf (rev 0)
+++ projects/jboss-jca/core/src/etc/default.mf 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: @java.vm.version@ (@java.vm.vendor@)
+Specification-Title: @specification.title@
+Specification-Version: @specification.version@
+Specification-Vendor: @specification.vendor@
+Implementation-Title: @implementation.title@
+Implementation-URL: @implementation.url@
+Implementation-Version: @implementation.version@
+Implementation-Vendor: @implementation.vendor@
+Implementation-Vendor-Id: @implementation.vendor.id@
\ No newline at end of file
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/advice/AbstractJCAInterceptor.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/advice/AbstractJCAInterceptor.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/advice/AbstractJCAInterceptor.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.advice;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.logging.Logger;
+
+/**
+ * AbstractJCAInterceptor.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractJCAInterceptor implements Interceptor
+{
+ /** The log */
+ protected final Logger log = Logger.getLogger(getClass());
+
+ public String getName()
+ {
+ return getClass().getName();
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/ConnectionManagerExceptionAdvice.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/ConnectionManagerExceptionAdvice.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/ConnectionManagerExceptionAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,47 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.cm;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.jca.plugins.advice.AbstractJCAInterceptor;
+import org.jboss.jca.spi.ResourceExceptionUtil;
+
+/**
+ * ConnectionManager exception advice.
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class ConnectionManagerExceptionAdvice extends AbstractJCAInterceptor
+{
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ try
+ {
+ return invocation.invokeNext();
+ }
+ catch (Throwable t)
+ {
+ throw ResourceExceptionUtil.checkApplicationServerInternal(t);
+ }
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/ConnectionManagerFactory.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/ConnectionManagerFactory.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/ConnectionManagerFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,118 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.cm;
+
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ManagedConnectionFactory;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.proxy.container.AOPProxyFactory;
+import org.jboss.aop.proxy.container.AOPProxyFactoryParameters;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+import org.jboss.logging.Logger;
+
+/**
+ * A POJO ConnectionManagerFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.5 $
+ */
+public class ConnectionManagerFactory
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(ConnectionManagerFactory.class);
+
+ /** The proxy factory */
+ private static final AOPProxyFactory proxyFactory = new GeneratedAOPProxyFactory();
+
+ /** The managed connection factory */
+ protected ManagedConnectionFactory managedConnectionFactory;
+
+ /** The aspect manager */
+ protected AspectManager manager;
+
+ /**
+ * Get the manager.
+ *
+ * @return the manager.
+ */
+ public AspectManager getManager()
+ {
+ return manager;
+ }
+
+ /**
+ * Set the manager.
+ *
+ * @param manager The manager to set.
+ */
+ public void setManager(AspectManager manager)
+ {
+ this.manager = manager;
+ }
+
+ /**
+ * Get the managedConnectionFactory.
+ *
+ * @return the managedConnectionFactory.
+ */
+ public ManagedConnectionFactory getManagedConnectionFactory()
+ {
+ return managedConnectionFactory;
+ }
+
+ /**
+ * Set the managedConnectionFactory.
+ *
+ * @param managedConnectionFactory the managedConnectionFactory.
+ */
+ public void setManagedConnectionFactory(ManagedConnectionFactory managedConnectionFactory)
+ {
+ this.managedConnectionFactory = managedConnectionFactory;
+ }
+
+ /**
+ * Get the connection factory
+ *
+ * @return the connection factory
+ * @throws Exception for any error
+ */
+ public Object getConnectionFactory() throws Exception
+ {
+ if (managedConnectionFactory == null)
+ throw new IllegalStateException("Null managed connection factory");
+ if (manager == null)
+ throw new IllegalStateException("Null manager");
+
+ Class[] interfaces = new Class[] { ConnectionManager.class };
+
+ AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+ params.setProxiedClass(Object.class);
+ params.setInterfaces(interfaces);
+ params.setTarget(new Object());
+
+ ConnectionManager cmProxy = (ConnectionManager) proxyFactory.createAdvisedProxy(params);
+ Object result = managedConnectionFactory.createConnectionFactory(cmProxy);
+ log.debug("Created connectionFactory=" + result + " for MCF=" + managedConnectionFactory);
+ return result;
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/TraceAdvice.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/TraceAdvice.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/TraceAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,54 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.cm;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.jca.plugins.advice.AbstractJCAInterceptor;
+
+/**
+ * Trace advice.
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class TraceAdvice extends AbstractJCAInterceptor
+{
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("BEFORE: " + invocation);
+ try
+ {
+ Object result = invocation.invokeNext();
+ if (trace)
+ log.trace("AFTER: " + invocation + " RESULT=" + result);
+ return result;
+ }
+ catch (Throwable t)
+ {
+ if (trace)
+ log.trace("AFTER: " + invocation, t);
+ throw t;
+ }
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/listener/ListenerAdvice.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/listener/ListenerAdvice.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/listener/ListenerAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,114 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.cm.listener;
+
+import javax.resource.spi.ApplicationServerInternalException;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.security.auth.Subject;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.jca.plugins.advice.AbstractJCAInterceptor;
+import org.jboss.jca.spi.ResourceExceptionUtil;
+import org.jboss.jca.spi.cm.ManagedConnectionContext;
+import org.jboss.jca.spi.cm.ManagedConnectionContextManager;
+
+/**
+ * ConnectionManager listener advice.
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class ListenerAdvice extends AbstractJCAInterceptor
+{
+ /** The ManagedConnectionContextManager */
+ protected ManagedConnectionContextManager contextManager;
+
+ /**
+ * Get the contextManager.
+ *
+ * @return the contextManager.
+ */
+ public ManagedConnectionContextManager getContextManager()
+ {
+ return contextManager;
+ }
+
+ /**
+ * Set the contextManager.
+ *
+ * @param contextManager the context manager.
+ */
+ public void setContextManager(ManagedConnectionContextManager contextManager)
+ {
+ this.contextManager = contextManager;
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ if (contextManager == null)
+ throw new ApplicationServerInternalException("No context manager");
+
+ MethodInvocation mi = (MethodInvocation) invocation;
+ ManagedConnectionFactory mcf = (ManagedConnectionFactory) mi.getArguments()[0];
+ ConnectionRequestInfo cri = (ConnectionRequestInfo) mi.getArguments()[1];
+ Subject subject = null; // TODO Subject
+
+ boolean trace = log.isTraceEnabled();
+
+ if (trace)
+ log.trace("Create ManagedConnection mcf=" + mcf + " subject=" + subject + " cri=" + cri);
+ ManagedConnection mc = null;
+ try
+ {
+ mc = mcf.createManagedConnection(subject, cri);
+ if (mc == null)
+ throw new ResourceAdapterInternalException("Null ManagedConnection from " + mcf);
+ if (trace)
+ log.trace("Created ManagedConnection result=" + mc);
+ }
+ catch (Throwable t)
+ {
+ throw ResourceExceptionUtil.checkResourceAdapterInternal(t);
+ }
+
+ if (trace)
+ log.trace("Create ManagedConnectionContext manager=" + contextManager + " mc=" + mc);
+ try
+ {
+ ManagedConnectionContext context = contextManager.createManagedConnectionContext(mcf, mc);
+ if (context == null)
+ throw new ApplicationServerInternalException("Null ManagedConnectionContext from " + contextManager);
+ if (trace)
+ log.trace("Created ManagedConnectionContext result=" + context);
+ return context;
+ }
+ catch (Throwable t)
+ {
+ ManagedConnectionContext.safeDestroy(mc);
+ throw ResourceExceptionUtil.checkApplicationServerInternal(t);
+ }
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/PoolAdvice.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/PoolAdvice.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/PoolAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,77 @@
+/*
+* JBoss, the OpenSource J2EE webOS
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
+package org.jboss.jca.plugins.cm.pool;
+
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.security.auth.Subject;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.jca.plugins.advice.AbstractJCAInterceptor;
+import org.jboss.jca.spi.ResourceExceptionUtil;
+import org.jboss.jca.spi.cm.ManagedConnectionContext;
+import org.jboss.jca.spi.pool.ManagedConnectionContextPool;
+import org.jboss.jca.spi.pool.ManagedConnectionContextPoolFactory;
+
+/**
+ * ConnectionManager pool advice.
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class PoolAdvice extends AbstractJCAInterceptor
+{
+ protected ManagedConnectionContextPool pool;
+
+ /**
+ * Create a new PoolAdvice.
+ *
+ * @param factory the pool factory
+ */
+ public PoolAdvice(ManagedConnectionContextPoolFactory factory)
+ {
+ if (factory == null)
+ throw new IllegalArgumentException("Null factory");
+ pool = factory.createPool();
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ MethodInvocation mi = (MethodInvocation) invocation;
+ ConnectionRequestInfo cri = (ConnectionRequestInfo) mi.getArguments()[1];
+ Subject subject = null; // TODO Subject
+
+ boolean trace = log.isTraceEnabled();
+
+ if (trace)
+ log.trace("Get ManagedConnectionContext from pool=" + pool + " subject=" + subject + " cri=" + cri);
+ try
+ {
+ ManagedConnectionContext context = pool.getManagedConnectonContext(subject, cri);
+ if (context != null)
+ {
+ context.setInUse(pool);
+ if (trace)
+ log.trace("Got ManagedConnectionContext result=" + context);
+ return context;
+ }
+ if (trace)
+ log.trace("No connection from pool=" + pool);
+ }
+ catch (Throwable t)
+ {
+ throw ResourceExceptionUtil.checkApplicationServerInternal(t);
+ }
+
+ // Create a new connection
+ ManagedConnectionContext context = (ManagedConnectionContext) invocation.invokeNext();
+ context.setPool(pool);
+ if (trace)
+ log.trace("Assigned to pool " + context);
+ return context;
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/none/NoPoolFactory.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/none/NoPoolFactory.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/none/NoPoolFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.cm.pool.none;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.security.auth.Subject;
+
+import org.jboss.jca.spi.cm.ManagedConnectionContext;
+import org.jboss.jca.spi.pool.ManagedConnectionContextPool;
+import org.jboss.jca.spi.pool.ManagedConnectionContextPoolFactory;
+
+/**
+ * NoPoolFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class NoPoolFactory implements ManagedConnectionContextPoolFactory, ManagedConnectionContextPool
+{
+ public ManagedConnectionContextPool createPool()
+ {
+ return this;
+ }
+
+ public ManagedConnectionContext getManagedConnectonContext(Subject subject, ConnectionRequestInfo info) throws ResourceException
+ {
+ return null;
+ }
+
+ public void returnManagedConnectonContext(ManagedConnectionContext context)
+ {
+ context.destroy();
+ }
+
+ public void removeManagedConnectonContext(ManagedConnectionContext context)
+ {
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/simple/SimplePool.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/simple/SimplePool.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/simple/SimplePool.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,91 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.cm.pool.simple;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.security.auth.Subject;
+
+import org.jboss.jca.spi.cm.ManagedConnectionContext;
+import org.jboss.jca.spi.pool.ManagedConnectionContextPool;
+import org.jboss.logging.Logger;
+
+/**
+ * SimplePool.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimplePool implements ManagedConnectionContextPool
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(SimplePool.class);
+
+ /** The pool */
+ private List pool = new ArrayList();
+
+ public ManagedConnectionContext getManagedConnectonContext(Subject subject, ConnectionRequestInfo cri) throws ResourceException
+ {
+ ManagedConnectionContext context = null;
+ while (true)
+ {
+ synchronized (pool)
+ {
+ int size = pool.size();
+ if (size == 0)
+ return null;
+ context = (ManagedConnectionContext) pool.remove(size-1);
+ }
+
+ if (context.match(subject, cri))
+ return context;
+ else
+ {
+ log.warn("Destroying unmatched connection context=" + context + " subject=" + subject + " cri=" + cri, new Throwable("STACKTRACE"));
+ context.destroy();
+ }
+ }
+ }
+
+ public void removeManagedConnectonContext(ManagedConnectionContext context)
+ {
+ synchronized (pool)
+ {
+ pool.remove(context);
+ if (log.isTraceEnabled())
+ log.trace("Removed context=" + context + " size=" + pool.size());
+ }
+ }
+
+ public void returnManagedConnectonContext(ManagedConnectionContext context)
+ {
+ synchronized (pool)
+ {
+ pool.add(context);
+ if (log.isTraceEnabled())
+ log.trace("Add context=" + context + " size=" + pool.size());
+ }
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/simple/SimplePoolFactory.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/simple/SimplePoolFactory.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/pool/simple/SimplePoolFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.cm.pool.simple;
+
+import org.jboss.jca.spi.pool.ManagedConnectionContextPool;
+import org.jboss.jca.spi.pool.ManagedConnectionContextPoolFactory;
+
+public class SimplePoolFactory implements ManagedConnectionContextPoolFactory
+{
+ public ManagedConnectionContextPool createPool()
+ {
+ return new SimplePool();
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/security/SecurityAdvice.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/security/SecurityAdvice.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/cm/security/SecurityAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.cm.security;
+
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.security.auth.Subject;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.jca.plugins.advice.AbstractJCAInterceptor;
+import org.jboss.jca.spi.cm.ManagedConnectionContext;
+
+/**
+ * ConnectionManager security advice.
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class SecurityAdvice extends AbstractJCAInterceptor
+{
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ MethodInvocation mi = (MethodInvocation) invocation;
+ ConnectionRequestInfo cri = (ConnectionRequestInfo) mi.getArguments()[1];
+ Subject subject = null; // TODO Subject
+
+ ManagedConnectionContext context = (ManagedConnectionContext) mi.invokeNext();
+
+ return context.getConnection(subject, cri);
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/Activation.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/Activation.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/Activation.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,158 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.endpoint;
+
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+
+import org.jboss.jca.spi.ResourceExceptionUtil;
+import org.jboss.logging.Logger;
+
+/**
+ * An Activation.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.3 $
+ */
+public class Activation
+{
+ /** The logger */
+ private static final Logger log = Logger.getLogger(Activation.class);
+
+ /** The endpoint factory */
+ protected MessageEndpointFactory messageEndpointFactory;
+
+ /** The activation spec */
+ protected ActivationSpec activationSpec;
+
+ /** The resource adapter */
+ protected ResourceAdapter resourceAdapter;
+
+ /**
+ * Get the activationSpec.
+ *
+ * @return the activationSpec.
+ */
+ public ActivationSpec getActivationSpec()
+ {
+ return activationSpec;
+ }
+
+ /**
+ * Set the activationSpec.
+ *
+ * @param activationSpec The activationSpec to set.
+ */
+ public void setActivationSpec(ActivationSpec activationSpec)
+ {
+ this.activationSpec = activationSpec;
+ }
+
+ /**
+ * Get the endpointFactory.
+ *
+ * @return the endpointFactory.
+ */
+ public MessageEndpointFactory getMessageEndpointFactory()
+ {
+ return messageEndpointFactory;
+ }
+
+ /**
+ * Set the endpointFactory.
+ *
+ * @param endpointFactory The messageEndpointFactory to set.
+ */
+ public void setMessageEndpointFactory(MessageEndpointFactory messageEndpointFactory)
+ {
+ this.messageEndpointFactory = messageEndpointFactory;
+ }
+
+ /**
+ * Get the resourceAdapter.
+ *
+ * @return the resourceAdapter.
+ */
+ public ResourceAdapter getResourceAdapter()
+ {
+ return resourceAdapter;
+ }
+
+ /**
+ * Set the resourceAdapter.
+ *
+ * @param resourceAdapter The resourceAdapter to set.
+ */
+ public void setResourceAdapter(ResourceAdapter resourceAdapter)
+ {
+ this.resourceAdapter = resourceAdapter;
+ }
+
+ public void start() throws Exception
+ {
+ if (resourceAdapter == null)
+ throw new IllegalStateException("Null resource adapter");
+ if (messageEndpointFactory == null)
+ throw new IllegalStateException("Null message endpoint factory");
+ if (activationSpec == null)
+ throw new IllegalStateException("Null activation spec");
+
+ boolean trace = log.isTraceEnabled();
+ try
+ {
+ if (trace)
+ log.trace("Trying to validate ActivationSpec " + activationSpec);
+ activationSpec.validate();
+ }
+ catch (UnsupportedOperationException e)
+ {
+ log.debug("Validation is not supported for ActivationSpec: " + activationSpec.getClass().getName());
+ }
+
+ if (trace)
+ log.trace("Activation rar=" + resourceAdapter + " mef=" + messageEndpointFactory + " spec=" + activationSpec);
+ try
+ {
+ resourceAdapter.endpointActivation(messageEndpointFactory, activationSpec);
+ }
+ catch (Throwable t)
+ {
+ throw ResourceExceptionUtil.checkResourceAdapterInternal(t);
+ }
+ }
+
+ public void stop()
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Deactivation rar=" + resourceAdapter + " mef=" + messageEndpointFactory + " spec=" + activationSpec);
+ try
+ {
+ resourceAdapter.endpointDeactivation(messageEndpointFactory, activationSpec);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error during deactivation rar=" + resourceAdapter + " mef=" + messageEndpointFactory + " spec=" + activationSpec, t);
+ }
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/POJOMessageEndpointAdvice.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/POJOMessageEndpointAdvice.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/POJOMessageEndpointAdvice.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,261 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.endpoint;
+
+import java.lang.reflect.Method;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.endpoint.MessageEndpoint;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.jca.plugins.advice.AbstractJCAInterceptor;
+
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
+
+/**
+ * Implements the message endpoint requirements.
+ *
+ * @todo transactions and classloaders
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.3 $
+ */
+public class POJOMessageEndpointAdvice extends AbstractJCAInterceptor
+{
+ /** Whether trace is enabled */
+ private boolean trace = log.isTraceEnabled();
+
+ /** Cached version of our proxy string */
+ private String cachedProxyString = null;
+
+ /** Whether this proxy has had before invoked */
+ protected SynchronizedBoolean beforeInvoked = new SynchronizedBoolean(false);
+
+ /** Whether this proxy has been released */
+ protected SynchronizedBoolean released = new SynchronizedBoolean(false);
+
+ /** Whether we have delivered a message */
+ protected SynchronizedBoolean delivered = new SynchronizedBoolean(false);
+
+ /** The in use thread */
+ protected Thread inUseThread = null;
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ MethodInvocation mi = (MethodInvocation) invocation;
+ check(mi);
+
+ Method method = mi.getMethod();
+ if (MessageEndpoint.class.equals(method.getDeclaringClass()))
+ {
+ String name = method.getName();
+ if ("beforeDelivery".equals(name))
+ beforeDelivery(mi);
+ else if ("afterDelivery".equals(name))
+ afterDelivery(mi);
+ else if ("release".equals(name))
+ release(mi);
+ return null;
+ }
+ else
+ {
+ return deliver(mi);
+ }
+ }
+
+ /**
+ * Deliver the message
+ *
+ * @param mi the method
+ * @return the result of the delivery
+ * @throws Throwable for any error
+ */
+ protected Object deliver(MethodInvocation mi) throws Throwable
+ {
+ // Have we already delivered a message?
+ if (delivered.get())
+ throw new IllegalStateException("Multiple message delivery between before and after delivery is not allowed for message endpoint " + getProxyString(mi));
+
+ if (trace)
+ log.trace("MessageEndpoint " + getProxyString(mi) + " delivering");
+
+ // Mark delivery if beforeDelivery was invoked
+ if (beforeInvoked.get())
+ delivered.set(true);
+
+ try
+ {
+ Object result = mi.invokeNext();
+ if (trace)
+ log.trace("MessageEndpoint " + getProxyString(mi) + " delivered");
+ return result;
+ }
+ catch (Throwable t)
+ {
+ if (trace)
+ log.trace("MessageEndpoint " + getProxyString(mi) + " delivery error", t);
+ throw t;
+ }
+ finally
+ {
+ // No before/after delivery, end any transaction and release the lock
+ if (beforeInvoked.get() == false)
+ releaseThreadLock(mi);
+ }
+ }
+
+ /**
+ * Release this message endpoint.
+ *
+ * @param mi the invocation
+ * @throws Throwable for any error
+ */
+ protected void release(MethodInvocation mi) throws Throwable
+ {
+ // We are now released
+ released.set(true);
+
+ if (trace)
+ log.trace("MessageEndpoint " + getProxyString(mi) + " released");
+
+ // Tidyup any outstanding delivery
+ if (beforeInvoked.get())
+ {
+ try
+ {
+ finish("release", mi, false);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error in release ", t);
+ }
+ }
+ }
+
+ /**
+ * Before delivery processing.
+ *
+ * @param mi the invocation
+ * @throws Throwable for any error
+ */
+ protected void beforeDelivery(MethodInvocation mi) throws Throwable
+ {
+ // Called out of sequence
+ if (beforeInvoked.get())
+ throw new IllegalStateException("Missing afterDelivery from the previous beforeDelivery for message endpoint " + getProxyString(mi));
+
+ if (trace)
+ log.trace("MessageEndpoint " + getProxyString(mi) + " before");
+ beforeInvoked.set(true);
+ }
+
+ /**
+ * After delivery processing.
+ *
+ * @param mi the invocation
+ * @throws Throwable for any error
+ */
+ protected void afterDelivery(MethodInvocation mi) throws Throwable
+ {
+ // Called out of sequence
+ if (beforeInvoked.get() == false)
+ throw new IllegalStateException("afterDelivery without a previous beforeDelivery for message endpoint " + getProxyString(mi));
+
+ // Finish this delivery committing if we can
+ try
+ {
+ finish("afterDelivery", mi, true);
+ }
+ catch (Throwable t)
+ {
+ throw new ResourceException(t);
+ }
+ finally
+ {
+ beforeInvoked.set(false);
+ }
+ }
+
+ /**
+ * Check the state of the method endpoint
+ *
+ * @param mi the method invocation
+ */
+ protected void check(MethodInvocation mi)
+ {
+ // Are we still useable?
+ trace = log.isTraceEnabled();
+ if (released.get())
+ throw new IllegalStateException("This message endpoint + " + getProxyString(mi) + " has been released");
+
+ // Concurrent invocation?
+ Thread currentThread = Thread.currentThread();
+ if (inUseThread != null && inUseThread != currentThread)
+ throw new IllegalStateException("This message endpoint + " + getProxyString(mi) + " is already in use by another thread " + inUseThread);
+ inUseThread = currentThread;
+
+ String method = mi.getMethod().getName();
+ if (trace)
+ log.trace("MessageEndpoint " + getProxyString(mi) + " in use by " + method + " " + inUseThread);
+ }
+
+ /**
+ * Finish the current delivery
+ *
+ * @param context the lifecycle method
+ * @param mi the invocation
+ * @param commit whether to commit
+ * @throws Throwable for any error
+ */
+ protected void finish(String context, MethodInvocation mi, boolean commit) throws Throwable
+ {
+ // Reset delivered flag
+ delivered.set(false);
+ // We no longer hold the lock
+ releaseThreadLock(mi);
+ }
+
+ /**
+ * Release the thread lock
+ *
+ * @param mi the invocation
+ */
+ protected void releaseThreadLock(MethodInvocation mi)
+ {
+ if (trace)
+ log.trace("MessageEndpoint " + getProxyString(mi) + " no longer in use by " + inUseThread);
+ inUseThread = null;
+ }
+
+ /**
+ * Get our proxy's string value.
+ *
+ * @param mi the invocation
+ * @return the string
+ */
+ protected String getProxyString(MethodInvocation mi)
+ {
+ if (cachedProxyString == null)
+ cachedProxyString = mi.getTargetObject().toString();
+ return cachedProxyString;
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/POJOMessageEndpointFactory.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/POJOMessageEndpointFactory.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/endpoint/POJOMessageEndpointFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,138 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.endpoint;
+
+import java.lang.reflect.Method;
+
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.transaction.xa.XAResource;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.proxy.container.AOPProxyFactory;
+import org.jboss.aop.proxy.container.AOPProxyFactoryParameters;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+
+/**
+ * A POJO MessageEndpointFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.5 $
+ */
+public class POJOMessageEndpointFactory implements MessageEndpointFactory
+{
+ /** The proxy factory */
+ private static final AOPProxyFactory proxyFactory = new GeneratedAOPProxyFactory();
+
+ /** The target */
+ protected Object target;
+
+ /** The aspect manager */
+ protected AspectManager manager;
+
+ /** The message listener class */
+ protected Class messageListener;
+
+ /**
+ * Get the manager.
+ *
+ * @return the manager.
+ */
+ public AspectManager getManager()
+ {
+ return manager;
+ }
+
+ /**
+ * Set the manager.
+ *
+ * @param manager The manager to set.
+ */
+ public void setManager(AspectManager manager)
+ {
+ this.manager = manager;
+ }
+
+ /**
+ * Get the messageListener.
+ *
+ * @return the messageListener.
+ */
+ public Class getMessageListener()
+ {
+ return messageListener;
+ }
+
+ /**
+ * Set the messageListener.
+ *
+ * @param messageListener The messageListener to set.
+ */
+ public void setMessageListener(Class messageListener)
+ {
+ this.messageListener = messageListener;
+ }
+
+ /**
+ * Get the target.
+ *
+ * @return the target.
+ */
+ public Object getTarget()
+ {
+ return target;
+ }
+
+ /**
+ * Set the target.
+ *
+ * @param target The target to set.
+ */
+ public void setTarget(Object target)
+ {
+ this.target = target;
+ }
+
+ public MessageEndpoint createEndpoint(XAResource resource) throws UnavailableException
+ {
+ if (target == null)
+ throw new IllegalStateException("Null target");
+ if (manager == null)
+ throw new IllegalStateException("Null manager");
+ if (messageListener == null)
+ throw new IllegalStateException("Null messageListener");
+
+ Class[] interfaces = new Class[] { messageListener, MessageEndpoint.class };
+
+ AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+ params.setInterfaces(interfaces);
+ params.setTarget(target);
+
+ return (MessageEndpoint) proxyFactory.createAdvisedProxy(params);
+ }
+
+ public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException
+ {
+ throw new org.jboss.util.NotImplementedException("FIXME NYI isDeliveryTransacted");
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/timer/JDKTimerFactory.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/timer/JDKTimerFactory.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/timer/JDKTimerFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.rar.timer;
+
+import java.util.Timer;
+
+import javax.resource.spi.UnavailableException;
+
+import org.jboss.jca.spi.rar.TimerFactory;
+
+/**
+ * A JDK TimerFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class JDKTimerFactory implements TimerFactory
+{
+ public Timer createTimer() throws UnavailableException
+ {
+ return new Timer();
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/work/JBossWorkManager.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/work/JBossWorkManager.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/work/JBossWorkManager.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,318 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.rar.work;
+
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.WorkRejectedException;
+import javax.transaction.xa.Xid;
+
+import org.jboss.logging.Logger;
+import org.jboss.tm.JBossXATerminator;
+import org.jboss.util.threadpool.Task;
+import org.jboss.util.threadpool.ThreadPool;
+
+/**
+ * The work manager implementation
+ *
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.3 $
+ */
+public class JBossWorkManager
+{
+ /** The logger */
+ private static final Logger log = Logger.getLogger(JBossWorkManager.class);
+
+ /** Whether trace is enabled */
+ private boolean trace = log.isTraceEnabled();
+
+ /** The work manager */
+ private WorkManager workManager = new WorkManagerImpl();
+
+ /** The thread pool */
+ protected ThreadPool threadPool;
+
+ /** The xa terminator */
+ protected JBossXATerminator xaTerminator;
+
+ /**
+ * Retrieve the thread pool
+ *
+ * @return the thread pool
+ */
+ public ThreadPool getThreadPool()
+ {
+ return threadPool;
+ }
+
+ /**
+ * Set the thread pool
+ *
+ * @param threadPool the thread pool
+ */
+ public void setThreadPool(ThreadPool threadPool)
+ {
+ this.threadPool = threadPool;
+ }
+
+ /**
+ * Get the xaTerminator.
+ *
+ * @return the xaTerminator.
+ */
+ public JBossXATerminator getXaTerminator()
+ {
+ return xaTerminator;
+ }
+
+ /**
+ * Set the xaTerminator.
+ *
+ * @param xaTerminator The xaTerminator to set.
+ */
+ public void setXaTerminator(JBossXATerminator xaTerminator)
+ {
+ this.xaTerminator = xaTerminator;
+ }
+
+ /**
+ * Get the work manager implementation
+ *
+ * @return the work manager
+ */
+ public WorkManager getWorkManager()
+ {
+ return workManager;
+ }
+
+ public void doWork(Work work, long startTimeout, ExecutionContext ctx, WorkListener listener) throws WorkException
+ {
+ if (ctx == null)
+ ctx = new ExecutionContext();
+ WorkWrapper wrapper = new WorkWrapper(this, work, Task.WAIT_FOR_COMPLETE, startTimeout, ctx, listener);
+ importWork(wrapper);
+ executeWork(wrapper);
+ if (wrapper.getWorkException() != null)
+ throw wrapper.getWorkException();
+ }
+
+ public void doWork(Work work) throws WorkException
+ {
+ doWork(work, WorkManager.INDEFINITE, null, null);
+ }
+
+ public long startWork(Work work, long startTimeout, ExecutionContext ctx, WorkListener listener) throws WorkException
+ {
+ if (ctx == null)
+ ctx = new ExecutionContext();
+ WorkWrapper wrapper = new WorkWrapper(this, work, Task.WAIT_FOR_START, startTimeout, ctx, listener);
+ importWork(wrapper);
+ executeWork(wrapper);
+ if (wrapper.getWorkException() != null)
+ throw wrapper.getWorkException();
+ return wrapper.getBlockedElapsed();
+ }
+
+ public long startWork(Work work) throws WorkException
+ {
+ return startWork(work, WorkManager.INDEFINITE, null, null);
+ }
+
+ public void scheduleWork(Work work, long startTimeout, ExecutionContext ctx, WorkListener listener) throws WorkException
+ {
+ if (ctx == null)
+ ctx = new ExecutionContext();
+ WorkWrapper wrapper = new WorkWrapper(this, work, Task.WAIT_NONE, startTimeout, ctx, listener);
+ importWork(wrapper);
+ executeWork(wrapper);
+ if (wrapper.getWorkException() != null)
+ throw wrapper.getWorkException();
+ }
+
+ public void scheduleWork(Work work) throws WorkException
+ {
+ scheduleWork(work, WorkManager.INDEFINITE, null, null);
+ }
+
+ /**
+ * Import any work
+ *
+ * @param wrapper the work wrapper
+ * @throws WorkException for any error
+ */
+ protected void importWork(WorkWrapper wrapper) throws WorkException
+ {
+ trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Importing work " + wrapper);
+
+ if (xaTerminator == null)
+ throw new WorkRejectedException("No XATermintor", WorkException.INTERNAL);
+
+ ExecutionContext ctx = wrapper.getExecutionContext();
+ if (ctx != null)
+ {
+ Xid xid = ctx.getXid();
+ if (xid != null)
+ {
+ long timeout = ctx.getTransactionTimeout();
+ xaTerminator.registerWork(wrapper.getWork(), xid, timeout);
+ }
+ }
+ if (trace)
+ log.trace("Imported work " + wrapper);
+ }
+
+ /**
+ * Execute the work
+ *
+ * @param wrapper the work wrapper
+ * @throws WorkException for any error
+ */
+ protected void executeWork(WorkWrapper wrapper) throws WorkException
+ {
+ if (trace)
+ log.trace("Submitting work to thread pool " + wrapper);
+
+ if (threadPool == null)
+ throw new WorkRejectedException("No thread pool", WorkException.INTERNAL);
+
+ threadPool.runTaskWrapper(wrapper);
+
+ if (trace)
+ log.trace("Submitted work to thread pool " + wrapper);
+ }
+
+ /**
+ * Start work
+ *
+ * @param wrapper the work wrapper
+ * @throws WorkException for any error
+ */
+ protected void startWork(WorkWrapper wrapper) throws WorkException
+ {
+ if (trace)
+ log.trace("Starting work " + wrapper);
+
+ if (xaTerminator == null)
+ throw new WorkRejectedException("No XATermintor", WorkException.INTERNAL);
+
+ ExecutionContext ctx = wrapper.getExecutionContext();
+ if (ctx != null)
+ {
+ Xid xid = ctx.getXid();
+ if (xid != null)
+ {
+ xaTerminator.startWork(wrapper.getWork(), xid);
+ }
+ }
+ if (trace)
+ log.trace("Started work " + wrapper);
+ }
+
+ /**
+ * End work
+ *
+ * @param wrapper the work wrapper
+ * @throws WorkException for any error
+ */
+ protected void endWork(WorkWrapper wrapper)
+ {
+ if (trace)
+ log.trace("Ending work " + wrapper);
+
+ ExecutionContext ctx = wrapper.getExecutionContext();
+ if (ctx != null)
+ {
+ Xid xid = ctx.getXid();
+ if (xid != null)
+ {
+ xaTerminator.endWork(wrapper.getWork(), xid);
+ }
+ }
+ if (trace)
+ log.trace("Ended work " + wrapper);
+ }
+
+ /**
+ * Cancel work
+ *
+ * @param wrapper the work wrapper
+ * @throws WorkException for any error
+ */
+ protected void cancelWork(WorkWrapper wrapper)
+ {
+ if (trace)
+ log.trace("Cancel work " + wrapper);
+
+ ExecutionContext ctx = wrapper.getExecutionContext();
+ if (ctx != null)
+ {
+ Xid xid = ctx.getXid();
+ if (xid != null)
+ {
+ xaTerminator.cancelWork(wrapper.getWork(), xid);
+ }
+ }
+ if (trace)
+ log.trace("Canceled work " + wrapper);
+ }
+
+ /**
+ * A WorkManagerImpl.
+ */
+ private class WorkManagerImpl implements WorkManager
+ {
+ public void doWork(Work work, long startTimeout, ExecutionContext ctx, WorkListener listener) throws WorkException
+ {
+ JBossWorkManager.this.doWork(work, startTimeout, ctx, listener);
+ }
+
+ public void doWork(Work work) throws WorkException
+ {
+ JBossWorkManager.this.doWork(work);
+ }
+
+ public void scheduleWork(Work work, long startTimeout, ExecutionContext ctx, WorkListener listener) throws WorkException
+ {
+ JBossWorkManager.this.scheduleWork(work, startTimeout, ctx, listener);
+ }
+
+ public void scheduleWork(Work work) throws WorkException
+ {
+ JBossWorkManager.this.scheduleWork(work);
+ }
+
+ public long startWork(Work work, long startTimeout, ExecutionContext ctx, WorkListener listener) throws WorkException
+ {
+ return JBossWorkManager.this.startWork(work, startTimeout, ctx, listener);
+ }
+
+ public long startWork(Work work) throws WorkException
+ {
+ return JBossWorkManager.this.startWork(work);
+ }
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/work/WorkWrapper.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/work/WorkWrapper.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/plugins/rar/work/WorkWrapper.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,341 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.plugins.rar.work;
+
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkCompletedException;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.WorkRejectedException;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.JBossStringBuilder;
+import org.jboss.util.threadpool.BasicTaskWrapper;
+import org.jboss.util.threadpool.StartTimeoutException;
+import org.jboss.util.threadpool.Task;
+
+/**
+ * Wraps the resource adapter's work.
+ *
+ * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.4 $
+ */
+public class WorkWrapper extends BasicTaskWrapper implements Task
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(WorkWrapper.class);
+
+ /** Whether we are tracing */
+ private boolean trace = log.isTraceEnabled();
+
+ /** The work */
+ private Work work;
+
+ /** The execution context */
+ private ExecutionContext executionContext;
+
+ /** the work listener */
+ private WorkListener workListener;
+
+ /** The start timeout */
+ private long startTimeout;
+
+ /** The work manager */
+ private JBossWorkManager workManager;
+
+ /** The wait type */
+ private int waitType;
+
+ /** The blocked time */
+ private long blockedTime;
+
+ /** Any exception */
+ private WorkException exception;
+
+ /**
+ * Create a new WorkWrapper
+ *
+ * @param workManager the work manager
+ * @param work the work
+ * @param waitType the waitType
+ * @param executionContext the execution context
+ * @param workListener the WorkListener
+ * @throws IllegalArgumentException for null work, execution context or a negative start timeout
+ */
+ public WorkWrapper(JBossWorkManager workManager, Work work, int waitType, long startTimeout, ExecutionContext executionContext, WorkListener workListener)
+ {
+ super();
+
+ if (work == null)
+ throw new IllegalArgumentException("Null work");
+ if (executionContext == null)
+ throw new IllegalArgumentException("Null execution context");
+ if (startTimeout < 0)
+ throw new IllegalArgumentException("Illegal start timeout: " + startTimeout);
+
+ this.workManager = workManager;
+ this.work = work;
+ this.waitType = waitType;
+ this.startTimeout = startTimeout;
+ this.executionContext = executionContext;
+ this.workListener = workListener;
+
+ setTask(this);
+ }
+
+ /**
+ * Get the work manager
+ *
+ * @return the work manager
+ */
+ public JBossWorkManager getWorkManager()
+ {
+ return workManager;
+ }
+
+ /**
+ * Retrieve the work
+ *
+ * @return the work
+ */
+ public Work getWork()
+ {
+ return work;
+ }
+
+ /**
+ * Retrieve the work listener
+ *
+ * @return the WorkListener
+ */
+ public WorkListener getWorkListener()
+ {
+ return workListener;
+ }
+
+ /**
+ * Retrieve the exection context
+ *
+ * @return the execution context
+ */
+ public ExecutionContext getExecutionContext()
+ {
+ return executionContext;
+ }
+
+ /**
+ * Retrieve the time blocked
+ *
+ * @return the blocked time
+ */
+ public long getBlockedElapsed()
+ {
+ return blockedTime;
+ }
+
+ /**
+ * Get any exception
+ *
+ * @return the exception or null if there is none
+ */
+ public WorkException getWorkException()
+ {
+ return exception;
+ }
+
+ public int getWaitType()
+ {
+ return waitType;
+ }
+
+ public int getPriority()
+ {
+ return Thread.NORM_PRIORITY;
+ }
+
+ public long getStartTimeout()
+ {
+ return startTimeout;
+ }
+
+ public long getCompletionTimeout()
+ {
+ return executionContext.getTransactionTimeout();
+ }
+
+ public void execute()
+ {
+ if (trace)
+ log.trace("Executing work " + this);
+ try
+ {
+ workManager.startWork(this);
+ }
+ catch (WorkException e)
+ {
+ taskRejected(new RuntimeException(e));
+ return;
+ }
+ try
+ {
+ work.run();
+ }
+ finally
+ {
+ workManager.endWork(this);
+ }
+ if (trace)
+ log.trace("Executed work " + this);
+ }
+
+ public void stop()
+ {
+ if (trace)
+ log.trace("Stopping work " + this);
+
+ work.release();
+ }
+
+ public void accepted(long time)
+ {
+ blockedTime = time;
+
+ if (trace)
+ log.trace("Accepted work " + this);
+
+ if (workListener != null)
+ {
+ WorkEvent event = new WorkEvent(workManager, WorkEvent.WORK_ACCEPTED, work, null);
+ workListener.workAccepted(event);
+ }
+ }
+
+ public void rejected(long time, Throwable throwable)
+ {
+ blockedTime = time;
+
+ if (trace)
+ {
+ if (throwable != null)
+ log.trace("Rejecting work " + this, throwable);
+ else
+ log.trace("Rejecting work " + this);
+ }
+
+ if (throwable != null)
+ {
+ exception = new WorkRejectedException(throwable);
+ if (throwable instanceof StartTimeoutException)
+ exception.setErrorCode(WorkRejectedException.START_TIMED_OUT);
+ }
+
+ workManager.cancelWork(this);
+
+ if (workListener != null)
+ {
+ WorkEvent event = new WorkEvent(workManager, WorkEvent.WORK_ACCEPTED, work, exception);
+ workListener.workRejected(event);
+ }
+ }
+
+ public void started(long time)
+ {
+ if (waitType != WAIT_NONE)
+ blockedTime = time;
+
+ if (workListener != null)
+ {
+ WorkEvent event = new WorkEvent(workManager, WorkEvent.WORK_STARTED, work, null);
+ workListener.workStarted(event);
+ }
+ }
+
+ public void completed(long time, Throwable throwable)
+ {
+ if (waitType == WAIT_FOR_COMPLETE)
+ blockedTime = time;
+
+ if (throwable != null)
+ exception = new WorkCompletedException(throwable);
+
+ if (trace)
+ log.trace("Completed work " + this);
+
+ if (workListener != null)
+ {
+ WorkEvent event = new WorkEvent(workManager, WorkEvent.WORK_COMPLETED, work, exception);
+ workListener.workCompleted(event);
+ }
+ }
+
+ public String toString()
+ {
+ JBossStringBuilder buffer = new JBossStringBuilder(100);
+ buffer.append("WorkWrapper@").append(Integer.toHexString(System.identityHashCode(this)));
+ buffer.append("[workManger=").append(workManager);
+ buffer.append(" work=").append(work);
+ buffer.append(" state=").append(getStateString());
+ if (executionContext != null && executionContext.getXid() != null)
+ {
+ buffer.append(" xid=").append(executionContext.getXid());
+ buffer.append(" txTimeout=").append(executionContext.getTransactionTimeout());
+ }
+ buffer.append(" waitType=");
+ switch (waitType)
+ {
+ case WAIT_NONE:
+ {
+ buffer.append("WAIT_NONE");
+ break;
+ }
+ case WAIT_FOR_START:
+ {
+ buffer.append("WAIT_FOR_START");
+ break;
+ }
+ case WAIT_FOR_COMPLETE:
+ {
+ buffer.append("WAIT_FOR_COMPLETE");
+ break;
+ }
+ default:
+ buffer.append("???");
+ }
+ if (startTimeout != WorkManager.INDEFINITE)
+ buffer.append(" startTimeout=").append(startTimeout);
+ long completionTimeout = getCompletionTimeout();
+ if (completionTimeout != -1)
+ buffer.append(" completionTimeout=").append(completionTimeout);
+ if (blockedTime != 0)
+ buffer.append(" blockTime=").append(blockedTime);
+ buffer.append(" elapsedTime=").append(getElapsedTime());
+ if (workListener != null)
+ buffer.append(" workListener=").append(workListener);
+ if (exception != null)
+ buffer.append(" exception=").append(exception);
+ buffer.append("]");
+ return buffer.toString();
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/spi/ResourceExceptionUtil.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/spi/ResourceExceptionUtil.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/spi/ResourceExceptionUtil.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.spi;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ApplicationServerInternalException;
+import javax.resource.spi.ResourceAdapterInternalException;
+
+/**
+ * A ResourceExceptionUtil.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class ResourceExceptionUtil
+{
+ /**
+ * Checks whether the throwable is a resource exception
+ *
+ * @param t the throwable
+ * @return any non-ResourceException
+ * @throws ResourceException if it is a resource exception
+ */
+ public static Throwable checkResourceException(Throwable t) throws ResourceException
+ {
+ if (t instanceof ResourceException)
+ throw (ResourceException) t;
+ else if (t instanceof SecurityException)
+ throw (SecurityException) t;
+ else
+ return t;
+ }
+
+ /**
+ * Handles a non resource exception as an application server internal
+ *
+ * @param t the throwable
+ * @return an application server internal for any non-ResourceException
+ * @throws ResourceException if it is a resource exception
+ */
+ public static ApplicationServerInternalException checkApplicationServerInternal(Throwable t) throws ResourceException
+ {
+ t = checkResourceException(t);
+ ApplicationServerInternalException e = new ApplicationServerInternalException("Unexpected error");
+ e.initCause(t);
+ return e;
+ }
+
+ /**
+ * Handles a non resource exception as a resource adapter internal
+ *
+ * @param t the throwable
+ * @return a resource adapter internal for any non-ResourceException
+ * @throws ResourceException if it is a resource exception
+ */
+ public static ResourceAdapterInternalException checkResourceAdapterInternal(Throwable t) throws ResourceException
+ {
+ t = checkResourceException(t);
+ ResourceAdapterInternalException e = new ResourceAdapterInternalException("Unexpected error in resource adapter");
+ e.initCause(t);
+ return e;
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/spi/cm/ManagedConnectionContext.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/spi/cm/ManagedConnectionContext.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/spi/cm/ManagedConnectionContext.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,480 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.spi.cm;
+
+import java.util.Collections;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ApplicationServerInternalException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.security.auth.Subject;
+
+import org.jboss.jca.spi.ResourceExceptionUtil;
+import org.jboss.jca.spi.pool.ManagedConnectionContextPool;
+import org.jboss.logging.Logger;
+import org.jboss.util.collection.CollectionsFactory;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
+
+/**
+ * A ManagedConnectionContext.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.5 $
+ */
+public class ManagedConnectionContext extends JBossObject implements ConnectionEventListener
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(ManagedConnectionContext.class);
+
+ /** Initializing state */
+ public static final int INITIALIZING = 0;
+
+ /** In the pool state */
+ public static final int POOL = 1;
+
+ /** Cleanup state */
+ public static final int CLEANUP = 2;
+
+ /** Checked out state */
+ public static final int INUSE = 3;
+
+ /** Destroying state */
+ public static final int DESTROYING = -1;
+
+ /** Destroyed state */
+ public static final int DESTROYED = -2;
+
+ /** The context manager */
+ protected ManagedConnectionContextManager contextManager;
+
+ /** The managed connection factory */
+ protected ManagedConnectionFactory managedConnectionFactory;
+
+ /** The managed connection */
+ protected ManagedConnection managedConnection;
+
+ /** The pool */
+ protected ManagedConnectionContextPool pool;
+
+ /** The state */
+ private SynchronizedInt state = new SynchronizedInt(INITIALIZING);
+
+ /** The connection handles */
+ protected Set handles = CollectionsFactory.createCopyOnWriteSet();
+
+ /** Any cached connection set */
+ protected Set connectionSet;
+
+ /**
+ * Safely destroy a managed connecton
+ *
+ * @param mc the managed connection
+ */
+ public static void safeDestroy(ManagedConnection mc)
+ {
+ if (mc == null)
+ {
+ log.error("Attempt to destroy null managed connection", new ApplicationServerInternalException("STACKTRACE"));
+ return;
+ }
+ try
+ {
+ mc.destroy();
+ }
+ catch (Throwable ignored)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Ignored error destroying managed connection " + mc, ignored);
+ }
+ }
+
+ /**
+ * Create a new ManagedConnectionContext.
+ *
+ * @param contextManager the context manager
+ * @param managedConnection the managed connection
+ * @throws ResourceException for any error
+ */
+ public ManagedConnectionContext(ManagedConnectionContextManager contextManager, ManagedConnectionFactory managedConnectionFactory, ManagedConnection managedConnection) throws ResourceException
+ {
+ if (contextManager == null)
+ throw new IllegalArgumentException("Null context manager");
+ if (managedConnectionFactory == null)
+ throw new IllegalArgumentException("Null managed connection factory");
+ if (managedConnection == null)
+ throw new IllegalArgumentException("Null managed connection");
+ this.contextManager = contextManager;
+ this.managedConnectionFactory = managedConnectionFactory;
+ this.managedConnection = managedConnection;
+
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Add ConnectionEventListener: " + this);
+ try
+ {
+ managedConnection.addConnectionEventListener(this);
+ }
+ catch (Throwable t)
+ {
+ throw ResourceExceptionUtil.checkResourceAdapterInternal(t);
+ }
+
+ changeState(INUSE);
+ }
+
+ /**
+ * Get the state of the connection
+ *
+ * @return the state
+ */
+ public int getState()
+ {
+ return state.get();
+ }
+
+ /**
+ * Set the context in use
+ */
+ public void setInUse(ManagedConnectionContextPool pool) throws ResourceException
+ {
+ if (getState() != POOL)
+ throw new ApplicationServerInternalException("Attempt to set in use when not in the pool " + this);
+ if (this.pool != pool)
+ throw new ApplicationServerInternalException("Attempt to change pool=" + pool + " context=" + this);
+ changeState(INUSE);
+ }
+
+ /**
+ * Set the pool
+ *
+ * @param pool the pool
+ */
+ public void setPool(ManagedConnectionContextPool pool)
+ {
+ this.pool = pool;
+ }
+
+ /**
+ * Get a connection from the managed connection
+ *
+ * @param subject the subject
+ * @param cri the connection request info
+ * @return the connection
+ * @throws ResourceException for any error
+ */
+ public Object getConnection(Subject subject, ConnectionRequestInfo cri) throws ResourceException
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Get Connection context=" + this + " subject=" + subject + " cri=" + cri);
+
+ if (getState() != INUSE)
+ throw new ApplicationServerInternalException("Attempt to get connection when NOT in use: " + this);
+
+ Object result = null;
+ try
+ {
+ result = managedConnection.getConnection(subject, cri);
+ }
+ catch (Throwable t)
+ {
+ // @todo probably already happened?
+ //ConnectionEvent event = new ConnectionEvent(managedConnection, ConnectionEvent.CONNECTION_ERROR_OCCURRED);
+ //connectionErrorOccurred(event);
+ throw ResourceExceptionUtil.checkResourceAdapterInternal(t);
+ }
+ if (result == null)
+ throw new ResourceAdapterInternalException("No connection returned");
+ registerHandle(trace, result);
+ if (trace)
+ log.trace("Got Connection result=" + result);
+ return result;
+ }
+
+ public void connectionClosed(ConnectionEvent event)
+ {
+ boolean trace = log.isTraceEnabled();
+ Object handle = event.getConnectionHandle();
+ if (trace)
+ log.trace("Connection Closed " + this + " handle=" + handle);
+
+ unregisterHandle(trace, handle);
+
+ boolean free = isFree();
+ if (trace)
+ log.trace("Free=" + free + " " + this);
+ if (free)
+ returnManagedConnection();
+ }
+
+ public void connectionErrorOccurred(ConnectionEvent event)
+ {
+ throw new org.jboss.util.NotImplementedException("FIXME NYI connectionErrorOccurred");
+ }
+
+ public void localTransactionCommitted(ConnectionEvent event)
+ {
+ throw new org.jboss.util.NotImplementedException("FIXME NYI localTransactionCommitted");
+ }
+
+ public void localTransactionRolledback(ConnectionEvent event)
+ {
+ throw new org.jboss.util.NotImplementedException("FIXME NYI localTransactionRolledback");
+ }
+
+ public void localTransactionStarted(ConnectionEvent event)
+ {
+ throw new org.jboss.util.NotImplementedException("FIXME NYI localTransactionStarted");
+ }
+
+ /**
+ * Match a connection
+ *
+ * @param subject the subject
+ * @param cri the connection request info
+ * @return true when it matches
+ */
+ public boolean match(Subject subject, ConnectionRequestInfo cri)
+ {
+ if (connectionSet == null)
+ connectionSet = Collections.singleton(managedConnection);
+
+ try
+ {
+ ManagedConnection result = managedConnectionFactory.matchManagedConnections(connectionSet, subject, cri);
+ if (result == null || result != managedConnection)
+ return false;
+ else
+ return true;
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error matching connection: " + this + " subject=" + subject + " cri=" + cri, t);
+ return false;
+ }
+ }
+
+ /**
+ * Destroy the managed connection context
+ */
+ public void destroy()
+ {
+ contextManager.removeManagedConnectionContext(this);
+ }
+
+ protected boolean cacheToString()
+ {
+ return false;
+ }
+
+ protected void toString(JBossStringBuilder buffer)
+ {
+ buffer.append("mc=").append(managedConnection);
+ buffer.append(" state=");
+ switch (getState())
+ {
+ case INITIALIZING:
+ {
+ buffer.append("INITIALIZING");
+ break;
+ }
+ case POOL:
+ {
+ buffer.append("POOL");
+ break;
+ }
+ case CLEANUP:
+ {
+ buffer.append("CLEANUP");
+ break;
+ }
+ case INUSE:
+ {
+ buffer.append("INUSE");
+ break;
+ }
+ case DESTROYING:
+ {
+ buffer.append("DESTROYING");
+ break;
+ }
+ case DESTROYED:
+ {
+ buffer.append("DESTROYED");
+ break;
+ }
+ default:
+ buffer.append("???");
+ }
+ if (pool != null)
+ buffer.append(" pool=").append(pool);
+ buffer.append(" handles=" + handles.size());
+ }
+
+ /**
+ * Destroy the managed connection context
+ */
+ protected void destroyContext()
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Destroy " + this);
+
+ if (isDestroyed())
+ return;
+
+ if (pool != null)
+ {
+ pool.removeManagedConnectonContext(this);
+ pool = null;
+ }
+
+ safeDestroy(managedConnection);
+ changeState(DESTROYED);
+ if (trace)
+ log.trace("Destroyed " + this);
+ }
+
+ /**
+ * Return the managed connection to the pool
+ */
+ protected void returnManagedConnection()
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Return ManagedConnection " + this);
+
+ int state = getState();
+ if (state == DESTROYING || state == DESTROYED)
+ return;
+ if (state != INUSE)
+ {
+ log.warn("Attempt to return connection when NOT in use " + this, new ApplicationServerInternalException("STACKTRACE"));
+ return;
+ }
+
+ changeState(CLEANUP);
+ if (trace)
+ log.trace("Cleanup " + this);
+ try
+ {
+ managedConnection.cleanup();
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error during cleanup " + this, t);
+ destroy();
+ return;
+ }
+ changeState(POOL);
+ if (trace)
+ log.trace("Return to pool " + this);
+ pool.returnManagedConnectonContext(this);
+ }
+
+ /**
+ * Cleanup the connection
+ *
+ * @throws ResourceException for any error
+ */
+ protected void cleanup() throws ResourceException
+ {
+ try
+ {
+ managedConnection.cleanup();
+ }
+ catch (Throwable t)
+ {
+ throw ResourceExceptionUtil.checkResourceAdapterInternal(t);
+ }
+ }
+
+ /**
+ * Whether the managed connection is free
+ *
+ * @return true when there are no handles
+ */
+ protected boolean isFree()
+ {
+ return handles.isEmpty();
+ }
+
+ /**
+ * Register a handle
+ *
+ * @param trace whether trace is enabled
+ * @param handle the connection handle
+ */
+ protected void registerHandle(boolean trace, Object handle)
+ {
+ if (trace)
+ log.trace("Register handle=" + handle + " context=" + this);
+ handles.add(handle);
+ }
+
+ /**
+ * Unregister a handle
+ *
+ * @param trace whether trace is enabled
+ * @param handle the connection handle
+ */
+ protected void unregisterHandle(boolean trace, Object handle)
+ {
+ if (trace)
+ log.trace("Unregister handle=" + handle + " context=" + this);
+ if (handles.remove(handle) == false)
+ log.warn("Attempt to unregister handle that was not registered mcc=" + this + " handle=" + handle, new ApplicationServerInternalException("STACKTRACE"));
+ }
+
+ /**
+ * Change the state
+ *
+ * @param newState the new state
+ * @param the previous value
+ */
+ private int changeState(int newState)
+ {
+ return state.set(newState);
+ }
+
+ /**
+ * Check whether we are already destroyed
+ *
+ * @return true if already destroyed/destroying
+ */
+ private boolean isDestroyed()
+ {
+ int state = changeState(DESTROYED);
+ if (state == DESTROYED)
+ changeState(DESTROYED);
+ return state == DESTROYING || state == DESTROYED;
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/spi/cm/ManagedConnectionContextManager.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/spi/cm/ManagedConnectionContextManager.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/spi/cm/ManagedConnectionContextManager.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,83 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.spi.cm;
+
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.collection.CollectionsFactory;
+
+/**
+ * A ManagedConnectionContextManager.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.3 $
+ */
+public class ManagedConnectionContextManager
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(ManagedConnectionContextManager.class);
+
+ /** The contexts */
+ private Set contexts = CollectionsFactory.createCopyOnWriteSet();
+
+ /**
+ * Create a new managed connection context
+ *
+ * @param managedConnectionFactory the managed connection factory
+ * @param managedConnection the managed connection
+ * @return the managed connection context
+ * @throws ResourceException for any error
+ */
+ public ManagedConnectionContext createManagedConnectionContext(ManagedConnectionFactory managedConnectionFactory, ManagedConnection managedConnection) throws ResourceException
+ {
+ boolean trace = log.isTraceEnabled();
+
+ ManagedConnectionContext context = new ManagedConnectionContext(this, managedConnectionFactory, managedConnection);
+ contexts.add(context);
+ if (trace)
+ log.trace("Created context=" + context + " size=" + contexts.size());
+ return context;
+ }
+
+ /**
+ * Remove a managed connection context
+ *
+ * @param context the managed connection context
+ */
+ public void removeManagedConnectionContext(ManagedConnectionContext context)
+ {
+ if (context == null)
+ throw new IllegalArgumentException("Null context");
+
+ boolean trace = log.isTraceEnabled();
+
+ context.destroyContext();
+ contexts.remove(context);
+ if (trace)
+ log.trace("Destroyed context=" + context + " size=" + contexts.size());
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/spi/pool/ManagedConnectionContextPool.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/spi/pool/ManagedConnectionContextPool.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/spi/pool/ManagedConnectionContextPool.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.spi.pool;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.security.auth.Subject;
+
+import org.jboss.jca.spi.cm.ManagedConnectionContext;
+
+/**
+ * ManagedConnectionContextPool.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ManagedConnectionContextPool
+{
+ /**
+ * Get a managed connection context
+ *
+ * @param subject the subject
+ * @param info the connecton request info
+ * @return the managed connection context
+ * @throws ResourceException for any error
+ */
+ ManagedConnectionContext getManagedConnectonContext(Subject subject, ConnectionRequestInfo info) throws ResourceException;
+
+ /**
+ * Return a managed connection context
+ *
+ * @param context the managed connection context
+ */
+ void returnManagedConnectonContext(ManagedConnectionContext context);
+
+ /**
+ * Remove a managed connection context
+ *
+ * @param context the managed connection context
+ */
+ void removeManagedConnectonContext(ManagedConnectionContext context);
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/spi/pool/ManagedConnectionContextPoolFactory.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/spi/pool/ManagedConnectionContextPoolFactory.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/spi/pool/ManagedConnectionContextPoolFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.spi.pool;
+
+/**
+ * ManagedConnectionContextPoolFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ManagedConnectionContextPoolFactory
+{
+ /**
+ * Create a managed connection context pool
+ *
+ * @return the pool
+ */
+ ManagedConnectionContextPool createPool();
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/spi/rar/BootstrapContextFactory.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/spi/rar/BootstrapContextFactory.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/spi/rar/BootstrapContextFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,147 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.spi.rar;
+
+import java.util.Timer;
+
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.work.WorkManager;
+
+/**
+ * A BootstrapContextFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class BootstrapContextFactory
+{
+ /** The bootstrap context */
+ protected JBossBootstrapContext bootstrapContext = new JBossBootstrapContext();
+
+ /** The work manager */
+ protected WorkManager workManager;
+
+ /** The XA terminator */
+ protected XATerminator xaTerminator;
+
+ /** The timer factory */
+ protected TimerFactory timerFactory;
+
+ /**
+ * Get the bootstrap context instance
+ *
+ * @return the instance
+ */
+ public BootstrapContext getBootstrapContext()
+ {
+ return bootstrapContext;
+ }
+
+ /**
+ * Get the workManager.
+ *
+ * @return the workManager.
+ */
+ public WorkManager getWorkManager()
+ {
+ return workManager;
+ }
+
+ /**
+ * Set the workManager.
+ *
+ * @param workManager The workManager to set.
+ */
+ public void setWorkManager(WorkManager workManager)
+ {
+ this.workManager = workManager;
+ }
+
+ /**
+ * Get the xaTerminator.
+ *
+ * @return the xaTerminator.
+ */
+ public XATerminator getXaTerminator()
+ {
+ return xaTerminator;
+ }
+
+ /**
+ * Set the xaTerminator.
+ *
+ * @param xaTerminator The xaTerminator to set.
+ */
+ public void setXaTerminator(XATerminator xaTerminator)
+ {
+ this.xaTerminator = xaTerminator;
+ }
+
+ /**
+ * Get the timerFactory.
+ *
+ * @return the timerFactory.
+ */
+ public TimerFactory getTimerFactory()
+ {
+ return timerFactory;
+ }
+
+ /**
+ * Set the timerFactory.
+ *
+ * @param timerFactory The timerFactory to set.
+ */
+ public void setTimerFactory(TimerFactory timerFactory)
+ {
+ this.timerFactory = timerFactory;
+ }
+
+ /**
+ * A JBossBootstrapContext.
+ */
+ private class JBossBootstrapContext implements BootstrapContext
+ {
+ public Timer createTimer() throws UnavailableException
+ {
+ if (timerFactory == null)
+ throw new IllegalStateException("No TimerFactory configured");
+ return timerFactory.createTimer();
+ }
+
+ public WorkManager getWorkManager()
+ {
+ if (workManager == null)
+ throw new IllegalStateException("No WorkManager configured");
+ return workManager;
+ }
+
+ public XATerminator getXATerminator()
+ {
+ if (xaTerminator == null)
+ throw new IllegalStateException("No XATerminator configured");
+ return xaTerminator;
+ }
+ }
+}
Added: projects/jboss-jca/core/src/main/org/jboss/jca/spi/rar/TimerFactory.java
===================================================================
--- projects/jboss-jca/core/src/main/org/jboss/jca/spi/rar/TimerFactory.java (rev 0)
+++ projects/jboss-jca/core/src/main/org/jboss/jca/spi/rar/TimerFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.jca.spi.rar;
+
+import java.util.Timer;
+
+import javax.resource.spi.UnavailableException;
+
+/**
+ * A TimerFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public interface TimerFactory
+{
+ /**
+ * Create a timer
+ *
+ * @return the timer
+ * @throws UnavailableException
+ */
+ Timer createTimer() throws UnavailableException;
+}
Added: projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/inflow/test/InflowUnitTestCase.xml
===================================================================
--- projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/inflow/test/InflowUnitTestCase.xml (rev 0)
+++ projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/inflow/test/InflowUnitTestCase.xml 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="BootstrapContextFactory" class="org.jboss.jca.spi.rar.BootstrapContextFactory"/>
+
+ <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+ <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+ </bean>
+
+ <beanfactory name="MessageEndpointAdvice" class="org.jboss.jca.plugins.endpoint.POJOMessageEndpointAdvice"/>
+
+ <bean name="MessageEndpointAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="MessageEndpointAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="scope">PER_INSTANCE</property>
+ </bean>
+
+ <bean name="MessageEndpointBinding" class="org.jboss.aop.microcontainer.beans.AspectBinding">
+ <property name="pointcut">execution(* $instanceof{javax.resource.spi.endpoint.MessageEndpoint}->*(..))</property>
+ <property name="aspect"><inject bean="MessageEndpointAspect" property="definition"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <bean name="TestRAR" class="org.jboss.test.jca.rar.support.TestResourceAdapter">
+ <start method="start">
+ <parameter><inject bean="BootstrapContextFactory" property="bootstrapContext"/></parameter>
+ </start>
+ </bean>
+
+ <bean name="ActivationSpec" class="org.jboss.test.jca.rar.support.TestActivationSpec">
+ <property name="name">testInflow</property>
+ <property name="anInt">10</property>
+ <property name="anInteger">50</property>
+ <property name="localhost">localhost</property>
+ <property name="props">message=hello</property>
+ </bean>
+
+ <bean name="Target" class="org.jboss.test.jca.rar.support.TestMessageListenerImpl"/>
+
+ <bean name="MessageEndpointFactory" class="org.jboss.jca.plugins.endpoint.POJOMessageEndpointFactory">
+ <property name="target"><inject bean="Target"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="messageListener">org.jboss.test.jca.rar.support.TestMessageListener</property>
+ </bean>
+
+ <bean name="Activation" class="org.jboss.jca.plugins.endpoint.Activation">
+ <property name="resourceAdapter"><inject bean="TestRAR"/></property>
+ <property name="activationSpec"><inject bean="ActivationSpec"/></property>
+ <property name="messageEndpointFactory"><inject bean="MessageEndpointFactory"/></property>
+ </bean>
+
+</deployment>
Added: projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/notx/test/NoTxUnitTestCase.xml
===================================================================
--- projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/notx/test/NoTxUnitTestCase.xml (rev 0)
+++ projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/notx/test/NoTxUnitTestCase.xml 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="BootstrapContextFactory" class="org.jboss.jca.spi.rar.BootstrapContextFactory"/>
+
+ <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+ <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+ </bean>
+
+ <beanfactory name="TraceAdvice" class="org.jboss.jca.plugins.cm.TraceAdvice"/>
+
+ <bean name="TraceAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="TraceAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <beanfactory name="ExceptionAdvice" class="org.jboss.jca.plugins.cm.ConnectionManagerExceptionAdvice"/>
+
+ <bean name="ExceptionAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="ExceptionAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <beanfactory name="SecurityAdvice" class="org.jboss.jca.plugins.cm.security.SecurityAdvice"/>
+
+ <bean name="SecurityAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="SecurityAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="scope">PER_INSTANCE</property>
+ </bean>
+
+ <bean name="PoolFactory" class="org.jboss.jca.plugins.cm.pool.simple.SimplePoolFactory"/>
+
+ <beanfactory name="PoolAdvice" class="org.jboss.jca.plugins.cm.pool.PoolAdvice">
+ <constructor><parameter><inject bean="PoolFactory"/></parameter></constructor>
+ </beanfactory>
+
+ <bean name="PoolAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="PoolAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="scope">PER_INSTANCE</property>
+ </bean>
+
+ <bean name="ManagedConnectionContextManager" class="org.jboss.jca.spi.cm.ManagedConnectionContextManager"/>
+
+ <beanfactory name="ListenerAdvice" class="org.jboss.jca.plugins.cm.listener.ListenerAdvice">
+ <property name="contextManager"><inject bean="ManagedConnectionContextManager"/></property>
+ </beanfactory>
+
+ <bean name="ListenerAspect" class="org.jboss.aop.microcontainer.beans.Aspect">
+ <property name="advice"><inject bean="ListenerAdvice"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="scope">PER_INSTANCE</property>
+ </bean>
+
+ <bean name="ConnectionManagerBinding" class="org.jboss.aop.microcontainer.beans.StackBinding">
+ <property name="pointcut">execution(* $instanceof{javax.resource.spi.ConnectionManager}->*(..))</property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ <property name="advices">
+ <list>
+ <inject bean="TraceAspect" property="definition"/>
+ <inject bean="ExceptionAspect" property="definition"/>
+ <inject bean="SecurityAspect" property="definition"/>
+ <inject bean="PoolAspect" property="definition"/>
+ <inject bean="ListenerAspect" property="definition"/>
+ </list>
+ </property>
+ </bean>
+
+ <bean name="TestRAR" class="org.jboss.test.jca.rar.support.TestResourceAdapter">
+ <start method="start">
+ <parameter><inject bean="BootstrapContextFactory" property="bootstrapContext"/></parameter>
+ </start>
+ </bean>
+
+ <bean name="ManagedConnectionFactory" class="org.jboss.test.jca.rar.support.TestManagedConnectionFactory">
+ <property name="resourceAdapter"><inject bean="TestRAR"/></property>
+ </bean>
+
+ <bean name="ConnectionManager" class="org.jboss.jca.plugins.cm.ConnectionManagerFactory">
+ <property name="managedConnectionFactory"><inject bean="ManagedConnectionFactory"/></property>
+ <property name="manager"><inject bean="AspectManager"/></property>
+ </bean>
+
+ <bean name="ConnectionFactory" class="java.lang.Object">
+ <constructor factoryMethod="getConnectionFactory">
+ <factory bean="ConnectionManager"/>
+ </constructor>
+ </bean>
+
+</deployment>
Added: projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/timer/test/TimerUnitTestCase.xml
===================================================================
--- projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/timer/test/TimerUnitTestCase.xml (rev 0)
+++ projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/timer/test/TimerUnitTestCase.xml 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="TimerFactory" class="org.jboss.jca.plugins.rar.timer.JDKTimerFactory"/>
+
+ <bean name="BootstrapContextFactory" class="org.jboss.jca.spi.rar.BootstrapContextFactory">
+ <property name="timerFactory"><inject bean="TimerFactory"/></property>
+ </bean>
+
+ <bean name="TestRAR" class="org.jboss.test.jca.rar.support.TestResourceAdapter">
+ <start method="start">
+ <parameter><inject bean="BootstrapContextFactory" property="bootstrapContext"/></parameter>
+ </start>
+ </bean>
+
+</deployment>
Added: projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/txinflow/test/TxInflowUnitTestCase.xml
===================================================================
--- projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/txinflow/test/TxInflowUnitTestCase.xml (rev 0)
+++ projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/txinflow/test/TxInflowUnitTestCase.xml 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="TransactionManager" class="org.jboss.tm.TxManager">
+ <constructor factoryClass="org.jboss.tm.TxManager" factoryMethod="getInstance"/>
+ <property name="globalIdsEnabled">true</property>
+ </bean>
+
+ <bean name="ThreadPool" class="org.jboss.util.threadpool.BasicThreadPool"/>
+
+ <bean name="WorkManager" class="org.jboss.jca.plugins.rar.work.JBossWorkManager">
+ <property name="threadPool"><inject bean="ThreadPool"/></property>
+ <property name="xaTerminator"><inject bean="TransactionManager"/></property>
+ </bean>
+
+ <bean name="BootstrapContextFactory" class="org.jboss.jca.spi.rar.BootstrapContextFactory">
+ <property name="workManager"><inject bean="WorkManager" property="workManager"/></property>
+ <property name="xaTerminator"><inject bean="TransactionManager"/></property>
+ </bean>
+
+ <bean name="TestRAR" class="org.jboss.test.jca.rar.support.TestResourceAdapter">
+ <start method="start">
+ <parameter><inject bean="BootstrapContextFactory" property="bootstrapContext"/></parameter>
+ </start>
+ </bean>
+
+</deployment>
Added: projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/work/test/WorkManagerUnitTestCase.xml
===================================================================
--- projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/work/test/WorkManagerUnitTestCase.xml (rev 0)
+++ projects/jboss-jca/core/src/resources/tests/org/jboss/test/jca/work/test/WorkManagerUnitTestCase.xml 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="ThreadPool" class="org.jboss.util.threadpool.BasicThreadPool"/>
+
+ <bean name="TransactionManager" class="org.jboss.tm.TxManager">
+ <constructor factoryClass="org.jboss.tm.TxManager" factoryMethod="getInstance"/>
+ <property name="globalIdsEnabled">true</property>
+ </bean>
+
+ <bean name="WorkManager" class="org.jboss.jca.plugins.rar.work.JBossWorkManager">
+ <property name="threadPool"><inject bean="ThreadPool"/></property>
+ <property name="xaTerminator"><inject bean="TransactionManager"/></property>
+ </bean>
+
+ <bean name="BootstrapContextFactory" class="org.jboss.jca.spi.rar.BootstrapContextFactory">
+ <property name="workManager"><inject bean="WorkManager" property="workManager"/></property>
+ </bean>
+
+ <bean name="TestRAR" class="org.jboss.test.jca.rar.support.TestResourceAdapter">
+ <start method="start">
+ <parameter><inject bean="BootstrapContextFactory" property="bootstrapContext"/></parameter>
+ </start>
+ </bean>
+
+</deployment>
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/JCAAllTestSuite.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/JCAAllTestSuite.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/JCAAllTestSuite.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.test.jca.timer.test.TimerTestSuite;
+
+/**
+ * JCA Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class JCAAllTestSuite extends TestSuite
+{
+ public static void main(String[] args) throws Exception
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite("JCA Tests");
+
+ suite.addTest(JCATestSuite.suite());
+ suite.addTest(TimerTestSuite.suite());
+
+ return suite;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/JCATest.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/JCATest.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/JCATest.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca;
+
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+
+/**
+ * A JCATest.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class JCATest extends MicrocontainerTest
+{
+ /**
+ * Create a new JCATest.
+ *
+ * @param name the test name
+ */
+ public JCATest(String name)
+ {
+ super(name);
+ }
+
+ protected void configureLogging()
+ {
+ enableTrace("org.jboss.jca");
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/JCATestSuite.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/JCATestSuite.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/JCATestSuite.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.jboss.test.jca.inflow.test.InflowTestSuite;
+import org.jboss.test.jca.notx.test.NoTxTestSuite;
+import org.jboss.test.jca.txinflow.test.TxInflowTestSuite;
+import org.jboss.test.jca.work.test.WorkManagerTestSuite;
+
+/**
+ * JCA Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class JCATestSuite extends TestSuite
+{
+ public static void main(String[] args) throws Exception
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite("JCA Tests");
+
+ suite.addTest(InflowTestSuite.suite());
+ suite.addTest(NoTxTestSuite.suite());
+ suite.addTest(TxInflowTestSuite.suite());
+ suite.addTest(WorkManagerTestSuite.suite());
+
+ return suite;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/inflow/test/InflowTestSuite.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/inflow/test/InflowTestSuite.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/inflow/test/InflowTestSuite.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.inflow.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Inflow Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class InflowTestSuite extends TestSuite
+{
+ public static void main(String[] args) throws Exception
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite("Inflow Tests");
+
+ suite.addTest(InflowUnitTestCase.suite());
+
+ return suite;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/inflow/test/InflowUnitTestCase.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/inflow/test/InflowUnitTestCase.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/inflow/test/InflowUnitTestCase.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,99 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.inflow.test;
+
+import java.lang.reflect.Method;
+
+import javax.resource.spi.endpoint.MessageEndpoint;
+
+import junit.framework.Test;
+
+import org.jboss.test.jca.JCATest;
+import org.jboss.test.jca.rar.support.TestMessage;
+import org.jboss.test.jca.rar.support.TestMessageListener;
+import org.jboss.test.jca.rar.support.TestResourceAdapter;
+
+/**
+ * Message Inflow Unit Tests
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.3 $
+ */
+public class InflowUnitTestCase extends JCATest
+{
+ Method deliverMessage;
+
+ public InflowUnitTestCase (String name) throws Exception
+ {
+ super(name);
+ deliverMessage = TestMessageListener.class.getMethod("deliverMessage", new Class[] { TestMessage.class });
+ }
+
+ public void testInflow() throws Throwable
+ {
+ TestResourceAdapter adapter = (TestResourceAdapter) getBean("TestRAR");
+ MessageEndpoint endpoint = adapter.getEndpoint("testInflow");
+ if (endpoint == null)
+ throw new Exception("Null endpoint");
+ TestMessage message = new TestMessage();
+ getLog().debug("before " + endpoint);
+ endpoint.beforeDelivery(deliverMessage);
+ getLog().debug("Sending message " + message + " to " + endpoint);
+ ((TestMessageListener) endpoint).deliverMessage(message);
+ getLog().debug("after " + endpoint);
+ endpoint.afterDelivery();
+ if (message.acknowledged == false)
+ throw new Exception("MDB did not acknowledge the message");
+ }
+
+ public void testBadInflow() throws Throwable
+ {
+ TestResourceAdapter adapter = (TestResourceAdapter) getBean("TestRAR");
+ MessageEndpoint endpoint = adapter.getEndpoint("testInflow");
+ if (endpoint == null)
+ throw new Exception("Null endpoint");
+ TestMessage message = new TestMessage();
+ getLog().debug("before " + endpoint);
+ endpoint.beforeDelivery(deliverMessage);
+ getLog().debug("Sending message " + message + endpoint);
+ ((TestMessageListener) endpoint).deliverMessage(message);
+ try
+ {
+ ((TestMessageListener) endpoint).deliverMessage(message);
+ fail("Should not be here");
+ }
+ catch (Exception e)
+ {
+ checkThrowable(IllegalStateException.class, e);
+ }
+ finally
+ {
+ getLog().debug("after " + endpoint);
+ endpoint.afterDelivery();
+ }
+ }
+
+ public static Test suite() throws Exception
+ {
+ return suite(InflowUnitTestCase.class);
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/notx/test/NoTxTestSuite.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/notx/test/NoTxTestSuite.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/notx/test/NoTxTestSuite.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.notx.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * NoTx Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class NoTxTestSuite extends TestSuite
+{
+ public static void main(String[] args) throws Exception
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite("NoTx Tests");
+
+ suite.addTest(NoTxUnitTestCase.suite());
+
+ return suite;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/notx/test/NoTxUnitTestCase.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/notx/test/NoTxUnitTestCase.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/notx/test/NoTxUnitTestCase.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.notx.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.jca.JCATest;
+import org.jboss.test.jca.rar.support.TestConnection;
+import org.jboss.test.jca.rar.support.TestConnectionFactory;
+
+/**
+ * NoTx Unit Tests
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.4 $
+ */
+public class NoTxUnitTestCase extends JCATest
+{
+ public NoTxUnitTestCase (String name)
+ {
+ super(name);
+ }
+
+ public void testNoTx() throws Throwable
+ {
+ TestConnectionFactory cf = (TestConnectionFactory) getBean("ConnectionFactory");
+ TestConnection c = cf.getConnection();
+ assertTrue("Should have a connection", c != null);
+ c.close();
+ c = cf.getConnection();
+ assertTrue("Should have a connection", c != null);
+ c.close();
+ }
+
+ public static Test suite() throws Exception
+ {
+ return suite(NoTxUnitTestCase.class);
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestActivationSpec.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestActivationSpec.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestActivationSpec.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,135 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+import java.net.InetAddress;
+import java.util.Properties;
+import javax.resource.ResourceException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.InvalidPropertyException;
+import javax.resource.spi.ResourceAdapter;
+
+/**
+ * A TestActivationSpec that has non-string java bean properties.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class TestActivationSpec implements ActivationSpec
+{
+ private ResourceAdapter ra;
+
+ private String name;
+
+ /** An int between 1-10 */
+ private int anInt;
+
+ /** An Integer between 50-100 */
+ private Integer anInteger;
+
+ /** The 127.0.0.1 address */
+ private InetAddress localhost;
+
+ /** Properties of the form key1=*;key2=*;... */
+ private Properties props;
+
+ public void validate() throws InvalidPropertyException
+ {
+ /** An int between 1-10 */
+ if (anInt <= 0 || anInt > 10)
+ throw new InvalidPropertyException("anInt is not between 1-10");
+ /** An int between 50-100 */
+ if (anInteger.intValue() <= 49 || anInteger.intValue() > 100)
+ throw new InvalidPropertyException("anInt is not between 50-100");
+ /** The 127.0.0.1 address */
+ if (localhost.getHostAddress().equals("127.0.0.1") == false)
+ throw new InvalidPropertyException("localhost is not 127.0.0.1");
+ /** Properties of the key1=*;key2=*;... */
+ if (props.size() == 0)
+ throw new InvalidPropertyException("props has no values");
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public int getAnInt()
+ {
+ return anInt;
+ }
+
+ public void setAnInt(int anInt)
+ {
+ this.anInt = anInt;
+ }
+
+ public Integer getAnInteger()
+ {
+ return anInteger;
+ }
+
+ public void setAnInteger(Integer anInteger)
+ {
+ this.anInteger = anInteger;
+ }
+
+ public InetAddress getLocalhost()
+ {
+ return localhost;
+ }
+
+ public void setLocalhost(InetAddress localhost)
+ {
+ this.localhost = localhost;
+ }
+
+ public Properties getProps()
+ {
+ return props;
+ }
+
+ public void setProps(Properties props)
+ {
+ this.props = props;
+ }
+
+ public ResourceAdapter getResourceAdapter()
+ {
+ return ra;
+ }
+
+ public void setResourceAdapter(ResourceAdapter ra) throws ResourceException
+ {
+ this.ra = ra;
+ }
+
+ public String toString()
+ {
+ return "TestActivationSpec with name " + name;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnection.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnection.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnection.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+/**
+ * TestConnection.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public interface TestConnection
+{
+ void close();
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionFactory.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionFactory.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+/**
+ * TestConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public interface TestConnectionFactory
+{
+ TestConnection getConnection() throws Exception;
+
+ TestConnection getConnection(String user, String password) throws Exception;
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionFactoryImpl.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionFactoryImpl.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionFactoryImpl.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+import java.io.Serializable;
+
+import javax.resource.spi.ConnectionManager;
+
+/**
+ * TestConnectionFactoryImpl.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class TestConnectionFactoryImpl implements TestConnectionFactory, Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -6670190353441291330L;
+
+ /** The managed connection factory */
+ protected TestManagedConnectionFactory mcf;
+
+ /** The connection manager */
+ protected ConnectionManager cm;
+
+ public TestConnectionFactoryImpl()
+ {
+ }
+
+ protected TestConnectionFactoryImpl(TestManagedConnectionFactory mcf, ConnectionManager cm)
+ {
+ this.mcf = mcf;
+ this.cm = cm;
+ }
+
+ public TestConnection getConnection() throws Exception
+ {
+ return (TestConnection) cm.allocateConnection(mcf, null);
+ }
+
+ public TestConnection getConnection(String user, String password) throws Exception
+ {
+ TestConnectionRequestInfo cri = new TestConnectionRequestInfo(user, password);
+ return (TestConnection) cm.allocateConnection(mcf, cri);
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionImpl.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionImpl.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionImpl.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+/**
+ * TestConnectionImpl.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class TestConnectionImpl implements TestConnection
+{
+ protected TestManagedConnection mc;
+
+ protected TestConnectionImpl()
+ {
+ }
+
+ protected void setManagedConnection(TestManagedConnection mc)
+ {
+ this.mc = mc;
+ }
+
+ public void close()
+ {
+ if (mc != null)
+ mc.close(this);
+ mc = null;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionRequestInfo.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionRequestInfo.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestConnectionRequestInfo.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,104 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+import java.io.Serializable;
+
+import javax.resource.spi.ConnectionRequestInfo;
+
+/**
+ * TestConnectionRequestInfo.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class TestConnectionRequestInfo implements ConnectionRequestInfo, Serializable
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1861728676406044442L;
+
+ /** The user */
+ protected String userName;
+
+ /** The password */
+ protected String password;
+
+ public TestConnectionRequestInfo(String userName, String password)
+ {
+ this.userName = userName;
+ this.password = password;
+ }
+
+ /**
+ * Get the user.
+ *
+ * @return the user.
+ */
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ /**
+ * Get the password.
+ *
+ * @return the password.
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public boolean equals(Object object)
+ {
+ if (object == null || object instanceof TestConnectionRequestInfo == false)
+ return false;
+
+ TestConnectionRequestInfo other = (TestConnectionRequestInfo) object;
+ if (userName == null)
+ {
+ if (other.userName != null)
+ return false;
+ }
+ else
+ {
+ if (userName.equals(other.userName) == false)
+ return false;
+ }
+ if (password == null)
+ {
+ if (other.password != null)
+ return false;
+ }
+ else
+ {
+ if (password.equals(other.password) == false)
+ return false;
+ }
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return ((userName == null) ? 37 : userName.hashCode()) + 37 * ((password == null) ? 37 : password.hashCode());
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestManagedConnection.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestManagedConnection.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestManagedConnection.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,188 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.LocalTransaction;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionMetaData;
+import javax.security.auth.Subject;
+import javax.transaction.xa.XAResource;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.collection.CollectionsFactory;
+
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
+
+/**
+ * TestManagedConnection.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.3 $
+ */
+public class TestManagedConnection implements ManagedConnection
+{
+ private static final Logger log = Logger.getLogger(TestManagedConnection.class);
+
+ protected SynchronizedBoolean destroyed = new SynchronizedBoolean(false);
+
+ protected Set handles = CollectionsFactory.createCopyOnWriteSet();
+
+ protected Set listeners = CollectionsFactory.createCopyOnWriteSet();
+
+ public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ TestConnectionImpl handle = new TestConnectionImpl();
+ associateConnection(handle);
+ return handle;
+ }
+
+ public void associateConnection(Object connection) throws ResourceException
+ {
+ if (connection == null || connection instanceof TestConnectionImpl == false)
+ throw new IllegalArgumentException("Not a TestConnectionImpl");
+ TestConnectionImpl handle = (TestConnectionImpl) connection;
+ handle.setManagedConnection(this);
+ handles.add(handle);
+ }
+
+ protected void disassociateConnection(Object connection)
+ {
+ handles.remove(connection);
+ }
+
+ public void close(Object handle)
+ {
+ if (destroyed.get())
+ return;
+ disassociateConnection(handle);
+ ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
+ event.setConnectionHandle(handle);
+ broadcastEvent(event);
+ }
+
+ public void cleanup() throws ResourceException
+ {
+ for (Iterator i = handles.iterator(); i.hasNext();)
+ {
+ TestConnectionImpl handle = (TestConnectionImpl) i.next();
+ handle.setManagedConnection(null);
+ }
+ handles.clear();
+ }
+
+ public void destroy() throws ResourceException
+ {
+ cleanup();
+ destroyed.set(true);
+ listeners.clear();
+ }
+
+ public void addConnectionEventListener(ConnectionEventListener listener)
+ {
+ if (destroyed.get())
+ throw new IllegalStateException("ManagedConnection is destroyed");
+ listeners.add(listener);
+ }
+
+ public void removeConnectionEventListener(ConnectionEventListener listener)
+ {
+ listeners.remove(listener);
+ }
+
+ protected void broadcastEvent(ConnectionEvent event)
+ {
+ for (Iterator i = listeners.iterator(); i.hasNext();)
+ {
+ ConnectionEventListener listener = (ConnectionEventListener) i.next();
+ try
+ {
+ switch (event.getId())
+ {
+ case ConnectionEvent.CONNECTION_CLOSED:
+ {
+ listener.connectionClosed(event);
+ break;
+ }
+ case ConnectionEvent.CONNECTION_ERROR_OCCURRED:
+ {
+ listener.connectionErrorOccurred(event);
+ break;
+ }
+ case ConnectionEvent.LOCAL_TRANSACTION_STARTED:
+ {
+ listener.localTransactionStarted(event);
+ break;
+ }
+ case ConnectionEvent.LOCAL_TRANSACTION_COMMITTED:
+ {
+ listener.localTransactionCommitted(event);
+ break;
+ }
+ case ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK:
+ {
+ listener.localTransactionRolledback(event);
+ break;
+ }
+ default:
+ throw new IllegalStateException("Illegal event id : " + event.getId());
+ }
+ }
+ catch (Throwable t)
+ {
+ log.warn("Ignored error from event listener " + listener + " event=" + event, t);
+ }
+ }
+ }
+
+ public ManagedConnectionMetaData getMetaData() throws ResourceException
+ {
+ return new TestManagedConnectionMetaData();
+ }
+
+ public LocalTransaction getLocalTransaction() throws ResourceException
+ {
+ throw new org.jboss.util.NotImplementedException("FIXME NYI getLocalTransaction");
+ }
+
+ public XAResource getXAResource() throws ResourceException
+ {
+ throw new org.jboss.util.NotImplementedException("FIXME NYI getXAResource");
+ }
+
+ public PrintWriter getLogWriter() throws ResourceException
+ {
+ throw new org.jboss.util.NotImplementedException("FIXME NYI getLogWriter");
+ }
+
+ public void setLogWriter(PrintWriter out) throws ResourceException
+ {
+ throw new org.jboss.util.NotImplementedException("FIXME NYI setLogWriter");
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestManagedConnectionFactory.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestManagedConnectionFactory.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,91 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+import java.io.PrintWriter;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterAssociation;
+import javax.security.auth.Subject;
+
+/**
+ * TestManagedConnectionFactory.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class TestManagedConnectionFactory implements ManagedConnectionFactory, ResourceAdapterAssociation
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 4517969739433575464L;
+
+ /** The resource adapter */
+ private TestResourceAdapter resourceAdapter;
+
+ public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ // TODO FIXME
+ return new TestManagedConnection();
+ }
+
+ public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+ {
+ // TODO FIXME
+ return (TestManagedConnection) connectionSet.iterator().next();
+ }
+
+ public Object createConnectionFactory() throws ResourceException
+ {
+ throw new org.jboss.util.NotImplementedException("FIXME NYI createConnectionFactory");
+ }
+
+ public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException
+ {
+ return new TestConnectionFactoryImpl(this, cxManager);
+ }
+
+ public PrintWriter getLogWriter() throws ResourceException
+ {
+ throw new org.jboss.util.NotImplementedException("FIXME NYI getLogWriter");
+ }
+
+ public void setLogWriter(PrintWriter out) throws ResourceException
+ {
+ throw new org.jboss.util.NotImplementedException("FIXME NYI setLogWriter");
+ }
+
+ public ResourceAdapter getResourceAdapter()
+ {
+ return resourceAdapter;
+ }
+
+ public void setResourceAdapter(ResourceAdapter ra) throws ResourceException
+ {
+ resourceAdapter = (TestResourceAdapter) ra;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestManagedConnectionMetaData.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestManagedConnectionMetaData.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestManagedConnectionMetaData.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ManagedConnectionMetaData;
+
+/**
+ * TestManagedConnectionMetaData.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class TestManagedConnectionMetaData implements ManagedConnectionMetaData
+{
+
+ public String getEISProductName() throws ResourceException
+ {
+ return "EISProductName";
+ }
+
+ public String getEISProductVersion() throws ResourceException
+ {
+ return "EISProductVersion";
+ }
+
+ public int getMaxConnections() throws ResourceException
+ {
+ return -1;
+ }
+
+ public String getUserName() throws ResourceException
+ {
+ return null;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestMessage.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestMessage.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestMessage.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+/**
+ * A TestMessage.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class TestMessage
+{
+ public boolean acknowledged = false;
+
+ public void acknowledge()
+ {
+ acknowledged = true;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestMessageListener.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestMessageListener.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestMessageListener.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+/**
+ * A TestMessageListener.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public interface TestMessageListener
+{
+ void deliverMessage(TestMessage message);
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestMessageListenerImpl.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestMessageListenerImpl.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestMessageListenerImpl.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,41 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A TestMessageListenerImpl.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class TestMessageListenerImpl implements TestMessageListener
+{
+ private static final Logger log = Logger.getLogger(TestMessageListenerImpl.class);
+
+ public void deliverMessage(TestMessage message)
+ {
+ log.debug("Acknowledging message " + message);
+ message.acknowledge();
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestResourceAdapter.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestResourceAdapter.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/rar/support/TestResourceAdapter.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,134 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.rar.support;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Timer;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.UnavailableException;
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.endpoint.MessageEndpoint;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.xa.XAResource;
+
+import org.jboss.util.collection.CollectionsFactory;
+
+/**
+ * A TestResourceAdapter.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.4 $
+ */
+public class TestResourceAdapter implements ResourceAdapter
+{
+ protected BootstrapContext ctx;
+
+ protected Map endpoints = CollectionsFactory.createConcurrentReaderMap();
+
+ public void start(BootstrapContext ctx) throws ResourceAdapterInternalException
+ {
+ this.ctx = ctx;
+ }
+
+ public void stop()
+ {
+
+ for (Iterator i = endpoints.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+ MessageEndpoint endpoint = (MessageEndpoint) entry.getValue();
+ if (endpoint != null)
+ {
+ endpoint.release();
+ i.remove();
+ }
+ }
+ ctx = null;
+ }
+
+ public MessageEndpoint getEndpoint(String name) throws Exception
+ {
+ for (Iterator i = endpoints.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry) i.next();
+ TestActivationSpec spec = (TestActivationSpec) entry.getKey();
+ if (name.equals(spec.getName()))
+ return (MessageEndpoint) entry.getValue();
+ }
+ throw new Exception("MessageEndpoint not found for name: " + name);
+ }
+
+ public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException
+ {
+ MessageEndpoint endpoint = endpointFactory.createEndpoint(null);
+ endpoints.put(spec, endpoint);
+ }
+
+ public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec)
+ {
+ MessageEndpoint endpoint = (MessageEndpoint) endpoints.remove(spec);
+ if (endpoint != null)
+ endpoint.release();
+ }
+
+ public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException
+ {
+ return null;
+ }
+
+ public Timer createTimerFromBootstrapContext() throws UnavailableException
+ {
+ if (ctx == null)
+ throw new IllegalStateException("No bootstrap context");
+ Timer timer = ctx.createTimer();
+ if (timer == null)
+ throw new IllegalStateException("createTimer() returned null");
+ return timer;
+ }
+
+ public WorkManager getWorkManagerFromBootstrapContext()
+ {
+ if (ctx == null)
+ throw new IllegalStateException("No bootstrap context");
+ WorkManager workManager = ctx.getWorkManager();
+ if (workManager == null)
+ throw new IllegalStateException("Null work manager");
+ return workManager;
+ }
+
+ public XATerminator getXATerminatorFromBootstrapContext()
+ {
+ if (ctx == null)
+ throw new IllegalStateException("No bootstrap context");
+ XATerminator xaTerminator = ctx.getXATerminator();
+ if (xaTerminator == null)
+ throw new IllegalStateException("Null xa terminator");
+ return xaTerminator;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/timer/test/TimerTestSuite.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/timer/test/TimerTestSuite.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/timer/test/TimerTestSuite.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.timer.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Timer Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class TimerTestSuite extends TestSuite
+{
+ public static void main(String[] args) throws Exception
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite("Timer Tests");
+
+ suite.addTest(TimerUnitTestCase.suite());
+
+ return suite;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/timer/test/TimerUnitTestCase.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/timer/test/TimerUnitTestCase.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/timer/test/TimerUnitTestCase.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,74 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.timer.test;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import junit.framework.Test;
+
+import org.jboss.test.jca.JCATest;
+import org.jboss.test.jca.rar.support.TestResourceAdapter;
+
+/**
+ * Timer Unit Tests
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.3 $
+ */
+public class TimerUnitTestCase extends JCATest
+{
+ public TimerUnitTestCase (String name)
+ {
+ super(name);
+ }
+
+ public void testTimer() throws Throwable
+ {
+ TestResourceAdapter adapter = (TestResourceAdapter) getBean("TestRAR");
+ Timer timer = adapter.createTimerFromBootstrapContext();
+ TestTimerTask task = new TestTimerTask();
+ getLog().debug("Schedule for 5 seconds " + task);
+ timer.schedule(task, 5000l);
+ getLog().debug("Sleep for 10 seconds");
+ Thread.sleep(10000);
+ if (task.complete == false)
+ throw new Exception("Task was not run");
+
+ }
+
+ public class TestTimerTask extends TimerTask
+ {
+ public boolean complete = false;
+
+ public void run()
+ {
+ getLog().debug("Run " + this);
+ complete = true;
+ }
+ }
+
+ public static Test suite() throws Exception
+ {
+ return suite(TimerUnitTestCase.class);
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/txinflow/test/TxInflowTestSuite.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/txinflow/test/TxInflowTestSuite.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/txinflow/test/TxInflowTestSuite.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.txinflow.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Tx Inflow Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class TxInflowTestSuite extends TestSuite
+{
+ public static void main(String[] args) throws Exception
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite("Tx Inflow Tests");
+
+ suite.addTest(TxInflowUnitTestCase.suite());
+
+ return suite;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/txinflow/test/TxInflowUnitTestCase.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/txinflow/test/TxInflowUnitTestCase.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/txinflow/test/TxInflowUnitTestCase.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,220 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.txinflow.test;
+
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import junit.framework.Test;
+
+import org.jboss.test.jca.JCATest;
+import org.jboss.test.jca.rar.support.TestResourceAdapter;
+import org.jboss.tm.TxUtils;
+
+/**
+ * Transaction Inflow Unit Tests
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.3 $
+ */
+public class TxInflowUnitTestCase extends JCATest
+{
+
+ public TxInflowUnitTestCase (String name)
+ {
+ super(name);
+ }
+
+ public void testTxInflow() throws Throwable
+ {
+ TestResourceAdapter adapter = (TestResourceAdapter) getBean("TestRAR");
+ XATerminator xt = adapter.getXATerminatorFromBootstrapContext();
+ WorkManager wm = adapter.getWorkManagerFromBootstrapContext();
+ TestWork work = new TestWork();
+ ExecutionContext ec = new ExecutionContext();
+ Xid xid = new MyXid(1);
+ ec.setXid(xid);
+
+ getLog().debug("doWork " + work);
+ wm.doWork(work, 0l, ec, null);
+ getLog().debug("doneWork " + work);
+ if (work.complete == false)
+ throw new Exception("Work was not done");
+ if (work.e != null)
+ throw work.e;
+ if (work.enlisted == false)
+ throw new Exception("Not enlisted");
+ if (work.delisted)
+ throw new Exception("Should not be ended yet");
+ if (work.committed)
+ throw new Exception("Should not be committed yet");
+
+ getLog().debug("committing");
+ xt.commit(xid, true);
+ getLog().debug("committed");
+ if (work.delisted == false)
+ throw new Exception("Should be ended");
+ if (work.committed == false)
+ throw new Exception("Should be committed");
+ }
+
+ public TransactionManager getTransactionManager() throws Exception
+ {
+ return (TransactionManager) getBean("TransactionManager");
+ }
+
+ public class MyXid implements Xid
+ {
+ int id;
+
+ public MyXid(int id)
+ {
+ this.id = id;
+ }
+
+ public byte[] getBranchQualifier()
+ {
+ // TODO getBranchQualifier
+ return null;
+ }
+
+ public int getFormatId()
+ {
+ return 666;
+ }
+
+ public byte[] getGlobalTransactionId()
+ {
+ return new byte[] { (byte) id };
+ }
+
+ public String toString()
+ {
+ return "MyXID(" + id + ")";
+ }
+ }
+
+ public class TestWork implements Work, XAResource
+ {
+ public boolean complete = false;
+ public Exception e;
+
+ public boolean enlisted = false;
+ public boolean delisted = false;
+ public boolean committed = false;
+
+ public void run()
+ {
+ try
+ {
+ getLog().debug("run " + this);
+ complete = true;
+ TransactionManager tm = getTransactionManager();
+ Transaction tx = tm.getTransaction();
+ getLog().debug("enlisting " + this);
+ tx.enlistResource(this);
+ getLog().debug("enlisted " + this);
+ }
+ catch (Exception e)
+ {
+ this.e = e;
+ }
+ }
+
+ public void release()
+ {
+ }
+
+ public void commit(Xid arg0, boolean arg1) throws XAException
+ {
+ getLog().debug("commit " + this);
+ committed = true;
+ }
+
+ public void end(Xid arg0, int arg1) throws XAException
+ {
+ getLog().debug("end " + this + " " + TxUtils.getXAResourceFlagsAsString(arg1));
+ delisted = true;
+ }
+
+ public void forget(Xid arg0) throws XAException
+ {
+ throw new XAException("NYI");
+ }
+
+ public int getTransactionTimeout() throws XAException
+ {
+ // TODO getTransactionTimeout
+ return 0;
+ }
+
+ public boolean isSameRM(XAResource arg0) throws XAException
+ {
+ // TODO isSameRM
+ return false;
+ }
+
+ public int prepare(Xid arg0) throws XAException
+ {
+ throw new XAException("NYI");
+ }
+
+ public Xid[] recover(int arg0) throws XAException
+ {
+ throw new XAException("NYI");
+ }
+
+ public void rollback(Xid arg0) throws XAException
+ {
+ throw new XAException("NYI");
+ }
+
+ public boolean setTransactionTimeout(int arg0) throws XAException
+ {
+ return false;
+ }
+
+ public void start(Xid arg0, int arg1) throws XAException
+ {
+ getLog().debug("start " + this + " " + TxUtils.getXAResourceFlagsAsString(arg1));
+ enlisted = true;
+ }
+ }
+
+ protected void configureLogging()
+ {
+ super.configureLogging();
+ enableTrace("org.jboss.tm");
+ }
+
+ public static Test suite() throws Exception
+ {
+ return suite(TxInflowUnitTestCase.class);
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/work/test/WorkManagerTestSuite.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/work/test/WorkManagerTestSuite.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/work/test/WorkManagerTestSuite.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,49 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.work.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Work Manager Test Suite.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.2 $
+ */
+public class WorkManagerTestSuite extends TestSuite
+{
+ public static void main(String[] args) throws Exception
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite("Work Manager Tests");
+
+ suite.addTest(WorkManagerUnitTestCase.suite());
+
+ return suite;
+ }
+}
Added: projects/jboss-jca/core/src/tests/org/jboss/test/jca/work/test/WorkManagerUnitTestCase.java
===================================================================
--- projects/jboss-jca/core/src/tests/org/jboss/test/jca/work/test/WorkManagerUnitTestCase.java (rev 0)
+++ projects/jboss-jca/core/src/tests/org/jboss/test/jca/work/test/WorkManagerUnitTestCase.java 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,77 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jca.work.test;
+
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkManager;
+
+import junit.framework.Test;
+
+import org.jboss.test.jca.JCATest;
+import org.jboss.test.jca.rar.support.TestResourceAdapter;
+
+/**
+ * WorkManager Unit Tests
+ *
+ * @author <a href="mailto:adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.3 $
+ */
+public class WorkManagerUnitTestCase extends JCATest
+{
+
+ public WorkManagerUnitTestCase (String name)
+ {
+ super(name);
+ }
+
+ public void testWorkManager() throws Throwable
+ {
+ TestResourceAdapter adapter = (TestResourceAdapter) getBean("TestRAR");
+ WorkManager wm = adapter.getWorkManagerFromBootstrapContext();
+ TestWork work = new TestWork();
+ getLog().debug("doWork " + work);
+ wm.doWork(work);
+ getLog().debug("doneWork " + work);
+ if (work.complete == false)
+ throw new Exception("Work was not done");
+ }
+
+ public class TestWork implements Work
+ {
+ public boolean complete = false;
+
+ public void run()
+ {
+ getLog().debug("runWork " + this);
+ complete = true;
+ }
+
+ public void release()
+ {
+ }
+ }
+
+ public static Test suite() throws Exception
+ {
+ return suite(WorkManagerUnitTestCase.class);
+ }
+}
Added: projects/jboss-jca/pom.xml
===================================================================
--- projects/jboss-jca/pom.xml (rev 0)
+++ projects/jboss-jca/pom.xml 2007-07-14 11:34:26 UTC (rev 64057)
@@ -0,0 +1,17 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jca</artifactId>
+ <packaging>pom</packaging>
+ <version>0.1.SNAPSHOT</version>
+ <name>JBoss JCA Aggregrator</name>
+ <url>http://www.jboss.org</url>
+ <description>The Jboss JCA Container project.</description>
+
+ <modules>
+ <module>adapter</module>
+ <module>core</module>
+ </modules>
+
+</project>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list