[teiid-commits] teiid SVN: r4065 - in branches/7.7.x/connectors: connector-infinispan and 21 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Mon May 7 13:53:08 EDT 2012


Author: van.halbert
Date: 2012-05-07 13:53:08 -0400 (Mon, 07 May 2012)
New Revision: 4065

Added:
   branches/7.7.x/connectors/connector-infinispan/
   branches/7.7.x/connectors/connector-infinispan/pom.xml
   branches/7.7.x/connectors/connector-infinispan/src/
   branches/7.7.x/connectors/connector-infinispan/src/assembly/
   branches/7.7.x/connectors/connector-infinispan/src/assembly/kit.xml
   branches/7.7.x/connectors/connector-infinispan/src/main/
   branches/7.7.x/connectors/connector-infinispan/src/main/ear/
   branches/7.7.x/connectors/connector-infinispan/src/main/ear/META-INF/
   branches/7.7.x/connectors/connector-infinispan/src/main/ear/META-INF/application.xml
   branches/7.7.x/connectors/connector-infinispan/src/main/ear/META-INF/jboss-app.xml
   branches/7.7.x/connectors/connector-infinispan/src/main/ear/infinispan-ds.xml
   branches/7.7.x/connectors/connector-infinispan/src/main/java/
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicConnection.java
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicConnectionFactory.java
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicManagedConnection.java
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicManagedConnectionFactory.java
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicResourceAdapter.java
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/ConnectionContext.java
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/ConnectionRequestInfoWrapper.java
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/ReflectionHelper.java
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/WrappedConnection.java
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/WrappedConnectionFactory.java
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/infinispan/
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanConnectionImpl.java
   branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanManagedConnectionFactory.java
   branches/7.7.x/connectors/connector-infinispan/src/main/rar/
   branches/7.7.x/connectors/connector-infinispan/src/main/rar/META-INF/
   branches/7.7.x/connectors/connector-infinispan/src/main/rar/META-INF/ra.xml
   branches/7.7.x/connectors/connector-infinispan/src/main/resources/
   branches/7.7.x/connectors/connector-infinispan/src/main/resources/org/
   branches/7.7.x/connectors/connector-infinispan/src/main/resources/org/teiid/
   branches/7.7.x/connectors/connector-infinispan/src/main/resources/org/teiid/resource/
   branches/7.7.x/connectors/connector-infinispan/src/main/resources/org/teiid/resource/adapter/
   branches/7.7.x/connectors/connector-infinispan/src/main/resources/org/teiid/resource/adapter/infinispan/
   branches/7.7.x/connectors/connector-infinispan/src/main/resources/org/teiid/resource/adapter/infinispan/i18n.properties
Log:
TEIID-2015 deploy Infinispan as an .ear to an AS 5 server which will support calling Infinispan remotely

Added: branches/7.7.x/connectors/connector-infinispan/pom.xml
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/pom.xml	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/pom.xml	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <artifactId>connectors</artifactId>
+        <groupId>org.jboss.teiid</groupId>
+        <version>7.7.1</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>connector-infinispan</artifactId>
+    <groupId>org.jboss.teiid.connectors</groupId>
+    <name>Infinispan Connector</name>
+    <description>This connector reads data from a Infinispan cache</description>
+    <properties>
+       <version.infinispan>5.1.2.FINAL</version.infinispan>
+       <version.hibernate.search>4.1.0.CR1</version.hibernate.search>
+    </properties>
+    <dependencies>
+
+        <dependency>
+			<groupId>org.jboss.teiid.connectors</groupId>
+			<artifactId>translator-object</artifactId>
+			<version>${project.version}</version>
+			<scope>compile</scope>
+		</dependency>
+		
+        <dependency>
+            <groupId>javax.resource</groupId>
+            <artifactId>connector-api</artifactId>
+             <version>1.5</version>
+              <scope>provided</scope>
+        </dependency>   
+
+		<dependency>
+	        <groupId>org.infinispan</groupId>
+    	    <artifactId>infinispan-core</artifactId>
+       		<version>${version.infinispan}</version>
+       	</dependency>	
+	    <dependency>
+	      <groupId>org.infinispan</groupId>
+	      <artifactId>infinispan-client-hotrod</artifactId>
+	      <version>${version.infinispan}</version>
+	    </dependency>  
+	    
+		<dependency>
+		  <groupId>org.jboss.logging</groupId>
+		  <artifactId>jboss-logging</artifactId>
+		  <version>3.1.1.GA</version>
+		</dependency>	     
+   	    
+		<dependency>
+		  <groupId>org.jboss.logmanager</groupId>
+		  <artifactId>jboss-logmanager</artifactId>
+		  <version>1.2.2.GA</version>
+		</dependency>  
+		 	    
+   	 	<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>		
+			<version>4.4</version>
+			<scope>test</scope>
+		</dependency>           
+        
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>build_jar</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>deploy_jar</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>jar</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>lib</classifier>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin> 
+		    <plugin>
+		        <artifactId>maven-assembly-plugin</artifactId>
+		        <configuration>
+		         <finalName>infinispan</finalName>
+		            <descriptors>
+		                <descriptor>src/assembly/kit.xml</descriptor>
+		            </descriptors>
+		            <outputDirectory>target/distribution</outputDirectory>
+		            <workDirectory>target/assembly/work</workDirectory>
+		        </configuration>
+		        <executions>
+		            <execution>
+		                <id>make-assembly</id>
+		                <phase>package</phase>
+		                <goals>
+		                    <goal>attached</goal>
+		                </goals>
+		            </execution>
+		        </executions>
+		      </plugin>  
+
+      <!-- plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <version>2.7</version>
+        <configuration>
+           <defaultJavaBundleDir>lib</defaultJavaBundleDir>
+           <modules>
+              <rarModule>
+             	 <bundleDir>/connector-infinispan.rar</bundleDir>
+             </rarModule>            
+             <javaModule>
+	  	        <groupId>org.infinispan</groupId>
+    		    <artifactId>infinispan-core</artifactId>
+    		    <includeInApplicationXml>true</includeInApplicationXml>
+             </javaModule>
+             <javaModule>
+	      		<groupId>org.infinispan</groupId>
+	      		<artifactId>infinispan-client-hotrod</artifactId>
+	      		<includeInApplicationXml>true</includeInApplicationXml>
+             </javaModule> 
+  
+          </modules>
+          
+		  <jboss>
+		    <data-sources>
+		      <data-source>src/kit/infinispan-ds.xml</data-source>
+		    </data-sources>
+		    
+			<loader-repository> 
+			      org.teiid.resource.adapter:loader=infinispan-jca.ear
+				  <loader-repository-config> 
+				     java2ParentDelegation=false 
+			     </loader-repository-config> 
+			</loader-repository>
+		    
+		  </jboss>          
+        </configuration>
+      </plugin -->		                   
+        </plugins>
+    </build>
+</project>

Added: branches/7.7.x/connectors/connector-infinispan/src/assembly/kit.xml
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/assembly/kit.xml	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/assembly/kit.xml	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,63 @@
+<!--This script builds a kit for the ctc-client -->
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+
+
+<!-- 
+  This packages the files into a directory that is then grabbed by the jbossas pom kitting process 
+  in order to build a complete set of artifacts to be deployed to a JBoss AS server
+ -->
+  
+  <id>jca.ear</id>
+   
+  <formats>
+	<format>dir</format>
+  </formats>
+  
+  <includeBaseDirectory>false</includeBaseDirectory>
+
+  <baseDirectory>/</baseDirectory>
+
+    <dependencySets>
+       
+        <dependencySet>
+          <outputDirectory>connector-infinispan.rar</outputDirectory>
+          <useTransitiveDependencies>true</useTransitiveDependencies>
+
+           <includes>
+ 
+            <include>org.jboss.teiid.connectors:connector-infinispan</include>
+            <include>org.infinispan:infinispan-core</include>
+            <include>org.infinispan:infinispan-client-hotrod</include>
+   
+            <include>commons-pool:commons-pool</include>
+            <include>org.jboss.logging:jboss-logging</include>
+            <include>org.jboss.logmanager:jboss-logmanager</include>
+            <include>org.jboss.marshalling:jboss-marshalling</include>
+            <include>org.jboss.marshalling:jboss-marshalling-river</include>
+
+
+          </includes>
+    
+        </dependencySet>
+
+    </dependencySets>
+
+    <fileSets>
+
+        <fileSet>
+            <directory>src/main/ear/</directory>
+            <outputDirectory>/</outputDirectory>
+
+        </fileSet>
+
+        <fileSet>
+            <directory>src/main/rar/</directory>
+            <outputDirectory>connector-infinispan.rar</outputDirectory>
+
+        </fileSet>
+
+    </fileSets>
+
+</assembly>
\ No newline at end of file

Added: branches/7.7.x/connectors/connector-infinispan/src/main/ear/META-INF/application.xml
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/ear/META-INF/application.xml	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/ear/META-INF/application.xml	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,12 @@
+<?xml version='1.0'  encoding='UTF-8'?>
+<!DOCTYPE application PUBLIC
+        "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+        "http://java.sun.com/dtd/application_1_3.dtd">
+
+<application>
+	<display-name>Infinispan</display-name>
+	  <module>
+	  <connector>connector-infinispan.rar</connector>
+	  </module>    
+               
+</application>

Added: branches/7.7.x/connectors/connector-infinispan/src/main/ear/META-INF/jboss-app.xml
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/ear/META-INF/jboss-app.xml	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/ear/META-INF/jboss-app.xml	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,16 @@
+<?xml version='1.0'  encoding='UTF-8'?>
+<!DOCTYPE jboss-app
+    PUBLIC "-//JBoss//DTD J2EE Application 1.3V2//EN"
+    "http://www.jboss.org/j2ee/dtd/jboss-app_3_2.dtd">
+<jboss-app>
+   <loader-repository> 
+      org.teiid.resource.adapter:loader=infinispan-jca.ear
+	  <loader-repository-config> 
+	     java2ParentDelegation=false 
+     </loader-repository-config> 
+  </loader-repository>
+   
+    <module>
+        <service>infinispan-ds.xml</service>
+    </module>
+</jboss-app>

Added: branches/7.7.x/connectors/connector-infinispan/src/main/ear/infinispan-ds.xml
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/ear/infinispan-ds.xml	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/ear/infinispan-ds.xml	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connection-factories>
+
+   <no-tx-connection-factory>
+      <!-- The jndi name of the DataSource -->
+      <jndi-name>InfinispanDS</jndi-name>
+      
+      <!-- The resource archive file that defines JCA connection for Coherence  -->
+      <rar-name>infinispan-jca.ear#connector-infinispan.rar</rar-name>
+      <!-- connection interface; (do not change this) -->
+      <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>     
+
+           <!-- (OPTIONAL) Infinispan Server List -->
+      <!-- config-property name="RemoteInfinispanServerList">host:port[;host:port...]</config-property-->
+<min-pool-size>5</min-pool-size>
+      <max-pool-size>20</max-pool-size>
+
+    </no-tx-connection-factory>
+
+</connection-factories>
\ No newline at end of file

Added: branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicConnection.java
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicConnection.java	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicConnection.java	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.resource.adapter.custom.spi;
+
+import javax.resource.ResourceException;
+import javax.resource.cci.Connection;
+import javax.resource.cci.ConnectionMetaData;
+import javax.resource.cci.Interaction;
+import javax.resource.cci.LocalTransaction;
+import javax.resource.cci.ResultSetInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.transaction.xa.XAResource;
+
+public abstract class BasicConnection implements Connection {
+
+	@Override
+	public Interaction createInteraction() throws ResourceException {
+		throw new ResourceException("This operation not supported"); //$NON-NLS-1$
+	}
+
+	@Override
+	public LocalTransaction getLocalTransaction() throws ResourceException {
+		return null;
+	}
+
+	@Override
+	public ConnectionMetaData getMetaData() throws ResourceException {
+		throw new ResourceException("This operation not supported"); //$NON-NLS-1$
+	}
+
+	@Override
+	public ResultSetInfo getResultSetInfo() throws ResourceException {
+		throw new ResourceException("This operation not supported"); //$NON-NLS-1$
+	}
+	
+	public XAResource getXAResource() throws ResourceException {
+		return null;
+	}
+	
+	/**
+	 * Tests the connection to see if it is still valid.
+	 * @return
+	 */
+	public boolean isAlive() {
+		return true;
+	}
+	
+	/**
+	 * Called by the {@link ManagedConnection} to indicate the physical connection
+	 * should be cleaned up for reuse.
+	 */
+	public void cleanUp() {
+		
+	}
+
+}

Added: branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicConnectionFactory.java
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicConnectionFactory.java	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicConnectionFactory.java	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,42 @@
+package org.teiid.resource.adapter.custom.spi;
+
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.resource.ResourceException;
+import javax.resource.cci.ConnectionFactory;
+import javax.resource.cci.ConnectionSpec;
+import javax.resource.cci.RecordFactory;
+import javax.resource.cci.ResourceAdapterMetaData;
+
+public abstract class BasicConnectionFactory implements ConnectionFactory {
+	private static final long serialVersionUID = 2900581028589520388L;
+	private Reference reference;
+	
+	@Override
+	public abstract BasicConnection getConnection() throws ResourceException;
+	
+	@Override
+	public BasicConnection getConnection(ConnectionSpec arg0) throws ResourceException {
+		throw new ResourceException("This operation not supported"); //$NON-NLS-1$;
+	}
+
+	@Override
+	public ResourceAdapterMetaData getMetaData() throws ResourceException {
+		throw new ResourceException("This operation not supported"); //$NON-NLS-1$;
+	}
+
+	@Override
+	public RecordFactory getRecordFactory() throws ResourceException {
+		throw new ResourceException("This operation not supported"); //$NON-NLS-1$
+	}
+
+	@Override
+	public void setReference(Reference arg0) {
+		this.reference = arg0; 
+	}
+
+	@Override
+	public Reference getReference() throws NamingException {
+		return this.reference;
+	}
+}

Added: branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicManagedConnection.java
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicManagedConnection.java	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicManagedConnection.java	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.resource.adapter.custom.spi;
+
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.cci.Connection;
+import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ConnectionEventListener;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.LocalTransaction;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionMetaData;
+import javax.security.auth.Subject;
+import javax.transaction.xa.XAResource;
+
+
+public class BasicManagedConnection implements ManagedConnection {
+	protected PrintWriter log;
+	protected final Collection<ConnectionEventListener> listeners = new ArrayList<ConnectionEventListener>();
+	private BasicConnection physicalConnection;
+	private final Set<WrappedConnection> handles = new HashSet<WrappedConnection>();
+	
+	public BasicManagedConnection(BasicConnection connection) {
+		this.physicalConnection = connection;
+	}
+
+	@Override
+	public void associateConnection(Object handle) throws ResourceException {
+		if (!(handle instanceof WrappedConnection)) {
+			throw new ResourceException("Wrong connection supplied to assosiate"); //$NON-NLS-1$
+		}
+		((WrappedConnection)handle).setManagedConnection(this);
+		synchronized (this.handles) {
+			this.handles.add((WrappedConnection)handle);
+		}
+	}
+
+	@Override
+	public void cleanup() throws ResourceException {
+		synchronized (this.handles) {
+			for (WrappedConnection wc:this.handles) {
+				wc.setManagedConnection(null);
+			}
+			handles.clear();
+		}
+		if (this.physicalConnection != null) {
+			this.physicalConnection.cleanUp();
+		}
+		ConnectionContext.setSubject(null);
+	}
+
+	@Override
+	public void destroy() throws ResourceException {
+		cleanup();
+		
+		this.physicalConnection.close();
+		this.physicalConnection = null;
+	}
+	
+	@Override
+	public ManagedConnectionMetaData getMetaData() throws ResourceException {
+		return null;
+	}
+	
+	@Override
+	public Object getConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
+		ConnectionContext.setSubject(arg0);
+		
+		WrappedConnection wc = new WrappedConnection(this); 
+		synchronized(this.handles) {
+			this.handles.add(wc);
+		}
+		return wc; 
+	}
+
+	@Override
+	public LocalTransaction getLocalTransaction() throws ResourceException {
+		return null;
+	}
+
+	@Override
+	public XAResource getXAResource() throws ResourceException {
+		return this.physicalConnection.getXAResource();
+	}
+	
+	@Override
+	public void addConnectionEventListener(ConnectionEventListener arg0) {
+		synchronized (this.listeners) {
+			this.listeners.add(arg0);
+		}
+	}	
+
+	@Override
+	public void removeConnectionEventListener(ConnectionEventListener arg0) {
+		synchronized (this.listeners) {
+			this.listeners.remove(arg0);
+		}
+	}
+
+	@Override
+	public void setLogWriter(PrintWriter arg0) throws ResourceException {
+		this.log = arg0;
+	}
+	
+	@Override
+	public PrintWriter getLogWriter() throws ResourceException {
+		return this.log;
+	}
+
+	// called by the wrapped connection to notify the close of the connection.
+	void connectionClosed(WrappedConnection wc) {
+		
+		synchronized (this.handles) {
+			handles.remove(wc);
+		}
+		
+		ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
+		ce.setConnectionHandle(wc);
+		
+		ArrayList<ConnectionEventListener> copy = null;
+		synchronized (this.listeners) {
+			copy = new ArrayList<ConnectionEventListener>(this.listeners);
+		}
+		
+		for(ConnectionEventListener l: copy) {
+			l.connectionClosed(ce);
+		}
+	}
+	
+   Connection getConnection() throws ResourceException {
+      if (this.physicalConnection == null)
+         throw new ResourceException("Connection has been destroyed!!!"); //$NON-NLS-1$
+      return this.physicalConnection;
+   }	
+   
+   public boolean isValid() {
+	   if (this.physicalConnection == null) {
+		   return false;
+	   }
+	   return this.physicalConnection.isAlive();
+   }
+}

Added: branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicManagedConnectionFactory.java
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicManagedConnectionFactory.java	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicManagedConnectionFactory.java	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.resource.adapter.custom.spi;
+
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterAssociation;
+import javax.resource.spi.ValidatingManagedConnectionFactory;
+import javax.security.auth.Subject;
+
+
+
+public abstract class BasicManagedConnectionFactory implements ManagedConnectionFactory, ResourceAdapterAssociation, ValidatingManagedConnectionFactory {
+
+	private static final long serialVersionUID = -7302713800883776790L;
+	private PrintWriter log;
+	private BasicResourceAdapter ra;
+	private BasicConnectionFactory cf;
+	
+	@Override
+	public abstract BasicConnectionFactory createConnectionFactory() throws ResourceException;
+
+	@Override
+	public Object createConnectionFactory(ConnectionManager cm) throws ResourceException {
+		this.cf = createConnectionFactory();
+		return this.cf;
+		// return new WrappedConnectionFactory(this.cf, cm, this);
+	}
+
+	@Override
+	public ManagedConnection createManagedConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
+//		Assertion.isNotNull(this.cf);
+		ConnectionContext.setSubject(arg0);
+		
+		BasicConnection connection = null;
+		if (arg1 instanceof ConnectionRequestInfoWrapper) {
+			connection = this.cf.getConnection(((ConnectionRequestInfoWrapper)arg1).cs);
+		}
+		else {
+			connection = this.cf.getConnection();
+		}
+		ConnectionContext.setSubject(null);
+		return new BasicManagedConnection(connection);
+	}
+
+	@Override
+	public PrintWriter getLogWriter() throws ResourceException {
+		return this.log;
+	}
+
+	@Override
+	public ManagedConnection matchManagedConnections(Set arg0, Subject arg1, ConnectionRequestInfo arg2) throws ResourceException {
+		return (ManagedConnection)arg0.iterator().next();
+	}
+
+	@Override
+	public void setLogWriter(PrintWriter arg0) throws ResourceException {
+		this.log = arg0;
+	}
+
+	@Override
+	public ResourceAdapter getResourceAdapter() {
+		return this.ra;
+	}
+
+	@Override
+	public void setResourceAdapter(ResourceAdapter arg0) throws ResourceException {
+		this.ra = (BasicResourceAdapter)arg0;
+	}
+	
+    public static <T> T getInstance(Class<T> expectedType, String className, Collection ctorObjs, Class defaultClass) throws ResourceException {
+    	try {
+	    	if (className == null) {
+	    		if (defaultClass == null) {
+	    			throw new ResourceException("Neither class name or default class specified to create an instance"); //$NON-NLS-1$
+	    		}
+	    		return expectedType.cast(defaultClass.newInstance());
+	    	}
+	    	return expectedType.cast(ReflectionHelper.create(className, ctorObjs, Thread.currentThread().getContextClassLoader()));
+		} catch (IllegalAccessException e) {
+			throw new ResourceException(e);
+		} catch(InstantiationException e) {
+			throw new ResourceException(e);
+		} catch (Exception e) {
+			throw new ResourceException(e);
+		}   	
+    }
+
+	@Override
+	public Set<BasicManagedConnection> getInvalidConnections(Set arg0) throws ResourceException {
+		HashSet<BasicManagedConnection> result = new HashSet<BasicManagedConnection>();
+		for (Object object : arg0) {
+			if (object instanceof BasicManagedConnection) {
+				BasicManagedConnection bmc = (BasicManagedConnection)object;
+				if (!bmc.isValid()) {
+					result.add(bmc);
+				}
+			}
+		}
+		return result;
+	}
+}

Added: branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicResourceAdapter.java
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicResourceAdapter.java	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/BasicResourceAdapter.java	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.teiid.resource.adapter.custom.spi;
+
+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.XATerminator;
+import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.resource.spi.work.WorkManager;
+import javax.transaction.xa.XAResource;
+
+public class BasicResourceAdapter implements ResourceAdapter {
+	BootstrapContext ctx;
+	
+	@Override
+	public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException {
+		throw new UnsupportedOperationException("not supported"); //$NON-NLS-1$
+	}
+
+	@Override
+	public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) {
+		throw new UnsupportedOperationException("not supported"); //$NON-NLS-1$
+	}
+
+	@Override
+	public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException {
+		return new XAResource[0];
+	}
+
+	@Override
+	public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
+		this.ctx = ctx;
+	}
+
+	@Override
+	public void stop() {
+	}
+
+	public WorkManager getWorkManager() {
+		return ctx.getWorkManager();
+	}
+	
+	public XATerminator getXATerminator() {
+		return ctx.getXATerminator();
+	}
+}

Added: branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/ConnectionContext.java
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/ConnectionContext.java	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/ConnectionContext.java	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.resource.adapter.custom.spi;
+
+import javax.security.auth.Subject;
+
+/**
+ * Thread local class to access the Subject in the Connector code. This is set just before the 
+ * connector connection is created.
+ */
+public class ConnectionContext {
+	private static ThreadLocal<Subject> SUBJECT = new ThreadLocal<Subject>() {
+		protected Subject initialValue() {
+			return null;
+		}
+	};
+
+	public static Subject getSubject() {
+		return SUBJECT.get();
+	}
+	
+	public static void setSubject(Subject subject) {
+		SUBJECT.set(subject);
+	}	
+}

Added: branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/ConnectionRequestInfoWrapper.java
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/ConnectionRequestInfoWrapper.java	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/ConnectionRequestInfoWrapper.java	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.resource.adapter.custom.spi;
+
+import javax.resource.cci.ConnectionSpec;
+import javax.resource.spi.ConnectionRequestInfo;
+
+class ConnectionRequestInfoWrapper implements ConnectionRequestInfo {
+	ConnectionSpec cs;
+	
+	public ConnectionRequestInfoWrapper(ConnectionSpec cs) {
+		this.cs = cs;
+	}
+}

Added: branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/ReflectionHelper.java
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/ReflectionHelper.java	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/ReflectionHelper.java	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,329 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.resource.adapter.custom.spi;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+
+public class ReflectionHelper {
+
+    private Class<?> targetClass;
+    private Map<String, LinkedList<Method>> methodMap = null;       // used for the brute-force method finder
+
+    /**
+     * Construct a ReflectionHelper instance that cache's some information about
+     * the target class.  The target class is the Class object upon which the
+     * methods will be found.
+     * @param targetClass the target class
+     * @throws IllegalArgumentException if the target class is null
+     */
+    public ReflectionHelper( Class<?> targetClass ) {
+        if ( targetClass == null ) {
+            throw new IllegalArgumentException("ReflectionHelper.errorConstructing"); //$NON-NLS-1$
+        }
+        this.targetClass = targetClass;
+    }
+
+    /**
+     * Find the best method on the target class that matches the signature specified
+     * with the specified name and the list of arguments.  This method first
+     * attempts to find the method with the specified arguments; if no such
+     * method is found, a NoSuchMethodException is thrown.
+     * <P>
+     * This method is unable to find methods with signatures that include both
+     * primitive arguments <i>and</i> arguments that are instances of <code>Number</code>
+     * or its subclasses.
+     * @param methodName the name of the method that is to be invoked.
+     * @param arguments the array of Object instances that correspond
+     * to the arguments passed to the method.
+     * @return the Method object that references the method that satisfies
+     * the requirements, or null if no satisfactory method could be found.
+     * @throws NoSuchMethodException if a matching method is not found.
+     * @throws SecurityException if access to the information is denied.
+     */
+    public Method findBestMethodOnTarget( String methodName, Object[] arguments ) throws NoSuchMethodException, SecurityException {
+    	if (arguments == null) {
+    		return findBestMethodWithSignature(methodName, Collections.EMPTY_LIST);
+    	}
+        int size = arguments.length;
+        List<Class<?>> argumentClasses = new ArrayList<Class<?>>(size);
+        for (int i=0; i!=size; ++i) {
+            if ( arguments[i] != null ) {
+                Class<?> clazz = arguments[i].getClass();
+                argumentClasses.add( clazz );
+            } else {
+                argumentClasses.add(null);
+            }
+        }
+        return findBestMethodWithSignature(methodName,argumentClasses);
+    }
+
+    /**
+     * Find the best method on the target class that matches the signature specified
+     * with the specified name and the list of argument classes.  This method first
+     * attempts to find the method with the specified argument classes; if no such
+     * method is found, a NoSuchMethodException is thrown.
+     * @param methodName the name of the method that is to be invoked.
+     * @param argumentsClasses the list of Class instances that correspond
+     * to the classes for each argument passed to the method.
+     * @return the Method object that references the method that satisfies
+     * the requirements, or null if no satisfactory method could be found.
+     * @throws NoSuchMethodException if a matching method is not found.
+     * @throws SecurityException if access to the information is denied.
+     */
+    public Method findBestMethodWithSignature( String methodName, Object[] argumentsClasses ) throws NoSuchMethodException, SecurityException {
+        List argumentClassesList = Arrays.asList(argumentsClasses);
+        return findBestMethodWithSignature(methodName,argumentClassesList);
+    }
+
+    /**
+     * Find the best method on the target class that matches the signature specified
+     * with the specified name and the list of argument classes.  This method first
+     * attempts to find the method with the specified argument classes; if no such
+     * method is found, a NoSuchMethodException is thrown.
+     * @param methodName the name of the method that is to be invoked.
+     * @param argumentsClasses the list of Class instances that correspond
+     * to the classes for each argument passed to the method.
+     * @return the Method object that references the method that satisfies
+     * the requirements, or null if no satisfactory method could be found.
+     * @throws NoSuchMethodException if a matching method is not found.
+     * @throws SecurityException if access to the information is denied.
+     */
+    public Method findBestMethodWithSignature( String methodName, List<Class<?>> argumentsClasses ) throws NoSuchMethodException, SecurityException {
+        // Attempt to find the method
+        Method result = null;
+        Class[] classArgs = new Class[argumentsClasses.size()];
+
+        // -------------------------------------------------------------------------------
+        // First try to find the method with EXACTLY the argument classes as specified ...
+        // -------------------------------------------------------------------------------
+        try {
+            argumentsClasses.toArray(classArgs);
+            result = this.targetClass.getMethod(methodName,classArgs);  // this may throw an exception if not found
+            return result;
+        } catch ( NoSuchMethodException e ) {
+            // No method found, so continue ...
+        }
+
+        // ---------------------------------------------------------------------------------------------
+        // Then try to find a method with the argument classes converted to a primitive, if possible ...
+        // ---------------------------------------------------------------------------------------------
+        List<Class<?>> argumentsClassList = convertArgumentClassesToPrimitives(argumentsClasses);
+        argumentsClassList.toArray(classArgs);
+        try {
+            result = this.targetClass.getMethod(methodName,classArgs);  // this may throw an exception if not found
+            return result;
+        } catch ( NoSuchMethodException e ) {
+            // No method found, so continue ...
+        }
+
+        // ---------------------------------------------------------------------------------------------
+        // Still haven't found anything.  So far, the "getMethod" logic only finds methods that EXACTLY
+        // match the argument classes (i.e., not methods declared with superclasses or interfaces of
+        // the arguments).  There is no canned algorithm in Java to do this, so we have to brute-force it.
+        // ---------------------------------------------------------------------------------------------
+        if ( this.methodMap == null ) {
+            this.methodMap = new HashMap<String, LinkedList<Method>>();
+            Method[] methods = this.targetClass.getMethods();
+            for ( int i=0; i!=methods.length; ++i ) {
+                Method method = methods[i];
+                LinkedList<Method> methodsWithSameName = this.methodMap.get(method.getName());
+                if ( methodsWithSameName == null ) {
+                    methodsWithSameName = new LinkedList<Method>();
+                    this.methodMap.put(method.getName(),methodsWithSameName);
+                }
+                methodsWithSameName.addFirst(method);   // add lower methods first
+            }
+        }
+
+        LinkedList<Method> methodsWithSameName = this.methodMap.get(methodName);
+        if ( methodsWithSameName == null ) {
+            throw new NoSuchMethodException(methodName);
+        }
+        for (Method method : methodsWithSameName) {
+            Class[] args = method.getParameterTypes();
+			boolean allMatch = argsMatch(argumentsClasses, argumentsClassList, args);
+            if ( allMatch ) {
+                if (result != null) {
+                    throw new NoSuchMethodException(methodName + " Args: " + argumentsClasses + " has multiple possible signatures."); //$NON-NLS-1$ //$NON-NLS-2$
+                }
+                result = method;
+            }
+        }
+        
+        if (result != null) {
+            return result;
+        }
+
+        throw new NoSuchMethodException(methodName + " Args: " + argumentsClasses); //$NON-NLS-1$
+    }
+
+	private static boolean argsMatch(List<Class<?>> argumentsClasses,
+			List<Class<?>> argumentsClassList, Class[] args) {
+        if ( args.length != argumentsClasses.size() ) {
+            return false;
+        }
+		for ( int i=0; i<args.length; ++i ) {
+		    Class<?> primitiveClazz = argumentsClassList.get(i);
+		    Class<?> objectClazz = argumentsClasses.get(i);
+		    if ( objectClazz != null ) {
+		        // Check for possible matches with (converted) primitive types
+		        // as well as the original Object type 
+		        if ( ! args[i].equals(primitiveClazz) && ! args[i].isAssignableFrom(objectClazz) ) {
+		            return false;   // found one that doesn't match
+		        }
+		    } else {
+		        // a null is assignable for everything except a primitive
+		        if ( args[i].isPrimitive() ) {
+		            return false;   // found one that doesn't match
+		        }
+		    }
+		}
+		return true;
+	}
+    
+    /**
+     * Convert any argument classes to primitives.
+     * @param arguments the list of argument classes.
+     * @return the list of Class instances in which any classes that could be represented
+     * by primitives (e.g., Boolean) were replaced with the primitive classes (e.g., Boolean.TYPE).
+     */
+    private static List<Class<?>> convertArgumentClassesToPrimitives( List<Class<?>> arguments ) {
+        List<Class<?>> result = new ArrayList<Class<?>>(arguments.size());
+        for (Class<?> clazz : arguments) {
+            if      ( clazz == Boolean.class   ) clazz = Boolean.TYPE;
+            else if ( clazz == Character.class ) clazz = Character.TYPE;
+            else if ( clazz == Byte.class      ) clazz = Byte.TYPE;
+            else if ( clazz == Short.class     ) clazz = Short.TYPE;
+            else if ( clazz == Integer.class   ) clazz = Integer.TYPE;
+            else if ( clazz == Long.class      ) clazz = Long.TYPE;
+            else if ( clazz == Float.class     ) clazz = Float.TYPE;
+            else if ( clazz == Double.class    ) clazz = Double.TYPE;
+            else if ( clazz == Void.class      ) clazz = Void.TYPE;
+            result.add( clazz );
+        }
+
+        return result;
+    }
+    
+    /**
+     * Helper method to load a class.
+     * @param className is the class to instantiate
+     * @param classLoader the class loader to use; may be null if the current
+     * class loader is to be used
+     * @return Class is the instance of the class 
+     * @throws ClassNotFoundException 
+     */
+    private static final Class<?> loadClass(final String className, final ClassLoader classLoader) throws ClassNotFoundException {
+        Class<?> cls = null;
+        if ( classLoader == null ) {
+            cls = Class.forName(className.trim());
+        } else {
+            cls = Class.forName(className.trim(),true,classLoader);
+        }
+        return cls;
+    }
+    
+    /**
+     * Helper method to create an instance of the class using the appropriate
+     * constructor based on the ctorObjs passed.
+     * @param className is the class to instantiate
+     * @param ctorObjs are the objects to pass to the constructor; optional, nullable
+     * @param classLoader the class loader to use; may be null if the current
+     * class loader is to be used
+     * @return Object is the instance of the class 
+     * @throws Exception if an error occurs instantiating the class
+     */
+
+    public static final Object create(String className, Collection<?> ctorObjs, 
+                                      final ClassLoader classLoader) throws Exception {
+    	try {
+	        int size = (ctorObjs == null ? 0 : ctorObjs.size());
+	        Class[] names = new Class[size];
+	        Object[] objArray = new Object[size];
+	        int i = 0;
+	
+	        if (size > 0) {
+	            for (Iterator<?> it=ctorObjs.iterator(); it.hasNext(); ) {
+	                Object obj = it.next();
+	                if (obj != null) {
+		                names[i] = obj.getClass();
+		                objArray[i] = obj;
+	                }
+	                i++;
+	            }
+	        } 
+	        return create(className, objArray, names, classLoader);
+    	} catch (Exception e) {
+    		throw new Exception(e);
+    	}
+    }
+    	
+    public static final Object create(String className, Object[] ctorObjs, Class<?>[] argTypes, 
+                final ClassLoader classLoader) throws Exception {
+    	Class<?> cls;
+        try {
+            cls = loadClass(className,classLoader);
+        } catch(Exception e) {
+            throw new Exception(e);
+        }
+        Constructor<?> ctor = null;
+        try {
+        	ctor = cls.getDeclaredConstructor(argTypes);
+        } catch (NoSuchMethodException e) {
+        	
+        }
+        
+        if (ctor == null && argTypes != null && argTypes.length > 0) {
+        	List<Class<?>> argumentsClasses = Arrays.asList(argTypes);
+        	List<Class<?>> argumentsClassList = convertArgumentClassesToPrimitives(argumentsClasses);
+        	for (Constructor<?> possible : cls.getDeclaredConstructors()) {
+        		if (argsMatch(argumentsClasses, argumentsClassList, possible.getParameterTypes())) {
+        			ctor = possible;
+        			break;
+        		}
+        	}
+        }
+        
+        if (ctor == null) {
+        	throw new Exception(className + " Args: " + Arrays.toString(argTypes)); //$NON-NLS-1$
+        }
+        
+        try {
+			return ctor.newInstance(ctorObjs);
+		} catch (Exception e) {
+			throw new Exception(e);
+		}
+    }
+    
+}

Added: branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/WrappedConnection.java
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/WrappedConnection.java	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/WrappedConnection.java	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.resource.adapter.custom.spi;
+
+import javax.resource.ResourceException;
+import javax.resource.cci.Connection;
+import javax.resource.cci.ConnectionMetaData;
+import javax.resource.cci.Interaction;
+import javax.resource.cci.ResultSetInfo;
+
+
+public class WrappedConnection implements Connection {
+
+	private BasicManagedConnection mc;
+	boolean closed = false;
+	
+	public WrappedConnection(BasicManagedConnection mc) {
+		this.mc = mc;
+	}
+	
+	@Override
+	public void close() throws ResourceException {
+		if (!this.closed && this.mc != null) {
+			this.closed = true;
+			this.mc.connectionClosed(this);
+			this.mc = null;
+		}
+	}
+
+	// Called by managed connection for the connection management
+	void setManagedConnection(BasicManagedConnection mc) {
+		this.mc = mc;
+	}
+
+	@Override
+	public Interaction createInteraction() throws ResourceException {
+		return this.mc.getConnection().createInteraction();
+	}
+
+	@Override
+	public javax.resource.cci.LocalTransaction getLocalTransaction() throws ResourceException {
+		return this.mc.getConnection().getLocalTransaction();
+	}
+
+	@Override
+	public ConnectionMetaData getMetaData() throws ResourceException {
+		return this.mc.getConnection().getMetaData();
+	}
+
+	@Override
+	public ResultSetInfo getResultSetInfo() throws ResourceException {
+		return this.mc.getConnection().getResultSetInfo();
+	}
+	
+	public Connection unwrap() throws ResourceException {
+		return this.mc.getConnection();
+	}
+
+}

Added: branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/WrappedConnectionFactory.java
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/WrappedConnectionFactory.java	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/custom/spi/WrappedConnectionFactory.java	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.resource.adapter.custom.spi;
+
+import java.io.Serializable;
+
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.resource.Referenceable;
+import javax.resource.ResourceException;
+import javax.resource.cci.Connection;
+import javax.resource.cci.ConnectionFactory;
+import javax.resource.cci.ConnectionSpec;
+import javax.resource.cci.RecordFactory;
+import javax.resource.cci.ResourceAdapterMetaData;
+import javax.resource.spi.ConnectionManager;
+
+
+public class WrappedConnectionFactory implements ConnectionFactory, Referenceable, Serializable  {
+
+	private static final long serialVersionUID = 5499157394014613035L;
+	private BasicConnectionFactory delegate;
+	private ConnectionManager cm;	
+	private BasicManagedConnectionFactory mcf;
+	private Reference reference;
+	
+	public WrappedConnectionFactory(BasicConnectionFactory delegate, ConnectionManager cm, BasicManagedConnectionFactory mcf) {
+		this.delegate = delegate;
+		this.cm = cm;
+		this.mcf = mcf;
+	}
+	
+	@Override
+	public Connection getConnection() throws ResourceException {
+		return (Connection)cm.allocateConnection(mcf, null);
+	}
+
+
+	@Override
+	public void setReference(Reference arg0) {
+		this.reference = arg0;
+	}
+
+	@Override
+	public Reference getReference() throws NamingException {
+		return this.reference;
+	}
+
+	@Override
+	public Connection getConnection(ConnectionSpec arg0) throws ResourceException {
+		return (Connection)cm.allocateConnection(mcf, new ConnectionRequestInfoWrapper(arg0));
+	}
+
+	@Override
+	public ResourceAdapterMetaData getMetaData() throws ResourceException {
+		return this.delegate.getMetaData();
+	}
+
+	@Override
+	public RecordFactory getRecordFactory() throws ResourceException {
+		return this.delegate.getRecordFactory();
+	}
+}

Added: branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanConnectionImpl.java
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanConnectionImpl.java	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanConnectionImpl.java	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.resource.adapter.infinispan;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.resource.ResourceException;
+
+import org.infinispan.client.hotrod.RemoteCache;
+import org.teiid.resource.adapter.custom.spi.BasicConnection;
+import org.teiid.translator.object.ObjectCacheConnection;
+
+
+/** 
+ * Represents an implementation of the connection to an Infinispan cache. 
+ */
+public class InfinispanConnectionImpl extends BasicConnection implements ObjectCacheConnection { 
+
+	private InfinispanManagedConnectionFactory config;
+	
+	public InfinispanConnectionImpl(InfinispanManagedConnectionFactory config) throws ResourceException {
+		this.config = config;
+	}
+
+	
+	/** 
+	 * Close the connection, if a connection requires closing.
+	 * (non-Javadoc)
+	 */
+	@Override
+    public void close() {
+		config = null;
+	}
+
+	/** 
+	 * Currently, this method always returns alive. We assume the connection is alive,
+	 * and rely on proper timeout values to automatically clean up connections before
+	 * any server-side timeout occurs. Rather than incur overhead by rebinding,
+	 * we'll assume the connection is always alive, and throw an error when it is actually used,
+	 * if the connection fails. This may be a more efficient way of handling failed connections,
+	 * with the one tradeoff that stale connections will not be detected until execution time. In
+	 * practice, there is no benefit to detecting stale connections before execution time.
+	 * 
+	 * One possible extension is to implement a UnsolicitedNotificationListener.
+	 * (non-Javadoc)
+	 */
+	public boolean isAlive() {
+		return (config == null ? false : config.getRemoteCacheManager().isStarted());
+	}
+
+	public List<Object> get(List<Object> args, String cacheName, Class<?> rootNodeType) throws Exception {
+		
+		RemoteCache<Object, Object> cache = config.getRemoteCacheManager().getCache(cacheName);
+		
+    	List<Object> results = null;
+    	if (args == null || args.size() == 0) {
+    		Map<Object, Object> c = cache.getBulk();
+    		results = new ArrayList<Object>();
+    		for (Iterator it = c.keySet().iterator(); it.hasNext();) {
+    			Object v = cache.get(it.next());
+    			if (v != null && v.getClass().equals(rootNodeType)) {
+    				addValue(v, results);
+    			}
+    		}
+
+    	} else {
+	    	results = new ArrayList<Object>(args.size());
+			for (Iterator<Object> it=args.iterator(); it.hasNext();) {
+				Object arg = it.next();
+				Object v = cache.get(arg);
+				if (v != null && v.getClass().equals(rootNodeType)) {
+    				addValue(v, results);    			}				
+			}
+    	}
+    	
+    	return results;
+		
+	}
+	
+	private void addValue(Object value, List<Object> results) {
+		if (value.getClass().isArray()) {
+			List<Object> listRows = Arrays.asList((Object[]) value);
+			results.addAll(listRows);
+			return;
+		}
+		
+		if (value instanceof Collection) {
+			results.addAll((Collection) value); 
+			return;
+		} 
+		
+		if (value instanceof Map) {
+			Map<?,Object> mapRows = (Map) value;
+			results.addAll(mapRows.values());
+			return;
+		}
+		
+		results.add(value);
+
+	}
+	
+}

Added: branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanManagedConnectionFactory.java
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanManagedConnectionFactory.java	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/java/org/teiid/resource/adapter/infinispan/InfinispanManagedConnectionFactory.java	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.resource.adapter.infinispan;
+
+import javax.resource.ResourceException;
+
+import org.infinispan.client.hotrod.RemoteCacheManager;
+import org.teiid.resource.adapter.custom.spi.BasicConnectionFactory;
+import org.teiid.resource.adapter.custom.spi.BasicManagedConnectionFactory;
+
+public class InfinispanManagedConnectionFactory extends BasicManagedConnectionFactory {
+
+	private String remoteServerList;
+	private RemoteCacheManager cacheContainer;
+	private Object lock = new Object();
+
+	@Override
+	public BasicConnectionFactory createConnectionFactory() throws ResourceException {
+		
+		synchronized(lock) {
+			
+			this.cacheContainer = getOrCreateCacheContainer();
+			if (this.cacheContainer == null) {
+	            throw new ResourceException("Unable to create Infinispan CacheContainer" );
+			}
+
+		}
+	
+		return new BasicConnectionFactory() {
+
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			public InfinispanConnectionImpl getConnection() throws ResourceException {
+				return new InfinispanConnectionImpl(InfinispanManagedConnectionFactory.this);
+			}
+		};
+	}	
+    
+	
+   public String getRemoteServerList() {
+        return remoteServerList;
+    }
+
+    /**
+     * Set the list of remote servers that make up the Infinispan cluster. The servers must be Infinispan HotRod servers. The list
+     * must be in the appropriate format of <code>host:port[;host:port...]</code> that would be used when defining an Infinispan
+     * {@link RemoteCacheManager} instance. If the value is missing, <code>localhost:11311</code> is assumed.
+     * 
+     * @param remoteInfinispanServerList the server list in appropriate <code>server:port;server2:port2</code> format.
+     */
+    public synchronized void setRemoteInfinispanServerList( String remoteInfinispanServerList ) {
+        if (this.remoteServerList == remoteInfinispanServerList || this.remoteServerList != null
+            && this.remoteServerList.equals(remoteInfinispanServerList)) return; // unchanged
+        this.remoteServerList = remoteInfinispanServerList;
+    }
+    
+    
+    protected RemoteCacheManager getRemoteCacheManager() {
+    	return this.cacheContainer;
+    }
+	private RemoteCacheManager getOrCreateCacheContainer() {
+		if (this.cacheContainer != null) {
+			return this.cacheContainer;
+		}
+        if (getRemoteServerList() == null || getRemoteServerList().equals("")) {
+        	return new RemoteCacheManager();
+        }
+        return new RemoteCacheManager(getRemoteServerList());
+
+    }
+
+  
+	
+}

Added: branches/7.7.x/connectors/connector-infinispan/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/rar/META-INF/ra.xml	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/rar/META-INF/ra.xml	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<connector version="1.5">
+
+   <vendor-name>Red Hat Middleware LLC</vendor-name>
+   <eis-type>Teiid Infinispan Connector</eis-type>
+   <resourceadapter-version>1.0</resourceadapter-version>
+   <license>
+      <description>
+ JBoss, Home of Professional Open Source.
+ Copyright 2006, 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.
+      </description>
+      <license-required>true</license-required>
+   </license>
+   <resourceadapter>
+      <resourceadapter-class>org.teiid.resource.adapter.custom.spi.BasicResourceAdapter</resourceadapter-class>
+
+      <outbound-resourceadapter>
+         <connection-definition>
+            <managedconnectionfactory-class>org.teiid.resource.adapter.infinispan.InfinispanManagedConnectionFactory</managedconnectionfactory-class>
+            
+            <connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
+            <connectionfactory-impl-class>org.teiid.resource.adapter.custom.spi.WrappedConnectionFactory</connectionfactory-impl-class>
+            <connection-interface>javax.resource.cci.Connection</connection-interface>
+            <connection-impl-class>org.teiid.resource.adapter.custom.spi.WrappedConnection</connection-impl-class>
+            
+            <!-- config-property>
+               <description>{$display:"Infinispan Server List",$description:"Infinispan Server List (host:port[;host:port...])",$required:"true"}</description>
+               <config-property-name>RemoteServerList</config-property-name>
+               <config-property-type>java.lang.String</config-property-type>
+               <config-property-value>localhost:11311</config-property-value>
+            </config-property-->           
+
+         </connection-definition>
+         
+         <transaction-support>NoTransaction</transaction-support>
+        
+        <authentication-mechanism>
+            <authentication-mechanism-type>BasicPassword</authentication-mechanism-type>
+            <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface>
+        </authentication-mechanism>
+        <reauthentication-support>false</reauthentication-support>
+      </outbound-resourceadapter>
+   </resourceadapter>
+</connector>

Added: branches/7.7.x/connectors/connector-infinispan/src/main/resources/org/teiid/resource/adapter/infinispan/i18n.properties
===================================================================
--- branches/7.7.x/connectors/connector-infinispan/src/main/resources/org/teiid/resource/adapter/infinispan/i18n.properties	                        (rev 0)
+++ branches/7.7.x/connectors/connector-infinispan/src/main/resources/org/teiid/resource/adapter/infinispan/i18n.properties	2012-05-07 17:53:08 UTC (rev 4065)
@@ -0,0 +1,21 @@
+#
+# JBoss, Home of Professional Open Source.
+# See the COPYRIGHT.txt file distributed with this work for information
+# regarding copyright ownership.  Some portions may be licensed
+# to Red Hat, Inc. under one or more contributor license agreements.
+# 
+# This library 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 library 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 library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#



More information about the teiid-commits mailing list