[jboss-cvs] JBossAS SVN: r112641 - in projects/jboss-jca/trunk: as/src/main/java/org/jboss/jca/as/rarinfo and 51 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 14 11:46:16 EST 2012


Author: jesper.pedersen
Date: 2012-02-14 11:46:11 -0500 (Tue, 14 Feb 2012)
New Revision: 112641

Added:
   projects/jboss-jca/trunk/common/src/main/resources/schema/ironjacamar_1_1.xsd
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnection.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnectionFactory.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnectionFactoryImpl.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnectionImpl.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyManagedConnection.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyManagedConnectionFactory.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyManagedConnectionMetaData.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyRaMetaData.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyResourceAdapter.java
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/package.html
   projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/testcases/LazyAssociationTestCase.java
   projects/jboss-jca/trunk/deployers/src/test/resources/lazy.rar/
   projects/jboss-jca/trunk/deployers/src/test/resources/lazy.rar/META-INF/
   projects/jboss-jca/trunk/deployers/src/test/resources/lazy.rar/META-INF/ironjacamar.xml
   projects/jboss-jca/trunk/deployers/src/test/resources/lazy.rar/META-INF/ra.xml
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/README.txt
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/build.xml
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/lib/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnection.java
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionFactory.java
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionFactoryImpl.java
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionImpl.java
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnection.java
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnectionFactory.java
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnectionMetaData.java
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldResourceAdapter.java
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/package.html
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/resources/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/resources/META-INF/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/resources/META-INF/ironjacamar.xml
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/jboss/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/jboss/jca/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/jboss/jca/samples/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/jboss/jca/samples/helloworld/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/jboss/jca/samples/helloworld/ConnectorTestCase.java
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/jboss/jca/samples/helloworld/package.html
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/resources/
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/resources/jndi.properties
   projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/resources/logging.properties
Modified:
   projects/jboss-jca/trunk/as/src/main/java/org/jboss/jca/as/converters/LegacyConnectionFactoryImp.java
   projects/jboss-jca/trunk/as/src/main/java/org/jboss/jca/as/rarinfo/Main.java
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/Defaults.java
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/common/CommonConnDef.java
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonConnDefImpl.java
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonIronJacamarParser.java
   projects/jboss-jca/trunk/common/src/main/resources/schema/resource-adapters_1_1.xsd
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/CoreBundle.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/ConnectionManager.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManagerFactory.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/AbstractConnectionListener.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/ConnectionListener.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/notx/NoTxConnectionManagerImpl.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPrefillPool.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/Pool.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/PoolFactory.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ArrayBlockingQueueManagedConnectionPool.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ManagedConnectionPool.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/OnePool.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/PoolByCri.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/PoolBySubject.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/PoolBySubjectAndCri.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/ReauthPool.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/common/MockConnectionManager.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/connections/InterleavingTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/NoTxConnectionListenerTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListenerTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/NoTxConnectionManagerTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/SerializableTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/pool/OnePoolTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/pool/PrefillTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/pool/TestConnectionTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/SerializableTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/XATxConnectionManagerTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/AbstractConnectionManagerTestCase.java
   projects/jboss-jca/trunk/deployers/build.xml
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
   projects/jboss-jca/trunk/doc/userguide/en-US/modules/logging.xml
   projects/jboss-jca/trunk/doc/userguide/en-US/modules/sample.xml
   projects/jboss-jca/trunk/doc/userguide/en-US/modules/schemas.xml
   projects/jboss-jca/trunk/sjc/build.xml
Log:
[JBJCA-747] LazyAssociatableConnectionManager/NoTx

Modified: projects/jboss-jca/trunk/as/src/main/java/org/jboss/jca/as/converters/LegacyConnectionFactoryImp.java
===================================================================
--- projects/jboss-jca/trunk/as/src/main/java/org/jboss/jca/as/converters/LegacyConnectionFactoryImp.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/as/src/main/java/org/jboss/jca/as/converters/LegacyConnectionFactoryImp.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -107,8 +107,9 @@
     */
    public void buildResourceAdapterImpl()  throws Exception
    {
-      CommonConnDefImpl connDef = new CommonConnDefImpl(configProperty, connectionDefinition, jndiName, poolName, 
-            Defaults.ENABLED, Defaults.USE_JAVA_CONTEXT, Defaults.USE_CCM, pool, timeOut, validation, security, null);
+      CommonConnDefImpl connDef = new CommonConnDefImpl(configProperty, connectionDefinition, jndiName, poolName,
+                                                        Defaults.ENABLED, Defaults.USE_JAVA_CONTEXT, Defaults.USE_CCM,
+                                                        Defaults.SHARABLE, pool, timeOut, validation, security, null);
       connectionDefinitions = new ArrayList<CommonConnDef>();
       connectionDefinitions.add(connDef);
       raImpl = new ResourceAdapterImpl(null, rarName, transactionSupport, connectionDefinitions, null,

Modified: projects/jboss-jca/trunk/as/src/main/java/org/jboss/jca/as/rarinfo/Main.java
===================================================================
--- projects/jboss-jca/trunk/as/src/main/java/org/jboss/jca/as/rarinfo/Main.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/as/src/main/java/org/jboss/jca/as/rarinfo/Main.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -383,9 +383,10 @@
                      pool = poolImpl;
                   }
                   CommonConnDefImpl connImpl = new CommonConnDefImpl(configProperty, classname, 
-                        "java:jboss/eis/" + poolName, poolName, 
-                        Defaults.ENABLED, Defaults.USE_JAVA_CONTEXT, Defaults.USE_CCM, 
-                        pool, null, null, secImpl, null);
+                                                                     "java:jboss/eis/" + poolName, poolName, 
+                                                                     Defaults.ENABLED, Defaults.USE_JAVA_CONTEXT,
+                                                                     Defaults.USE_CCM, Defaults.SHARABLE, 
+                                                                     pool, null, null, secImpl, null);
                   connDefs.add(connImpl);
                }
 
@@ -551,9 +552,10 @@
                pool = poolImpl;
             }
             CommonConnDefImpl connImpl = new CommonConnDefImpl(configProperty, classname, 
-                  "java:jboss/eis/" + poolName, poolName, 
-                  Defaults.ENABLED, Defaults.USE_JAVA_CONTEXT, Defaults.USE_CCM, 
-                  pool, null, null, secImpl, null);
+                                                               "java:jboss/eis/" + poolName, poolName, 
+                                                               Defaults.ENABLED, Defaults.USE_JAVA_CONTEXT,
+                                                               Defaults.USE_CCM, Defaults.SHARABLE, 
+                                                               pool, null, null, secImpl, null);
             connDefs = new ArrayList<CommonConnDef>();
             connDefs.add(connImpl);
          }

Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/Defaults.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/Defaults.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/Defaults.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -59,6 +59,11 @@
     */
    public static final boolean JTA = Boolean.TRUE;
    
+   /**
+    * SHARABLE
+    */
+   public static final Boolean SHARABLE = Boolean.TRUE;
+   
    // POOL
 
    /**

Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/common/CommonConnDef.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/common/CommonConnDef.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/metadata/common/CommonConnDef.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -86,6 +86,13 @@
    public Boolean isUseCcm();
 
    /**
+    * Get the sharable
+    *
+    * @return the value
+    */
+   public Boolean isSharable();
+
+   /**
     * Get the pool.
     *
     * @return the pool.
@@ -270,7 +277,11 @@
       /** use-ccm attribute
       *
       */
-      USE_CCM("use-ccm");
+      USE_CCM("use-ccm"),
+      /** sharable attribute
+      *
+      */
+      SHARABLE("sharable");
 
       private final String name;
 

Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonConnDefImpl.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonConnDefImpl.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonConnDefImpl.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -60,6 +60,8 @@
 
    private final Boolean useCcm;
 
+   private final Boolean sharable;
+
    private final CommonPool pool;
 
    private final CommonTimeOut timeOut;
@@ -80,6 +82,7 @@
     * @param enabled enabled
     * @param useJavaContext useJavaContext
     * @param useCcm useCcm
+    * @param sharable sharable
     * @param pool pool
     * @param timeOut timeOut
     * @param validation validation
@@ -87,8 +90,9 @@
     * @param recovery recovery
     */
    public CommonConnDefImpl(Map<String, String> configProperties, String className, String jndiName,
-      String poolName, Boolean enabled, Boolean useJavaContext, Boolean useCcm, CommonPool pool, CommonTimeOut timeOut,
-      CommonValidation validation, CommonSecurity security, Recovery recovery)
+                            String poolName, Boolean enabled, Boolean useJavaContext, Boolean useCcm, Boolean sharable,
+                            CommonPool pool, CommonTimeOut timeOut,
+                            CommonValidation validation, CommonSecurity security, Recovery recovery)
    {
       super();
       if (configProperties != null)
@@ -106,6 +110,7 @@
       this.enabled = enabled;
       this.useJavaContext = useJavaContext;
       this.useCcm = useCcm;
+      this.sharable = sharable;
       this.pool = pool;
       this.timeOut = timeOut;
       this.validation = validation;
@@ -192,6 +197,17 @@
    }
 
    /**
+    * Get the sharable
+    *
+    * @return the sharable
+    */
+   @Override
+   public final Boolean isSharable()
+   {
+      return sharable;
+   }
+
+   /**
     * Get the pool.
     *
     * @return the pool.
@@ -257,6 +273,7 @@
       result = prime * result + ((timeOut == null) ? 0 : timeOut.hashCode());
       result = prime * result + ((useJavaContext == null) ? 0 : useJavaContext.hashCode());
       result = prime * result + ((useCcm == null) ? 0 : useCcm.hashCode());
+      result = prime * result + ((sharable == null) ? 0 : sharable.hashCode());
       result = prime * result + ((validation == null) ? 0 : validation.hashCode());
       return result;
    }
@@ -348,6 +365,13 @@
       }
       else if (!useCcm.equals(other.useCcm))
          return false;
+      if (sharable == null)
+      {
+         if (other.sharable != null)
+            return false;
+      }
+      else if (!sharable.equals(other.sharable))
+         return false;
       if (validation == null)
       {
          if (other.validation != null)
@@ -386,6 +410,9 @@
       if (useCcm != null)
          sb.append(" ").append(CommonConnDef.Attribute.USE_CCM).append("=\"").append(useCcm).append("\"");
 
+      if (sharable != null)
+         sb.append(" ").append(CommonConnDef.Attribute.SHARABLE).append("=\"").append(sharable).append("\"");
+
       sb.append(">");
 
       if (configProperties != null && configProperties.size() > 0)

Modified: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonIronJacamarParser.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonIronJacamarParser.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/metadata/common/CommonIronJacamarParser.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -83,6 +83,7 @@
       String jndiName = null;
       String poolName = null;
       Boolean useCcm = Boolean.TRUE;
+      Boolean sharable = Boolean.TRUE;
       int attributeSize = reader.getAttributeCount();
 
       Boolean isXa = Boolean.FALSE;
@@ -116,6 +117,10 @@
                useCcm = attributeAsBoolean(reader, attribute.getLocalName(), true);
                break;
             }
+            case SHARABLE : {
+               sharable = attributeAsBoolean(reader, attribute.getLocalName(), true);
+               break;
+            }
             default :
                throw new ParserException(bundle.unexpectedAttribute(attribute.getLocalName(), reader.getLocalName()));
          }
@@ -132,7 +137,8 @@
                {
 
                   return new CommonConnDefImpl(configProperties, className, jndiName, poolName, enabled,
-                                               useJavaContext, useCcm, pool, timeOut, validation, security, recovery);
+                                               useJavaContext, useCcm, sharable, pool, timeOut, validation,
+                                               security, recovery);
                }
                else
                {

Added: projects/jboss-jca/trunk/common/src/main/resources/schema/ironjacamar_1_1.xsd
===================================================================
--- projects/jboss-jca/trunk/common/src/main/resources/schema/ironjacamar_1_1.xsd	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/resources/schema/ironjacamar_1_1.xsd	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,655 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+           elementFormDefault="qualified"
+           targetNamespace="http://www.jboss.org/ironjacamar/schema"
+           xmlns="http://www.jboss.org/ironjacamar/schema"
+           version="1.0">
+
+  <xs:complexType name="boolean-presenceType"></xs:complexType>
+
+  <xs:complexType name="config-propertyType" mixed="true">
+    <xs:annotation>
+      <xs:documentation>
+        <![CDATA[[
+          Specifies an override for a config-property element in ra.xml or a @ConfigProperty
+         ]]>
+      </xs:documentation>
+    </xs:annotation>
+    <xs:simpleContent>
+      <xs:extension base="xs:token">
+        <xs:attribute use="required" name="name" type="xs:token">
+          <xs:annotation>
+            <xs:documentation>
+              <![CDATA[[
+                Specifies the name of the config-property
+               ]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:attribute>
+      </xs:extension>
+    </xs:simpleContent>
+  </xs:complexType>
+
+  <xs:complexType name="ironjacamarType">
+    <xs:sequence>
+      <xs:element name="bean-validation-groups" type="bean-validation-groupsType" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies bean validation group that should be used
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="bootstrap-context" type="xs:token" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies the unique name of the bootstrap context that should be used
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="config-property" type="config-propertyType" minOccurs="0" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+               The config-property specifies resource adapter configuration properties.
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="transaction-support" type="transaction-supportType" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies the transaction support level of the resource adapter
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="connection-definitions" type="connection-definitionsType" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies the connection definitions
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="admin-objects" type="admin-objectsType" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies the administration objects
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:simpleType name="transaction-supportType">
+    <xs:annotation>
+      <xs:documentation>
+        <![CDATA[[
+          Define the type of transaction supported by this resource adapter.
+          Valid values are: NoTransaction, LocalTransaction, XATransaction
+         ]]>
+      </xs:documentation>
+    </xs:annotation>
+    <xs:restriction base="xs:token">
+      <xs:enumeration value="NoTransaction" />
+      <xs:enumeration value="LocalTransaction" />
+      <xs:enumeration value="XATransaction" />
+    </xs:restriction>
+  </xs:simpleType>
+
+  <xs:attributeGroup name="common-attribute">
+    <xs:attribute name="class-name" type="xs:token" use="optional">
+      <xs:annotation>
+        <xs:documentation>
+          <![CDATA[[
+            Specifies the the fully qualified class name of a managed connection factory
+            or admin object
+           ]]>
+        </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
+    <xs:attribute name="jndi-name" type="xs:token" use="required">
+      <xs:annotation>
+        <xs:documentation>
+          <![CDATA[[
+            Specifies the JNDI name
+           ]]>
+        </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
+    <xs:attribute name="enabled" type="xs:boolean" default="true" form="unqualified" use="optional">
+      <xs:annotation>
+        <xs:documentation>
+          <![CDATA[[
+            Should the object in question be activated
+           ]]>
+        </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
+    <xs:attribute default="true" name="use-java-context" type="xs:boolean">
+      <xs:annotation>
+        <xs:documentation>
+          <![CDATA[[
+            Specifies if a java:/ JNDI context should be used 
+           ]]>
+        </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
+    <xs:attribute name="pool-name" type="xs:token" use="optional">
+      <xs:annotation>
+        <xs:documentation>
+          <![CDATA[[
+            Specifies the pool name for the object
+           ]]>
+        </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
+  </xs:attributeGroup>
+
+  <xs:complexType name="admin-objectType">
+    <xs:sequence>
+      <xs:element name="config-property" type="config-propertyType" minOccurs="0" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies an administration object configuration property.
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+    <xs:attributeGroup ref="common-attribute"></xs:attributeGroup>
+  </xs:complexType>
+
+  <xs:complexType name="timeoutType">
+    <xs:sequence>
+      <xs:element name="blocking-timeout-millis" type="xs:nonNegativeInteger" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+                The blocking-timeout-millis element indicates the maximum time in 
+                milliseconds to block while waiting for a connection before throwing an exception. 
+                Note that this blocks only while waiting for a permit for a connection, and 
+                will never throw an exception if creating a new connection takes an inordinately 
+                long time. The default is 30000 (30 seconds).  
+              ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="idle-timeout-minutes" type="xs:nonNegativeInteger" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              The idle-timeout-minutes elements indicates the maximum time in minutes 
+              a connection may be idle before being closed. The actual maximum time depends 
+              also on the IdleRemover scan time, which is 1/2 the smallest idle-timeout-minutes 
+              of any pool. 
+              ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="allocation-retry" type="xs:nonNegativeInteger" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              The allocation retry element indicates the number of times that allocating 
+              a connection should be tried before throwing an exception. The default is 
+              0.  
+              ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="allocation-retry-wait-millis" type="xs:nonNegativeInteger" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              The allocation retry wait millis element indicates the time in milliseconds 
+              to wait between retrying to allocate a connection. The default is 5000 (5 seconds). 
+              ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="xa-resource-timeout" type="xs:nonNegativeInteger" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Passed to XAResource.setTransactionTimeout(). Default is zero which does not invoke the setter.              
+              Specified in seconds - e.g. 5 minutes
+              <xa-resource-timeout>300</xa-resource-timeout>
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="validationType">
+    <xs:sequence>
+      <xs:element name="background-validation" type="xs:boolean" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              An element to specify that connections should be validated on a background 
+              thread versus being validated prior to use 
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="background-validation-millis" type="xs:nonNegativeInteger" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              The background-validation-millis element specifies the amount of 
+              time, in millis, that background validation will run. 
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="use-fast-fail" type="xs:boolean" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Whether fail a connection allocation on the first connection if it 
+              is invalid (true) or keep trying until the pool is exhausted of all potential 
+              connections (false). Default is false. e.g. <use-fast-fail>true</use-fast-fail>
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="connection-definitionsType">
+    <xs:sequence>
+      <xs:element name="connection-definition" type="connection-defintionType" minOccurs="1" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies a connection definition
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="connection-defintionType">
+    <xs:sequence>
+      <xs:element name="config-property" type="config-propertyType" minOccurs="0" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+               The config-property specifies managed connection factory configuration properties.
+              ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:choice>
+        <xs:element name="pool" type="poolType" minOccurs="0" maxOccurs="1">
+          <xs:annotation>
+            <xs:documentation>
+                <![CDATA[[
+                  Specifies pooling settings
+                 ]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="xa-pool" type="xa-poolType" minOccurs="0" maxOccurs="1">
+          <xs:annotation>
+            <xs:documentation>
+                <![CDATA[[
+                  Specifies xa-pooling settings
+                 ]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:element>
+      </xs:choice>
+      <xs:element name="security" type="securityType" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies security settings
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="timeout" type="timeoutType" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies timeout settings
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="validation" type="validationType" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies validation settings
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="recovery" type="recoverType" minOccurs="0" maxOccurs="1"></xs:element>
+    </xs:sequence>
+    <xs:attribute name="use-ccm" type="xs:boolean" default="true" use="optional">
+      <xs:annotation>
+        <xs:documentation>
+          <![CDATA[[
+            Enable cached connection manager
+           ]]>
+        </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
+    <xs:attribute name="sharable" type="xs:boolean" default="true" use="optional">
+      <xs:annotation>
+        <xs:documentation>
+          <![CDATA[[
+            Defines the connections as sharable which allows lazy association to be enabled
+            if supported
+           ]]>
+        </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
+    <xs:attributeGroup ref="common-attribute"></xs:attributeGroup>
+  </xs:complexType>
+
+  <xs:complexType name="poolType">
+    <xs:sequence>
+      <xs:element name="min-pool-size" type="xs:nonNegativeInteger" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              The min-pool-size element indicates the minimum number of connections 
+              a pool should hold. These are not created until a Subject is known from a 
+              request for a connection. This default to 0. Ex: <min-pool-size>1</min-pool-size>
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="max-pool-size" type="xs:nonNegativeInteger" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              The max-pool-size element indicates the maximum number of connections 
+              for a pool. No more than max-pool-size connections will be created in each sub-pool. 
+              This defaults to 20. 
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="prefill" type="xs:boolean" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Whether to attempt to prefill the connection pool. 
+              Default is false. e.g. <prefill>false</prefill>.
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="use-strict-min" type="xs:boolean" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies if the min-pool-size should be considered strictly.
+              Default false
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="flush-strategy" type="xs:token" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies how the pool should be flush in case of an error.
+              Valid values are: FailingConnectionOnly (default), IdleConnections, EntirePool 
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  
+  <xs:complexType name="xa-poolType">
+    <xs:complexContent>
+      <xs:extension base="poolType">
+        <xs:sequence>
+          <xs:element name="is-same-rm-override" type="xs:boolean" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>
+                <![CDATA[[
+                  The is-same-rm-override element allows one to unconditionally 
+                  set whether the javax.transaction.xa.XAResource.isSameRM(XAResource) returns 
+                  true or false. Ex: <is-same-rm-override>true</is-same-rm-override>
+                 ]]>
+              </xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="interleaving" type="boolean-presenceType" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>
+                <![CDATA[[
+                  An element to enable interleaving for XA connection factories 
+                  Ex: <interleaving/>
+                 ]]>
+              </xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="no-tx-separate-pools" type="boolean-presenceType" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>
+                <![CDATA[[
+                  Oracle does not like XA connections getting used both inside and outside a JTA transaction. 
+                  To workaround the problem you can create separate sub-pools for the different contexts
+                  using <no-tx-separate-pools/>
+                  Ex: <no-tx-separate-pools/>
+                 ]]>
+              </xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="pad-xid" type="xs:boolean" default="false" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>
+                <![CDATA[[
+                   Should the Xid be padded
+                   Ex: <pad-xid>true</pad-xid>
+                 ]]>
+              </xs:documentation>
+            </xs:annotation>
+          </xs:element>
+          <xs:element name="wrap-xa-resource" type="xs:boolean" default="false" minOccurs="0">
+            <xs:annotation>
+              <xs:documentation>
+                <![CDATA[[
+                   Should the XAResource instances be wrapped in a org.jboss.tm.XAResourceWrapper
+                   instance
+                   Ex: <wrap-xa-resource>true</wrap-xa-resource>
+                 ]]>
+              </xs:documentation>
+            </xs:annotation>
+          </xs:element>
+        </xs:sequence>
+      </xs:extension>
+    </xs:complexContent>
+  </xs:complexType>
+
+  <xs:complexType name="securityType">
+    <xs:sequence>
+      <xs:choice>
+        <xs:element name="application" type="boolean-presenceType" minOccurs="0" maxOccurs="1">
+          <xs:annotation>
+            <xs:documentation>
+              <![CDATA[[
+                Indicates that app supplied parameters (such as from getConnection(user, pw))
+                are used to distinguish connections in the pool.
+                Ex:
+                <application/>
+              ]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="security-domain" type="xs:token" minOccurs="0" maxOccurs="1">
+          <xs:annotation>
+            <xs:documentation>
+              <![CDATA[[
+                Indicates Subject (from security domain) are used to distinguish connections in the pool. 
+                The content of the security-domain is the name of the JAAS security manager that will handle
+                authentication. This name correlates to the JAAS login-config.xml descriptor
+                application-policy/name attribute.
+                Ex:
+                <security-domain>HsqlDbRealm</security-domain>
+              ]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:element>
+        <xs:element name="security-domain-and-application" type="xs:token" minOccurs="0" maxOccurs="1">
+          <xs:annotation>
+            <xs:documentation>
+              <![CDATA[[
+                Indicates that either app supplied parameters (such as from
+                getConnection(user, pw)) or Subject (from security domain) are used to
+                distinguish connections in the pool. The content of the
+                security-domain is the name of the JAAS security manager that will handle
+                authentication. This name correlates to the JAAS login-config.xml descriptor
+                application-policy/name attribute.
+                
+                Ex:
+                <security-domain-and-application>HsqlDbRealm</security-domain-and-application>
+              ]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:element>
+      </xs:choice>
+    </xs:sequence>
+  </xs:complexType>
+
+
+  <xs:complexType name="admin-objectsType">
+    <xs:sequence>
+      <xs:element name="admin-object" type="admin-objectType" minOccurs="1" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies the setup for an admin object
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+
+  <xs:complexType name="bean-validation-groupsType">
+    <xs:sequence>
+      <xs:element name="bean-validation-group" type="xs:token" minOccurs="1" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies the fully qualified class name for a bean validation group that
+              should be used for validation
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:complexType name="recoverType">
+    <xs:sequence>
+      <xs:element name="recover-credential" type="credentialType" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies the security options used when creating a connection during recovery.
+              Note: if this credential are not specified the security credential are used for recover too
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="recover-plugin" type="extensionType" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Specifies the extension plugin used in spi (core.spi.xa) 
+              which can be implemented by various plugins to provide better feedback to the XA recovery system.
+             ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+    <xs:attribute name="no-recovery" type="xs:boolean" default="false" use="optional">
+      <xs:annotation>
+        <xs:documentation>
+          <![CDATA[[
+            Specify if the xa-datasource should be excluded from recovery.
+            Default false.
+           ]]>
+        </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
+  </xs:complexType>
+  <xs:complexType name="extensionType">
+    <xs:sequence>
+      <xs:element name="config-property" type="config-propertyType"></xs:element>
+    </xs:sequence>
+    <xs:attribute name="class-name" type="xs:token" use="required"></xs:attribute>
+  </xs:complexType>
+  <xs:complexType name="credentialType">
+    <xs:sequence>
+      <xs:element name="user-name" type="xs:token" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>
+              <![CDATA[[
+                Specify the username used when creating a new connection. 
+                Ex: <user-name>sa</user-name>
+               ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="password" type="xs:token" minOccurs="0">
+        <xs:annotation>
+          <xs:documentation>
+              <![CDATA[[
+                Specify the password used when creating a new connection. 
+                Ex: <password>sa-pass</password>
+               ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+      <xs:element name="security-domain" type="xs:token" minOccurs="0" maxOccurs="1">
+        <xs:annotation>
+          <xs:documentation>
+            <![CDATA[[
+              Indicates Subject (from security domain) are used to distinguish connections in the pool. 
+              The content of the security-domain is the name of the JAAS security manager that will handle
+              authentication. This name correlates to the JAAS login-config.xml descriptor
+              application-policy/name attribute.
+              Ex:
+              <security-domain>HsqlDbRealm</security-domain>
+            ]]>
+          </xs:documentation>
+        </xs:annotation>
+      </xs:element>
+    </xs:sequence>
+   </xs:complexType>
+  
+
+  <xs:element name="ironjacamar" type="ironjacamarType">
+    <xs:annotation>
+      <xs:documentation>
+        <![CDATA[[
+          Specifies the fully qualified class name for a bean validation group that
+          should be used for validation
+         ]]>
+      </xs:documentation>
+    </xs:annotation>
+  </xs:element>
+</xs:schema>

Modified: projects/jboss-jca/trunk/common/src/main/resources/schema/resource-adapters_1_1.xsd
===================================================================
--- projects/jboss-jca/trunk/common/src/main/resources/schema/resource-adapters_1_1.xsd	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/common/src/main/resources/schema/resource-adapters_1_1.xsd	2012-02-14 16:46:11 UTC (rev 112641)
@@ -391,6 +391,16 @@
         </xs:documentation>
       </xs:annotation>
     </xs:attribute>
+    <xs:attribute name="sharable" type="xs:boolean" default="true" use="optional">
+      <xs:annotation>
+        <xs:documentation>
+          <![CDATA[[
+            Defines the connections as sharable which allows lazy association to be enabled
+            if supported
+           ]]>
+        </xs:documentation>
+      </xs:annotation>
+    </xs:attribute>
     <xs:attributeGroup ref="common-attribute"></xs:attributeGroup>
   </xs:complexType>
 

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/CoreBundle.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/CoreBundle.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/CoreBundle.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -300,6 +300,20 @@
    @Message(id = 463, value = "Unable to set XAResource transaction timeout: %s")
    public String unableSetXAResourceTransactionTimeout(String jndiName);
       
+   /**
+    * Unable to find connection listener
+    * @return The value
+    */
+   @Message(id = 464, value = "Unable to find connection listener")
+   public String unableToFindConnectionListener();
+      
+   /**
+    * Connection is null
+    * @return The value
+    */
+   @Message(id = 465, value = "Connection is null")
+   public String connectionIsNull();
+      
    // TRANSACTION SYNCHRONIZER (500)
    
    // POOL MANAGER (600)

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/ConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/ConnectionManager.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/api/connectionmanager/ConnectionManager.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -24,6 +24,11 @@
 
 import org.jboss.jca.core.api.connectionmanager.listener.ConnectionListener;
 
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+
 /**
  * The JBoss specific connection manager interface.
  * 
@@ -33,6 +38,36 @@
 public interface ConnectionManager extends javax.resource.spi.ConnectionManager
 {
    /**
+    * Associate a managed connection to a logical connection
+    *
+    * @param connection The connection
+    * @param mcf The managed connection factory
+    * @param cri The connection request information
+    * @return The managed connection
+    * @exception ResourceException Thrown if an error occurs
+    */
+   public ManagedConnection associateManagedConnection(Object connection, ManagedConnectionFactory mcf,
+                                                       ConnectionRequestInfo cri)
+      throws ResourceException;
+
+   /**
+    * Dissociate a managed connection from a logical connection. The return value
+    * of this method will indicate if the managed connection has more connections
+    * attached (false), or if it was return to the pool (true).
+    *
+    * If the managed connection is return to the pool its <code>cleanup</code> method
+    * will be called
+    *
+    * @param connection The connection
+    * @param mc The managed connection
+    * @param mcf The managed connection factory
+    * @return True if the managed connection was freed; otherwise false
+    * @exception ResourceException Thrown if an error occurs
+    */
+   public boolean dissociateManagedConnection(Object connection, ManagedConnection mc, ManagedConnectionFactory mcf)
+      throws ResourceException;
+
+   /**
     * Kill given connection listener wrapped connection instance.
     * @param cl connection listener that wraps connection
     * @param kill kill connection or not

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -41,6 +41,7 @@
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.resource.spi.security.PasswordCredential;
 import javax.security.auth.Subject;
@@ -95,6 +96,9 @@
    /** Jndi name */
    private String jndiName;
 
+   /** Sharable */
+   private boolean sharable;
+
    /**
     * Creates a new instance of connection manager.
     */
@@ -177,6 +181,24 @@
    }
 
    /**
+    * Is sharable
+    * @return The value
+    */
+   public boolean isSharable()
+   {
+      return sharable;
+   }
+
+   /**
+    * Set the sharable flag
+    * @param v The value
+    */
+   public void setSharable(boolean v)
+   {
+      this.sharable = v;
+   }
+
+   /**
     * {@inheritDoc}
     */
    public String getSecurityDomain()
@@ -440,7 +462,6 @@
       }
    }
 
-
    /**
     * {@inheritDoc}
     */
@@ -501,6 +522,65 @@
    /**
     * {@inheritDoc}
     */
+   public void associateConnection(Object connection, ManagedConnectionFactory mcf, ConnectionRequestInfo cri)
+      throws ResourceException
+   {
+      associateManagedConnection(connection, mcf, cri);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public ManagedConnection associateManagedConnection(Object connection, ManagedConnectionFactory mcf,
+                                                       ConnectionRequestInfo cri)
+      throws ResourceException
+   {
+      // Check for pooling!
+      if (pool == null)
+      {
+         throw new ResourceException(bundle.tryingUseConnectionFactoryShutDown());
+      }
+
+      // It is an explicit spec requirement that equals be used for matching rather than ==.
+      if (!pool.getManagedConnectionFactory().equals(mcf))
+      {
+         throw new ResourceException(
+            bundle.wrongManagedConnectionFactorySentToAllocateConnection(pool.getManagedConnectionFactory(), mcf));
+      }
+
+      if (connection == null)
+         throw new ResourceException(bundle.connectionIsNull());
+
+      // Pick a managed connection from the pool
+      Subject subject = getSubject();
+      ConnectionListener cl = getManagedConnection(subject, cri);
+
+      // Tell each connection manager the managed connection is active
+      reconnectManagedConnection(cl);
+
+      // Associate managed connection with the connection
+      cl.getManagedConnection().associateConnection(connection);
+      registerAssociation(cl, connection);
+
+      if (cachedConnectionManager != null)
+      {
+         cachedConnectionManager.registerConnection(this, cl, connection, cri);
+      }
+
+      return cl.getManagedConnection();
+   }
+ 
+   /**
+    * {@inheritDoc}
+    */
+   public void inactiveConnectionClosed(Object connection, ManagedConnectionFactory mcf)
+   {
+      // We don't track inactive connections
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public void disconnect(Collection<ConnectionRecord> conRecords, Set<String> unsharableResources)
       throws ResourceException
    {

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManagerFactory.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManagerFactory.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/ConnectionManagerFactory.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -55,6 +55,7 @@
     * @param securityDomain The security domain 
     * @param useCcm Should the CCM be used
     * @param ccm The cached connection manager
+    * @param sharable Enable sharable connections
     * @param flushStrategy The flush strategy
     * @param allocationRetry The allocation retry value
     * @param allocationRetryWaitMillis The allocation retry millis value
@@ -66,6 +67,7 @@
                                                        final String securityDomain,
                                                        final boolean useCcm,
                                                        final CachedConnectionManager ccm,
+                                                       final boolean sharable,
                                                        final FlushStrategy flushStrategy,
                                                        final Integer allocationRetry,
                                                        final Long allocationRetryWaitMillis)
@@ -100,6 +102,7 @@
       setProperties(cm, pool,
                     subjectFactory, securityDomain, 
                     useCcm, ccm,
+                    sharable,
                     flushStrategy,
                     allocationRetry, allocationRetryWaitMillis, 
                     null);
@@ -116,6 +119,7 @@
     * @param securityDomain The security domain 
     * @param useCcm Should the CCM be used
     * @param ccm The cached connection manager
+    * @param sharable Enable sharable connections
     * @param flushStrategy The flush strategy
     * @param allocationRetry The allocation retry value
     * @param allocationRetryWaitMillis The allocation retry millis value
@@ -133,6 +137,7 @@
                                                   final String securityDomain,
                                                   final boolean useCcm,
                                                   final CachedConnectionManager ccm,
+                                                  final boolean sharable,
                                                   final FlushStrategy flushStrategy,
                                                   final Integer allocationRetry,
                                                   final Long allocationRetryWaitMillis,
@@ -177,6 +182,7 @@
       setProperties(cm, pool, 
                     subjectFactory, securityDomain, 
                     useCcm, ccm,
+                    sharable,
                     flushStrategy,
                     allocationRetry, allocationRetryWaitMillis,
                     txIntegration.getTransactionManager());
@@ -193,6 +199,7 @@
     * @param securityDomain The security domain
     * @param useCcm Should the CCM be used
     * @param ccm The cached connection manager
+    * @param sharable Enable sharable connections
     * @param flushStrategy The flush strategy
     * @param allocationRetry The allocation retry value
     * @param allocationRetryWaitMillis The allocation retry millis value
@@ -204,6 +211,7 @@
                               String securityDomain,
                               boolean useCcm,
                               CachedConnectionManager ccm,
+                              boolean sharable,
                               FlushStrategy flushStrategy,
                               Integer allocationRetry,
                               Long allocationRetryWaitMillis,
@@ -225,6 +233,8 @@
 
       if (useCcm)
          cm.setCachedConnectionManager(ccm);
+
+      cm.setSharable(sharable);
    }
 
    /**

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/AbstractConnectionListener.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/AbstractConnectionListener.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/AbstractConnectionListener.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -44,8 +44,7 @@
  * contract.
  * 
  * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a> 
- * @version $Rev: $
- *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a> 
  */
 public abstract class AbstractConnectionListener implements ConnectionListener
 {
@@ -283,23 +282,17 @@
    /**
     * Unregister connections.
     */
-   protected  void unregisterConnections()
+   public  void unregisterConnections()
    {
-      try
+      if (getCachedConnectionManager() != null)
       {
-         Iterator<Object> itHandles = connectionHandles.iterator();
-         
-         while (itHandles.hasNext())
+         for (Object handle : connectionHandles)
          {
-            Object handle = itHandles.next();
-            if (getCachedConnectionManager() != null)
-               getCachedConnectionManager().unregisterConnection(getConnectionManager(), handle);
+            getCachedConnectionManager().unregisterConnection(getConnectionManager(), handle);
          }
       }
-      finally
-      {
-         connectionHandles.clear();
-      }
+
+      connectionHandles.clear();
    }
    
 
@@ -368,6 +361,19 @@
       }
    }
    
+   /**
+    * {@inheritDoc}
+    */
+   public boolean controls(Object connection, ManagedConnection mc)
+   {
+      if (managedConnection.equals(mc))
+      {
+         if (connectionHandles.contains(connection))
+            return true;
+      }
+
+      return false;
+   }
    
    /**
     * {@inheritDoc}

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/ConnectionListener.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/ConnectionListener.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/listener/ConnectionListener.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -24,6 +24,7 @@
 import org.jboss.jca.core.connectionmanager.pool.api.Pool;
 
 import javax.resource.ResourceException;
+import javax.resource.spi.ManagedConnection;
 import javax.transaction.SystemException;
 
 /**
@@ -102,6 +103,11 @@
    public void unregisterConnection(Object handle);
 
    /**
+    * Unregister all connections
+    */
+   public void unregisterConnections();
+
+   /**
     * Is the managed connection free?
     * 
     * @return true when it is free
@@ -150,4 +156,12 @@
     *           milliseconds.
     */
    public void setLastValidatedTime(long lastValidated);
+
+   /**
+    * Controls the connection / managed connection pair
+    * @param connection The connection
+    * @param mc The managed connection
+    * @return True if the connection listener controls the pair, otherwise false
+    */
+   public boolean controls(Object connection, ManagedConnection mc);
 }

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/notx/NoTxConnectionManagerImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/notx/NoTxConnectionManagerImpl.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/notx/NoTxConnectionManagerImpl.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -22,6 +22,7 @@
 
 package org.jboss.jca.core.connectionmanager.notx;
 
+import org.jboss.jca.core.CoreBundle;
 import org.jboss.jca.core.CoreLogger;
 import org.jboss.jca.core.connectionmanager.AbstractConnectionManager;
 import org.jboss.jca.core.connectionmanager.ConnectionRecord;
@@ -33,10 +34,13 @@
 import java.util.Collection;
 
 import javax.resource.ResourceException;
+import javax.resource.spi.LazyAssociatableConnectionManager;
 import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
 import javax.transaction.SystemException;
 
 import org.jboss.logging.Logger;
+import org.jboss.logging.Messages;
 
 /**
  * Non transactional connection manager implementation.
@@ -44,11 +48,16 @@
  * @author <a href="mailto:gurkanerdogdu at yahoo.com">Gurkan Erdogdu</a>
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
-public class NoTxConnectionManagerImpl extends AbstractConnectionManager implements NoTxConnectionManager
+public class NoTxConnectionManagerImpl extends AbstractConnectionManager implements NoTxConnectionManager,
+                                                                                    LazyAssociatableConnectionManager
+
 {
    /** The logger */
    private static CoreLogger log = Logger.getMessageLogger(CoreLogger.class, NoTxConnectionManager.class.getName());
 
+   /** The bundle */
+   private static CoreBundle bundle = Messages.getBundle(CoreBundle.class);
+ 
    /** Serial version uid */
    private static final long serialVersionUID = 1L;
 
@@ -81,11 +90,51 @@
       return cli;
    }
 
+   /**
+    * {@inheritDoc}
+    */
+   public boolean dissociateManagedConnection(Object connection, ManagedConnection mc, ManagedConnectionFactory mcf)
+      throws ResourceException
+   {
+      if (connection == null || mc == null || mcf == null)
+         throw new ResourceException(bundle.unableToFindConnectionListener());
+
+      ConnectionListener cl = getPool().findConnectionListener(connection, mc);
+
+      if (cl != null)
+      {
+         if (getCachedConnectionManager() != null)
+         {
+            try
+            {
+               getCachedConnectionManager().unregisterConnection(this, connection);
+            }
+            catch (Throwable t)
+            {
+               log.debug("Throwable from unregisterConnection", t);
+            }
+         }
+
+         unregisterAssociation(cl, connection);
+      
+         if (cl.isManagedConnectionFree())
+         {
+            returnManagedConnection(cl, false);
+            return true;
+         }
+      }
+      else
+      {
+         throw new ResourceException(bundle.unableToFindConnectionListener());
+      }
+
+      return false;
+   }
+
    @Override
    public void transactionStarted(Collection<ConnectionRecord> conns) throws SystemException
    {
-      //doing nothing
-
+      // Doing nothing
    }
 
    @Override

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPool.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -44,6 +44,7 @@
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.resource.spi.RetryableException;
 import javax.security.auth.Subject;
@@ -97,15 +98,19 @@
    /** Statistics */
    private PoolStatistics statistics;
 
+   /** Are the connections sharable */
+   private boolean sharable;
+
    /**
     * Create a new base pool.
     *
     * @param mcf the managed connection factory
     * @param pc the pool configuration
     * @param noTxSeparatePools noTxSeparatePool
+    * @param sharable Are the connections sharable
     */
    protected AbstractPool(final ManagedConnectionFactory mcf, final PoolConfiguration pc,
-                          final boolean noTxSeparatePools)
+                          final boolean noTxSeparatePools, final boolean sharable)
    {
       if (mcf == null)
          throw new IllegalArgumentException("MCF is null");
@@ -116,6 +121,7 @@
       this.mcf = mcf;
       this.poolConfiguration = pc;
       this.noTxSeparatePools = noTxSeparatePools;
+      this.sharable = sharable;
       this.log = getLogger();
       this.trace = log.isTraceEnabled();
       this.statistics = new PoolStatisticsImpl(pc.getMaxSize(), mcpPools);
@@ -140,6 +146,15 @@
    }
 
    /**
+    * Is sharable
+    * @return The value
+    */
+   public boolean isSharable()
+   {
+      return sharable;
+   }
+
+   /**
     * Retrieve the key for this request.
     *
     * @param subject the subject
@@ -546,6 +561,21 @@
    /**
     * {@inheritDoc}
     */
+   public ConnectionListener findConnectionListener(Object connection, ManagedConnection mc)
+   {
+      for (ManagedConnectionPool mcp : mcpPools.values())
+      {
+         ConnectionListener cl = mcp.findConnectionListener(connection, mc);
+         if (cl != null)
+            return cl;
+      }
+
+      return null;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public ManagedConnectionFactory getManagedConnectionFactory()
    {
       return mcf;

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPrefillPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPrefillPool.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/AbstractPrefillPool.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -45,11 +45,12 @@
     * @param mcf the managed connection factory
     * @param pc the pool configuration
     * @param noTxSeparatePools noTxSeparatePool
+    * @param sharable Are the connections sharable
     */
    protected AbstractPrefillPool(final ManagedConnectionFactory mcf, final PoolConfiguration pc,
-                                 final boolean noTxSeparatePools)
+                                 final boolean noTxSeparatePools, final boolean sharable)
    {
-      super(mcf, pc, noTxSeparatePools);
+      super(mcf, pc, noTxSeparatePools, sharable);
       this.shouldPrefill = pc.isPrefill();
    }
 

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/Pool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/Pool.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/Pool.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -28,6 +28,7 @@
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.security.auth.Subject;
 import javax.transaction.Transaction;
@@ -48,6 +49,12 @@
    public void setName(String poolName);
    
    /**
+    * Is sharable
+    * @return The value
+    */
+   public boolean isSharable();
+
+   /**
     * Retrieve the managed connection factory for this pool.
     * 
     * @return the managed connection factory
@@ -74,6 +81,14 @@
       throws ResourceException;
 
    /**
+    * Find a connection listener
+    * @param connection The connection
+    * @param mc The managed connection
+    * @return The connection listener
+    */
+   public ConnectionListener findConnectionListener(Object connection, ManagedConnection mc);
+
+   /**
     * Return a connection
     * 
     * @param cl the connection event listener wrapping the connection

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/PoolFactory.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/PoolFactory.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/PoolFactory.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -50,12 +50,14 @@
     * @param mcf The managed connection factory
     * @param pc The pool configuration
     * @param noTxSeparatePools no-tx separate pool
+    * @param sharable Are the connections sharable
     * @return The pool instance
     */
    public Pool create(final PoolStrategy strategy,
                       final ManagedConnectionFactory mcf,
                       final PoolConfiguration pc,
-                      final boolean noTxSeparatePools)
+                      final boolean noTxSeparatePools,
+                      final boolean sharable)
    {
       if (strategy == null)
          throw new IllegalArgumentException("Strategy is null");
@@ -69,19 +71,19 @@
       switch (strategy)
       {
          case POOL_BY_CRI:
-            return new PoolByCri(mcf, pc, noTxSeparatePools);
+            return new PoolByCri(mcf, pc, noTxSeparatePools, sharable);
 
          case POOL_BY_SUBJECT:
-            return new PoolBySubject(mcf, pc, noTxSeparatePools);
+            return new PoolBySubject(mcf, pc, noTxSeparatePools, sharable);
 
          case POOL_BY_SUBJECT_AND_CRI:
-            return new PoolBySubjectAndCri(mcf, pc, noTxSeparatePools);
+            return new PoolBySubjectAndCri(mcf, pc, noTxSeparatePools, sharable);
 
          case ONE_POOL:
-            return new OnePool(mcf, pc, noTxSeparatePools);
+            return new OnePool(mcf, pc, noTxSeparatePools, sharable);
 
          case REAUTH:
-            return new ReauthPool(mcf, pc, noTxSeparatePools);
+            return new ReauthPool(mcf, pc, noTxSeparatePools, sharable);
       }
 
       throw new IllegalArgumentException("Unknown strategy " + strategy);

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ArrayBlockingQueueManagedConnectionPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ArrayBlockingQueueManagedConnectionPool.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ArrayBlockingQueueManagedConnectionPool.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -371,6 +371,20 @@
    /**
     * {@inheritDoc}
     */
+   public ConnectionListener findConnectionListener(Object connection, ManagedConnection mc)
+   {
+      for (ConnectionListener cl : checkedOut)
+      {
+         if (cl.controls(connection, mc))
+            return cl;
+      }
+
+      return null;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public void returnConnection(ConnectionListener cl, boolean kill)
    {
       if (trace)

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ManagedConnectionPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ManagedConnectionPool.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/ManagedConnectionPool.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -30,6 +30,7 @@
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.security.auth.Subject;
 
@@ -63,6 +64,14 @@
    public ConnectionListener getConnection(Subject subject, ConnectionRequestInfo cri) throws ResourceException;
    
    /**
+    * Find a connection listener
+    * @param connection The connection
+    * @param mc The managed connection
+    * @return The connection listener; <code>null</code> if the connection listener doesn't belong
+    */
+   public ConnectionListener findConnectionListener(Object connection, ManagedConnection mc);
+
+   /**
     * Return connection to the pool.
     * @param cl connection listener
     * @param kill kill connection

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreArrayListManagedConnectionPool.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -44,6 +44,8 @@
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.DissociatableManagedConnection;
+import javax.resource.spi.LazyAssociatableConnectionManager;
 import javax.resource.spi.ManagedConnection;
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.resource.spi.RetryableUnavailableException;
@@ -119,6 +121,9 @@
    /** Statistics */
    private ManagedConnectionPoolStatisticsImpl statistics;
 
+   /** Supports lazy association */
+   private Boolean supportsLazyAssociation;
+   
    /**
     * Constructor
     */
@@ -157,6 +162,11 @@
       this.cls = new ArrayList<ConnectionListener>(this.maxSize);
       this.statistics = new ManagedConnectionPoolStatisticsImpl(maxSize);
       this.permits = new Semaphore(maxSize, true, statistics);
+      this.supportsLazyAssociation = null;
+      
+      // Check if connection manager supports lazy association
+      if (!(clf instanceof LazyAssociatableConnectionManager))
+         supportsLazyAssociation = Boolean.FALSE;
 
       // Schedule managed connection pool for prefill
       if (pc.isPrefill() && p instanceof PrefillPool && pc.getMinSize() > 0)
@@ -187,6 +197,18 @@
    }
 
    /**
+    * Is the pool full ?
+    * @return True if full, otherwise false
+    */
+   public boolean isFull()
+   {
+      synchronized (cls)
+      {
+         return checkedOut.size() == maxSize;
+      }
+   }
+
+   /**
     * Check if the pool has reached a certain size
     * @param size The size
     * @return True if reached; otherwise false
@@ -212,8 +234,9 @@
       
       if (poolConfiguration.isBackgroundValidation() && poolConfiguration.getBackgroundValidationMillis() > 0)
       {
-         log.debug("Registering for background validation at interval " + 
-                   poolConfiguration.getBackgroundValidationMillis());
+         if (debug)
+            log.debug("Registering for background validation at interval " + 
+                      poolConfiguration.getBackgroundValidationMillis());
          
          //Register validation
          ConnectionValidator.getInstance().registerPool(this, poolConfiguration.getBackgroundValidationMillis());
@@ -245,6 +268,18 @@
 
       subject = (subject == null) ? defaultSubject : subject;
       cri = (cri == null) ? defaultCri : cri;
+
+      if (pool.isSharable() && (supportsLazyAssociation == null || supportsLazyAssociation.booleanValue()) && isFull())
+      {
+         if (supportsLazyAssociation == null)
+            checkLazyAssociation();
+
+         if (supportsLazyAssociation != null && supportsLazyAssociation.booleanValue())
+         {
+            detachConnectionListener();
+         }
+      }
+
       long startWait = System.currentTimeMillis();
       try
       {
@@ -392,8 +427,33 @@
    /**
     * {@inheritDoc}
     */
+   public ConnectionListener findConnectionListener(Object connection, ManagedConnection mc)
+   {
+      synchronized (cls)
+      {
+         for (ConnectionListener cl : checkedOut)
+         {
+            if (cl.controls(connection, mc))
+               return cl;
+         }
+      }
+
+      return null;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
    public void returnConnection(ConnectionListener cl, boolean kill)
    {
+      returnConnection(cl, kill, true);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void returnConnection(ConnectionListener cl, boolean kill, boolean cleanup)
+   {
       if (trace)
       {
          synchronized (cls)
@@ -424,15 +484,18 @@
          return;
       }
 
-      try
+      if (cleanup)
       {
-         cl.getManagedConnection().cleanup();
+         try
+         {
+            cl.getManagedConnection().cleanup();
+         }
+         catch (ResourceException re)
+         {
+            log.resourceExceptionCleaningUpManagedConnection(cl, re);
+            kill = true;
+         }
       }
-      catch (ResourceException re)
-      {
-         log.resourceExceptionCleaningUpManagedConnection(cl, re);
-         kill = true;
-      }
 
       synchronized (cls)
       {
@@ -799,7 +862,8 @@
       }
       catch (Throwable t)
       {
-         log.debug("Exception destroying ManagedConnection " + cl, t);
+         if (debug)
+            log.debug("Exception destroying ManagedConnection " + cl, t);
       }
 
       mc.removeConnectionEventListener(cl);
@@ -919,7 +983,8 @@
     */
    private ConnectionListener removeForFrequencyCheck()
    {
-      log.debug("Checking for connection within frequency");
+      if (debug)
+         log.debug("Checking for connection within frequency");
 
       ConnectionListener cl = null;
 
@@ -948,13 +1013,90 @@
     */
    private void returnForFrequencyCheck(ConnectionListener cl)
    {
-      log.debug("Returning for connection within frequency");
+      if (debug)
+         log.debug("Returning for connection within frequency");
 
       cl.setLastValidatedTime(System.currentTimeMillis());
       cls.add(cl);
    }
 
    /**
+    * Check if the resource adapter supports lazy association
+    */
+   private void checkLazyAssociation()
+   {
+      synchronized (cls)
+      {
+         ConnectionListener cl = null;
+
+         if (checkedOut.size() > 0)
+            cl = checkedOut.get(0);
+
+         if (cl == null && cls.size() > 0)
+            cl = cls.get(0);
+
+         if (cl != null)
+         {
+            ManagedConnection mc = cl.getManagedConnection();
+
+            if (mc instanceof DissociatableManagedConnection)
+            {
+               if (debug)
+                  log.debug("Enable lazy association support for: " + pool.getName());
+
+               supportsLazyAssociation = Boolean.TRUE;
+            }
+            else
+            {
+               if (debug)
+                  log.debug("Disable lazy association support for: " + pool.getName());
+
+               supportsLazyAssociation = Boolean.FALSE;
+            }
+         }
+      }
+   }
+
+   /**
+    * Detach connection listener
+    */
+   private void detachConnectionListener()
+   {
+      ConnectionListener cl = null;
+
+      synchronized (cls)
+      {
+         if (checkedOut.size() > 0)
+            cl = checkedOut.remove(0);
+
+         if (cl != null)
+         {
+            try
+            {
+               if (trace)
+                  log.tracef("Detach: %s", cl); 
+
+               DissociatableManagedConnection dmc = (DissociatableManagedConnection)cl.getManagedConnection();
+               dmc.dissociateConnections();
+               
+               cl.unregisterConnections();
+               
+               returnConnection(cl, false, false);
+            }
+            catch (Throwable t)
+            {
+               // Ok - didn't work; nuke it and disable
+               if (debug)
+                  log.debug("Exception during detach for: " + pool.getName(), t); 
+
+               supportsLazyAssociation = Boolean.FALSE;
+               returnConnection(cl, true, true);
+            }
+         }
+      }
+   }
+
+   /**
     * String representation
     * @return The string
     */

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/OnePool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/OnePool.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/OnePool.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -50,10 +50,12 @@
     * @param mcf managed connection factory
     * @param pc pool configuration
     * @param noTxSeparatePools notx seperate pool
+    * @param sharable Are the connections sharable
     */
-   public OnePool(final ManagedConnectionFactory mcf, final PoolConfiguration pc, final boolean noTxSeparatePools)
+   public OnePool(final ManagedConnectionFactory mcf, final PoolConfiguration pc,
+                  final boolean noTxSeparatePools, final boolean sharable)
    {
-      super(mcf, pc, noTxSeparatePools);
+      super(mcf, pc, noTxSeparatePools, sharable);
    }
 
    /**

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/PoolByCri.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/PoolByCri.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/PoolByCri.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -49,11 +49,12 @@
     * @param mcf managed connection factory
     * @param pc pool configuration
     * @param noTxSeparatePools notx seperate pool
+    * @param sharable Are the connections sharable
     */
    public PoolByCri(final ManagedConnectionFactory mcf, final PoolConfiguration pc,
-                    final boolean noTxSeparatePools)
+                    final boolean noTxSeparatePools, final boolean sharable)
    {
-      super(mcf, pc, noTxSeparatePools);
+      super(mcf, pc, noTxSeparatePools, sharable);
    }
 
    /**

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/PoolBySubject.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/PoolBySubject.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/PoolBySubject.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -56,11 +56,12 @@
     * @param mcf managed connection factory
     * @param pc pool configuration
     * @param noTxSeparatePools notx seperate pool
+    * @param sharable Are the connections sharable
     */
    public PoolBySubject(final ManagedConnectionFactory mcf, final PoolConfiguration pc,
-                        final boolean noTxSeparatePools)
+                        final boolean noTxSeparatePools, final boolean sharable)
    {
-      super(mcf, pc, noTxSeparatePools);
+      super(mcf, pc, noTxSeparatePools, sharable);
    }
 
    /**

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/PoolBySubjectAndCri.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/PoolBySubjectAndCri.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/PoolBySubjectAndCri.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -50,11 +50,12 @@
     * @param mcf managed connection factory
     * @param pc pool configuration
     * @param noTxSeparatePools notx seperate pool
+    * @param sharable Are the connections sharable
     */
    public PoolBySubjectAndCri(final ManagedConnectionFactory mcf, final PoolConfiguration pc,
-                              final boolean noTxSeparatePools)
+                              final boolean noTxSeparatePools, final boolean sharable)
    {
-      super(mcf, pc, noTxSeparatePools);
+      super(mcf, pc, noTxSeparatePools, sharable);
    }
 
    /**

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/ReauthPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/ReauthPool.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/ReauthPool.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -54,12 +54,14 @@
     * @param mcf managed connection factory
     * @param pc pool configuration
     * @param noTxSeparatePools notx seperate pool
+    * @param sharable Are the connections sharable
     */
    public ReauthPool(final ManagedConnectionFactory mcf,
                      final PoolConfiguration pc,
-                     final boolean noTxSeparatePools)
+                     final boolean noTxSeparatePools,
+                     final boolean sharable)
    {
-      super(mcf, pc, noTxSeparatePools);
+      super(mcf, pc, noTxSeparatePools, sharable);
    }
 
    /**

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerImpl.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -46,6 +46,7 @@
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionRequestInfo;
 import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
 import javax.security.auth.Subject;
 import javax.transaction.RollbackException;
 import javax.transaction.SystemException;
@@ -415,6 +416,16 @@
    }
 
    /**
+    * {@inheritDoc}
+    */
+   public boolean dissociateManagedConnection(Object connection, ManagedConnection mc, ManagedConnectionFactory mcf)
+      throws ResourceException
+   {
+
+      return false;
+   }
+
+   /**
     * Init lock
     * @return The lock
     */

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/common/MockConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/common/MockConnectionManager.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/common/MockConnectionManager.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -31,6 +31,7 @@
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
 import javax.transaction.SystemException;
 
 import org.jboss.logging.Logger;
@@ -73,6 +74,15 @@
       return null;
    }
 
+   /**
+    * {@inheritDoc}
+    */
+   public boolean dissociateManagedConnection(Object connection, ManagedConnection mc, ManagedConnectionFactory mcf)
+      throws ResourceException
+   {
+      return false;
+   }
+
    @Override
    public void transactionStarted(Collection<ConnectionRecord> conns) throws SystemException
    {

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/connections/InterleavingTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/connections/InterleavingTestCase.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/connections/InterleavingTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -418,12 +418,12 @@
 
       PoolFactory pf = new PoolFactory();
     
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true, true);
       
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       TxConnectionManagerImpl tcm =
          (TxConnectionManagerImpl)cmf.createTransactional(TransactionSupportLevel.XATransaction, pool,
-                                                          null, null, false, null,
+                                                          null, null, false, null, true,
                                                           FlushStrategy.FAILING_CONNECTION_ONLY,
                                                           null, null, ti, null, null, null, null, null);
       tcm.setInterleaving(true);

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/NoTxConnectionListenerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/NoTxConnectionListenerTestCase.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/NoTxConnectionListenerTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -222,12 +222,12 @@
       PoolConfiguration pc = new PoolConfiguration();
       PoolFactory pf = new PoolFactory();
 
-      pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
+      pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true, true);
 
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       ConnectionManager connectionManager = 
          cmf.createNonTransactional(TransactionSupportLevel.NoTransaction, pool,
-                                    null, null, false, null, 
+                                    null, null, false, null, true,
                                     FlushStrategy.FAILING_CONNECTION_ONLY,
                                     null, null);
 

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListenerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListenerTestCase.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/listener/TxConnectionListenerTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -717,12 +717,12 @@
       PoolConfiguration pc = new PoolConfiguration();
       PoolFactory pf = new PoolFactory();
 
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true, true);
 
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       ConnectionManager connectionManager =
          cmf.createTransactional(TransactionSupportLevel.LocalTransaction, pool,
-                                 null, null, false, null, FlushStrategy.FAILING_CONNECTION_ONLY,
+                                 null, null, false, null, true, FlushStrategy.FAILING_CONNECTION_ONLY,
                                  null, null, ti, null, null, null, null, null);
 
       txConnectionManager = (TxConnectionManager) connectionManager;

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/NoTxConnectionManagerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/NoTxConnectionManagerTestCase.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/NoTxConnectionManagerTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -75,11 +75,11 @@
       PoolConfiguration pc = new PoolConfiguration();
       PoolFactory pf = new PoolFactory();
 
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true, true);
 
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       connectionManager = 
-         cmf.createNonTransactional(TransactionSupportLevel.NoTransaction, pool, null, null, false, null, 
+         cmf.createNonTransactional(TransactionSupportLevel.NoTransaction, pool, null, null, false, null, true,
                                     FlushStrategy.FAILING_CONNECTION_ONLY,
                                     null, null);
       assertNotNull(connectionManager);

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/SerializableTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/SerializableTestCase.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/SerializableTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -63,12 +63,12 @@
       PoolConfiguration pc = new PoolConfiguration();
       PoolFactory pf = new PoolFactory();
 
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true, true);
 
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
 
       ConnectionManager connectionManager = cmf.createNonTransactional(TransactionSupportLevel.NoTransaction,
-                                                                       pool, null, null, false, null, 
+                                                                       pool, null, null, false, null, true,
                                                                        FlushStrategy.FAILING_CONNECTION_ONLY,
                                                                        null, null);
       assertNotNull(connectionManager);

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/pool/OnePoolTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/pool/OnePoolTestCase.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/pool/OnePoolTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -68,7 +68,7 @@
    @Test
    public void getKeyShouldReturnSameBooleanValuePassedAsSeparateNoTx() throws Exception
    {
-      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false);
+      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false, true);
       assertThat((Boolean) pool.getKey(null, null, true), is(true));
       assertThat((Boolean) pool.getKey(null, null, false), is(false));
    }
@@ -81,7 +81,7 @@
    @Test(expected = IllegalArgumentException.class)
    public void constructorShouldThrowIllegalArgumentExceptionForNullManagedConnectionFactory() throws Exception
    {
-      OnePool pool = new OnePool(null, mock(PoolConfiguration.class), false);
+      OnePool pool = new OnePool(null, mock(PoolConfiguration.class), false, true);
    }
 
    /**
@@ -92,7 +92,7 @@
    @Test(expected = IllegalArgumentException.class)
    public void constructorShouldThrowIllegalArgumentExceptionForNullPoolConfiguration() throws Exception
    {
-      OnePool pool = new OnePool(mock(ManagedConnectionFactory.class), null, false);
+      OnePool pool = new OnePool(mock(ManagedConnectionFactory.class), null, false, true);
    }
 
    /**
@@ -104,7 +104,7 @@
    public void emptySubPoolShouldDoNothing() throws Exception
    {
       //given
-      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false);
+      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false, true);
       //when (note: argument is not important, set to null just for convenience)
       ((OnePool) pool).emptySubPool(null);
       //then
@@ -120,7 +120,7 @@
    public void flushPoolShouldLeaveSubPoolEmpty() throws Exception
    {
       //given
-      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false);
+      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false, true);
       //when (note: argument is not important, set to null just for convenience)
       ((OnePool) pool).flush();
       //then
@@ -137,7 +137,7 @@
    public void shutdownShouldLeaveSubPoolEmpty() throws Exception
    {
       //given
-      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false);
+      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false, true);
       //when (note: argument is not important, set to null just for convenience)
       ((OnePool) pool).shutdown();
       //then
@@ -154,7 +154,7 @@
    public void getTransactionOldConnectionShouldThrowResourceExceptionIfLockFail() throws Exception
    {
       //given
-      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false);
+      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false, true);
       Transaction trackByTransaction = mock(Transaction.class);
       //doThrow(new InterruptedException()).lock(trackByTransaction);
       //when
@@ -171,7 +171,7 @@
    public void getTransactionOldConnectionShouldReturnNullIfClIsNullButCorrectlyLockAndUnlock() throws Exception
    {
       //given
-      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false);
+      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false, true);
       Transaction trackByTransaction = mock(Transaction.class);
       //when
       //Object returnValue = pool.getTransactionOldConnection(trackByTransaction);
@@ -188,7 +188,7 @@
    public void getTransactionOldConnectionShouldReturnValueIfClHasValueAndCorrectlyLockAndUnlock() throws Exception
    {
       //given
-      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false);
+      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false, true);
       Transaction trackByTransaction = mock(Transaction.class);
       ConnectionListener listener = mock(ConnectionListener.class);
       //when
@@ -206,7 +206,7 @@
    public void getTransactionNewConnectionShouldGetConnectionBeforeLocking() throws Exception
    {
       //given
-      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false);
+      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false, true);
       Transaction trackByTransaction = mock(Transaction.class);
       ConnectionListener listener = mock(ConnectionListener.class);
       ManagedConnectionPool mcp = mock(ManagedConnectionPool.class);
@@ -236,7 +236,7 @@
       throws Exception
    {
       //given
-      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false);
+      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false, true);
       Transaction trackByTransaction = mock(Transaction.class);
       ManagedConnectionPool mcp = mock(ManagedConnectionPool.class);
       ConnectionListener cl = mock(ConnectionListener.class);
@@ -268,7 +268,7 @@
    public void getTransactionNewConnectionShouldUseTheOtherFromDifferentThreadIfAlreadyTracked() throws Exception
    {
       //given
-      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false);
+      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false, true);
       Transaction trackByTransaction = mock(Transaction.class);
       ManagedConnectionPool mcp = mock(ManagedConnectionPool.class);
       ConnectionListener cl = mock(ConnectionListener.class);
@@ -307,7 +307,7 @@
    public void getTransactionNewConnectionShouldUseMcpReturnedCl() throws Exception
    {
       //given
-      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false);
+      AbstractPool pool = new OnePool(mock(ManagedConnectionFactory.class), mock(PoolConfiguration.class), false, true);
       Transaction trackByTransaction = mock(Transaction.class);
       ManagedConnectionPool mcp = mock(ManagedConnectionPool.class);
       ConnectionListener cl = mock(ConnectionListener.class);

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/pool/PrefillTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/pool/PrefillTestCase.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/pool/PrefillTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -65,7 +65,7 @@
       config.setPrefill(true);
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, config, false);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, config, false, true);
 
       assertTrue(pool instanceof PrefillPool);
 
@@ -73,7 +73,7 @@
 
       NoTxConnectionManager noTxConnectionManager = 
          cmf.createNonTransactional(TransactionSupportLevel.NoTransaction, 
-                                    pool, null, null, false, null, 
+                                    pool, null, null, false, null, true,
                                     FlushStrategy.FAILING_CONNECTION_ONLY,
                                     null, null);
 
@@ -109,7 +109,7 @@
       config.setPrefill(false);
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, config, false);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, config, false, true);
 
       assertTrue(pool instanceof PrefillPool);
 
@@ -117,7 +117,7 @@
 
       NoTxConnectionManager noTxConnectionManager = 
          cmf.createNonTransactional(TransactionSupportLevel.NoTransaction, pool, 
-                                    null, null, false, null, 
+                                    null, null, false, null, true,
                                     FlushStrategy.FAILING_CONNECTION_ONLY,
                                     null, null);
 
@@ -151,7 +151,7 @@
       PoolConfiguration config = new PoolConfiguration();
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.POOL_BY_CRI, mcf, config, false);
+      Pool pool = pf.create(PoolStrategy.POOL_BY_CRI, mcf, config, false, true);
 
       assertFalse(pool instanceof PrefillPool);
    }
@@ -174,7 +174,7 @@
       config.setPrefill(true);
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.POOL_BY_SUBJECT, mcf, config, false);
+      Pool pool = pf.create(PoolStrategy.POOL_BY_SUBJECT, mcf, config, false, true);
 
       assertTrue(pool instanceof PrefillPool);
 
@@ -182,7 +182,7 @@
 
       NoTxConnectionManager noTxConnectionManager = 
          cmf.createNonTransactional(TransactionSupportLevel.NoTransaction, app,
-                                    subjectFactory, "domain", false, null, 
+                                    subjectFactory, "domain", false, null, true,
                                     FlushStrategy.FAILING_CONNECTION_ONLY,
                                     null, null);
 
@@ -221,7 +221,7 @@
       config.setPrefill(false);
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.POOL_BY_SUBJECT, mcf, config, false);
+      Pool pool = pf.create(PoolStrategy.POOL_BY_SUBJECT, mcf, config, false, true);
 
       assertTrue(pool instanceof PrefillPool);
 
@@ -229,7 +229,7 @@
 
       NoTxConnectionManager noTxConnectionManager = 
          cmf.createNonTransactional(TransactionSupportLevel.NoTransaction, app,
-                                    subjectFactory, "domain", false, null, 
+                                    subjectFactory, "domain", false, null, true,
                                     FlushStrategy.FAILING_CONNECTION_ONLY,
                                     null, null);
 
@@ -263,7 +263,7 @@
       PoolConfiguration config = new PoolConfiguration();
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.POOL_BY_SUBJECT_AND_CRI, mcf, config, false);
+      Pool pool = pf.create(PoolStrategy.POOL_BY_SUBJECT_AND_CRI, mcf, config, false, true);
 
       assertFalse(pool instanceof PrefillPool);
    }
@@ -281,7 +281,7 @@
       PoolConfiguration config = new PoolConfiguration();
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.REAUTH, mcf, config, false);
+      Pool pool = pf.create(PoolStrategy.REAUTH, mcf, config, false, true);
 
       assertFalse(pool instanceof PrefillPool);
    }

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/pool/TestConnectionTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/pool/TestConnectionTestCase.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/pool/TestConnectionTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -59,11 +59,11 @@
       PoolConfiguration config = new PoolConfiguration();
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, config, false);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, config, false, true);
 
       NoTxConnectionManager noTxConnectionManager = 
          cmf.createNonTransactional(TransactionSupportLevel.NoTransaction, 
-                                    pool, null, null, false, null, 
+                                    pool, null, null, false, null, true,
                                     FlushStrategy.FAILING_CONNECTION_ONLY,
                                     null, null);
 
@@ -83,7 +83,7 @@
       PoolConfiguration config = new PoolConfiguration();
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.POOL_BY_CRI, mcf, config, false);
+      Pool pool = pf.create(PoolStrategy.POOL_BY_CRI, mcf, config, false, true);
 
       assertFalse(pool.testConnection());
    }
@@ -103,11 +103,11 @@
       PoolConfiguration config = new PoolConfiguration();
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.POOL_BY_SUBJECT, mcf, config, false);
+      Pool pool = pf.create(PoolStrategy.POOL_BY_SUBJECT, mcf, config, false, true);
 
       NoTxConnectionManager noTxConnectionManager = 
          cmf.createNonTransactional(TransactionSupportLevel.NoTransaction, pool,
-                                    subjectFactory, "domain", false, null, 
+                                    subjectFactory, "domain", false, null, true,
                                     FlushStrategy.FAILING_CONNECTION_ONLY,
                                     null, null);
 
@@ -127,7 +127,7 @@
       PoolConfiguration config = new PoolConfiguration();
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.POOL_BY_SUBJECT_AND_CRI, mcf, config, false);
+      Pool pool = pf.create(PoolStrategy.POOL_BY_SUBJECT_AND_CRI, mcf, config, false, true);
 
       assertFalse(pool.testConnection());
    }
@@ -145,7 +145,7 @@
       PoolConfiguration config = new PoolConfiguration();
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.REAUTH, mcf, config, false);
+      Pool pool = pf.create(PoolStrategy.REAUTH, mcf, config, false, true);
 
       assertFalse(pool.testConnection());
    }

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/SerializableTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/SerializableTestCase.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/SerializableTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -72,11 +72,11 @@
       PoolConfiguration pc = new PoolConfiguration();
       PoolFactory pf = new PoolFactory();
 
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true, true);
 
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       ConnectionManager connectionManager = cmf.createTransactional(TransactionSupportLevel.XATransaction,
-                                                                    pool, null, null, false, null, 
+                                                                    pool, null, null, false, null, true,
                                                                     FlushStrategy.FAILING_CONNECTION_ONLY,
                                                                     null, null, ti,
                                                                     Boolean.FALSE, null, null, null, null);

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/TxConnectionManagerTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -428,12 +428,13 @@
       PoolConfiguration pc = new PoolConfiguration();
       PoolFactory pf = new PoolFactory();
     
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true, true);
       
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       return (TxConnectionManager) cmf.createTransactional(TransactionSupportLevel.XATransaction, pool,
-                                   null, null, false, null, FlushStrategy.FAILING_CONNECTION_ONLY,
-                                   null, null, ti, null, null, null, null, null);
+                                                           null, null, false, null, true, 
+                                                           FlushStrategy.FAILING_CONNECTION_ONLY,
+                                                           null, null, ti, null, null, null, null, null);
    }
 
    /**

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/XATxConnectionManagerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/XATxConnectionManagerTestCase.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/XATxConnectionManagerTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -280,12 +280,12 @@
       PoolConfiguration pc = new PoolConfiguration();
       PoolFactory pf = new PoolFactory();
 
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true, true);
 
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       ConnectionManager connectionManager =
          cmf.createTransactional(TransactionSupportLevel.XATransaction, pool,
-                                 null, null, false, null, FlushStrategy.FAILING_CONNECTION_ONLY,
+                                 null, null, false, null, true, FlushStrategy.FAILING_CONNECTION_ONLY,
                                  null, null, ti,
                                  Boolean.FALSE, null, null, null, null);
       assertNotNull(connectionManager);

Modified: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/AbstractConnectionManagerTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/AbstractConnectionManagerTestCase.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/unit/AbstractConnectionManagerTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -61,7 +61,7 @@
       PoolConfiguration pc = new PoolConfiguration();
       PoolFactory pf = new PoolFactory();
 
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, new MockManagedConnectionFactory(), pc, false);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, new MockManagedConnectionFactory(), pc, false, true);
       pool.setConnectionListenerFactory(connectionManager);
       connectionManager.setPool(pool);
 
@@ -146,7 +146,7 @@
       PoolConfiguration pc = new PoolConfiguration();
       PoolFactory pf = new PoolFactory();
 
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, false);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, false, true);
       pool.setConnectionListenerFactory(connectionManager);
       connectionManager.setPool(pool);
 
@@ -236,7 +236,7 @@
       PoolConfiguration pc = new PoolConfiguration();
       PoolFactory pf = new PoolFactory();
 
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, new MockManagedConnectionFactory(), pc, false);
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, new MockManagedConnectionFactory(), pc, false, true);
       pool.setConnectionListenerFactory(connectionManager);
 
       connectionManager.setPool(pool);

Modified: projects/jboss-jca/trunk/deployers/build.xml
===================================================================
--- projects/jboss-jca/trunk/deployers/build.xml	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/deployers/build.xml	2012-02-14 16:46:11 UTC (rev 112641)
@@ -196,7 +196,11 @@
           includes="org/jboss/jca/test/deployers/spec/rars/configproperty/*.class"/>
        <fileset dir="src/test/resources/config-property.rar"/>
     </jar>
-   
+    <jar destfile="${build.deployers.dir}/lazy.rar">
+       <fileset dir="${build.deployers.dir}/test"
+          includes="org/jboss/jca/test/deployers/spec/rars/lazy/*.class"/>
+       <fileset dir="src/test/resources/lazy.rar"/>
+    </jar>
   </target>
 
   <!-- ================================= 

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -454,7 +454,7 @@
          }
       }
 
-      Pool pool = pf.create(strategy, mcf, pc, false);
+      Pool pool = pf.create(strategy, mcf, pc, false, true);
 
       // Connection manager properties
       Integer allocationRetry = null;
@@ -491,6 +491,7 @@
          cm = cmf.createTransactional(TransactionSupportLevel.LocalTransaction, pool, 
                                       getSubjectFactory(securityDomain), securityDomain,
                                       ds.isUseCcm(), getCachedConnectionManager(),
+                                      true,
                                       flushStrategy,
                                       allocationRetry, allocationRetryWaitMillis,
                                       getTransactionIntegration(),
@@ -501,6 +502,7 @@
          cm = cmf.createNonTransactional(TransactionSupportLevel.NoTransaction, pool, 
                                          getSubjectFactory(securityDomain), securityDomain,
                                          ds.isUseCcm(), getCachedConnectionManager(),
+                                         true,
                                          flushStrategy, allocationRetry, allocationRetryWaitMillis);
       }
 
@@ -617,7 +619,7 @@
          }
       }
 
-      Pool pool = pf.create(strategy, mcf, pc, noTxSeparatePool.booleanValue());
+      Pool pool = pf.create(strategy, mcf, pc, noTxSeparatePool.booleanValue(), true);
 
       // Connection manager properties
       Integer allocationRetry = null;
@@ -665,6 +667,7 @@
       ConnectionManager cm =
          cmf.createTransactional(tsl, pool, getSubjectFactory(securityDomain), securityDomain,
                                  ds.isUseCcm(), getCachedConnectionManager(),
+                                 true,
                                  flushStrategy,
                                  allocationRetry, allocationRetryWaitMillis,
                                  getTransactionIntegration(), interleaving,

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -1351,8 +1351,12 @@
                            strategy = PoolStrategy.REAUTH;
                         }
 
-                        Pool pool = pf.create(strategy, mcf, pc, noTxSeparatePool.booleanValue());
+                        Boolean sharable = Boolean.TRUE;
+                        if (connectionDefinition != null)
+                           sharable = connectionDefinition.isSharable();
 
+                        Pool pool = pf.create(strategy, mcf, pc, noTxSeparatePool.booleanValue(), sharable.booleanValue());
+
                         // Add a connection manager
                         ConnectionManagerFactory cmf = new ConnectionManagerFactory();
                         ConnectionManager cm = null;
@@ -1410,6 +1414,7 @@
                            cm = cmf.createNonTransactional(tsl, pool,
                                                            getSubjectFactory(securityDomain), securityDomain,
                                                            useCCM, getCachedConnectionManager(),
+                                                           sharable,
                                                            flushStrategy,
                                                            allocationRetry, allocationRetryWaitMillis);
                         }
@@ -1436,6 +1441,7 @@
                            cm = cmf.createTransactional(tsl, pool,
                                                         getSubjectFactory(securityDomain), securityDomain,
                                                         useCCM, getCachedConnectionManager(),
+                                                        sharable,
                                                         flushStrategy,
                                                         allocationRetry, allocationRetryWaitMillis,
                                                         getTransactionIntegration(), interleaving,
@@ -1736,8 +1742,13 @@
                                        strategy = PoolStrategy.REAUTH;
                                     }
 
-                                    Pool pool = pf.create(strategy, mcf, pc, noTxSeparatePool.booleanValue());
+                                    Boolean sharable = Boolean.TRUE;
+                                    if (connectionDefinition != null)
+                                       sharable = connectionDefinition.isSharable();
 
+                                    Pool pool = pf.create(strategy, mcf, pc, noTxSeparatePool.booleanValue(),
+                                                          sharable.booleanValue());
+
                                     // Add a connection manager
                                     ConnectionManagerFactory cmf = new ConnectionManagerFactory();
                                     ConnectionManager cm = null;
@@ -1797,6 +1808,7 @@
                                                                        getSubjectFactory(securityDomain),
                                                                        securityDomain,
                                                                        useCCM, getCachedConnectionManager(),
+                                                                       sharable,
                                                                        flushStrategy,
                                                                        allocationRetry, allocationRetryWaitMillis);
                                     }
@@ -1825,6 +1837,7 @@
                                        cm = cmf.createTransactional(tsl, pool,
                                                                     getSubjectFactory(securityDomain), securityDomain,
                                                                     useCCM, getCachedConnectionManager(),
+                                                                    sharable,
                                                                     flushStrategy,
                                                                     allocationRetry, allocationRetryWaitMillis,
                                                                     getTransactionIntegration(),

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnection.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnection.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnection.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.deployers.spec.rars.lazy;
+
+/**
+ * LazyConnection
+ *
+ * @version $Revision: $
+ */
+public interface LazyConnection
+{
+   /**
+    * isManagedConnectionSet
+    * @return boolean
+    */
+   public boolean isManagedConnectionSet();
+
+   /**
+    * Close managed connection
+    */
+   public void closeManagedConnection();
+
+   /**
+    * Associate
+    */
+   public void associate();
+
+   /**
+    * Close
+    */
+   public void close();
+}

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnectionFactory.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnectionFactory.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnectionFactory.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.deployers.spec.rars.lazy;
+
+import java.io.Serializable;
+
+import javax.resource.Referenceable;
+import javax.resource.ResourceException;
+
+/**
+ * LazyConnectionFactory
+ *
+ * @version $Revision: $
+ */
+public interface LazyConnectionFactory extends Serializable, Referenceable
+{
+   /** 
+    * Get connection from factory
+    *
+    * @return LazyConnection instance
+    * @exception ResourceException Thrown if a connection can't be obtained
+    */
+   public LazyConnection getConnection() throws ResourceException;
+
+}

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnectionFactoryImpl.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnectionFactoryImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnectionFactoryImpl.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.deployers.spec.rars.lazy;
+
+import javax.naming.NamingException;
+import javax.naming.Reference;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+
+import org.jboss.logging.Logger;
+
+/**
+ * LazyConnectionFactoryImpl
+ *
+ * @version $Revision: $
+ */
+public class LazyConnectionFactoryImpl implements LazyConnectionFactory
+{
+   /** The serial version UID */
+   private static final long serialVersionUID = 1L;
+
+   /** The logger */
+   private static Logger log = Logger.getLogger(LazyConnectionFactoryImpl.class);
+
+   /** Reference */
+   private Reference reference;
+
+   /** ManagedConnectionFactory */
+   private LazyManagedConnectionFactory mcf;
+
+   /** ConnectionManager */
+   private ConnectionManager connectionManager;
+
+   /**
+    * Default constructor
+    */
+   public LazyConnectionFactoryImpl()
+   {
+   }
+
+   /**
+    * Default constructor
+    * @param mcf ManagedConnectionFactory
+    * @param cxManager ConnectionManager
+    */
+   public LazyConnectionFactoryImpl(LazyManagedConnectionFactory mcf, ConnectionManager cxManager)
+   {
+      this.mcf = mcf;
+      this.connectionManager = cxManager;
+   }
+
+   /** 
+    * Get connection from factory
+    *
+    * @return LazyConnection instance
+    * @exception ResourceException Thrown if a connection can't be obtained
+    */
+   @Override
+   public LazyConnection getConnection() throws ResourceException
+   {
+      log.trace("getConnection()");
+      return (LazyConnection)connectionManager.allocateConnection(mcf, null);
+   }
+
+   /**
+    * Get the Reference instance.
+    *
+    * @return Reference instance
+    * @exception NamingException Thrown if a reference can't be obtained
+    */
+   @Override
+   public Reference getReference() throws NamingException
+   {
+      log.trace("getReference()");
+      return reference;
+   }
+
+   /**
+    * Set the Reference instance.
+    *
+    * @param reference A Reference instance
+    */
+   @Override
+   public void setReference(Reference reference)
+   {
+      log.trace("setReference()");
+      this.reference = reference;
+   }
+}

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnectionImpl.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnectionImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyConnectionImpl.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.deployers.spec.rars.lazy;
+
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.LazyAssociatableConnectionManager;
+
+import org.jboss.logging.Logger;
+
+/**
+ * LazyConnectionImpl
+ *
+ * @version $Revision: $
+ */
+public class LazyConnectionImpl implements LazyConnection
+{
+   /** The logger */
+   private static Logger log = Logger.getLogger(LazyConnectionImpl.class);
+
+   /** Connection manager */
+   private ConnectionManager cm;
+
+   /** ManagedConnection */
+   private LazyManagedConnection mc;
+
+   /** ManagedConnectionFactory */
+   private LazyManagedConnectionFactory mcf;
+
+   /** ConnectionRequestInfo */
+   private ConnectionRequestInfo cri;
+
+   /**
+    * Default constructor
+    * @param mc LazyManagedConnection
+    * @param mcf LazyManagedConnectionFactory
+    * @param cm ConnectionManager
+    * @param cri ConnectionRequestInfo
+    */
+   public LazyConnectionImpl(LazyManagedConnection mc, LazyManagedConnectionFactory mcf,
+                             ConnectionManager cm, ConnectionRequestInfo cri)
+   {
+      this.mc = mc;
+      this.mcf = mcf;
+      this.cm = cm;
+      this.cri = cri;
+   }
+
+   /**
+    * Call isManagedConnectionSet
+    * @return boolean
+    */
+   public boolean isManagedConnectionSet()
+   {
+      log.trace("isManagedConnectionSet()");
+
+      return mc != null;
+   }
+
+   /**
+    * Close managed connection
+    */
+   public void closeManagedConnection()
+   {
+      log.trace("closeManagedConnection()");
+      
+      if (mc != null)
+      {
+         try
+         {
+            if (cm instanceof org.jboss.jca.core.api.connectionmanager.ConnectionManager)
+            {
+               org.jboss.jca.core.api.connectionmanager.ConnectionManager jboss =
+                  (org.jboss.jca.core.api.connectionmanager.ConnectionManager)cm;
+
+               boolean result = jboss.dissociateManagedConnection(this, mc, mcf);
+               log.trace("Result=" + result);
+
+               mc = null;
+            }
+         }
+         catch (Throwable t)
+         {
+            log.error("CloseManagedConnection", t);
+         }
+      }
+   }
+
+   /**
+    * Associate
+    */
+   public void associate()
+   {
+      log.trace("associate()");
+      if (cm instanceof LazyAssociatableConnectionManager)
+      {
+         try
+         {
+            LazyAssociatableConnectionManager lacm = (LazyAssociatableConnectionManager)cm;
+            lacm.associateConnection(this, mcf, cri);
+         }
+         catch (Throwable t)
+         {
+            log.error("Associate", t);
+         }
+      }
+   }
+
+   /**
+    * Close
+    */
+   public void close()
+   {
+      log.trace("close()");
+      if (mc != null)
+      {
+         mc.closeHandle(this);
+      }
+      else
+      {
+         if (cm instanceof LazyAssociatableConnectionManager)
+         {
+            LazyAssociatableConnectionManager lacm = (LazyAssociatableConnectionManager)cm;
+            lacm.inactiveConnectionClosed(this, mcf);
+         }
+      }
+   }
+
+   /**
+    * Set the managed connection
+    * @param mc The value
+    */
+   void setManagedConnection(LazyManagedConnection mc)
+   {
+      log.trace("setManagedConnection(" + mc + ")");
+      this.mc = mc;
+   }
+}

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyManagedConnection.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyManagedConnection.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyManagedConnection.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,276 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.deployers.spec.rars.lazy;
+
+import java.io.PrintWriter;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.resource.NotSupportedException;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.DissociatableManagedConnection;
+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;
+
+/**
+ * LazyManagedConnection
+ *
+ * @version $Revision: $
+ */
+public class LazyManagedConnection implements ManagedConnection, DissociatableManagedConnection
+{
+   /** The logger */
+   private static Logger log = Logger.getLogger(LazyManagedConnection.class);
+
+   /** The logwriter */
+   private PrintWriter logwriter;
+
+   /** Connection manager */
+   private ConnectionManager cm;
+
+   /** ManagedConnectionFactory */
+   private LazyManagedConnectionFactory mcf;
+
+   /** Listeners */
+   private List<ConnectionEventListener> listeners;
+
+   /** Connection */
+   private LazyConnectionImpl connection;
+
+   /**
+    * Default constructor
+    * @param mcf mcf
+    */
+   public LazyManagedConnection(LazyManagedConnectionFactory mcf, ConnectionManager cm)
+   {
+      this.mcf = mcf;
+      this.cm = cm;
+      this.logwriter = null;
+      this.listeners = Collections.synchronizedList(new ArrayList<ConnectionEventListener>(1));
+      this.connection = null;
+   }
+
+   /**
+    * Creates a new connection handle for the underlying physical connection 
+    * represented by the ManagedConnection instance. 
+    *
+    * @param subject Security context as JAAS subject
+    * @param cxRequestInfo ConnectionRequestInfo instance
+    * @return generic Object instance representing the connection handle. 
+    * @throws ResourceException generic exception if operation fails
+    */
+   public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+   {
+      log.trace("getConnection()");
+
+      if (connection != null)
+         connection.setManagedConnection(null);
+         
+      connection = new LazyConnectionImpl(this, mcf, cm, cxRequestInfo);
+      return connection;
+   }
+
+   /**
+    * Used by the container to change the association of an 
+    * application-level connection handle with a ManagedConneciton instance.
+    *
+    * @param connection Application-level connection handle
+    * @throws ResourceException generic exception if operation fails
+    */
+   public void associateConnection(Object connection) throws ResourceException
+   {
+      log.trace("associateConnection()");
+
+      if (this.connection != null)
+         this.connection.setManagedConnection(null);
+
+      if (connection != null)
+      {
+         if (!(connection instanceof LazyConnectionImpl))
+            throw new ResourceException("Connection isn't LazyConnectionImpl: " + connection.getClass().getName());
+
+         this.connection = (LazyConnectionImpl)connection;
+         this.connection.setManagedConnection(this);
+      }
+      else
+      {
+         this.connection = null;
+      }
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public void dissociateConnections() throws ResourceException
+   {
+      log.trace("dissociateConnections()");
+
+      if (connection != null)
+      {
+         connection.setManagedConnection(null);
+         connection = null;
+      }
+   }
+
+   /**
+    * Application server calls this method to force any cleanup on the ManagedConnection instance.
+    *
+    * @throws ResourceException generic exception if operation fails
+    */
+   public void cleanup() throws ResourceException
+   {
+      log.trace("cleanup()");
+
+      if (connection != null)
+      {
+         connection.setManagedConnection(null);
+         connection = null;
+      }
+   }
+
+   /**
+    * Destroys the physical connection to the underlying resource manager.
+    *
+    * @throws ResourceException generic exception if operation fails
+    */
+   public void destroy() throws ResourceException
+   {
+      log.trace("destroy()");
+
+      if (connection != null)
+      {
+         connection.setManagedConnection(null);
+         connection = null;
+      }
+   }
+
+   /**
+    * Adds a connection event listener to the ManagedConnection instance.
+    *
+    * @param listener A new ConnectionEventListener to be registered
+    */
+   public void addConnectionEventListener(ConnectionEventListener listener)
+   {
+      log.trace("addConnectionEventListener()");
+      if (listener == null)
+         throw new IllegalArgumentException("Listener is null");
+      listeners.add(listener);
+   }
+
+   /**
+    * Removes an already registered connection event listener from the ManagedConnection instance.
+    *
+    * @param listener already registered connection event listener to be removed
+    */
+   public void removeConnectionEventListener(ConnectionEventListener listener)
+   {
+      log.trace("removeConnectionEventListener()");
+      if (listener == null)
+         throw new IllegalArgumentException("Listener is null");
+      listeners.remove(listener);
+   }
+
+   /**
+    * Close handle
+    *
+    * @param handle The handle
+    */
+   public void closeHandle(LazyConnection handle)
+   {
+      ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
+      event.setConnectionHandle(handle);
+      for (ConnectionEventListener cel : listeners)
+      {
+         cel.connectionClosed(event);
+      }
+   }
+
+   /**
+    * Gets the log writer for this ManagedConnection instance.
+    *
+    * @return Character ourput stream associated with this Managed-Connection instance
+    * @throws ResourceException generic exception if operation fails
+    */
+   public PrintWriter getLogWriter() throws ResourceException
+   {
+      log.trace("getLogWriter()");
+      return logwriter;
+   }
+
+   /**
+    * Sets the log writer for this ManagedConnection instance.
+    *
+    * @param out Character Output stream to be associated
+    * @throws ResourceException  generic exception if operation fails
+    */
+   public void setLogWriter(PrintWriter out) throws ResourceException
+   {
+      log.trace("setLogWriter()");
+      logwriter = out;
+   }
+
+   /**
+    * Returns an <code>javax.resource.spi.LocalTransaction</code> instance.
+    *
+    * @return LocalTransaction instance
+    * @throws ResourceException generic exception if operation fails
+    */
+   public LocalTransaction getLocalTransaction() throws ResourceException
+   {
+      throw new NotSupportedException("LocalTransaction not supported");
+   }
+
+   /**
+    * Returns an <code>javax.transaction.xa.XAresource</code> instance. 
+    *
+    * @return XAResource instance
+    * @throws ResourceException generic exception if operation fails
+    */
+   public XAResource getXAResource() throws ResourceException
+   {
+      throw new NotSupportedException("GetXAResource not supported not supported");
+   }
+
+   /**
+    * Gets the metadata information for this connection's underlying EIS resource manager instance. 
+    *
+    * @return ManagedConnectionMetaData instance
+    * @throws ResourceException generic exception if operation fails
+    */
+   public ManagedConnectionMetaData getMetaData() throws ResourceException
+   {
+      log.trace("getMetaData()");
+      return new LazyManagedConnectionMetaData();
+   }
+}

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyManagedConnectionFactory.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyManagedConnectionFactory.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,217 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.deployers.spec.rars.lazy;
+
+import java.io.PrintWriter;
+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.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterAssociation;
+
+import javax.security.auth.Subject;
+
+import org.jboss.logging.Logger;
+
+/**
+ * LazyManagedConnectionFactory
+ *
+ * @version $Revision: $
+ */
+public class LazyManagedConnectionFactory implements ManagedConnectionFactory, ResourceAdapterAssociation
+{
+
+   /** The serial version UID */
+   private static final long serialVersionUID = 1L;
+
+   /** The logger */
+   private static Logger log = Logger.getLogger(LazyManagedConnectionFactory.class);
+
+   /** Connection manager */
+   private ConnectionManager cm;
+
+   /** The resource adapter */
+   private ResourceAdapter ra;
+
+   /** The logwriter */
+   private PrintWriter logwriter;
+
+   /**
+    * Default constructor
+    */
+   public LazyManagedConnectionFactory()
+   {
+      this.cm = null;
+      this.ra = null;
+      this.logwriter = null;
+   }
+
+   /**
+    * Creates a Connection Factory instance. 
+    *
+    * @param cxManager ConnectionManager to be associated with created EIS connection factory instance
+    * @return EIS-specific Connection Factory instance or javax.resource.cci.ConnectionFactory instance
+    * @throws ResourceException Generic exception
+    */
+   public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException
+   {
+      log.trace("createConnectionFactory()");
+
+      this.cm = cxManager;
+
+      return new LazyConnectionFactoryImpl(this, cxManager);
+   }
+
+   /**
+    * Creates a Connection Factory instance. 
+    *
+    * @return EIS-specific Connection Factory instance or javax.resource.cci.ConnectionFactory instance
+    * @throws ResourceException Generic exception
+    */
+   public Object createConnectionFactory() throws ResourceException
+   {
+      throw new ResourceException("This resource adapter doesn't support non-managed environments");
+   }
+
+   /**
+    * Creates a new physical connection to the underlying EIS resource manager.
+    *
+    * @param subject Caller's security information
+    * @param cxRequestInfo Additional resource adapter specific connection request information
+    * @throws ResourceException generic exception
+    * @return ManagedConnection instance 
+    */
+   public ManagedConnection createManagedConnection(Subject subject,
+         ConnectionRequestInfo cxRequestInfo) throws ResourceException
+   {
+      log.trace("createManagedConnection()");
+      return new LazyManagedConnection(this, cm);
+   }
+
+   /**
+    * Returns a matched connection from the candidate set of connections. 
+    *
+    * @param connectionSet Candidate connection set
+    * @param subject Caller's security information
+    * @param cxRequestInfo Additional resource adapter specific connection request information
+    * @throws ResourceException generic exception
+    * @return ManagedConnection if resource adapter finds an acceptable match otherwise null 
+    */
+   public ManagedConnection matchManagedConnections(Set connectionSet,
+         Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException
+   {
+      log.trace("matchManagedConnections()");
+      ManagedConnection result = null;
+      Iterator it = connectionSet.iterator();
+      while (result == null && it.hasNext())
+      {
+         ManagedConnection mc = (ManagedConnection)it.next();
+         if (mc instanceof LazyManagedConnection)
+         {
+            result = mc;
+         }
+
+      }
+      return result;
+   }
+
+   /**
+    * Get the log writer for this ManagedConnectionFactory instance.
+    *
+    * @return PrintWriter
+    * @throws ResourceException generic exception
+    */
+   public PrintWriter getLogWriter() throws ResourceException
+   {
+      log.trace("getLogWriter()");
+      return logwriter;
+   }
+
+   /**
+    * Set the log writer for this ManagedConnectionFactory instance.
+    *
+    * @param out PrintWriter - an out stream for error logging and tracing
+    * @throws ResourceException generic exception
+    */
+   public void setLogWriter(PrintWriter out) throws ResourceException
+   {
+      log.trace("setLogWriter()");
+      logwriter = out;
+   }
+
+   /**
+    * Get the resource adapter
+    *
+    * @return The handle
+    */
+   public ResourceAdapter getResourceAdapter()
+   {
+      log.trace("getResourceAdapter()");
+      return ra;
+   }
+
+   /**
+    * Set the resource adapter
+    *
+    * @param ra The handle
+    */
+   public void setResourceAdapter(ResourceAdapter ra)
+   {
+      log.trace("setResourceAdapter()");
+      this.ra = ra;
+   }
+
+   /** 
+    * Returns a hash code value for the object.
+    * @return A hash code value for this object.
+    */
+   @Override
+   public int hashCode()
+   {
+      int result = 17;
+      return result;
+   }
+
+   /** 
+    * Indicates whether some other object is equal to this one.
+    * @param other The reference object with which to compare.
+    * @return true if this object is the same as the obj argument, false otherwise.
+    */
+   @Override
+   public boolean equals(Object other)
+   {
+      if (other == null)
+         return false;
+      if (other == this)
+         return true;
+      if (!(other instanceof LazyManagedConnectionFactory))
+         return false;
+      LazyManagedConnectionFactory obj = (LazyManagedConnectionFactory)other;
+      boolean result = true; 
+      return result;
+   }
+}

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyManagedConnectionMetaData.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyManagedConnectionMetaData.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyManagedConnectionMetaData.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.deployers.spec.rars.lazy;
+
+import javax.resource.ResourceException;
+
+import javax.resource.spi.ManagedConnectionMetaData;
+
+import org.jboss.logging.Logger;
+
+/**
+ * LazyManagedConnectionMetaData
+ *
+ * @version $Revision: $
+ */
+public class LazyManagedConnectionMetaData implements ManagedConnectionMetaData
+{
+   /** The logger */
+   private static Logger log = Logger.getLogger(LazyManagedConnectionMetaData.class);
+
+   /**
+    * Default constructor
+    */
+   public LazyManagedConnectionMetaData()
+   {
+   }
+
+   /**
+    * Returns Product name of the underlying EIS instance connected through the ManagedConnection.
+    *
+    * @return Product name of the EIS instance
+    * @throws ResourceException Thrown if an error occurs
+    */
+   @Override
+   public String getEISProductName() throws ResourceException
+   {
+      log.trace("getEISProductName()");
+      return "Lazy";
+   }
+
+   /**
+    * Returns Product version of the underlying EIS instance connected through the ManagedConnection.
+    *
+    * @return Product version of the EIS instance
+    * @throws ResourceException Thrown if an error occurs
+    */
+   @Override
+   public String getEISProductVersion() throws ResourceException
+   {
+      log.trace("getEISProductVersion()");
+      return "1.0";
+   }
+
+   /**
+    * Returns maximum limit on number of active concurrent connections 
+    *
+    * @return Maximum limit for number of active concurrent connections
+    * @throws ResourceException Thrown if an error occurs
+    */
+   @Override
+   public int getMaxConnections() throws ResourceException
+   {
+      log.trace("getMaxConnections()");
+      return 0;
+   }
+
+   /**
+    * Returns name of the user associated with the ManagedConnection instance
+    *
+    * @return Name of the user
+    * @throws ResourceException Thrown if an error occurs
+    */
+   @Override
+   public String getUserName() throws ResourceException
+   {
+      log.trace("getUserName()");
+      return null;
+   }
+}

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyRaMetaData.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyRaMetaData.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyRaMetaData.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.deployers.spec.rars.lazy;
+
+import javax.resource.cci.ResourceAdapterMetaData;
+
+/**
+ * LazyRaMetaData
+ *
+ * @version $Revision: $
+ */
+public class LazyRaMetaData implements ResourceAdapterMetaData
+{
+   /**
+    * Default constructor
+    */
+   public LazyRaMetaData()
+   {
+   }
+
+   /**
+    * Gets the version of the resource adapter.
+    *
+    * @return String representing version of the resource adapter
+    */
+   @Override
+   public String getAdapterVersion()
+   {
+      return "1.0";
+   }
+
+   /**
+    * Gets the name of the vendor that has provided the resource adapter.
+    *
+    * @return String representing name of the vendor 
+    */
+   @Override
+   public String getAdapterVendorName()
+   {
+      return "JBoss, by Red Hat";
+   }
+
+   /**
+    * Gets a tool displayable name of the resource adapter.
+    *
+    * @return String representing the name of the resource adapter
+    */
+   @Override
+   public String getAdapterName()
+   {
+      return "Lazy resource adapter";
+   }
+
+   /**
+    * Gets a tool displayable short desription of the resource adapter.
+    *
+    * @return String describing the resource adapter
+    */
+   @Override
+   public String getAdapterShortDescription()
+   {
+      return "Lazy connection association";
+   }
+
+   /**
+    * Returns a string representation of the version
+    *
+    * @return String representing the supported version of the connector architecture
+    */
+   @Override
+   public String getSpecVersion()
+   {
+      return "1.5";
+   }
+
+   /**
+    * Returns an array of fully-qualified names of InteractionSpec
+    *
+    * @return Array of fully-qualified class names of InteractionSpec classes
+    */
+   @Override
+   public String[] getInteractionSpecsSupported()
+   {
+      return null;
+   }
+
+   /**
+    * Returns true if the implementation class for the Interaction
+    *
+    * @return boolean Depending on method support
+    */
+   @Override
+   public boolean supportsExecuteWithInputAndOutputRecord()
+   {
+      return false;
+   }
+
+   /**
+    * Returns true if the implementation class for the Interaction
+    *
+    * @return boolean Depending on method support
+    */
+   @Override
+   public boolean supportsExecuteWithInputRecordOnly()
+   {
+      return false;
+   }
+
+   /**
+    * Returns true if the resource adapter implements the LocalTransaction
+    *
+    * @return true If resource adapter supports resource manager local transaction demarcation 
+    */
+   @Override
+   public boolean supportsLocalTransactionDemarcation()
+   {
+      return false;
+   }
+}

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyResourceAdapter.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyResourceAdapter.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/LazyResourceAdapter.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.deployers.spec.rars.lazy;
+
+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;
+
+import org.jboss.logging.Logger;
+
+/**
+ * LazyResourceAdapter
+ *
+ * @version $Revision: $
+ */
+public class LazyResourceAdapter implements ResourceAdapter
+{
+
+   /** The logger */
+   private static Logger log = Logger.getLogger(LazyResourceAdapter.class);
+
+   /** Enable */
+   private Boolean Enable;
+
+   /**
+    * Default constructor
+    */
+   public LazyResourceAdapter()
+   {
+
+   }
+
+   /** 
+    * Set Enable
+    * @param Enable The value
+    */
+   public void setEnable(Boolean Enable)
+   {
+      this.Enable = Enable;
+   }
+
+   /** 
+    * Get Enable
+    * @return The value
+    */
+   public Boolean getEnable()
+   {
+      return Enable;
+   }
+
+   /**
+    * This is called during the activation of a message endpoint.
+    *
+    * @param endpointFactory A message endpoint factory instance.
+    * @param spec An activation spec JavaBean instance.
+    * @throws ResourceException generic exception 
+    */
+   public void endpointActivation(MessageEndpointFactory endpointFactory,
+      ActivationSpec spec) throws ResourceException
+   {
+      log.trace("endpointActivation()");
+   }
+
+   /**
+    * This is called when a message endpoint is deactivated. 
+    *
+    * @param endpointFactory A message endpoint factory instance.
+    * @param spec An activation spec JavaBean instance.
+    */
+   public void endpointDeactivation(MessageEndpointFactory endpointFactory,
+      ActivationSpec spec)
+   {
+      log.trace("endpointDeactivation()");
+   }
+
+   /**
+    * This is called when a resource adapter instance is bootstrapped.
+    *
+    * @param ctx A bootstrap context containing references 
+    * @throws ResourceAdapterInternalException indicates bootstrap failure.
+    */
+   public void start(BootstrapContext ctx)
+      throws ResourceAdapterInternalException
+   {
+      log.trace("start()");
+   }
+
+   /**
+    * This is called when a resource adapter instance is undeployed or
+    * during application server shutdown. 
+    */
+   public void stop()
+   {
+      log.trace("stop()");
+   }
+
+   /**
+    * This method is called by the application server during crash recovery.
+    *
+    * @param specs An array of ActivationSpec JavaBeans 
+    * @throws ResourceException generic exception 
+    * @return An array of XAResource objects
+    */
+   public XAResource[] getXAResources(ActivationSpec[] specs)
+      throws ResourceException
+   {
+      log.trace("getXAResources()");
+      return null;
+   }
+
+   /** 
+    * Returns a hash code value for the object.
+    * @return A hash code value for this object.
+    */
+   @Override
+   public int hashCode()
+   {
+      int result = 17;
+      if (Enable != null)
+         result += 31 * result + 7 * Enable.hashCode();
+      else
+         result += 31 * result + 7;
+      return result;
+   }
+
+   /** 
+    * Indicates whether some other object is equal to this one.
+    * @param other The reference object with which to compare.
+    * @return true if this object is the same as the obj argument, false otherwise.
+    */
+   @Override
+   public boolean equals(Object other)
+   {
+      if (other == null)
+         return false;
+      if (other == this)
+         return true;
+      if (!(other instanceof LazyResourceAdapter))
+         return false;
+      LazyResourceAdapter obj = (LazyResourceAdapter)other;
+      boolean result = true; 
+      if (result)
+      {
+         if (Enable == null)
+            result = obj.getEnable() == null;
+         else
+            result = Enable.equals(obj.getEnable());
+      }
+      return result;
+   }
+
+
+}

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/package.html
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/lazy/package.html	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,3 @@
+<body>
+A resource adapter for testing lazy connection association
+</body>

Added: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/testcases/LazyAssociationTestCase.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/testcases/LazyAssociationTestCase.java	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/testcases/LazyAssociationTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.deployers.spec.rars.testcases;
+
+import org.jboss.jca.embedded.dsl.InputStreamDescriptor;
+import org.jboss.jca.test.deployers.spec.ArquillianJCATestUtils;
+import org.jboss.jca.test.deployers.spec.rars.lazy.LazyConnection;
+import org.jboss.jca.test.deployers.spec.rars.lazy.LazyConnectionFactory;
+
+import javax.annotation.Resource;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptor;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Test cases for deploying a lazy association resource adapter archive
+ *
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+ at RunWith(Arquillian.class)
+public class LazyAssociationTestCase
+{
+
+   //-------------------------------------------------------------------------------------||
+   //---------------------- GIVEN --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   /**
+    * Define the deployment
+    * @return The deployment archive
+    * @throws Exception in case of errors
+    */
+   @Deployment(order = 1)
+   public static ResourceAdapterArchive createDeployment() throws Exception
+   {
+      String archiveName = "lazy.rar";
+      String packageName = "org.jboss.jca.test.deployers.spec.rars.lazy";
+      ResourceAdapterArchive raa = ArquillianJCATestUtils.buidShrinkwrapRa(archiveName, packageName);
+      raa.addAsManifestResource(archiveName + "/META-INF/ra.xml", "ra.xml");
+      raa.addAsManifestResource(archiveName + "/META-INF/ironjacamar.xml", "ironjacamar.xml");
+
+      return raa;
+   }
+
+   //-------------------------------------------------------------------------------------||
+   //---------------------- WHEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   //
+   @Resource(mappedName = "java:/eis/LazyConnectionFactory")
+   private LazyConnectionFactory connectionFactory;
+
+   //-------------------------------------------------------------------------------------||
+   //---------------------- THEN  --------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Basic
+    * @exception Throwable Thrown if case of an error
+    */
+   @Test
+   public void testBasic() throws Throwable
+   {
+      assertNotNull(connectionFactory);
+
+      LazyConnection lc = null;
+      try
+      {
+         lc = connectionFactory.getConnection();
+
+         assertTrue(lc.isManagedConnectionSet());
+
+         lc.closeManagedConnection();
+
+         assertFalse(lc.isManagedConnectionSet());
+
+         lc.associate();
+
+         assertTrue(lc.isManagedConnectionSet());
+      }
+      catch (Throwable t)
+      {
+         t.printStackTrace();
+
+         fail("Throwable:" + t.getMessage());
+      }
+      finally
+      {
+         if (lc != null)
+            lc.close();
+      }
+   }
+
+   /**
+    * Two connections - one managed connection
+    * @exception Throwable Thrown if case of an error
+    */
+   @Test
+   public void testTwoConnections() throws Throwable
+   {
+      assertNotNull(connectionFactory);
+
+      LazyConnection lc1 = null;
+      LazyConnection lc2 = null;
+      try
+      {
+         lc1 = connectionFactory.getConnection();
+
+         assertTrue(lc1.isManagedConnectionSet());
+
+         lc2 = connectionFactory.getConnection();
+
+         assertTrue(lc2.isManagedConnectionSet());
+         assertFalse(lc1.isManagedConnectionSet());
+
+         lc2.closeManagedConnection();
+
+         assertFalse(lc1.isManagedConnectionSet());
+         assertFalse(lc2.isManagedConnectionSet());
+
+         lc1.associate();
+
+         assertTrue(lc1.isManagedConnectionSet());
+         assertFalse(lc2.isManagedConnectionSet());
+      }
+      catch (Throwable t)
+      {
+         t.printStackTrace();
+
+         fail("Throwable:" + t.getMessage());
+      }
+      finally
+      {
+         if (lc1 != null)
+            lc1.close();
+
+         if (lc2 != null)
+            lc2.close();
+      }
+   }
+}

Added: projects/jboss-jca/trunk/deployers/src/test/resources/lazy.rar/META-INF/ironjacamar.xml
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/resources/lazy.rar/META-INF/ironjacamar.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/resources/lazy.rar/META-INF/ironjacamar.xml	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,45 @@
+<!--
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+-->
+
+<ironjacamar xmlns="http://www.jboss.org/ironjacamar/schema"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema 
+             http://www.jboss.org/ironjacamar/schema/ironjacamar_1_1.xsd">
+  <config-property name="Enable">true</config-property>
+
+  <transaction-support>NoTransaction</transaction-support>
+  
+  <connection-definitions>
+    <connection-definition class-name="org.jboss.jca.test.deployers.spec.rars.lazy.LazyManagedConnectionFactory"
+                           jndi-name="java:/eis/LazyConnectionFactory" pool-name="LazyConnectionFactory"
+                           sharable="true">
+      <pool>
+        <min-pool-size>0</min-pool-size>
+        <max-pool-size>1</max-pool-size>
+      </pool>
+    </connection-definition>
+  </connection-definitions>
+
+
+</ironjacamar>

Added: projects/jboss-jca/trunk/deployers/src/test/resources/lazy.rar/META-INF/ra.xml
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/resources/lazy.rar/META-INF/ra.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/test/resources/lazy.rar/META-INF/ra.xml	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+-->
+
+<connector xmlns="http://java.sun.com/xml/ns/j2ee"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+           http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
+           version="1.5">
+
+   <vendor-name>Red Hat Middleware LLC</vendor-name>
+   <eis-type>Test RA</eis-type>
+   <resourceadapter-version>0.1</resourceadapter-version>
+   <resourceadapter>
+      <resourceadapter-class>org.jboss.jca.test.deployers.spec.rars.lazy.LazyResourceAdapter</resourceadapter-class>
+      <config-property>
+         <config-property-name>Enable</config-property-name>
+         <config-property-type>java.lang.Boolean</config-property-type>
+         <config-property-value>true</config-property-value>
+      </config-property>
+
+      <outbound-resourceadapter>
+         <connection-definition>
+            <managedconnectionfactory-class>org.jboss.jca.test.deployers.spec.rars.lazy.LazyManagedConnectionFactory</managedconnectionfactory-class>
+            <connectionfactory-interface>org.jboss.jca.test.deployers.spec.rars.lazy.LazyConnectionFactory</connectionfactory-interface>
+            <connectionfactory-impl-class>org.jboss.jca.test.deployers.spec.rars.lazy.LazyConnectionFactoryImpl</connectionfactory-impl-class>
+            <connection-interface>org.jboss.jca.test.deployers.spec.rars.lazy.LazyConnection</connection-interface>
+            <connection-impl-class>org.jboss.jca.test.deployers.spec.rars.lazy.LazyConnectionImpl</connection-impl-class>
+         </connection-definition>
+         <transaction-support>NoTransaction</transaction-support>
+         <reauthentication-support>false</reauthentication-support>
+      </outbound-resourceadapter>
+   </resourceadapter>
+</connector>

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/README.txt
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/README.txt	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/README.txt	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,35 @@
+The HelloWorld/Lazy resource adapter
+====================================
+
+Introduction
+------------
+The HelloWorld/Lazy resource adapter example shows a simple example of how to use and
+implement the interfaces in the Java EE Connector Architecture specification which
+takes advantage of the lazy association mechanism to reestablish the relationship
+between the logical (HelloWorldConnectionImpl) and the physical connection
+(HelloWorldManagedConnection).
+
+The HelloWorld/Lazy sample exposes the HelloWorldConnection interface where developers
+can invoke the exposed methods.
+
+The example shows how to build and test a resource adapter.
+
+How to build and test
+---------------------
+1. Install Ant 1.8 (http://ant.apache.org)
+
+2. Copy all libs from sjc/lib directory
+
+    cd doc/samples/helloworld-lazy
+    cp -R ../../../lib .
+    cp ../../../bin/ironjacamar-sjc.jar lib/
+
+   Note that the above refers to the standalone distribution of IronJacamar.
+
+3. Build
+
+    ant
+
+4. Test
+
+    ant test

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/build.xml
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/build.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/build.xml	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,205 @@
+<!--
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+-->
+
+<project name="helloworld-lazy" basedir="." default="rar">
+
+  <!-- ================================= 
+       Properties              
+       ================================= -->
+  <property name="build.dir" value="${basedir}/build" />
+  <property name="target.dir" value="${basedir}/target" />
+  <property name="lib.dir" value="${basedir}/lib" />
+
+  <property name="javac.debug" value="on" />
+  <property name="javac.deprecation" value="on" />
+  <property name="javac.optimize" value="off" />
+
+  <property name="junit.printsummary" value="yes" />
+  <property name="junit.haltonerror" value="no" />
+  <property name="junit.haltonfailure" value="no" />
+  <property name="junit.fork" value="yes" />
+  <property name="junit.timeout" value="60000" />
+  <property name="junit.jvm" value="" />
+  <property name="junit.jvm.options" value="-Xms128m -Xmx512m -XX:MaxPermSize=256m" />
+  <property name="junit.batchtest.haltonerror" value="no" />
+  <property name="junit.batchtest.haltonfailure" value="no" />
+  <property name="junit.batchtest.fork" value="yes" />
+  
+  <path id="lib.path.id">
+    <fileset dir="${lib.dir}">
+      <include name="**/*.jar"/>
+    </fileset>
+  </path>
+    
+  <path id="test.lib.path.id">
+    <fileset dir="${lib.dir}">
+      <include name="**/*.jar"/>
+    </fileset>
+    <fileset dir="${build.dir}">
+      <include name="**/*.jar"/>
+    </fileset>
+  </path>
+  
+  <!-- ================================= 
+       Target: init
+       ================================= -->
+  <target name="init">
+    <mkdir dir="${lib.dir}" />
+  </target>
+
+  <!-- ================================= 
+       Target: compile
+       ================================= -->
+  <target name="compile" depends="init">
+    <mkdir dir="${build.dir}" />
+
+    <javac srcdir="${basedir}/src/main/java"
+           destdir="${build.dir}"
+           classpathref="lib.path.id"
+           debug="${javac.debug}"
+           deprecation="${javac.deprecation}"
+           optimize="${javac.optimize}">
+    </javac> 
+  </target>
+  
+  <!-- ================================= 
+       Target: rar
+       ================================= -->
+  <target name="rar" depends="compile">
+    <mkdir dir="${target.dir}" />
+    <mkdir dir="${basedir}/src/main/resources" />
+    <jar destfile="${build.dir}/helloworld.jar"
+         basedir="${build.dir}"
+         includes="**/*.class"/>
+    <jar destfile="${target.dir}/helloworld.rar">
+      <fileset dir="${basedir}/src/main/resources" includes="META-INF/*"/>
+      <fileset dir="${build.dir}" includes="**/*.jar"/>
+    </jar>
+  </target>
+  
+      
+  <!-- ================================= 
+       Target: prepare-test
+       ================================= -->
+  <target name="prepare-test" depends="init">
+    <mkdir dir="${build.dir}/test" />
+
+    <javac srcdir="src/test"
+           destdir="${build.dir}/test"
+           classpathref="test.lib.path.id"
+           debug="${javac.debug}"
+           deprecation="${javac.deprecation}"
+           optimize="${javac.optimize}">
+      <compilerarg value="-Xlint"/>
+    </javac> 
+
+    <copy todir="${build.dir}/test">
+      <fileset dir="src/main/resources"/>
+      <fileset dir="src/test/resources"/>
+    </copy>
+  </target>
+
+  <!-- ================================= 
+       Target: test
+       ================================= -->
+  <target name="test" depends="rar, prepare-test">
+    <mkdir dir="${basedir}/reports"/>
+
+    <junit dir="src/test"
+           printsummary="${junit.printsummary}"
+           haltonerror="${junit.haltonerror}"
+           haltonfailure="${junit.haltonfailure}"
+           fork="${junit.fork}"
+           timeout="${junit.timeout}">
+      
+      <jvmarg line="${junit.jvm.options}"/>
+      <sysproperty key="archives.dir" value="${target.dir}"/>
+      <sysproperty key="reports.dir" value="${basedir}/reports"/>
+      <sysproperty key="java.util.logging.manager" value="org.jboss.logmanager.LogManager"/>
+      <sysproperty key="log4j.defaultInitOverride" value="true"/>
+      <sysproperty key="org.jboss.logging.Logger.pluginClass" 
+      	           value="org.jboss.logging.logmanager.LoggerPluginImpl"/>
+      <sysproperty key="test.dir" value="${build.dir}/test"/>
+      <sysproperty key="xb.builder.useUnorderedSequence" value="true"/>
+      
+      <classpath>
+        <fileset dir="${lib.dir}" includes="**/*.jar" />
+        <fileset dir="${build.dir}" includes="*.jar" />
+        <pathelement location="${build.dir}/test"/>
+      </classpath>
+      
+      <formatter type="plain"/>
+      <formatter type="xml"/>
+      
+      <batchtest todir="${basedir}/reports"
+                 haltonerror="${junit.batchtest.haltonerror}"
+                 haltonfailure="${junit.batchtest.haltonfailure}"
+                 fork="${junit.batchtest.fork}">
+        
+        <fileset dir="${build.dir}/test">
+          <include name="**/*TestCase.class"/>
+        </fileset>
+      </batchtest>
+
+    </junit>
+    
+  </target>
+  
+  <!-- ================================= 
+       Target: docs
+       ================================= -->
+  <target name="docs" depends="compile">
+    <mkdir dir="${target.dir}/docs"/>
+    <javadoc packagenames="*"
+             sourcepath="src/main/java"
+             destdir="${target.dir}/docs"
+             classpathref="lib.path.id">
+    </javadoc>
+  </target>
+  
+  <!-- ================================= 
+       Target: clean              
+       ================================= -->
+  <target name="clean">
+    <delete>
+      <fileset dir="${basedir}" defaultexcludes="no">
+        <include name="**/*~"/>
+        <include name="**/*.bak"/>
+      </fileset>
+    </delete>
+    <delete dir="${build.dir}"/>
+    <delete dir="${target.dir}"/>
+    <delete dir="${basedir}/reports"/>
+  </target>
+
+  <!-- ================================= 
+       Target: dist-clean              
+       ================================= -->
+  <target name="dist-clean" depends="init,clean">
+    <delete includeemptydirs="true">
+      <fileset dir="${lib.dir}" includes="**/*"/>
+    </delete>
+  </target>
+
+</project>

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnection.java
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnection.java	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnection.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.samples.helloworld;
+
+/**
+ * HelloWorldConnection
+ *
+ * @version $Revision: $
+ */
+public interface HelloWorldConnection
+{
+   /**
+    * HelloWorld
+    * @return String
+    */
+   public String helloWorld();
+
+   /**
+    * HelloWorld
+    * @param name A name
+    * @return String
+    */
+   public String helloWorld(String name);
+
+   /**
+    * Close
+    */
+   public void close();
+}

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionFactory.java
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionFactory.java	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionFactory.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.samples.helloworld;
+
+import java.io.Serializable;
+
+import javax.resource.Referenceable;
+import javax.resource.ResourceException;
+
+/**
+ * HelloWorldConnectionFactory
+ *
+ * @version $Revision: $
+ */
+public interface HelloWorldConnectionFactory extends Serializable, Referenceable
+{
+   /** 
+    * Get connection from factory
+    *
+    * @return HelloWorldConnection instance
+    * @exception ResourceException Thrown if a connection can't be obtained
+    */
+   public HelloWorldConnection getConnection() throws ResourceException;
+
+}

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionFactoryImpl.java
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionFactoryImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionFactoryImpl.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.samples.helloworld;
+
+import javax.naming.NamingException;
+import javax.naming.Reference;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+
+/**
+ * HelloWorldConnectionFactoryImpl
+ *
+ * @version $Revision: $
+ */
+public class HelloWorldConnectionFactoryImpl implements HelloWorldConnectionFactory
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   private Reference reference;
+
+   private HelloWorldManagedConnectionFactory mcf;
+   private ConnectionManager connectionManager;
+
+   /**
+    * Default constructor
+    * @param mcf ManagedConnectionFactory
+    * @param cxManager ConnectionManager
+    */
+   public HelloWorldConnectionFactoryImpl(HelloWorldManagedConnectionFactory mcf,
+                                          ConnectionManager cxManager)
+   {
+      this.mcf = mcf;
+      this.connectionManager = cxManager;
+   }
+
+   /** 
+    * Get connection from factory
+    *
+    * @return HelloWorldConnection instance
+    * @exception ResourceException Thrown if a connection can't be obtained
+    */
+   @Override
+   public HelloWorldConnection getConnection() throws ResourceException
+   {
+      return (HelloWorldConnection)connectionManager.allocateConnection(mcf, null);
+   }
+
+   /**
+    * Get the Reference instance.
+    *
+    * @return Reference instance
+    * @exception NamingException Thrown if a reference can't be obtained
+    */
+   @Override
+   public Reference getReference() throws NamingException
+   {
+      return reference;
+   }
+
+   /**
+    * Set the Reference instance.
+    *
+    * @param reference A Reference instance
+    */
+   @Override
+   public void setReference(Reference reference)
+   {
+      this.reference = reference;
+   }
+}

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionImpl.java
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionImpl.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.samples.helloworld;
+
+import java.util.logging.Logger;
+
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.LazyAssociatableConnectionManager;
+
+/**
+ * HelloWorldConnectionImpl
+ *
+ * @version $Revision: $
+ */
+public class HelloWorldConnectionImpl implements HelloWorldConnection
+{
+   /** The logger */
+   private static Logger log = Logger.getLogger("HelloWorldConnectionImpl");
+
+   /** Connection Manager */
+   private ConnectionManager cm;
+
+   /** ManagedConnection */
+   private HelloWorldManagedConnection mc;
+
+   /** ManagedConnectionFactory */
+   private HelloWorldManagedConnectionFactory mcf;
+
+   /** ConnectionRequestInfo */
+   private ConnectionRequestInfo cri;
+
+   /**
+    * Default constructor
+    * @param mc HelloWorldManagedConnection
+    * @param mcf HelloWorldManagedConnectionFactory
+    * @param cm The connection manager
+    * @param cri The connection request info
+    */
+   public HelloWorldConnectionImpl(HelloWorldManagedConnection mc,
+                                   HelloWorldManagedConnectionFactory mcf,
+                                   ConnectionManager cm,
+                                   ConnectionRequestInfo cri)
+   {
+      this.mc = mc;
+      this.mcf = mcf;
+      this.cm = cm;
+      this.cri = cri;
+   }
+
+   /**
+    * Call helloWorld
+    * @return String helloworld
+    */
+   public String helloWorld()
+   {
+      return helloWorld(((HelloWorldResourceAdapter)mcf.getResourceAdapter()).getName());
+   }
+
+   /**
+    * Call helloWorld
+    * @param name String name
+    * @return String helloworld
+    */
+   public String helloWorld(String name)
+   {
+      if (mc == null)
+         associate();
+
+      return mc.helloWorld(name);
+   }
+
+   /**
+    * Close
+    */
+   public void close()
+   {
+      if (mc != null)
+      {
+         mc.closeHandle(this);
+      }
+      else
+      {
+         if (cm instanceof LazyAssociatableConnectionManager)
+         {
+            LazyAssociatableConnectionManager lacm = (LazyAssociatableConnectionManager)cm;
+            lacm.inactiveConnectionClosed(this, mcf);
+         }
+      }
+   }
+
+   /**
+    * Set the managed connection
+    * @param mc The managed connection
+    */
+   void setManagedConnection(HelloWorldManagedConnection mc)
+   {
+      this.mc = mc;
+   }
+
+   /**
+    * Associate
+    */
+   private void associate()
+   {
+      if (cm instanceof LazyAssociatableConnectionManager)
+      {
+         try
+         {
+            LazyAssociatableConnectionManager lacm = (LazyAssociatableConnectionManager)cm;
+            lacm.associateConnection(this, mcf, cri);
+         }
+         catch (Throwable t)
+         {
+            log.severe("Associate" + t.getMessage());
+         }
+      }
+   }
+}

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnection.java
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnection.java	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnection.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,284 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.samples.helloworld;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.resource.NotSupportedException;
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.DissociatableManagedConnection;
+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;
+
+/**
+ * HelloWorldManagedConnection
+ *
+ * @version $Revision: $
+ */
+public class HelloWorldManagedConnection implements ManagedConnection,
+                                                    DissociatableManagedConnection
+{
+   /** The logger */
+   private static Logger log = Logger.getLogger("HelloWorldManagedConnection");
+
+   /** Connection manager */
+   private ConnectionManager cm;
+
+   /** MCF */
+   private HelloWorldManagedConnectionFactory mcf;
+
+   /** Log writer */
+   private PrintWriter logWriter;
+
+   /** Listeners */
+   private List<ConnectionEventListener> listeners;
+
+   /** Connection */
+   private HelloWorldConnectionImpl connection;
+
+   /**
+    * Constructor
+    * @param cm The connection manager
+    * @param mcf The managed connection factory
+    */
+   public HelloWorldManagedConnection(ConnectionManager cm,
+                                      HelloWorldManagedConnectionFactory mcf)
+   {
+      this.cm = cm;
+      this.mcf = mcf;
+      this.logWriter = null;
+      this.listeners = Collections.synchronizedList(new ArrayList<ConnectionEventListener>(1));
+      this.connection = null;
+   }
+
+   /**
+    * Creates a new connection handle for the underlying physical connection 
+    * represented by the ManagedConnection instance. 
+    *
+    * @param subject Security context as JAAS subject
+    * @param cxRequestInfo ConnectionRequestInfo instance
+    * @return generic Object instance representing the connection handle. 
+    * @throws ResourceException generic exception if operation fails
+    */
+   public Object getConnection(Subject subject,
+                               ConnectionRequestInfo cxRequestInfo) 
+      throws ResourceException
+   {
+      if (connection != null)
+      {
+         connection.setManagedConnection(null);
+      }
+
+      connection = new HelloWorldConnectionImpl(this, mcf, cm, cxRequestInfo);
+
+      return connection;
+   }
+
+   /**
+    * Used by the container to change the association of an 
+    * application-level connection handle with a ManagedConneciton instance.
+    *
+    * @param connection Application-level connection handle
+    * @throws ResourceException generic exception if operation fails
+    */
+   public void associateConnection(Object connection) throws ResourceException
+   {
+      if (connection == null)
+         throw new ResourceException("Null connection handle");
+
+      if (!(connection instanceof HelloWorldConnectionImpl))
+         throw new ResourceException("Wrong connection handle");
+
+      if (this.connection != null)
+      {
+         this.connection.setManagedConnection(null);
+      }
+
+      this.connection = (HelloWorldConnectionImpl)connection;
+      this.connection.setManagedConnection(this);
+   }
+
+   /**
+    * This method is called by an application server (that is capable of lazy
+    * connection association optimization) in order to dissociate a ManagedConnection
+    * instance from all of its connection handles.
+    * @exception ResourceException Thrown if an error occurs
+    */
+   public void dissociateConnections() throws ResourceException
+   {
+      if (connection != null)
+      {
+         connection.setManagedConnection(null);
+         connection = null;
+      }
+   }
+
+   /**
+    * Application server calls this method to force any cleanup on 
+    * the ManagedConnection instance.
+    *
+    * @throws ResourceException generic exception if operation fails
+    */
+   public void cleanup() throws ResourceException
+   {
+      if (connection != null)
+      {
+         connection.setManagedConnection(null);
+         connection = null;
+      }
+   }
+
+   /**
+    * Destroys the physical connection to the underlying resource manager.
+    *
+    * @throws ResourceException generic exception if operation fails
+    */
+   public void destroy() throws ResourceException
+   {
+      if (connection != null)
+      {
+         connection.setManagedConnection(null);
+         connection = null;
+      }
+   }
+
+   /**
+    * Adds a connection event listener to the ManagedConnection instance.
+    *
+    * @param listener A new ConnectionEventListener to be registered
+    */
+   public void addConnectionEventListener(ConnectionEventListener listener)
+   {
+      if (listener == null)
+         throw new IllegalArgumentException("Listener is null");
+
+      listeners.add(listener);
+   }
+
+   /**
+    * Removes an already registered connection event listener 
+    * from the ManagedConnection instance.
+    *
+    * @param listener Already registered connection event listener to be removed
+    */
+   public void removeConnectionEventListener(ConnectionEventListener listener)
+   {
+      if (listener == null)
+         throw new IllegalArgumentException("Listener is null");
+
+      listeners.remove(listener);
+   }
+
+   /**
+    * Gets the log writer for this ManagedConnection instance.
+    *
+    * @return Character ourput stream associated with this 
+    *         Managed-Connection instance
+    * @throws ResourceException generic exception if operation fails
+    */
+   public PrintWriter getLogWriter() throws ResourceException
+   {
+      return logWriter;
+   }
+
+   /**
+    * Sets the log writer for this ManagedConnection instance.
+    *
+    * @param out Character Output stream to be associated
+    * @throws ResourceException generic exception if operation fails
+    */
+   public void setLogWriter(PrintWriter out) throws ResourceException
+   {
+      this.logWriter = out;
+   }
+
+   /**
+    * Returns an <code>javax.resource.spi.LocalTransaction</code> instance.
+    *
+    * @return LocalTransaction instance
+    * @throws ResourceException generic exception if operation fails
+    */
+   public LocalTransaction getLocalTransaction() throws ResourceException
+   {
+      throw new NotSupportedException("LocalTransaction not supported");
+   }
+
+   /**
+    * Returns an <code>javax.transaction.xa.XAresource</code> instance. 
+    *
+    * @return XAResource instance
+    * @throws ResourceException generic exception if operation fails
+    */
+   public XAResource getXAResource() throws ResourceException
+   {
+      throw new NotSupportedException("GetXAResource not supported");
+   }
+
+   /**
+    * Gets the metadata information for this connection's underlying 
+    * EIS resource manager instance. 
+    *
+    * @return ManagedConnectionMetaData instance
+    * @throws ResourceException generic exception if operation fails
+    */
+   public ManagedConnectionMetaData getMetaData() throws ResourceException
+   {
+      return new HelloWorldManagedConnectionMetaData();
+   }
+
+   /**
+    * Call helloWorld
+    * @param name String name
+    * @return String helloworld
+    */
+   String helloWorld(String name)
+   {
+      return "Hello World, " + name + " !";
+   }
+
+   /**
+    * Close handle
+    * @param handle The handle
+    */
+   void closeHandle(HelloWorldConnection handle)
+   {
+      ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
+      event.setConnectionHandle(handle);
+
+      for (ConnectionEventListener cel : listeners)
+      {
+         cel.connectionClosed(event);
+      }
+   }
+}

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnectionFactory.java	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnectionFactory.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,221 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.samples.helloworld;
+
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionDefinition;
+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;
+
+/**
+ * HelloWorldManagedConnectionFactory
+ *
+ * @version $Revision: $
+ */
+ at ConnectionDefinition(connectionFactory = HelloWorldConnectionFactory.class,
+   connectionFactoryImpl = HelloWorldConnectionFactoryImpl.class,
+   connection = HelloWorldConnection.class,
+   connectionImpl = HelloWorldConnectionImpl.class)
+public class HelloWorldManagedConnectionFactory 
+   implements ManagedConnectionFactory, ResourceAdapterAssociation
+{
+
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 1L;
+
+   /** The logger */
+   private static Logger log = Logger.getLogger("HelloWorldManagedConnectionFactory");
+
+   /** The resource adapter */
+   private ResourceAdapter ra;
+
+   /** The connection manager */
+   private ConnectionManager cm;
+
+   /** The logwriter */
+   private PrintWriter logwriter;
+
+   /**
+    * Default constructor
+    */
+   public HelloWorldManagedConnectionFactory()
+   {
+      this.ra = null;
+      this.cm = null;
+      this.logwriter = null;
+   }
+
+   /**
+    * Creates a Connection Factory instance. 
+    *
+    * @return EIS-specific Connection Factory instance or 
+    *         javax.resource.cci.ConnectionFactory instance
+    * @throws ResourceException Generic exception
+    */
+   public Object createConnectionFactory() throws ResourceException
+   {
+      throw new ResourceException("This resource adapter doesn't support non-managed environments");
+   }
+
+   /**
+    * Creates a Connection Factory instance. 
+    *
+    * @param cxManager ConnectionManager to be associated with created EIS 
+    *        connection factory instance
+    * @return EIS-specific Connection Factory instance or 
+    *        javax.resource.cci.ConnectionFactory instance
+    * @throws ResourceException Generic exception
+    */
+   public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException
+   {
+      this.cm = cxManager;
+
+      return new HelloWorldConnectionFactoryImpl(this, cxManager);
+   }
+
+   /**
+    * Creates a new physical connection to the underlying EIS resource manager.
+    *
+    * @param subject Caller's security information
+    * @param cxRequestInfo Additional resource adapter specific connection 
+    *        request information
+    * @throws ResourceException generic exception
+    * @return ManagedConnection instance 
+    */
+   public ManagedConnection createManagedConnection(Subject subject,
+                                                    ConnectionRequestInfo cxRequestInfo) 
+      throws ResourceException
+   {
+      return new HelloWorldManagedConnection(cm, this);
+   }
+
+   /**
+    * Returns a matched connection from the candidate set of connections. 
+    *
+    * @param connectionSet Candidate connection set
+    * @param subject Caller's security information
+    * @param cxRequestInfo Additional resource adapter specific connection request information
+    * @throws ResourceException generic exception
+    * @return ManagedConnection if resource adapter finds an acceptable match otherwise null 
+    */
+   public ManagedConnection matchManagedConnections(Set connectionSet,
+                                                    Subject subject, ConnectionRequestInfo cxRequestInfo) 
+      throws ResourceException
+   {
+      Iterator it = connectionSet.iterator();
+      while (it.hasNext()) 
+      {
+         ManagedConnection mc = (ManagedConnection)it.next();
+         if (mc instanceof HelloWorldManagedConnection) 
+         {
+            return (HelloWorldManagedConnection)mc;
+         }
+      }
+
+      return null;
+   }
+
+   /**
+    * Get the log writer for this ManagedConnectionFactory instance.
+    *
+    * @return PrintWriter
+    * @throws ResourceException generic exception
+    */
+   public PrintWriter getLogWriter() throws ResourceException
+   {
+      return logwriter;
+   }
+
+   /**
+    * Set the log writer for this ManagedConnectionFactory instance.
+    *
+    * @param out PrintWriter - an out stream for error logging and tracing
+    * @throws ResourceException generic exception
+    */
+   public void setLogWriter(PrintWriter out) throws ResourceException
+   {
+      logwriter = out;
+   }
+
+   /**
+    * Get the resource adapter
+    *
+    * @return The handle
+    */
+   public ResourceAdapter getResourceAdapter()
+   {
+      return ra;
+   }
+
+   /**
+    * Set the resource adapter
+    *
+    * @param ra The handle
+    */
+   public void setResourceAdapter(ResourceAdapter ra)
+   {
+      this.ra = ra;
+   }
+
+   /** 
+    * Returns a hash code value for the object.
+    * @return A hash code value for this object.
+    */
+   @Override
+   public int hashCode()
+   {
+      int result = 17;
+      return result;
+   }
+
+   /** 
+    * Indicates whether some other object is equal to this one.
+    * @param other The reference object with which to compare.
+    * @return true If this object is the same as the obj argument, false otherwise.
+    */
+   @Override
+   public boolean equals(Object other)
+   {
+      if (other == null)
+         return false;
+      if (other == this)
+         return true;
+      if (!(other instanceof HelloWorldManagedConnectionFactory))
+         return false;
+      HelloWorldManagedConnectionFactory obj = (HelloWorldManagedConnectionFactory)other;
+      boolean result = true; 
+      return result;
+   }
+
+
+}

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnectionMetaData.java
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnectionMetaData.java	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnectionMetaData.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.samples.helloworld;
+
+import javax.resource.ResourceException;
+
+import javax.resource.spi.ManagedConnectionMetaData;
+
+/**
+ * HelloWorldManagedConnectionMetaData
+ *
+ * @version $Revision: $
+ */
+public class HelloWorldManagedConnectionMetaData implements ManagedConnectionMetaData
+{
+   /**
+    * Default constructor
+    */
+   public HelloWorldManagedConnectionMetaData()
+   {
+   }
+
+   /**
+    * Returns Product name of the underlying EIS instance connected 
+    * through the ManagedConnection.
+    *
+    * @return Product name of the EIS instance
+    * @throws ResourceException Thrown if an error occurs
+    */
+   @Override
+   public String getEISProductName() throws ResourceException
+   {
+      return "HelloWorld Resource Adapter";
+   }
+
+   /**
+    * Returns Product version of the underlying EIS instance connected 
+    * through the ManagedConnection.
+    *
+    * @return Product version of the EIS instance
+    * @throws ResourceException Thrown if an error occurs
+    */
+   @Override
+   public String getEISProductVersion() throws ResourceException
+   {
+      return "1.0";
+   }
+
+   /**
+    * Returns maximum limit on number of active concurrent connections 
+    *
+    * @return Maximum limit for number of active concurrent connections
+    * @throws ResourceException Thrown if an error occurs
+    */
+   @Override
+   public int getMaxConnections() throws ResourceException
+   {
+      return 0;
+   }
+
+   /**
+    * Returns name of the user associated with the ManagedConnection instance
+    *
+    * @return Name of the user
+    * @throws ResourceException Thrown if an error occurs
+    */
+   @Override
+   public String getUserName() throws ResourceException
+   {
+      return null;
+   }
+}

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldResourceAdapter.java
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldResourceAdapter.java	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldResourceAdapter.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.samples.helloworld;
+
+import java.util.logging.Logger;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ActivationSpec;
+import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ConfigProperty;
+import javax.resource.spi.Connector;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterInternalException;
+import javax.resource.spi.TransactionSupport;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+
+import javax.transaction.xa.XAResource;
+
+/**
+ * HelloWorldResourceAdapter
+ *
+ * @version $Revision: $
+ */
+ at Connector(
+   reauthenticationSupport = false,
+   transactionSupport = TransactionSupport.TransactionSupportLevel.NoTransaction)
+public class HelloWorldResourceAdapter implements ResourceAdapter
+{
+   /** The logger */
+   private static Logger log = Logger.getLogger("HelloWorldResourceAdapter");
+
+   /** Name property */
+   @ConfigProperty(defaultValue = "AS 7", supportsDynamicUpdates = true)
+   private String name;
+
+   /**
+    * Default constructor
+    */
+   public HelloWorldResourceAdapter()
+   {
+   }
+
+   /** 
+    * Set name
+    * @param name The value
+    */
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+
+   /** 
+    * Get name
+    * @return The value
+    */
+   public String getName()
+   {
+      return name;
+   }
+
+   /**
+    * This is called during the activation of a message endpoint.
+    *
+    * @param endpointFactory A message endpoint factory instance.
+    * @param spec An activation spec JavaBean instance.
+    * @throws ResourceException generic exception 
+    */
+   public void endpointActivation(MessageEndpointFactory endpointFactory,
+                                  ActivationSpec spec) throws ResourceException
+   {
+   }
+
+   /**
+    * This is called when a message endpoint is deactivated. 
+    *
+    * @param endpointFactory A message endpoint factory instance.
+    * @param spec An activation spec JavaBean instance.
+    */
+   public void endpointDeactivation(MessageEndpointFactory endpointFactory,
+                                    ActivationSpec spec)
+   {
+   }
+
+   /**
+    * This is called when a resource adapter instance is bootstrapped.
+    *
+    * @param ctx A bootstrap context containing references 
+    * @throws ResourceAdapterInternalException indicates bootstrap failure.
+    */
+   public void start(BootstrapContext ctx)
+      throws ResourceAdapterInternalException
+   {
+   }
+
+   /**
+    * This is called when a resource adapter instance is undeployed or
+    * during application server shutdown. 
+    */
+   public void stop()
+   {
+   }
+
+   /**
+    * This method is called by the application server during crash recovery.
+    *
+    * @param specs an array of ActivationSpec JavaBeans 
+    * @throws ResourceException generic exception 
+    * @return an array of XAResource objects
+    */
+   public XAResource[] getXAResources(ActivationSpec[] specs)
+      throws ResourceException
+   {
+      return null;
+   }
+
+   /** 
+    * Returns a hash code value for the object.
+    * @return A hash code value for this object.
+    */
+   @Override
+   public int hashCode()
+   {
+      int result = 17;
+      if (name != null)
+         result += 31 * result + 7 * name.hashCode();
+      else
+         result += 31 * result + 7;
+      return result;
+   }
+
+   /** 
+    * Indicates whether some other object is equal to this one.
+    * @param other The reference object with which to compare.
+    * @return true If this object is the same as the obj argument, false otherwise.
+    */
+   @Override
+   public boolean equals(Object other)
+   {
+      if (other == null)
+         return false;
+      if (other == this)
+         return true;
+      if (!(other instanceof HelloWorldResourceAdapter))
+         return false;
+      HelloWorldResourceAdapter obj = (HelloWorldResourceAdapter)other;
+      boolean result = true; 
+      if (result)
+      {
+         if (name == null)
+            result = obj.getName() == null;
+         else
+            result = name.equals(obj.getName());
+      }
+      return result;
+   }
+}

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/package.html
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/package.html	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,3 @@
+<body>
+This package contains helloworld sample
+</body>

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/resources/META-INF/ironjacamar.xml
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/resources/META-INF/ironjacamar.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/main/resources/META-INF/ironjacamar.xml	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ironjacamar>
+  <connection-definitions>
+    <connection-definition 
+     class-name="org.jboss.jca.samples.helloworld.HelloWorldManagedConnectionFactory" 
+     jndi-name="java:/eis/HelloWorld">
+      <pool>
+        <min-pool-size>0</min-pool-size>
+        <max-pool-size>1</max-pool-size>
+      </pool>
+    </connection-definition>
+  </connection-definitions>
+</ironjacamar>

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/jboss/jca/samples/helloworld/ConnectorTestCase.java
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/jboss/jca/samples/helloworld/ConnectorTestCase.java	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/jboss/jca/samples/helloworld/ConnectorTestCase.java	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.samples.helloworld;
+
+import java.util.UUID;
+import java.util.logging.Logger;
+
+import javax.annotation.Resource;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import static org.junit.Assert.*;
+
+
+/**
+ * ConnectorTestCase
+ *
+ * @version $Revision: $
+ */
+ at RunWith(Arquillian.class)
+public class ConnectorTestCase
+{
+   private static Logger log = Logger.getLogger("ConnectorTestCase");
+
+   private static String deploymentName = "ConnectorTestCase";
+
+   /**
+    * Define the deployment
+    *
+    * @return The deployment archive
+    */
+   @Deployment
+   public static ResourceAdapterArchive createDeployment()
+   {
+      ResourceAdapterArchive raa =
+         ShrinkWrap.create(ResourceAdapterArchive.class, deploymentName + ".rar");
+      JavaArchive ja = ShrinkWrap.create(JavaArchive.class, 
+         UUID.randomUUID().toString() + ".jar");
+      ja.addClasses(HelloWorldResourceAdapter.class, 
+         HelloWorldManagedConnectionFactory.class, 
+         HelloWorldManagedConnection.class, 
+         HelloWorldManagedConnectionMetaData.class, 
+         HelloWorldConnectionFactory.class, 
+         HelloWorldConnectionFactoryImpl.class, 
+         HelloWorldConnection.class, 
+         HelloWorldConnectionImpl.class);
+      raa.addAsLibrary(ja);
+      raa.addAsManifestResource("META-INF/ironjacamar.xml", "ironjacamar.xml");
+
+      return raa;
+   }
+
+   /** resource */
+   @Resource(mappedName = "java:/eis/HelloWorld")
+   private HelloWorldConnectionFactory connectionFactory;
+
+   /**
+    * Test helloWorld
+    *
+    * @exception Throwable Thrown if case of an error
+    */
+   @Test
+   public void testHelloWorldNoArgs() throws Throwable
+   {
+      assertNotNull(connectionFactory);
+      HelloWorldConnection connection = connectionFactory.getConnection();
+      assertNotNull(connection);
+      String result = connection.helloWorld();
+      connection.close();
+   }
+
+   /**
+    * Test helloWorld
+    *
+    * @exception Throwable Thrown if case of an error
+    */
+   @Test
+   public void testHelloWorldNameString() throws Throwable
+   {
+      assertNotNull(connectionFactory);
+      HelloWorldConnection connection = connectionFactory.getConnection();
+      assertNotNull(connection);
+      String result = connection.helloWorld(null);
+      connection.close();
+   }
+
+   /**
+    * Test helloWorld with two connections
+    *
+    * max-pool-size is 1, so once getConnection() is called
+    * the second time, the managed connection for connection1
+    * is dissociated.
+    *
+    * @exception Throwable Thrown if case of an error
+    */
+   @Test
+   public void testHelloWorldTwoConnections() throws Throwable
+   {
+      assertNotNull(connectionFactory);
+
+      HelloWorldConnection connection1 = connectionFactory.getConnection();
+      assertNotNull(connection1);
+      String result1 = connection1.helloWorld(null);
+      assertNotNull(result1);
+
+      HelloWorldConnection connection2 = connectionFactory.getConnection();
+      assertNotNull(connection2);
+      String result2 = connection2.helloWorld(null);
+      assertNotNull(result2);
+
+      connection1.close();
+      connection2.close();
+   }
+}

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/jboss/jca/samples/helloworld/package.html
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/jboss/jca/samples/helloworld/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/java/org/jboss/jca/samples/helloworld/package.html	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,3 @@
+<body>
+This package contains helloworld sample testcase
+</body>

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/resources/jndi.properties
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/resources/jndi.properties	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/resources/jndi.properties	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,2 @@
+java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

Added: projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/resources/logging.properties
===================================================================
--- projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/resources/logging.properties	                        (rev 0)
+++ projects/jboss-jca/trunk/doc/samples/helloworld-lazy/src/test/resources/logging.properties	2012-02-14 16:46:11 UTC (rev 112641)
@@ -0,0 +1,39 @@
+
+# Additional logger names to configure (root logger is always configured)
+loggers=org.jboss.jca,org.jboss,org.jnp,com.arjuna
+
+# Root logger level
+logger.level=${iron.jacamar.log.level:INFO}
+logger.handlers=CONSOLE, FILE
+
+# org.jboss.jca
+logger.org.jboss.jca.level=DEBUG
+
+# org.jboss
+logger.org.jboss.level=INFO
+
+# org.jnp
+logger.org.jnp.level=INFO
+
+# com.arjuna
+logger.com.arjuna.level=INFO
+
+# Console handler configuration
+handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
+handler.CONSOLE.properties=autoFlush
+handler.CONSOLE.level=${iron.jacamar.log.console.level:INFO}
+handler.CONSOLE.autoFlush=true
+handler.CONSOLE.formatter=PATTERN
+
+# File handler configuration
+handler.FILE=org.jboss.logmanager.handlers.FileHandler
+handler.FILE.level=${iron.jacamar.log.file.level:DEBUG}
+handler.FILE.properties=autoFlush,fileName
+handler.FILE.autoFlush=true
+handler.FILE.fileName=${reports.dir}/test.log
+handler.FILE.formatter=PATTERN
+
+# Formatter pattern configuration
+formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
+formatter.PATTERN.properties=pattern
+formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c{1}] %m%n

Modified: projects/jboss-jca/trunk/doc/userguide/en-US/modules/logging.xml
===================================================================
--- projects/jboss-jca/trunk/doc/userguide/en-US/modules/logging.xml	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/doc/userguide/en-US/modules/logging.xml	2012-02-14 16:46:11 UTC (rev 112641)
@@ -275,6 +275,16 @@
             <entry>Unable to set XAResource transaction timeout</entry>
           </row>
           <row>
+            <entry>464</entry>
+            <entry><code>EXCEPTION</code></entry>
+            <entry>Unable to find connection listener</entry>
+          </row>
+          <row>
+            <entry>465</entry>
+            <entry><code>EXCEPTION</code></entry>
+            <entry>Connection is null</entry>
+          </row>
+          <row>
             <entry>501</entry>
             <entry><code>WARN</code></entry>
             <entry>Thread is not the enlisting thread</entry>

Modified: projects/jboss-jca/trunk/doc/userguide/en-US/modules/sample.xml
===================================================================
--- projects/jboss-jca/trunk/doc/userguide/en-US/modules/sample.xml	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/doc/userguide/en-US/modules/sample.xml	2012-02-14 16:46:11 UTC (rev 112641)
@@ -264,4 +264,129 @@
 
   </section>
 
+  <section id="sample_helloworld_lazy">
+    <title>HelloWorld/Lazy example</title>
+
+    <section id="sample_helloworld_lazy_introduction">
+      <title>Introduction</title>
+
+      <para>The HelloWorld/Lazy resource adapter example shows a simple example of how to use and
+      implement the interfaces in the Java EE Connector Architecture specification which
+      takes advantage of the lazy association mechanism to reestablish the relationship
+      between the logical (<code>HelloWorldConnectionImpl</code>) and the physical connection
+      (<code>HelloWorldManagedConnection</code>).</para>
+
+      <para>The HelloWorld/Lazy sample exposes the HelloWorldConnection interface where developers
+      can invoke the exposed methods.</para>
+
+      <para>The sample shows how to build and test a resource adapter.</para>
+
+      <section id="sample_helloworld_lazy_introduction_setup">
+        <title>Setup</title>
+        <para>The build environment needs various libraries in order to being able to build and
+        test the resource adapter. The setup is done by</para>
+        <programlisting>
+cd doc/samples/helloworld-lazy
+cp -R ../../../lib .
+cp ../../../bin/ironjacamar-sjc.jar lib/
+        </programlisting>
+      </section>
+
+      <section id="sample_helloworld_lazy_introduction_building">
+        <title>Building</title>
+        <para>Building the resource adapter is done by</para>
+        <programlisting>
+ant rar
+        </programlisting>
+      </section>
+
+      <section id="sample_helloworld_lazy_introduction_testing">
+        <title>Testing</title>
+        <para>Testing the resource adapter is done by</para>
+        <programlisting>
+ant test
+        </programlisting>
+      </section>
+
+    </section>
+
+    <section id="sample_helloworld_lazy_resourceadpater">
+      <title>HelloWorld/Lazy Resource Adapter</title>
+      <programlisting language="java">
+<xi:include parse="text" href="../../samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldResourceAdapter.java" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+      </programlisting>
+    </section>
+
+    <section id="sample_helloworld_lazy_mcf">
+      <title>HelloWorld/Lazy Managed Connection Factory</title>
+      <programlisting language="java">
+<xi:include parse="text" href="../../samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnectionFactory.java" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+      </programlisting>
+    </section>
+
+    <section id="sample_helloworld_lazy_mc">
+      <title>HelloWorld/Lazy Managed Connection</title>
+      <programlisting language="java">
+<xi:include parse="text" href="../../samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnection.java" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+      </programlisting>
+    </section>
+
+    <section id="sample_helloworld_lazy_cf">
+      <title>HelloWorld/Lazy Connection Factory</title>
+      <programlisting language="java">
+<xi:include parse="text" href="../../samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionFactory.java" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+      </programlisting>
+    </section>
+
+    <section id="sample_helloworld_lazy_cfimpl">
+      <title>HelloWorld/Lazy Connection Factory Implementation</title>
+      <programlisting language="java">
+<xi:include parse="text" href="../../samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionFactoryImpl.java" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+      </programlisting>
+    </section>
+
+    <section id="sample_helloworld_lazy_connection">
+      <title>HelloWorld/Lazy Connection</title>
+      <programlisting language="java">
+<xi:include parse="text" href="../../samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnection.java" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+      </programlisting>
+    </section>
+
+    <section id="sample_helloworld_lazy_connectionimpl">
+      <title>HelloWorld/Lazy Connection Implementation</title>
+      <programlisting language="java">
+<xi:include parse="text" href="../../samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldConnectionImpl.java" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+      </programlisting>
+    </section>
+
+    <section id="sample_helloworld_lazy_metadata">
+      <title>HelloWorld/Lazy Managed Connection MetaData</title>
+      <programlisting language="java">
+<xi:include parse="text" href="../../samples/helloworld-lazy/src/main/java/org/jboss/jca/samples/helloworld/HelloWorldManagedConnectionMetaData.java" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+      </programlisting>
+    </section>
+
+    <section id="sample_helloworld_lazy_ironjacamarxml">
+      <title>HelloWorld/Lazy ironjacamar.xml</title>
+      <programlisting language="java">
+<xi:include parse="text" href="../../samples/helloworld-lazy/src/main/resources/META-INF/ironjacamar.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+      </programlisting>
+    </section>
+
+    <section id="sample_helloworld_lazy_testcase">
+      <title>HelloWorld/Lazy Connection Test Case</title>
+      <programlisting language="java">
+<xi:include parse="text" href="../../samples/helloworld-lazy/src/test/java/org/jboss/jca/samples/helloworld/ConnectorTestCase.java" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+      </programlisting>
+    </section>
+
+    <section id="sample_helloworld_lazy_buildxml">
+      <title>HelloWorld/Lazy Ant build.xml</title>
+      <programlisting language="xml">
+<xi:include parse="text" href="../../samples/helloworld-lazy/build.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+      </programlisting>
+    </section>
+
+  </section>
+
 </appendix>

Modified: projects/jboss-jca/trunk/doc/userguide/en-US/modules/schemas.xml
===================================================================
--- projects/jboss-jca/trunk/doc/userguide/en-US/modules/schemas.xml	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/doc/userguide/en-US/modules/schemas.xml	2012-02-14 16:46:11 UTC (rev 112641)
@@ -53,6 +53,18 @@
     </programlisting>
   </section>
 
+  <!-- IronJacamar 1.1 -->
+  <section id="ironjacamar11">
+    <title>IronJacamar 1.1</title>
+
+    <programlisting language="xml">
+      <xi:include parse="text" 
+                  href="../../../common/src/main/resources/schema/ironjacamar_1_1.xsd"
+                  xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
+    </programlisting>
+  </section>
+
   <!-- Resource adapters 1.0 -->
   <section id="ra10">
     <title>Resource adapters 1.0</title>

Modified: projects/jboss-jca/trunk/sjc/build.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/build.xml	2012-02-13 21:47:08 UTC (rev 112640)
+++ projects/jboss-jca/trunk/sjc/build.xml	2012-02-14 16:46:11 UTC (rev 112641)
@@ -248,6 +248,7 @@
         <include name="schema/resource-adapters_1_0.xsd"/>
         <include name="schema/resource-adapters_1_1.xsd"/>
         <include name="schema/ironjacamar_1_0.xsd"/>
+        <include name="schema/ironjacamar_1_1.xsd"/>
       </fileset>
     </copy>
 



More information about the jboss-cvs-commits mailing list