[teiid-commits] teiid SVN: r1961 - in trunk: build/kit-jboss-container/deploy/teiid and 42 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Mar 12 16:47:15 EST 2010


Author: shawkins
Date: 2010-03-12 16:47:08 -0500 (Fri, 12 Mar 2010)
New Revision: 1961

Added:
   trunk/client/src/main/java/com/metamatrix/dqp/client/DQP.java
   trunk/client/src/main/java/com/metamatrix/dqp/client/StreamingLobChunckProducer.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java
   trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java
   trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
Removed:
   trunk/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java
   trunk/client/src/main/java/com/metamatrix/dqp/client/impl/
   trunk/client/src/main/java/org/teiid/transport/
   trunk/common-core/src/main/java/com/metamatrix/api/exception/MultipleException.java
   trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorAnnotations.java
   trunk/engine/src/main/java/com/metamatrix/common/queue/
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
   trunk/runtime/src/main/java/com/metamatrix/dqp/
Modified:
   trunk/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMBlob.java
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMClob.java
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java
   trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
   trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
   trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java
   trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
   trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java
   trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java
   trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java
   trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java
   trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java
   trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java
   trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
   trunk/client/src/main/java/com/metamatrix/common/xa/MMXid.java
   trunk/client/src/main/java/com/metamatrix/dqp/client/MetadataResult.java
   trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
   trunk/client/src/main/java/com/metamatrix/jdbc/api/ExecutionProperties.java
   trunk/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java
   trunk/client/src/main/java/org/teiid/adminapi/Session.java
   trunk/client/src/main/java/org/teiid/adminapi/Transaction.java
   trunk/client/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
   trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
   trunk/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
   trunk/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadataMapper.java
   trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServiceRegistry.java
   trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorEnvironment.java
   trunk/connector-api/src/main/java/org/teiid/connector/api/DataNotAvailableException.java
   trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java
   trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/RuntimeMetadata.java
   trunk/engine/pom.xml
   trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/SessionService.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java
   trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
   trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java
   trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
   trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java
   trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
   trunk/pom.xml
   trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
   trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
   trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
   trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
   trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
   trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
   trunk/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java
   trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
Log:
TEIID-1015 TEIID-897 temporarily converting Teiid processing to a single threaded model.  reintroduced the transaction manger to handle local and request level transactions. changing the default autowrap name to DETECT. consolidating threadlocal and security concerns.

Modified: trunk/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- trunk/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml	2010-03-12 21:47:08 UTC (rev 1961)
@@ -72,6 +72,7 @@
         <property name="adminSocketConfiguration"><inject bean="AdminSocketConfiguration"/></property>
         <property name="workManager"><inject bean="WorkManager"/></property>
         <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
+        <property name="TransactionManager"><inject bean="TransactionManager"/></property>
         <property name="authorizationService"><inject bean="AuthorizationService"/></property>
         <property name="sessionService"><inject bean="SessionService"/></property>
         <property name="bufferService"><inject bean="BufferService"/></property>
@@ -87,7 +88,7 @@
         <!-- Maximum allowed fetch size, set via JDBC. User requested value ignored above this value. (default 20480) -->
         <property name="maxRowsFetchSize">20480</property>
         <!-- The max lob chunk size in KB transferred each time when processing blobs, clobs(100KB default) -->
-        <property name="lobChunkSizeInKB">10</property>
+        <property name="lobChunkSizeInKB">100</property>
         <!-- The maximum number of query plans that are cached. Note: this is a memory based cache. (default 250)  -->
         <property name="preparedPlanCacheMaxCount">250</property>
         <!-- Maximum number of cached lookup tables. Note: this is a memory based cache and should be set to a value of at least 10 to accomidate system usage. (default 200) -->

Modified: trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnection.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -28,7 +28,7 @@
 public interface ServerConnection {
 	
 	public static final int PING_INTERVAL = 120000;
-	public static final String LOCAL_CONNECTION = "localConnection";
+	public static final String LOCAL_CONNECTION = "localConnection"; //$NON-NLS-1$
 
 	<T> T getService(Class<T> iface);
 	

Modified: trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnection.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -242,7 +242,7 @@
 	}
 
 	public <T> T getService(Class<T> iface) {
-		return (T)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new ServerConnectionInvocationHandler(iface));
+		return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new ServerConnectionInvocationHandler(iface)));
 	}
 	public synchronized void close() {
 		shutdown(true);

Modified: trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -59,7 +59,7 @@
 import com.metamatrix.common.util.crypto.Cryptor;
 import com.metamatrix.common.util.crypto.DhKeyGenerator;
 import com.metamatrix.common.util.crypto.NullCryptor;
-import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQP;
 import com.metamatrix.dqp.client.ResultsFuture;
 
 /**
@@ -303,7 +303,7 @@
 		
 		public RemoteInvocationHandler(Class<?> targetClass) {
 			this.targetClass = targetClass;
-			this.secure = !ClientSideDQP.class.isAssignableFrom(targetClass);
+			this.secure = !DQP.class.isAssignableFrom(targetClass);
 		}
 
 		//## JDBC4.0-begin ##

Modified: trunk/client/src/main/java/com/metamatrix/common/xa/MMXid.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/xa/MMXid.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/com/metamatrix/common/xa/MMXid.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -27,6 +27,7 @@
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.math.BigInteger;
+import java.util.Arrays;
 
 import javax.transaction.xa.Xid;
 
@@ -41,6 +42,9 @@
 	private byte[] branchQualifier;
 	private String toString;
 	
+	public MMXid() {
+	}
+	
 	public MMXid(Xid xid) {
 	    this.formatID = xid.getFormatId();
 	    this.globalTransactionId = xid.getGlobalTransactionId();
@@ -78,36 +82,14 @@
         if(obj == this) {
             return true;
         } 
-		if(obj == null || !(obj instanceof MMXid)){
+		if(!(obj instanceof MMXid)){
 			return false;
 		}
 		MMXid that = (MMXid)obj;
-		if(this.formatID != that.formatID){
-			return false;
-		}
-		if(!areByteArraysEqual(this.globalTransactionId, that.globalTransactionId)){
-			return false;
-		}
-		if(!areByteArraysEqual(this.branchQualifier, that.branchQualifier)){
-			return false;
-		}
-		return true;
+		return this.formatID == that.formatID
+				&& Arrays.equals(this.globalTransactionId, that.globalTransactionId)
+				&& Arrays.equals(this.branchQualifier, that.branchQualifier);
 	}
-
-	private boolean areByteArraysEqual(byte[] firstByteArray, byte[] secondByteArray){
-		if(firstByteArray == null || secondByteArray == null){
-			return false;
-		}
-		if(firstByteArray.length != secondByteArray.length){
-			return false;
-		}
-		for(int i=0; i< firstByteArray.length; i++){
-			if(firstByteArray[i] != secondByteArray[i]){
-				return false;
-			}
-		}
-		return true;
-	}
 	
 	/** 
 	 * @see java.lang.Object#toString()

Deleted: trunk/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,85 +0,0 @@
-/*
- * 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 com.metamatrix.dqp.client;
-
-import java.util.List;
-
-import javax.transaction.xa.Xid;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.lob.LobChunk;
-import com.metamatrix.common.xa.MMXid;
-import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.message.ResultsMessage;
-
-public interface ClientSideDQP {
-	
-	ResultsFuture<ResultsMessage> executeRequest(long reqID, RequestMessage message) throws MetaMatrixProcessingException, MetaMatrixComponentException;
-	
-	ResultsFuture<ResultsMessage> processCursorRequest(long reqID, int batchFirst, int fetchSize) throws MetaMatrixProcessingException;
-
-	ResultsFuture<?> closeRequest(long requestID) throws MetaMatrixProcessingException, MetaMatrixComponentException;
-	
-	boolean cancelRequest(long requestID) throws MetaMatrixProcessingException, MetaMatrixComponentException;
-	
-	ResultsFuture<?> closeLobChunkStream(int lobRequestId, long requestId, String streamId) throws MetaMatrixProcessingException, MetaMatrixComponentException;
-	
-	ResultsFuture<LobChunk> requestNextLobChunk(int lobRequestId, long requestId, String streamId) throws MetaMatrixProcessingException, MetaMatrixComponentException;
-		
-	List<String> getXmlSchemas(String docName) throws MetaMatrixComponentException, QueryMetadataException;
-
-	MetadataResult getMetadata(long requestID) throws MetaMatrixComponentException, MetaMatrixProcessingException;
-	
-	MetadataResult getMetadata(long requestID, String preparedSql, boolean allowDoubleQuotedVariable) throws MetaMatrixComponentException, MetaMatrixProcessingException;
-	
-    // local transaction
- 
-	ResultsFuture<?> begin() throws XATransactionException;
-
-    ResultsFuture<?> commit() throws XATransactionException; 
-
-    ResultsFuture<?> rollback() throws XATransactionException; 
-
-    // XA
-
-    ResultsFuture<?> start(MMXid xid,
-            int flags,
-            int timeout) throws XATransactionException;
-
-    ResultsFuture<?> end(MMXid xid,
-            int flags) throws XATransactionException;
-
-    ResultsFuture<Integer> prepare(MMXid xid) throws XATransactionException;
-
-    ResultsFuture<?> commit(MMXid xid, boolean onePhase) throws XATransactionException;
-    
-    ResultsFuture<?> rollback(MMXid xid) throws XATransactionException;
-
-    ResultsFuture<?> forget(MMXid xid) throws XATransactionException;
-
-    ResultsFuture<Xid[]> recover(int flag) throws XATransactionException; 
-    
-}

Copied: trunk/client/src/main/java/com/metamatrix/dqp/client/DQP.java (from rev 1955, trunk/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java)
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/client/DQP.java	                        (rev 0)
+++ trunk/client/src/main/java/com/metamatrix/dqp/client/DQP.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -0,0 +1,85 @@
+/*
+ * 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 com.metamatrix.dqp.client;
+
+import java.util.List;
+
+import javax.transaction.xa.Xid;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.common.lob.LobChunk;
+import com.metamatrix.common.xa.MMXid;
+import com.metamatrix.common.xa.XATransactionException;
+import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.message.ResultsMessage;
+
+public interface DQP {
+	
+	ResultsFuture<ResultsMessage> executeRequest(long reqID, RequestMessage message) throws MetaMatrixProcessingException, MetaMatrixComponentException;
+	
+	ResultsFuture<ResultsMessage> processCursorRequest(long reqID, int batchFirst, int fetchSize) throws MetaMatrixProcessingException;
+
+	ResultsFuture<?> closeRequest(long requestID) throws MetaMatrixProcessingException, MetaMatrixComponentException;
+	
+	boolean cancelRequest(long requestID) throws MetaMatrixProcessingException, MetaMatrixComponentException;
+	
+	ResultsFuture<?> closeLobChunkStream(int lobRequestId, long requestId, String streamId) throws MetaMatrixProcessingException, MetaMatrixComponentException;
+	
+	ResultsFuture<LobChunk> requestNextLobChunk(int lobRequestId, long requestId, String streamId) throws MetaMatrixProcessingException, MetaMatrixComponentException;
+		
+	List<String> getXmlSchemas(String docName) throws MetaMatrixComponentException, QueryMetadataException;
+
+	MetadataResult getMetadata(long requestID) throws MetaMatrixComponentException, MetaMatrixProcessingException;
+	
+	MetadataResult getMetadata(long requestID, String preparedSql, boolean allowDoubleQuotedVariable) throws MetaMatrixComponentException, MetaMatrixProcessingException;
+	
+    // local transaction
+ 
+	ResultsFuture<?> begin() throws XATransactionException;
+
+    ResultsFuture<?> commit() throws XATransactionException; 
+
+    ResultsFuture<?> rollback() throws XATransactionException; 
+
+    // XA
+
+    ResultsFuture<?> start(MMXid xid,
+            int flags,
+            int timeout) throws XATransactionException;
+
+    ResultsFuture<?> end(MMXid xid,
+            int flags) throws XATransactionException;
+
+    ResultsFuture<Integer> prepare(MMXid xid) throws XATransactionException;
+
+    ResultsFuture<?> commit(MMXid xid, boolean onePhase) throws XATransactionException;
+    
+    ResultsFuture<?> rollback(MMXid xid) throws XATransactionException;
+
+    ResultsFuture<?> forget(MMXid xid) throws XATransactionException;
+
+    ResultsFuture<Xid[]> recover(int flag) throws XATransactionException; 
+    
+}

Modified: trunk/client/src/main/java/com/metamatrix/dqp/client/MetadataResult.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/client/MetadataResult.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/com/metamatrix/dqp/client/MetadataResult.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -35,6 +35,9 @@
 	private Map[] columnMetadata;
 	private int parameterCount;
 	
+	public MetadataResult() {
+	}
+	
 	public MetadataResult(Map[] columnMetadata, int parameterCount) {
 		super();
 		this.columnMetadata = columnMetadata;

Copied: trunk/client/src/main/java/com/metamatrix/dqp/client/StreamingLobChunckProducer.java (from rev 1955, trunk/client/src/main/java/com/metamatrix/dqp/client/impl/StreamingLobChunckProducer.java)
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/client/StreamingLobChunckProducer.java	                        (rev 0)
+++ trunk/client/src/main/java/com/metamatrix/dqp/client/StreamingLobChunckProducer.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -0,0 +1,89 @@
+/*
+ * 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 com.metamatrix.dqp.client;
+
+import java.io.IOException;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.metamatrix.api.exception.MetaMatrixException;
+import com.metamatrix.common.comm.CommonCommPlugin;
+import com.metamatrix.common.lob.LobChunk;
+import com.metamatrix.common.lob.LobChunkProducer;
+import com.metamatrix.common.types.Streamable;
+
+public class StreamingLobChunckProducer implements LobChunkProducer {
+	
+	public static class Factory {
+		private final Streamable<?> streamable;
+		private final DQP dqp;
+		private final long requestId;
+		
+		public Factory(DQP dqp,
+				long requestId, Streamable<?> streamable) {
+			super();
+			this.dqp = dqp;
+			this.requestId = requestId;
+			this.streamable = streamable;
+		}
+
+		public StreamingLobChunckProducer getLobChunkProducer() {
+			return new StreamingLobChunckProducer(dqp, requestId, streamable);
+		}
+	}
+	
+	private static AtomicInteger REQUEST_SEQUENCE = new AtomicInteger(0);
+
+	private final Streamable<?> streamable;
+	private final DQP dqp;
+	private final long requestId;
+	private final int streamRequestId = REQUEST_SEQUENCE.getAndIncrement();
+
+	public StreamingLobChunckProducer(DQP dqp, long requestId,
+			Streamable<?> streamable) {
+		this.dqp = dqp;
+		this.requestId = requestId;
+		this.streamable = streamable;
+	}
+
+	public LobChunk getNextChunk() throws IOException {
+	    try {
+	    	Future<LobChunk> result = dqp.requestNextLobChunk(streamRequestId, requestId, streamable.getReferenceStreamId());
+	    	return result.get();
+	    } catch (Exception e) {
+	        IOException ex = new IOException(CommonCommPlugin.Util.getString("StreamImpl.Unable_to_read_data_from_stream", e.getMessage())); //$NON-NLS-1$
+	        ex.initCause(e);
+	        throw ex;                        
+	    }                
+	}
+
+	public void close() throws IOException {
+	    try {
+	    	dqp.closeLobChunkStream(streamRequestId, requestId, streamable.getReferenceStreamId());
+	    } catch (MetaMatrixException e) {
+	        IOException ex = new IOException(e.getMessage());
+	        ex.initCause(e);
+	        throw  ex;
+		}                    
+	}
+}

Modified: trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/com/metamatrix/dqp/message/RequestMessage.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -187,7 +187,7 @@
      */
     public String getTxnAutoWrapMode() {
     	if (txnAutoWrapMode == null) {
-    		return ExecutionProperties.TXN_WRAP_AUTO;
+    		return ExecutionProperties.TXN_WRAP_DETECT;
     	}
         return txnAutoWrapMode;
     }
@@ -202,7 +202,7 @@
     		txnAutoWrapMode = txnAutoWrapMode.toUpperCase();
     		if (!(txnAutoWrapMode.equals(ExecutionProperties.TXN_WRAP_OFF)
     			|| txnAutoWrapMode.equals(ExecutionProperties.TXN_WRAP_ON)
-    			|| txnAutoWrapMode.equals(ExecutionProperties.TXN_WRAP_AUTO))) {
+    			|| txnAutoWrapMode.equals(ExecutionProperties.TXN_WRAP_DETECT))) {
     			throw new MetaMatrixProcessingException(CommonCommPlugin.Util.getString("RequestMessage.invalid_txnAutoWrap", txnAutoWrapMode)); //$NON-NLS-1$
     		}
     	} 

Modified: trunk/client/src/main/java/com/metamatrix/jdbc/api/ExecutionProperties.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/jdbc/api/ExecutionProperties.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/com/metamatrix/jdbc/api/ExecutionProperties.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -60,7 +60,7 @@
      * Transaction auto wrap constant - checks if a command
      * requires a transaction and will be automatically wrap it.
      */
-    public static final String TXN_WRAP_AUTO = "AUTO"; //$NON-NLS-1$
+    public static final String TXN_WRAP_DETECT = "DETECT"; //$NON-NLS-1$
 
     /** 
      * Whether to use result set cache if it is available 

Modified: trunk/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -36,20 +36,6 @@
 public class SessionToken implements Serializable, Cloneable {
 	public final static long serialVersionUID = -2853708320435636107L;
 
-	private static ThreadLocal<SessionToken> CONTEXTS = new ThreadLocal<SessionToken>() {
-		protected SessionToken initialValue() {
-			return null;
-		}
-	};
-
-	public static SessionToken getSession() {
-		return CONTEXTS.get();
-	}
-	
-	public static void setSession(SessionToken context) {
-		CONTEXTS.set(context);
-	}	
-	
 	/** The session ID */
 	private long sessionID;
 	private String userName;

Modified: trunk/client/src/main/java/org/teiid/adminapi/Session.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Session.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/org/teiid/adminapi/Session.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -76,7 +76,7 @@
     public int getVDBVersion();
     
     /**
-     * Get the IPAddress for this Session
+     * Get the IPAddress for this Session.  Note this value is reported from the client.
      * @return
      */
     public String getIPAddress();
@@ -84,7 +84,7 @@
  
     /**
      * Get the host name of the machine the client is 
-     * accessing from
+     * accessing from.  Note this value is reported from the client.
      * @return 
      */
     public String getClientHostName();

Modified: trunk/client/src/main/java/org/teiid/adminapi/Transaction.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/Transaction.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/org/teiid/adminapi/Transaction.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -39,14 +39,14 @@
 	String getScope();
 	
 	/**
-	 * Return the Xid of the Global transaction.  Will be null for non-Global transactions.
+	 * Returns the Xid string for GLOBAL transactions or the Transaction id string LOCAL/REQUEST.
 	 * @return
 	 */
-	String getXid();
+	String getId();
 	
 	
 	/**
-	 * Get the date the transaction was created.
+	 * Get the local creation time.
 	 * @return
 	 */
 	long getCreatedTime();

Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/ListOverMap.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/ListOverMap.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/ListOverMap.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -23,12 +23,15 @@
  */
 package org.teiid.adminapi.impl;
 
+import java.io.Serializable;
 import java.util.AbstractList;
 import java.util.LinkedHashMap;
 import java.util.Set;
 
-final class ListOverMap<E> extends AbstractList<E> {
+final class ListOverMap<E> extends AbstractList<E> implements Serializable {
 	
+	private static final long serialVersionUID = 5171741731121210240L;
+	
 	private LinkedHashMap<String, E> map = new LinkedHashMap<String, E>();
 	private KeyBuilder<E> builder;
 	
@@ -81,7 +84,7 @@
 	}	
 }
 
-interface KeyBuilder<E> {
+interface KeyBuilder<E> extends Serializable {
 	String getKey(E entry);
 }
 

Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -23,12 +23,17 @@
 
 import java.util.Date;
 
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+
 import org.jboss.managed.api.annotation.ManagementObjectID;
 import org.jboss.managed.api.annotation.ManagementProperty;
 import org.jboss.metatype.api.annotations.MetaMapping;
 import org.teiid.adminapi.Session;
 
+import com.metamatrix.platform.security.api.SessionToken;
 
+
 /**
  * Add and delete properties also in the Mapper class for correct wrapping for profile service.
  */
@@ -46,6 +51,13 @@
     private int vdbVersion;
     private long sessionId;
     private String securityDomain;
+    
+    //server session state
+    private transient VDBMetaData vdb;
+    private transient SessionToken sessionToken;
+    private transient LoginContext loginContext;
+    private transient Object securityContext;
+    private transient boolean embedded;
 
 	@Override
 	@ManagementProperty(description="Application assosiated with Session", readOnly=true)
@@ -148,7 +160,8 @@
 		this.securityDomain = domain;
 	}	
 	
-    public String toString() {
+    @SuppressWarnings("nls")
+	public String toString() {
     	StringBuilder str = new StringBuilder();
     	str.append("session: sessionid=").append(sessionId);
     	str.append("; userName=").append(userName);
@@ -161,5 +174,50 @@
     	str.append("; securityDomain=").append(securityDomain); 
     	str.append("; lastPingTime=").append(new Date(lastPingTime));
     	return str.toString();
-    }	
+    }
+
+	public VDBMetaData getVdb() {
+		return vdb;
+	}
+
+	public void setVdb(VDBMetaData vdb) {
+		this.vdb = vdb;
+	}
+
+	public SessionToken getSessionToken() {
+		return sessionToken;
+	}
+
+	public void setSessionToken(SessionToken sessionToken) {
+		this.sessionToken = sessionToken;
+	}
+
+	public LoginContext getLoginContext() {
+		return loginContext;
+	}
+
+	public void setLoginContext(LoginContext loginContext) {
+		this.loginContext = loginContext;
+	}
+
+	public Object getSecurityContext() {
+		return securityContext;
+	}
+
+	public void setSecurityContext(Object securityContext) {
+		this.securityContext = securityContext;
+	}	
+	
+	public Subject getSubject() {
+		return this.loginContext.getSubject();
+	}
+	
+	public void setEmbedded(boolean embedded) {
+		this.embedded = embedded;
+	}
+
+	public boolean isEmbedded() {
+		return embedded;
+	}
+	
 }

Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadata.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -36,7 +36,7 @@
 	private static final long serialVersionUID = -8588785315218789068L;
 	private long associatedSession;
 	private String scope;
-	private String xid;
+	private String id;
 	private long createdTime;
 
 	@Override
@@ -60,13 +60,13 @@
 	}
 
 	@Override
-	@ManagementProperty(description="XID", readOnly=true)
-	public String getXid() {
-		return xid;
+	@ManagementProperty(description="ID", readOnly=true)
+	public String getId() {
+		return id;
 	}
 
-	public void setXid(String xid) {
-		this.xid = xid;
+	public void setId(String id) {
+		this.id = id;
 	}
 	
 	@Override
@@ -84,7 +84,7 @@
         StringBuffer result = new StringBuffer();
         result.append(AdminPlugin.Util.getString("TransactionImpl.associatedSession")).append(associatedSession); //$NON-NLS-1$
         result.append(AdminPlugin.Util.getString("TransactionImpl.scope")).append(scope); //$NON-NLS-1$
-        result.append(AdminPlugin.Util.getString("TransactionImpl.xid")).append(xid); //$NON-NLS-1$
+        result.append(AdminPlugin.Util.getString("TransactionImpl.id")).append(id); //$NON-NLS-1$
         result.append(AdminPlugin.Util.getString("TransactionImpl.createdTime")).append(new Date(createdTime)); //$NON-NLS-1$
         return result.toString();
 	}

Modified: trunk/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadataMapper.java
===================================================================
--- trunk/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadataMapper.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/main/java/org/teiid/adminapi/impl/TransactionMetadataMapper.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -69,7 +69,7 @@
 			transaction.set("associatedSession", SimpleValueSupport.wrap(object.getAssociatedSession()));
 			transaction.set("createdTime", SimpleValueSupport.wrap(object.getCreatedTime()));
 			transaction.set("scope", SimpleValueSupport.wrap(object.getScope()));
-			transaction.set("xid", SimpleValueSupport.wrap(object.getXid()));
+			transaction.set("id", SimpleValueSupport.wrap(object.getId()));
 			
 			return transaction;
 		}
@@ -88,9 +88,9 @@
 			transaction.setAssociatedSession((Long) metaValueFactory.unwrap(compositeValue.get("associatedSession")));
 			transaction.setCreatedTime((Long) metaValueFactory.unwrap(compositeValue.get("createdTime")));
 			transaction.setScope((String) metaValueFactory.unwrap(compositeValue.get("scope")));
-			transaction.setXid((String) metaValueFactory.unwrap(compositeValue.get("xid")));
+			transaction.setId((String) metaValueFactory.unwrap(compositeValue.get("id")));
 			return transaction;
 		}
-		throw new IllegalStateException("Unable to unwrap session " + metaValue);
+		throw new IllegalStateException("Unable to unwrap transaction " + metaValue);
 	}
 }

Modified: trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServiceRegistry.java
===================================================================
--- trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServiceRegistry.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServiceRegistry.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -33,7 +33,7 @@
 import com.metamatrix.client.ExceptionUtil;
 import com.metamatrix.common.xa.XATransactionException;
 import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQP;
 import com.metamatrix.platform.security.api.ILogon;
 
 public class TestSocketServiceRegistry extends TestCase {
@@ -62,7 +62,7 @@
 	
 	public void testComponentExceptionConversion() throws Exception {
 		
-		Method m = ClientSideDQP.class.getMethod("getMetadata", new Class[] {Long.TYPE});
+		Method m = DQP.class.getMethod("getMetadata", new Class[] {Long.TYPE});
 		
 		Throwable t = ExceptionUtil.convertException(m, new NullPointerException());
 		
@@ -71,7 +71,7 @@
 	
 	public void testXATransactionExceptionConversion() throws Exception {
 		
-		Method m = ClientSideDQP.class.getMethod("recover", new Class[] {Integer.TYPE});
+		Method m = DQP.class.getMethod("recover", new Class[] {Integer.TYPE});
 		
 		Throwable t = ExceptionUtil.convertException(m, new MetaMatrixComponentException());
 		

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/BaseDataSource.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -219,7 +219,7 @@
      * Transaction auto wrap constant - checks if a command
      * requires a transaction and will be automatically wrap it.
      */
-    public static final String TXN_WRAP_AUTO = ExecutionProperties.TXN_WRAP_AUTO;
+    public static final String TXN_WRAP_AUTO = ExecutionProperties.TXN_WRAP_DETECT;
 
     /**
      * String to hold additional properties that are not represented with an explicit getter/setter

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMBlob.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMBlob.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMBlob.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -34,7 +34,7 @@
 import com.metamatrix.common.types.BlobType;
 import com.metamatrix.common.types.Streamable;
 import com.metamatrix.common.util.SqlUtil;
-import com.metamatrix.dqp.client.impl.StreamingLobChunckProducer;
+import com.metamatrix.dqp.client.StreamingLobChunckProducer;
 import com.metamatrix.jdbc.LobSearchUtil.StreamProvider;
 
 /**

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMClob.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMClob.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMClob.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -38,7 +38,7 @@
 import com.metamatrix.common.types.ClobType;
 import com.metamatrix.common.types.Streamable;
 import com.metamatrix.common.util.SqlUtil;
-import com.metamatrix.dqp.client.impl.StreamingLobChunckProducer;
+import com.metamatrix.dqp.client.StreamingLobChunckProducer;
 
 /**
  * This object holds a chunk of char data and implements the JDBC Clob interface.

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -64,7 +64,7 @@
 import com.metamatrix.common.util.SqlUtil;
 import com.metamatrix.common.xa.MMXid;
 import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQP;
 import com.metamatrix.dqp.client.ResultsFuture;
 import com.metamatrix.jdbc.api.ExecutionProperties;
 
@@ -115,7 +115,7 @@
     private boolean readOnly = false;
     
     private boolean disableLocalTransactions = false;
-    private ClientSideDQP dqp;
+    private DQP dqp;
     protected ServerConnection serverConn;
         
     /**
@@ -128,12 +128,12 @@
     public MMConnection(ServerConnection serverConn, Properties info, String url) {        
     	this.serverConn = serverConn;
         this.url = url;
-        this.dqp = serverConn.getService(ClientSideDQP.class);
+        this.dqp = serverConn.getService(DQP.class);
         
         // set default properties if not overridden
         String overrideProp = info.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP);
         if ( overrideProp == null || overrideProp.trim().length() == 0 ) {
-            info.put(ExecutionProperties.PROP_TXN_AUTO_WRAP, ExecutionProperties.TXN_WRAP_AUTO);
+            info.put(ExecutionProperties.PROP_TXN_AUTO_WRAP, ExecutionProperties.TXN_WRAP_DETECT);
         }
 
         // Get default fetch size
@@ -180,7 +180,7 @@
         return this.propInfo;
     }
     
-    ClientSideDQP getDQP() {
+    DQP getDQP() {
     	return this.dqp;
     }
     

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMResultSet.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -63,7 +63,7 @@
 import com.metamatrix.common.util.SqlUtil;
 import com.metamatrix.common.util.TimestampWithTimezone;
 import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.dqp.client.impl.StreamingLobChunckProducer;
+import com.metamatrix.dqp.client.StreamingLobChunckProducer;
 import com.metamatrix.dqp.message.ResultsMessage;
 import com.metamatrix.jdbc.BatchResults.Batch;
 

Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -53,7 +53,7 @@
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
 import com.metamatrix.common.util.SqlUtil;
 import com.metamatrix.core.util.ObjectConverterUtil;
-import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQP;
 import com.metamatrix.dqp.message.ParameterInfo;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.message.ResultsMessage;
@@ -193,7 +193,7 @@
         }        
     }
 
-    protected ClientSideDQP getDQP() {
+    protected DQP getDQP() {
     	return this.driverConnection.getDQP();
     }
     

Modified: trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java
===================================================================
--- trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/main/java/org/teiid/jdbc/EmbeddedProfile.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -25,6 +25,7 @@
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.text.MessageFormat;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.Properties;
 import java.util.ResourceBundle;
@@ -32,15 +33,17 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.teiid.transport.LocalServerConnection;
-
+import com.metamatrix.common.comm.api.ServerConnection;
 import com.metamatrix.common.comm.exception.CommunicationException;
 import com.metamatrix.common.comm.exception.ConnectionException;
 import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.MetaMatrixCoreException;
 import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.ReflectionHelper;
 import com.metamatrix.jdbc.BaseDataSource;
 import com.metamatrix.jdbc.JDBCPlugin;
 import com.metamatrix.jdbc.MMConnection;
+import com.metamatrix.jdbc.MMSQLException;
 import com.metamatrix.jdbc.util.MMJDBCURL;
 
 
@@ -88,13 +91,16 @@
         // and make sure we have all the properties we need.
         validateProperties(info);
         try {
-			return new MMConnection(new LocalServerConnection(info), info, url);
+        	ServerConnection sc = (ServerConnection)ReflectionHelper.create("org.teiid.transport.LocalServerConnection", Arrays.asList(info), Thread.currentThread().getContextClassLoader()); //$NON-NLS-1$
+			return new MMConnection(sc, info, url);
 		} catch (MetaMatrixRuntimeException e) {
-			throw new SQLException(e);
+			throw MMSQLException.create(e);
 		} catch (ConnectionException e) {
-			throw new SQLException(e);
+			throw MMSQLException.create(e);
 		} catch (CommunicationException e) {
-			throw new SQLException(e);
+			throw MMSQLException.create(e);
+		} catch (MetaMatrixCoreException e) {
+			throw MMSQLException.create(e);
 		}
     }
     

Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestAllResultsImpl.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -45,7 +45,7 @@
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
 import com.metamatrix.common.types.MMJDBCSQLTypeInfo;
 import com.metamatrix.common.util.TimestampWithTimezone;
-import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQP;
 import com.metamatrix.dqp.client.ResultsFuture;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.message.ResultsMessage;
@@ -698,7 +698,7 @@
 	static MMResultSet helpTestBatching(MMStatement statement, int fetchSize, int batchLength,
 			int totalLength) throws InterruptedException, ExecutionException,
 			MetaMatrixProcessingException, SQLException, TimeoutException {
-		ClientSideDQP dqp = mock(ClientSideDQP.class);
+		DQP dqp = mock(DQP.class);
 		stub(statement.getDQP()).toReturn(dqp);
 		stub(statement.getFetchSize()).toReturn(fetchSize);
 		for (int i = batchLength; i < totalLength; i += batchLength) {

Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -36,7 +36,7 @@
 import com.metamatrix.common.comm.api.ServerConnection;
 import com.metamatrix.common.xa.MMXid;
 import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQP;
 import com.metamatrix.dqp.client.ResultsFuture;
 import com.metamatrix.platform.security.api.LogonResult;
 import com.metamatrix.platform.security.api.SessionToken;
@@ -54,7 +54,7 @@
     
     public static MMConnection getMMConnection() {
     	ServerConnection mock = mock(ServerConnection.class);
-    	ClientSideDQP dqp = mock(ClientSideDQP.class);
+    	DQP dqp = mock(DQP.class);
     	try {
 			stub(dqp.start((MMXid)Mockito.anyObject(), Mockito.anyInt(), Mockito.anyInt())).toAnswer(new Answer() {
 				@Override
@@ -77,7 +77,7 @@
 		} catch (XATransactionException e) {
 			throw new RuntimeException(e);
 		}
-    	stub(mock.getService(ClientSideDQP.class)).toReturn(dqp);
+    	stub(mock.getService(DQP.class)).toReturn(dqp);
     	Properties props = new Properties();
     	props.setProperty(BaseDataSource.VDB_NAME, STD_DATABASE_NAME);
     	props.setProperty(BaseDataSource.VDB_VERSION, String.valueOf(STD_DATABASE_VERSION));

Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMDataSource.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -524,7 +524,7 @@
         final String partialMode = "false"; //$NON-NLS-1$
         final boolean secure = false;
         helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,null,transactionAutoWrap, partialMode, -1, false, secure, 
-                            "jdbc:teiid:vdbName at mm://hostname:7001;ApplicationName=JDBC;serverURL=mm://hostname:7001;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName"); //$NON-NLS-1$ 
+                            "jdbc:teiid:vdbName at mm://hostname:7001;ApplicationName=JDBC;serverURL=mm://hostname:7001;partialResultsMode=false;autoCommitTxn=DETECT;VirtualDatabaseName=vdbName"); //$NON-NLS-1$ 
     }
     
     public void testBuildURL3() {
@@ -536,7 +536,7 @@
         final String partialMode = "false"; //$NON-NLS-1$
         final boolean secure = false;
         helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,null,transactionAutoWrap, partialMode, -1, true, secure,
-                            "jdbc:teiid:vdbName at mm://hostname:7001;ApplicationName=JDBC;serverURL=mm://hostname:7001;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$ 
+                            "jdbc:teiid:vdbName at mm://hostname:7001;ApplicationName=JDBC;serverURL=mm://hostname:7001;partialResultsMode=false;autoCommitTxn=DETECT;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$ 
     }
 
     // Test secure protocol
@@ -549,7 +549,7 @@
         final String partialMode = "false"; //$NON-NLS-1$
         final boolean secure = true;
         helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,null,transactionAutoWrap, partialMode, -1, true, secure,
-                            "jdbc:teiid:vdbName at mms://hostname:7001;ApplicationName=JDBC;serverURL=mms://hostname:7001;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$ 
+                            "jdbc:teiid:vdbName at mms://hostname:7001;ApplicationName=JDBC;serverURL=mms://hostname:7001;partialResultsMode=false;autoCommitTxn=DETECT;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$ 
     }
 
     /*
@@ -567,7 +567,7 @@
         final String partialMode = "false"; //$NON-NLS-1$
         final boolean secure = false;
         helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,alternateServers,transactionAutoWrap, partialMode, -1, true, secure,
-                            "jdbc:teiid:vdbName at mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$ 
+                            "jdbc:teiid:vdbName at mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;partialResultsMode=false;autoCommitTxn=DETECT;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$ 
     }
 
     /*
@@ -585,7 +585,7 @@
         final String partialMode = "false"; //$NON-NLS-1$
         final boolean secure = true;
         helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,alternateServers,transactionAutoWrap, partialMode, -1, true, secure,
-                            "jdbc:teiid:vdbName at mms://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mms://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$ 
+                            "jdbc:teiid:vdbName at mms://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mms://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;partialResultsMode=false;autoCommitTxn=DETECT;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$ 
     }
 
     /*
@@ -604,7 +604,7 @@
         final String partialMode = "false"; //$NON-NLS-1$
         final boolean secure = false;
         helpTestBuildingURL(vdbName,vdbVersion,serverName,portNumber,alternateServers,transactionAutoWrap, partialMode, -1, true, secure,
-                            "jdbc:teiid:vdbName at mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;partialResultsMode=false;autoCommitTxn=AUTO;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$ 
+                            "jdbc:teiid:vdbName at mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;ApplicationName=JDBC;serverURL=mm://hostName:7001,hostName:7002,hostName2:7001,hostName2:7002;partialResultsMode=false;autoCommitTxn=DETECT;VirtualDatabaseName=vdbName;sqlOptions=SHOWPLAN"); //$NON-NLS-1$ 
     }
     
     public void testBuildURL_AdditionalProperties() {

Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMPreparedStatement.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -37,7 +37,7 @@
 import org.mockito.Mockito;
 
 import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQP;
 import com.metamatrix.dqp.client.ResultsFuture;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.message.ResultsMessage;
@@ -73,7 +73,7 @@
 	@Test public void testBatchedUpdateExecution() throws Exception {
 		// Build up a fake connection instance for use with the prepared statement
 		MMConnection conn = Mockito.mock(MMConnection.class);
-		ClientSideDQP dqp = Mockito.mock(ClientSideDQP.class);
+		DQP dqp = Mockito.mock(DQP.class);
 		ServerConnection serverConn = Mockito.mock(ServerConnection.class);
 		LogonResult logonResult = Mockito.mock(LogonResult.class);
 		

Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMResultSet.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -40,7 +40,7 @@
 import org.junit.Test;
 
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQP;
 import com.metamatrix.dqp.message.ResultsMessage;
 
 public class TestMMResultSet {
@@ -727,7 +727,7 @@
 
 	static MMStatement createMockStatement(int cursorType) throws SQLException {
 		MMStatement statement = mock(MMStatement.class);
-		stub(statement.getDQP()).toReturn(mock(ClientSideDQP.class));
+		stub(statement.getDQP()).toReturn(mock(DQP.class));
 		stub(statement.getResultSetType()).toReturn(cursorType);
 		TimeZone tz = TimeZone.getTimeZone("GMT-06:00"); //$NON-NLS-1$
 		TimeZone serverTz = TimeZone.getTimeZone("GMT-05:00"); //$NON-NLS-1$

Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMStatement.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -32,7 +32,7 @@
 import org.junit.Test;
 import org.mockito.Mockito;
 
-import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQP;
 import com.metamatrix.dqp.client.ResultsFuture;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.message.ResultsMessage;
@@ -46,7 +46,7 @@
 	
 	@Test public void testBatchExecution() throws Exception {
 		MMConnection conn = Mockito.mock(MMConnection.class);
-		ClientSideDQP dqp = Mockito.mock(ClientSideDQP.class);
+		DQP dqp = Mockito.mock(DQP.class);
 		ResultsFuture<ResultsMessage> results = new ResultsFuture<ResultsMessage>(); 
 		Mockito.stub(dqp.executeRequest(Mockito.anyLong(), (RequestMessage)Mockito.anyObject())).toReturn(results);
 		ResultsMessage rm = new ResultsMessage();

Deleted: trunk/common-core/src/main/java/com/metamatrix/api/exception/MultipleException.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/api/exception/MultipleException.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/common-core/src/main/java/com/metamatrix/api/exception/MultipleException.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,122 +0,0 @@
-/*
- * 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 com.metamatrix.api.exception;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.*;
-
-/**
- * Exception that represents the occurrence of multiple exceptions.
- */
-public class MultipleException extends Exception implements Externalizable {
-
-	/**
-     *The set of Throwable instances that make up this exception
-     * @link aggregation
-     * @associates <b>java.lang.Throwable</b>
-     * @supplierCardinality 1..*
-     */
-    private List throwablesList = null;
-
-    /** An error code. */
-    private String code;
-    
-    
-    /**
-     * No-arg Constructor
-     */
-    public MultipleException() {
-    	super();
-    }
-    
-    /**
-     * Construct an instance with the set of exceptions and error message
-     * specified.
-     *
-     * @param throwables the set of exceptions that is to comprise
-     * this exception
-     * @param message The error message
-     */
-    public MultipleException( Collection throwables, String message ) {
-        this( throwables, null, message );
-    }
-
-    /**
-     * Construct an instance with the set of exceptions, and an error code and
-     * message specified.
-     *
-     * @param throwables the set of exceptions that is to comprise
-     * this exception
-     * @param message The error message
-     * @param code    The error code
-     */
-    public MultipleException( Collection<Throwable> throwables, String code, String message ) {
-        super( message );
-        this.throwablesList = Collections.unmodifiableList(new ArrayList<Throwable>(throwables));
-        setCode( code );
-    }
-
-    /**
-     * Get the code for this exception.
-     * @return the code value
-     */
-    public String getCode(){
-            return code;
-	}
-	
-    /**
-     * Set the code for this exception.
-     * @param code the new code value
-     */
-    public void setCode(String code){
-            this.code = code;
-        }
-
-    /**
-     * Obtain the set of exceptions that comprise this exception.
-     * @return the set of Throwable instances that comprise this exception.
-     */
-    public List getExceptions() {
-    	return this.throwablesList;
-    }
-
-	//## JDBC4.0-begin ##
-	@Override
-	//## JDBC4.0-end ##
-	public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException {
-		this.code = (String)in.readObject();
-		this.throwablesList = ExceptionHolder.toThrowables((List<ExceptionHolder>)in.readObject());
-	}
-
-	//## JDBC4.0-begin ##
-	@Override
-	//## JDBC4.0-end ##
-	public void writeExternal(ObjectOutput out) throws IOException {
-		out.writeObject(code);
-		out.writeObject(ExceptionHolder.toExceptionHolders(throwablesList));
-	}
-}
-

Deleted: trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorAnnotations.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorAnnotations.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorAnnotations.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,40 +0,0 @@
-/*
- * 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.connector.api;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-
-
-public class ConnectorAnnotations {
-	
-	@Retention(RetentionPolicy.RUNTIME)
-	@Target({ElementType.TYPE})
-	public @interface SynchronousWorkers {
-		boolean enabled() default true;
-	}
-	
-}

Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorEnvironment.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorEnvironment.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/ConnectorEnvironment.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -65,12 +65,6 @@
 	public boolean isXaCapable();
 	
     /**
-     * Indicates whether the connector represents a pooled resource.  If it does, then
-     * synchronous workers will be used.
-     */
-	boolean isSynchWorkers();
-	
-    /**
      * Obtain a reference to the logger that can be used to add messages to the 
      * log files for debugging and error recovery.
      * @return The {@link ConnectorLogger} 

Modified: trunk/connector-api/src/main/java/org/teiid/connector/api/DataNotAvailableException.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/api/DataNotAvailableException.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/connector-api/src/main/java/org/teiid/connector/api/DataNotAvailableException.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -21,11 +21,13 @@
  */
 package org.teiid.connector.api;
 
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
 /**
  * Used by asynch connectors to indicate data is not available 
  * and results should be polled for after the given delay.
  */
-public class DataNotAvailableException extends ConnectorException {
+public class DataNotAvailableException extends MetaMatrixRuntimeException {
 
 	private static final long serialVersionUID = 5569111182915674334L;
 

Modified: trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/connector-api/src/main/java/org/teiid/connector/basic/BasicManagedConnectionFactory.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -179,15 +179,6 @@
 	}
 
 	@Override
-	public boolean isSynchWorkers() {
-		return synchWorkers;
-	}
-
-	public void setSynchWorkers(Boolean arg0) {
-		this.synchWorkers = arg0.booleanValue();
-	}
-
-	@Override
 	public Properties getOverrideCapabilities() throws ConnectorException {
 		if (this.overrideCapabilities == null && this.overrideCapabilitiesFile != null) {
 			try {

Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/RuntimeMetadata.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/RuntimeMetadata.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/RuntimeMetadata.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -34,14 +34,14 @@
      * @param fullName
      * @return The object
      */
-    Table getGroup(String fullName) throws ConnectorException;
+    Table getTable(String fullName) throws ConnectorException;
 
     /**
      * Look up an object by identifier
      * @param fullName
      * @return The object
      */
-    Column getElement(String fullName) throws ConnectorException;
+    Column getColumn(String fullName) throws ConnectorException;
 
     /**
      * Look up an object by identifier

Modified: trunk/engine/pom.xml
===================================================================
--- trunk/engine/pom.xml	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/pom.xml	2010-03-12 21:47:08 UTC (rev 1961)
@@ -58,10 +58,14 @@
 		<dependency>
 			<groupId>javax.resource</groupId>
 			<artifactId>connector-api</artifactId>
-			<scope>provided</scope>
 		</dependency>
 
 		<dependency>
+			<groupId>javax.transaction</groupId>
+                <artifactId>jta</artifactId>
+		</dependency>
+
+		<dependency>
 			<groupId>org.jboss.deployers</groupId>
 			<artifactId>jboss-deployers-vfs-spi</artifactId>
 			<scope>provided</scope>

Modified: trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -42,9 +42,6 @@
     // by default we support implicit close.
     private boolean supportsImplicitClose = true;
 
-    // this flag is used to notify the connector state
-    private boolean requestClosed;
-    
     private boolean isTransactional;
     
     private List<Exception> warnings;
@@ -53,15 +50,11 @@
 	public AtomicResultsMessage() {
 	}
 	
-	public AtomicResultsMessage(AtomicRequestMessage msg, List[] results, String[] dataTypes) {
-		this(msg);
+	public AtomicResultsMessage(List[] results, String[] dataTypes) {
 		this.dataTypes = dataTypes;
         this.results = results;
 	}
 	
-	public AtomicResultsMessage(AtomicRequestMessage msg) {
-	}
-	
     public boolean supportsImplicitClose() {
         return this.supportsImplicitClose;
     }
@@ -78,15 +71,7 @@
         finalRow = i;
     }
 
-    public boolean isRequestClosed() {
-        return this.requestClosed;
-    }
-
-    public void setRequestClosed(boolean requestClosed) {
-        this.requestClosed = requestClosed;
-    }     
-    
-	public  List[] getResults() {
+	public List[] getResults() {
 		return results;
 	}
 
@@ -95,7 +80,6 @@
         results = BatchSerializer.readBatch(in, dataTypes);
         finalRow = in.readInt();
         supportsImplicitClose = in.readBoolean();
-        requestClosed = in.readBoolean();
         warnings = (List<Exception>)in.readObject();
 	}
 
@@ -104,7 +88,6 @@
         BatchSerializer.writeBatch(out, dataTypes, results);
         out.writeInt(finalRow);
         out.writeBoolean(supportsImplicitClose);
-        out.writeBoolean(requestClosed);
         out.writeObject(warnings);
 	}
 

Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/SessionService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/SessionService.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/SessionService.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -138,9 +138,6 @@
      */
     public void pingServer(long sessionID) throws InvalidSessionException;
     
-    
-    public void setLocalSession(long sessionID);
-    
     SessionMetadata getActiveSession(long sessionID);
     
 	void setDqp(DQPCore dqp);

Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -24,20 +24,17 @@
 
 import java.io.Serializable;
 import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.resource.spi.work.ExecutionContext;
+import javax.transaction.Transaction;
 
 public class TransactionContext extends ExecutionContext implements Serializable{
 
 	private static final long serialVersionUID = -8689401273499649058L;
 
 	public enum Scope {
-		BLOCK,
 		GLOBAL,
 		LOCAL,
 		NONE,
@@ -47,14 +44,19 @@
     private String threadId;
     private Scope transactionType = Scope.NONE;
     private long creationTime;
-    private boolean rollback = false;
+    private boolean rollback;
+    private Transaction transaction;
+    private boolean embeddedTransaction;
     private Set<String> suspendedBy = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
-    private Map<String, AtomicInteger> txnSources = Collections.synchronizedMap(new HashMap<String, AtomicInteger>());
     
-    public boolean isInTransaction() {
-        return (getXid() != null && this.txnSources.size() > 0);
-    }
-
+    public boolean isEmbeddedTransaction() {
+		return embeddedTransaction;
+	}
+    
+    public void setEmbeddedTransaction(boolean embeddedTransaction) {
+		this.embeddedTransaction = embeddedTransaction;
+	}
+    
     public long getCreationTime() {
 		return creationTime;
 	}
@@ -78,17 +80,25 @@
     public String getThreadId() {
         return threadId;
     }
+    
+    public Transaction getTransaction() {
+		return transaction;
+	}
+    
+    public void setTransaction(Transaction transaction) {
+		this.transaction = transaction;
+	}
 
     public String toString() {
         StringBuffer sb = new StringBuffer();
-        this.buildString(sb);
+        if (getXid() != null) {
+        	sb.append("xid: ").append(getXid()); //$NON-NLS-1$
+        } else {
+        	sb.append(transaction);
+        }
         return sb.toString();
     }
 
-    private void buildString(StringBuffer sb) {
-        sb.append("xid: ").append(getXid()); //$NON-NLS-1$
-    }
-    
     public void setRollbackOnly() {
     	this.rollback = true;
     }
@@ -101,17 +111,4 @@
         return this.suspendedBy;
     }
 
-	public void incrementPartcipatingSourceCount(String source) {
-		AtomicInteger count = txnSources.get(source);
-		if (count == null) {
-			txnSources.put(source, new AtomicInteger(1));
-		}
-		else {
-			count.incrementAndGet();
-		}
-	}
-	
-	public boolean isOnePhase() {
-		return this.txnSources.size() == 1;
-	}    
 }
\ No newline at end of file

Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -39,13 +39,17 @@
 public interface TransactionService {
     
     // processor level methods
-    TransactionContext start(TransactionContext context) throws XATransactionException;
+    TransactionContext begin(TransactionContext context) throws XATransactionException;
 
     TransactionContext commit(TransactionContext context) throws XATransactionException;
 
     TransactionContext rollback(TransactionContext context) throws XATransactionException;
 
     TransactionContext getOrCreateTransactionContext(String threadId);
+    
+    void suspend(TransactionContext context) throws XATransactionException;
+    
+    void resume(TransactionContext context) throws XATransactionException;
 
     // local transaction methods
     TransactionContext begin(String threadId) throws XATransactionException;

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/AsynchConnectorWorkItem.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,69 +0,0 @@
-/*
- * 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.dqp.internal.datamgr.impl;
-
-import javax.resource.spi.work.WorkEvent;
-import javax.resource.spi.work.WorkManager;
-
-import org.teiid.connector.api.ConnectorException;
-
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
-
-public class AsynchConnectorWorkItem extends ConnectorWorkItem {
-    private WorkManager workManager;            
-	
-    AsynchConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver, WorkManager wm) throws ConnectorException {
-    	super(message, manager, resultsReceiver);
-    	this.workManager = wm;
-    }
-    
-    @Override
-    protected boolean dataNotAvailable(long delay) {
-    	try {
-			this.manager.scheduleTask(workManager, this, delay);
-		} catch (ConnectorException e) {
-			throw new MetaMatrixRuntimeException(e.getCause());
-		}
-    	return false;
-    }
-    
-	@Override
-    protected void resumeProcessing() {
-    	try {
-			this.manager.reenqueueRequest(workManager, this);
-		} catch (ConnectorException e) {
-			throw new MetaMatrixRuntimeException(e.getCause());
-		}
-    }
-
-	@Override
-	public void workCompleted(WorkEvent arg0) {
-		if (this.lastBatch) {
-			manager.removeState(this.id);
-			sendClose();
-		}
-	}	
-}
\ No newline at end of file

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -32,9 +32,6 @@
 
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkException;
-import javax.resource.spi.work.WorkManager;
 
 import org.jboss.managed.api.annotation.ManagementComponent;
 import org.jboss.managed.api.annotation.ManagementObject;
@@ -45,7 +42,6 @@
 import org.teiid.connector.api.Connection;
 import org.teiid.connector.api.Connector;
 import org.teiid.connector.api.ConnectorCapabilities;
-import org.teiid.connector.api.ConnectorEnvironment;
 import org.teiid.connector.api.ConnectorException;
 import org.teiid.connector.api.ExecutionContext;
 import org.teiid.connector.basic.WrappedConnection;
@@ -54,20 +50,18 @@
 import org.teiid.connector.metadata.runtime.MetadataStore;
 import org.teiid.dqp.internal.cache.DQPContextCache;
 import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
+import org.teiid.dqp.internal.process.StatsCapturingWorkManager;
 import org.teiid.logging.api.CommandLogMessage;
 import org.teiid.logging.api.CommandLogMessage.Event;
 import org.teiid.security.SecurityHelper;
 
-import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.queue.StatsCapturingWorkManager;
 import com.metamatrix.common.util.LogConstants;
 import com.metamatrix.core.log.MessageLevel;
 import com.metamatrix.core.util.Assertion;
 import com.metamatrix.dqp.DQPPlugin;
 import com.metamatrix.dqp.message.AtomicRequestID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
 import com.metamatrix.dqp.service.BufferService;
 import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
 import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
@@ -88,11 +82,8 @@
 	public static final int DEFAULT_MAX_THREADS = 20;
 	private String connectorName;
 	    
-    private StatsCapturingWorkManager workManager;
     private SecurityHelper securityHelper;
     
-    protected ConnectorWorkItemFactory workItemFactory;
-    
     private volatile ConnectorStatus state = ConnectorStatus.NOT_INITIALIZED;
 
     //services acquired in start
@@ -109,13 +100,12 @@
 	
     public ConnectorManager(String name, int maxThreads, SecurityHelper securityHelper) {
     	if (name == null) {
-    		throw new IllegalArgumentException("Connector name can not be null");
+    		throw new IllegalArgumentException("Connector name can not be null"); //$NON-NLS-1$
     	}
     	if (maxThreads <= 0) {
     		maxThreads = DEFAULT_MAX_THREADS;
     	}
     	this.connectorName = name;
-    	this.workManager = new StatsCapturingWorkManager(this.connectorName, maxThreads);
     	this.securityHelper = securityHelper;
     }
     
@@ -176,89 +166,22 @@
         }
     }
     
-    public void executeRequest(WorkManager workManager, ResultsReceiver<AtomicResultsMessage> receiver, AtomicRequestMessage message) throws ConnectorException {
+    public ConnectorWork executeRequest(AtomicRequestMessage message) throws ConnectorException {
         // Set the connector ID to be used; if not already set. 
     	checkStatus();
     	AtomicRequestID atomicRequestId = message.getAtomicRequestID();
     	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {atomicRequestId, "Create State"}); //$NON-NLS-1$
 
-    	ConnectorWorkItem item = workItemFactory.createWorkItem(message, receiver, workManager);
-    	
+    	ConnectorWorkItem item = new ConnectorWorkItem(message, this);
         Assertion.isNull(requestStates.put(atomicRequestId, item), "State already existed"); //$NON-NLS-1$
-		enqueueRequest(workManager, item);
+        return item;
     }
     
-    private void enqueueRequest(WorkManager workManager, ConnectorWorkItem work) throws ConnectorException {
-        try {
-        	// if connector is immutable, then we do not want pass-on the transaction context.
-        	if (work.securityContext.isTransactional()) {
-        		this.workManager.scheduleWork(workManager, work, work.requestMsg.getTransactionContext(), 0);
-        	}
-        	else {
-        		this.workManager.scheduleWork(workManager, work);
-        	}
-		} catch (WorkException e) {
-			throw new ConnectorException(e);
-		}
-    }
-    
-    void reenqueueRequest(WorkManager workManager, AsynchConnectorWorkItem work)  throws ConnectorException {
-    	enqueueRequest(workManager, work);
-    }
-    
-    ConnectorWorkItem getState(AtomicRequestID requestId) {
+    ConnectorWork getState(AtomicRequestID requestId) {
         return requestStates.get(requestId);
     }
     
-    @SuppressWarnings("unused")
-	public void requstMore(AtomicRequestID requestId) throws ConnectorException {
-    	ConnectorWorkItem workItem = getState(requestId);
-    	if (workItem == null) {
-    		return; //already closed
-    	}
-	    workItem.requestMore();
-    }
-    
-    public void cancelRequest(AtomicRequestID requestId) {
-    	ConnectorWorkItem workItem = getState(requestId);
-    	if (workItem == null) {
-    		return; //already closed
-    	}
-	    workItem.requestCancel();
-    }
-    
-    public void closeRequest(AtomicRequestID requestId) {
-    	ConnectorWorkItem workItem = getState(requestId);
-    	if (workItem == null) {
-    		return; //already closed
-    	}
-	    workItem.requestClose();
-    }
-    
     /**
-     * Schedule a task to be executed after the specified delay (in milliseconds) 
-     * @param task The task to execute
-     * @param delay The delay to wait (in ms) before executing the task
-     * @since 4.3.3
-     */
-    public void scheduleTask(WorkManager workManager, final AsynchConnectorWorkItem state, long delay) throws ConnectorException {
-    	try {
-			this.workManager.scheduleWork(workManager, new Work() {
-				@Override
-				public void run() {
-					state.requestMore();
-				}
-				@Override
-				public void release() {
-					
-				}
-			}, null, delay);
-		} catch (WorkException e) {
-			throw new ConnectorException(e);
-		}        
-    }
-    
-    /**
      * Remove the state associated with
      * the given <code>RequestID</code>.
      */
@@ -278,7 +201,7 @@
     /**
      * initialize this <code>ConnectorManager</code>.
      */
-    public synchronized void start() throws ConnectorException {
+    public synchronized void start() {
     	if (this.state != ConnectorStatus.NOT_INITIALIZED) {
     		return;
     	}
@@ -286,15 +209,6 @@
         
         LogManager.logInfo(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorManagerImpl.Initializing_connector", connectorName)); //$NON-NLS-1$
 
-     	ConnectorEnvironment connectorEnv = null;
-		
-		connectorEnv = getConnector().getConnectorEnvironment();
-    	
-    	if (!connectorEnv.isSynchWorkers() && connectorEnv.isXaCapable()) {
-    		throw new ConnectorException(DQPPlugin.Util.getString("ConnectorManager.xa_capbility_not_supported", this.connectorName)); //$NON-NLS-1$
-    	}
-
-		this.workItemFactory = new ConnectorWorkItemFactory(this, connectorEnv.isSynchWorkers());
     	this.state = ConnectorStatus.OPEN;
     }
     
@@ -309,19 +223,10 @@
             this.state= ConnectorStatus.CLOSED;
 		}
         
-        if (workManager != null) {
-        	this.workManager.shutdownNow();
-        }
-        
         //ensure that all requests receive a response
-        for (ConnectorWorkItem workItem : this.requestStates.values()) {
-        	try {
-        		workItem.resultsReceiver.exceptionOccurred(new ConnectorException(DQPPlugin.Util.getString("Connector_Shutting_down", new Object[] {workItem.id, this.connectorName}))); //$NON-NLS-1$
-        	} catch (Exception e) {
-        		//ignore
-        	}
+        for (ConnectorWork workItem : this.requestStates.values()) {
+    		workItem.cancel();
 		}
-        
     }
 
     /**
@@ -329,10 +234,10 @@
      * this service.
      * If there are no queues, an empty Collection is returned.
      */
-    @ManagementProperty(description="Get Runtime workmanager statistics", use={ViewUse.STATISTIC}, readOnly=true)
+   /* @ManagementProperty(description="Get Runtime workmanager statistics", use={ViewUse.STATISTIC}, readOnly=true)
     public WorkerPoolStatisticsMetadata getWorkManagerStatistics() {
         return workManager.getStats();
-    }
+    }*/
 
     /**
      * Add begin point to transaction monitoring table.

Added: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -0,0 +1,42 @@
+/*
+ * 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.dqp.internal.datamgr.impl;
+
+import org.teiid.connector.api.ConnectorException;
+
+import com.metamatrix.dqp.message.AtomicResultsMessage;
+
+/**
+ * Represents a connector execution in batched form.
+ */
+public interface ConnectorWork {
+
+	void cancel();
+
+	AtomicResultsMessage more() throws ConnectorException;
+
+	void close();
+
+	AtomicResultsMessage execute() throws ConnectorException;
+
+}
\ No newline at end of file


Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -27,8 +27,6 @@
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import javax.resource.spi.work.WorkEvent;
-
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.connector.api.Connection;
 import org.teiid.connector.api.Connector;
@@ -44,14 +42,11 @@
 import org.teiid.connector.metadata.runtime.RuntimeMetadata;
 import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
 import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
-import org.teiid.dqp.internal.process.AbstractWorkItem;
-import org.teiid.dqp.internal.process.DQPWorkContext;
 import org.teiid.logging.api.CommandLogMessage.Event;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.comm.exception.CommunicationException;
+import com.metamatrix.common.buffer.TupleBuffer;
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.common.types.TransformationException;
@@ -68,50 +63,37 @@
 import com.metamatrix.query.sql.lang.StoredProcedure;
 import com.metamatrix.query.sql.symbol.SingleElementSymbol;
 
-public abstract class ConnectorWorkItem extends AbstractWorkItem {
+public class ConnectorWorkItem implements ConnectorWork {
 	
-	private static class NeedsClosedException extends Exception {}
-	
 	/* Permanent state members */
-    protected AtomicRequestID id;
-    protected ConnectorManager manager;
-    protected AtomicRequestMessage requestMsg;
-    protected Connector connector;
-    QueryMetadataInterface queryMetadata;
+	private AtomicRequestID id;
+    private ConnectorManager manager;
+    private AtomicRequestMessage requestMsg;
+    private Connector connector;
+    private QueryMetadataInterface queryMetadata;
     
     /* Created on new request */
-    protected Connection connection;
-    protected ConnectorEnvironment connectorEnv;
-    protected ExecutionContextImpl securityContext;
-    protected volatile ResultSetExecution execution;
-    protected ProcedureBatchHandler procedureBatchHandler;
+    private Connection connection;
+    private ConnectorEnvironment connectorEnv;
+    private ExecutionContextImpl securityContext;
+    private volatile ResultSetExecution execution;
+    private ProcedureBatchHandler procedureBatchHandler;
     private org.teiid.connector.language.Command translatedCommand;
     private Class<?>[] schema;
     private List<Integer> convertToRuntimeType;
     private boolean[] convertToDesiredRuntimeType;
         
     /* End state information */    
-    protected boolean lastBatch;
-    protected int rowCount;
+    private boolean lastBatch;
+    private int rowCount;
+    private boolean error;
     
-    protected enum RequestState {
-    	NEW, MORE, CLOSE
-    }
-        
-    protected RequestState requestState = RequestState.NEW;
-    
     private AtomicBoolean isCancelled = new AtomicBoolean();
-    private volatile boolean moreRequested;
-    private volatile boolean closeRequested;
-    private boolean isClosed;
-
-    protected ResultsReceiver<AtomicResultsMessage> resultsReceiver;
     
-    ConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) throws ConnectorException {
+    ConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager) throws ConnectorException {
         this.id = message.getAtomicRequestID();
         this.requestMsg = message;
         this.manager = manager;
-        this.resultsReceiver = resultsReceiver;
         AtomicRequestID requestID = this.requestMsg.getAtomicRequestID();
         this.securityContext = new ExecutionContextImpl(requestMsg.getWorkContext().getVdbName(),
                 requestMsg.getWorkContext().getVdbVersion(),                
@@ -144,112 +126,38 @@
         	throw new ConnectorException(e);
         }
     }
-
-    protected void createConnection() throws ConnectorException {
-        LogManager.logTrace(LogConstants.CTX_CONNECTOR, new Object[] {id, "creating connection for atomic-request"});  //$NON-NLS-1$
-    	this.connection = this.connector.getConnection();
-    }
     
-    protected void process() {
-    	DQPWorkContext.setWorkContext(this.requestMsg.getWorkContext());
-    	boolean success = true;
-    	try {
-    		checkForCloseEvent();
-    		switch (this.requestState) {
-	    		case NEW:
-    				createExecution();
-		    		//prior to processing new, mark me as MORE
-		        	if (this.requestState == RequestState.NEW) {
-		        		this.requestState = RequestState.MORE;
-		        		checkForCloseEvent();
-			        	processNewRequest();
-		        	}
-		        	break;
-	    		case MORE:
-	    			processMoreRequest();
-	    			break;
-	    		case CLOSE:
-	    			return;
-    		}
-			if (lastBatch && !this.securityContext.keepExecutionAlive()) {
-				this.requestState = RequestState.CLOSE;
-			}
-		} catch (NeedsClosedException e) {
-    		this.requestState = RequestState.CLOSE;
-    	} catch (Throwable t){
-    		success = false;
-    		this.requestState = RequestState.CLOSE;
-        	handleError(t);
-        } finally {
-        	if (this.requestState == RequestState.CLOSE) {
-    			processClose(success);
-        	} 
-        	DQPWorkContext.releaseWorkContext();
-        }
-    }
-
-	private void checkForCloseEvent() throws NeedsClosedException {
-		if (this.isCancelled.get() || this.closeRequested) {
-			throw new NeedsClosedException();
-		}
+    public AtomicRequestID getId() {
+		return id;
 	}
-    
-    public void requestCancel() {
+
+    public void cancel() {
     	try {
             LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Processing CANCEL request"}); //$NON-NLS-1$
-            asynchCancel();
-            this.manager.logSRCCommand(this.requestMsg, this.securityContext, Event.CANCEL, -1);
+            if (this.isCancelled.compareAndSet(false, true)) {
+                this.manager.logSRCCommand(this.requestMsg, this.securityContext, Event.CANCEL, -1);
+    	        if(execution != null) {
+    	            execution.cancel();
+    	        }            
+    	        LogManager.logDetail(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("DQPCore.The_atomic_request_has_been_cancelled", this.id)); //$NON-NLS-1$
+        	}
         } catch (ConnectorException e) {
             LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, DQPPlugin.Util.getString("Cancel_request_failed", this.id)); //$NON-NLS-1$
-        } finally {
-    		moreWork();
         }
     }
     
-    public synchronized void requestMore() {
-    	Assertion.assertTrue(!this.moreRequested, "More already requested"); //$NON-NLS-1$
-    	this.moreRequested = true;
-    	Assertion.assertTrue(!this.lastBatch, "More should not be requested after the last batch"); //$NON-NLS-1$
-    	assert this.requestState != RequestState.NEW : "More should not be requested during NEW"; //$NON-NLS-1$
-		moreWork();
-    }
-    
-    public synchronized void requestClose() {
-    	if (this.requestState == RequestState.CLOSE || this.closeRequested) {
-    		LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Already closing request"}); //$NON-NLS-1$
-    		return;
+    public AtomicResultsMessage more() throws ConnectorException {
+    	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Processing MORE request"}); //$NON-NLS-1$
+    	try {
+    		return handleBatch();
+    	} catch (Throwable t) {
+    		throw handleError(t);
     	}
-    	this.closeRequested = true;
-    	moreWork();
     }
     
-    private void handleError(Throwable t) {
-    	if (t instanceof RuntimeException && t.getCause() != null) {
-    		t = t.getCause();
-    	}
-        manager.logSRCCommand(this.requestMsg, this.securityContext, Event.ERROR, null);
-        
-        String msg = DQPPlugin.Util.getString("ConnectorWorker.process_failed", this.id); //$NON-NLS-1$
-        if (isCancelled.get()) {            
-            LogManager.logDetail(LogConstants.CTX_CONNECTOR, msg);
-        } else if (t instanceof ConnectorException || t instanceof MetaMatrixProcessingException) {
-        	LogManager.logWarning(LogConstants.CTX_CONNECTOR, t, msg);
-        } else {
-            LogManager.logError(LogConstants.CTX_CONNECTOR, t, msg);
-        }    
-
-        if (!(t instanceof CommunicationException)) {
-            if (t instanceof ConnectorException) {
-                t = new ConnectorException(t, DQPPlugin.Util.getString("ConnectorWorker.error_occurred", this.manager.getName(), t.getMessage())); //$NON-NLS-1$
-            }        	
-            this.resultsReceiver.exceptionOccurred(t);
-        }
-    }
-    
-    protected void processClose(boolean success) {
-    	this.isClosed = true;
+    public void close() {
     	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Processing Close :", this.requestMsg.getCommand()}); //$NON-NLS-1$
-    	if (success) {
+    	if (!error) {
             manager.logSRCCommand(this.requestMsg, this.securityContext, Event.END, this.rowCount);
         }
         try {
@@ -262,119 +170,134 @@
         } catch (Throwable e) {
             LogManager.logError(LogConstants.CTX_CONNECTOR, e, e.getMessage());
         } finally {
-        	// Close the underlying connection, but send the close response only upon the notification from
-        	// container in workCompleted call.
+            manager.removeState(this.id);
             if (connection != null) {
                 connection.close();
                 LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Closed connection"}); //$NON-NLS-1$
             }
-        }        
+        } 
     }
-
-	protected void sendClose() {
-		AtomicResultsMessage response = new AtomicResultsMessage(this.requestMsg);
-		response.setRequestClosed(true);
-		this.resultsReceiver.receiveResults(response);
-	}
     
-    protected void processNewRequest() throws ConnectorException {
-    	// Execute query
-    	this.execution.execute();
-        LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Executed command"}); //$NON-NLS-1$
-
-        handleBatch();
-    }
-
-	protected void createExecution() throws MetaMatrixComponentException,
-			ConnectorException {
-    	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.requestMsg.getAtomicRequestID(), "Processing NEW request:", this.requestMsg.getCommand()}); //$NON-NLS-1$                                     
-		
-        createConnection();
+    private ConnectorException handleError(Throwable t) {
+    	if (t instanceof DataNotAvailableException) {
+    		throw (DataNotAvailableException)t;
+    	}
+    	error = true;
+    	if (t instanceof RuntimeException && t.getCause() != null) {
+    		t = t.getCause();
+    	}
+        manager.logSRCCommand(this.requestMsg, this.securityContext, Event.ERROR, null);
         
-        LogManager.logTrace(LogConstants.CTX_CONNECTOR, new Object[] {id, "creating execution for atomic-request"});  //$NON-NLS-1$
-
-        // Translate the command
-        Command command = this.requestMsg.getCommand();
-		List<SingleElementSymbol> symbols = this.requestMsg.getCommand().getProjectedSymbols();
-		this.schema = new Class[symbols.size()];
-		this.convertToDesiredRuntimeType = new boolean[symbols.size()];
-		this.convertToRuntimeType = new ArrayList<Integer>(symbols.size());
-		for (int i = 0; i < schema.length; i++) {
-			SingleElementSymbol symbol = symbols.get(i);
-			this.schema[i] = symbol.getType();
-			this.convertToDesiredRuntimeType[i] = true;
-			this.convertToRuntimeType.add(i);
+        String msg = DQPPlugin.Util.getString("ConnectorWorker.process_failed", this.id); //$NON-NLS-1$
+        if (isCancelled.get()) {            
+            LogManager.logDetail(LogConstants.CTX_CONNECTOR, msg);
+        } else if (t instanceof ConnectorException || t instanceof MetaMatrixProcessingException) {
+        	LogManager.logWarning(LogConstants.CTX_CONNECTOR, t, msg);
+        } else {
+            LogManager.logError(LogConstants.CTX_CONNECTOR, t, msg);
+        } 
+		if (t instanceof ConnectorException) {
+			return (ConnectorException)t;
 		}
+		if (t instanceof RuntimeException) {
+			throw (RuntimeException)t;
+		}
+		return new ConnectorException(t);
+    }
+    
+	public AtomicResultsMessage execute() throws ConnectorException {
+        if(isCancelled()) {
+    		throw new ConnectorException("Request canceled"); //$NON-NLS-1$
+    	}
 
-        LanguageBridgeFactory factory = new LanguageBridgeFactory(queryMetadata);
-        this.translatedCommand = factory.translate(command);
-
-        RuntimeMetadata rmd = new RuntimeMetadataImpl(queryMetadata);
-        
-        // Create the execution based on mode
-        final Execution exec = connection.createExecution(this.translatedCommand, this.securityContext, rmd);
-        if (this.translatedCommand instanceof Call) {
-        	Assertion.isInstanceOf(this.execution, ProcedureExecution.class, "IProcedure Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
-        	this.execution = (ProcedureExecution)exec;
-        	StoredProcedure proc = (StoredProcedure)command;
-        	if (proc.returnParameters()) {
-        		this.procedureBatchHandler = new ProcedureBatchHandler((Call)this.translatedCommand, (ProcedureExecution)this.execution);
-        	}
-        } else if (this.translatedCommand instanceof QueryExpression){
-        	Assertion.isInstanceOf(this.execution, ResultSetExecution.class, "IQueryCommand Executions are expected to be ResultSetExecutions"); //$NON-NLS-1$
-        	this.execution = (ResultSetExecution)exec;
-        } else {
-        	Assertion.isInstanceOf(this.execution, UpdateExecution.class, "Update Executions are expected to be UpdateExecutions"); //$NON-NLS-1$
-        	this.execution = new ResultSetExecution() {
-        		private int[] results;
-        		private int index;
-        		
-        		@Override
-        		public void cancel() throws ConnectorException {
-        			exec.cancel();
-        		}
-        		@Override
-        		public void close() throws ConnectorException {
-        			exec.close();
-        		}
-        		@Override
-        		public void execute() throws ConnectorException {
-        			exec.execute();
-        		}
-        		@Override
-        		public List<?> next() throws ConnectorException,
-        				DataNotAvailableException {
-        			if (results == null) {
-        				results = ((UpdateExecution)exec).getUpdateCounts();
-        			}
-        			if (index < results.length) {
-        				return Arrays.asList(results[index++]);
-        			}
-        			return null;
-        		}
-        	};
-        }
-        
-        LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.requestMsg.getAtomicRequestID(), "Obtained execution"}); //$NON-NLS-1$      
-        //Log the Source Command (Must be after obtaining the execution context)
-        manager.logSRCCommand(this.requestMsg, this.securityContext, Event.NEW, null); 
+    	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.requestMsg.getAtomicRequestID(), "Processing NEW request:", this.requestMsg.getCommand()}); //$NON-NLS-1$                                     
+    	try {
+	    	this.connection = this.connector.getConnection();
+	        
+	        // Translate the command
+	        Command command = this.requestMsg.getCommand();
+			List<SingleElementSymbol> symbols = this.requestMsg.getCommand().getProjectedSymbols();
+			this.schema = new Class[symbols.size()];
+			this.convertToDesiredRuntimeType = new boolean[symbols.size()];
+			this.convertToRuntimeType = new ArrayList<Integer>(symbols.size());
+			for (int i = 0; i < schema.length; i++) {
+				SingleElementSymbol symbol = symbols.get(i);
+				this.schema[i] = symbol.getType();
+				this.convertToDesiredRuntimeType[i] = true;
+				this.convertToRuntimeType.add(i);
+			}
+	
+	        LanguageBridgeFactory factory = new LanguageBridgeFactory(queryMetadata);
+	        this.translatedCommand = factory.translate(command);
+	
+	        RuntimeMetadata rmd = new RuntimeMetadataImpl(queryMetadata);
+	        
+	        // Create the execution based on mode
+	        final Execution exec = connection.createExecution(this.translatedCommand, this.securityContext, rmd);
+	        if (this.translatedCommand instanceof Call) {
+	        	Assertion.isInstanceOf(this.execution, ProcedureExecution.class, "IProcedure Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
+	        	this.execution = (ProcedureExecution)exec;
+	        	StoredProcedure proc = (StoredProcedure)command;
+	        	if (proc.returnParameters()) {
+	        		this.procedureBatchHandler = new ProcedureBatchHandler((Call)this.translatedCommand, (ProcedureExecution)this.execution);
+	        	}
+	        } else if (this.translatedCommand instanceof QueryExpression){
+	        	Assertion.isInstanceOf(this.execution, ResultSetExecution.class, "IQueryCommand Executions are expected to be ResultSetExecutions"); //$NON-NLS-1$
+	        	this.execution = (ResultSetExecution)exec;
+	        } else {
+	        	Assertion.isInstanceOf(this.execution, UpdateExecution.class, "Update Executions are expected to be UpdateExecutions"); //$NON-NLS-1$
+	        	this.execution = new ResultSetExecution() {
+	        		private int[] results;
+	        		private int index;
+	        		
+	        		@Override
+	        		public void cancel() throws ConnectorException {
+	        			exec.cancel();
+	        		}
+	        		@Override
+	        		public void close() throws ConnectorException {
+	        			exec.close();
+	        		}
+	        		@Override
+	        		public void execute() throws ConnectorException {
+	        			exec.execute();
+	        		}
+	        		@Override
+	        		public List<?> next() throws ConnectorException,
+	        				DataNotAvailableException {
+	        			if (results == null) {
+	        				results = ((UpdateExecution)exec).getUpdateCounts();
+	        			}
+	        			if (index < results.length) {
+	        				return Arrays.asList(results[index++]);
+	        			}
+	        			return null;
+	        		}
+	        	};
+	        }
+	        LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.requestMsg.getAtomicRequestID(), "Obtained execution"}); //$NON-NLS-1$      
+	        //Log the Source Command (Must be after obtaining the execution context)
+	        manager.logSRCCommand(this.requestMsg, this.securityContext, Event.NEW, null); 
+	        
+	        // Execute query
+	    	this.execution.execute();
+	        LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Executed command"}); //$NON-NLS-1$
+	
+	        return handleBatch();
+    	} catch (Throwable t) {
+    		throw handleError(t);
+    	}
 	}
     
-    protected void handleBatch() 
-        throws ConnectorException {
+    protected AtomicResultsMessage handleBatch() throws ConnectorException {
     	Assertion.assertTrue(!this.lastBatch);
         LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Sending results from connector"}); //$NON-NLS-1$
         int batchSize = 0;
         List<List> rows = new ArrayList<List>(batchSize/4);
-        boolean sendResults = true;
         
         try {
 	        while (batchSize < this.requestMsg.getFetchSize()) {
 	        	
-	        	if (shouldAbortProcessing()) {
-	        		throw new ConnectorException("Container requested to abort the operation!");
-	        	}
-	        	
         		List row = this.execution.next();
             	if (row == null) {
             		this.lastBatch = true;
@@ -403,7 +326,7 @@
 	        }
     	} catch (DataNotAvailableException e) {
     		if (rows.size() == 0) {
-    			sendResults = dataNotAvailable(e.getRetryDelay());
+    			throw e;
     		}
     	}
                 
@@ -416,26 +339,19 @@
         			this.rowCount++;
         		}
         	}
-            LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Obtained last batch, total row count:", rowCount}); //$NON-NLS-1$
+            LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Obtained last batch, total row count:", rowCount}); //$NON-NLS-1$\
         }   
         
-        if (sendResults) {
-        	sendResults(rows);
-        }
-    }
-
-	protected void sendResults(List<List> rows) {
-		int currentRowCount = rows.size();
+    	int currentRowCount = rows.size();
 		if ( !lastBatch && currentRowCount == 0 ) {
 		    // Defect 13366 - Should send all batches, even if they're zero size.
 		    // Log warning if received a zero-size non-last batch from the connector.
 		    LogManager.logWarning(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorWorker.zero_size_non_last_batch", requestMsg.getConnectorName())); //$NON-NLS-1$
 		}
 
-		AtomicResultsMessage response = createResultsMessage(this.requestMsg, rows.toArray(new List[currentRowCount]), requestMsg.getCommand().getProjectedSymbols());
+		AtomicResultsMessage response = createResultsMessage(rows.toArray(new List[currentRowCount]), requestMsg.getCommand().getProjectedSymbols());
 		
-		// if we need to keep the execution alive, then we can not support
-		// implicit close.
+		// if we need to keep the execution alive, then we can not support implicit close.
 		response.setSupportsImplicitClose(!this.securityContext.keepExecutionAlive());
 		response.setTransactional(this.securityContext.isTransactional());
 		response.setWarnings(this.securityContext.getWarnings());
@@ -443,7 +359,7 @@
 		if ( lastBatch ) {
 		    response.setFinalRow(rowCount);
 		} 
-		this.resultsReceiver.receiveResults(response);
+		return response;
 	}
 
 	private void correctTypes(List row) throws ConnectorException {
@@ -484,79 +400,18 @@
 		}
 	}
     
-    protected abstract boolean dataNotAvailable(long delay);
-    
-    private void processMoreRequest() throws ConnectorException {
-    	Assertion.assertTrue(this.moreRequested, "More was not requested"); //$NON-NLS-1$
-    	this.moreRequested = false;
-    	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Processing MORE request"}); //$NON-NLS-1$
-
-        handleBatch();
-    }
-            
-    public static AtomicResultsMessage createResultsMessage(AtomicRequestMessage message, List[] batch, List columnSymbols) {
-        String[] dataTypes = new String[columnSymbols.size()];
-
-        for(int i=0; i<columnSymbols.size(); i++) {
-            SingleElementSymbol symbol = (SingleElementSymbol) columnSymbols.get(i);
-            dataTypes[i] = DataTypeManager.getDataTypeName(symbol.getType());
-        }
-        
-        return new AtomicResultsMessage(message, batch, dataTypes);
+    public static AtomicResultsMessage createResultsMessage(List[] batch, List columnSymbols) {
+        String[] dataTypes = TupleBuffer.getTypeNames(columnSymbols);        
+        return new AtomicResultsMessage(batch, dataTypes);
     }    
             
-    void asynchCancel() throws ConnectorException {
-    	if (this.isCancelled.compareAndSet(false, true)) {
-	        if(execution != null) {
-	            execution.cancel();
-	        }            
-	        LogManager.logDetail(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("DQPCore.The_atomic_request_has_been_cancelled", this.id)); //$NON-NLS-1$
-    	}
-    }
-    
     boolean isCancelled() {
     	return this.isCancelled.get();
     }
 
 	@Override
-	protected boolean isDoneProcessing() {
-		return isClosed;
-	}
-	
-	@Override
 	public String toString() {
 		return this.id.toString();
 	}
 
-	@Override
-	public void workCompleted(WorkEvent arg0) {
-        manager.removeState(this.id);
-        sendClose();
-	}
-
-	@Override
-	public void workRejected(WorkEvent event) {
-		try {
-			asynchCancel();
-		} catch (ConnectorException e) {
-			LogManager.logError(LogConstants.CTX_CONNECTOR, event.getException(), this.id.toString()); 
-		}
-	}
-	
-	@Override
-    protected boolean assosiateSecurityContext() {
-		DQPWorkContext context = requestMsg.getWorkContext();
-		if (context.getSubject() != null) {
-        	return manager.getSecurityHelper().assosiateSecurityContext(context.getSecurityDomain(), context.getSecurityContext());			
-		}
-		return false;
-	}
-    
-	@Override
-    protected void clearSecurityContext() {
-		DQPWorkContext context = requestMsg.getWorkContext();
-		if (context.getSubject() != null) {
-			manager.getSecurityHelper().clearSecurityContext(context.getSecurityDomain());			
-		}
-	}
 }
\ No newline at end of file

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItemFactory.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,52 +0,0 @@
-/*
- * 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.dqp.internal.datamgr.impl;
-
-
-
-import javax.resource.spi.work.WorkManager;
-
-import org.teiid.connector.api.ConnectorException;
-
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
-
-public class ConnectorWorkItemFactory {
-	
-	private ConnectorManager manager;
-	private boolean synchWorkers;
-
-	public ConnectorWorkItemFactory(ConnectorManager manager, boolean synchWorkers) {
-		this.manager = manager;
-		this.synchWorkers = synchWorkers;
-	}
-	
-	public ConnectorWorkItem createWorkItem(AtomicRequestMessage message, ResultsReceiver<AtomicResultsMessage> receiver, WorkManager wm) throws ConnectorException {
-    	if (synchWorkers) {
-    		return new SynchConnectorWorkItem(message, manager, receiver);
-    	} 
-    	return new AsynchConnectorWorkItem(message, manager, receiver, wm);
-	}
-	
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,156 +0,0 @@
-/*
- * 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.dqp.internal.datamgr.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.Semaphore;
-
-import javax.resource.spi.work.WorkEvent;
-import javax.transaction.xa.Xid;
-
-import org.teiid.connector.api.ConnectorException;
-
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.service.TransactionContext;
-
-public class SynchConnectorWorkItem extends ConnectorWorkItem {
-
-	private static class TransactionLock {
-		Semaphore lock = new Semaphore(1, true);
-		int pendingCount;
-	}
-
-	private static Map<Xid, TransactionLock> TRANSACTION_LOCKS = new HashMap<Xid, TransactionLock>();
-
-	private TransactionLock lock;
-
-	SynchConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver) throws ConnectorException  {
-		super(message, manager, resultsReceiver);
-		
-		// since container makes sure that there is no current work registered under current transaction it is
-		// required that lock must be acquired before we schedule the work.
-		try {
-			acquireTransactionLock();
-		} catch (InterruptedException e) {
-			interrupted(e);
-		} 			
-	}
-	
-	@Override
-	public void run() {
-		while (!this.isDoneProcessing()) { //process until closed
-			super.run();
-		}
-	}
-
-	@Override
-	protected void pauseProcessing() {
-		try {
-			while (isIdle()) {
-				this.wait();
-			}
-		} catch (InterruptedException e) {
-			interrupted(e);
-		}
-	}
-
-	private void interrupted(InterruptedException e) {
-		LogManager.logDetail(LogConstants.CTX_CONNECTOR, e, this.id +" Interrupted, proceeding to close"); //$NON-NLS-1$
-		this.requestCancel();
-	}
-
-	@Override
-	protected void resumeProcessing() {
-		this.notify();
-	}
-	
-	private void acquireTransactionLock() throws InterruptedException {		
-		if (!this.requestMsg.isTransactional()) {
-			return;
-		}
-		TransactionContext tc = this.requestMsg.getTransactionContext();		
-		Xid key = tc.getXid();
-
-		TransactionLock existing = null;
-		synchronized (TRANSACTION_LOCKS) {
-			existing = TRANSACTION_LOCKS.get(key);
-			if (existing == null) {
-				existing = new TransactionLock();
-				TRANSACTION_LOCKS.put(key, existing);
-			}
-			existing.pendingCount++;
-			tc.incrementPartcipatingSourceCount(requestMsg.getConnectorName());
-		}
-		existing.lock.acquire();
-		this.lock = existing;
-		LogManager.logTrace("got the connector lock on =", key);
-	}
-
-	private void releaseTxnLock() {
-		if (!this.requestMsg.isTransactional() || this.lock == null) {
-			return;
-		}
-		TransactionContext tc = this.requestMsg.getTransactionContext();
-		synchronized (TRANSACTION_LOCKS) {
-			lock.pendingCount--;
-			if (lock.pendingCount == 0) {
-				Xid key = tc.getXid();
-				TRANSACTION_LOCKS.remove(key);
-				LogManager.logTrace("released the connector lock on =", key);
-			}
-		}
-		lock.lock.release();
-		this.lock = null;
-	}
-	
-    @Override
-    protected boolean dataNotAvailable(long delay) {
-		LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {
-				"AtomicRequest", id, "On connector", manager.getName(), " threw a DataNotAvailableException, but will be ignored since this is a Synch Connector." }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
-    	return true;
-    }
-
-    
-	@Override
-	public void workCompleted(WorkEvent event) {
-		try {
-			super.workCompleted(event);
-		} finally {
-			releaseTxnLock();
-		}
-	}
-
-	@Override
-	public void workRejected(WorkEvent event) {
-		try {
-			super.workRejected(event);
-		} finally {
-			releaseTxnLock();
-		}
-	}
-}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -63,6 +63,8 @@
 import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.dqp.message.ParameterInfo;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.metadata.TempMetadataID;
@@ -118,7 +120,7 @@
         }
     }
 
-    public org.teiid.connector.language.Command translate(Command command) throws MetaMatrixComponentException {
+    public org.teiid.connector.language.Command translate(Command command) {
         if (command == null) return null;
         if (command instanceof Query) {
             return translate((Query)command);
@@ -138,14 +140,14 @@
         throw new AssertionError();
     }
     
-    QueryExpression translate(QueryCommand command) throws MetaMatrixComponentException {
+    QueryExpression translate(QueryCommand command) {
     	if (command instanceof Query) {
             return translate((Query)command);
         } 
     	return translate((SetQuery)command);
     }
 
-    org.teiid.connector.language.SetQuery translate(SetQuery union) throws MetaMatrixComponentException {
+    org.teiid.connector.language.SetQuery translate(SetQuery union) {
         org.teiid.connector.language.SetQuery result = new org.teiid.connector.language.SetQuery();
         result.setAll(union.isAll());
         switch (union.getOperation()) {
@@ -167,7 +169,7 @@
     }
 
     /* Query */
-    Select translate(Query query) throws MetaMatrixComponentException {
+    Select translate(Query query) {
         List symbols = query.getSelect().getSymbols();
         List<DerivedColumn> translatedSymbols = new ArrayList<DerivedColumn>(symbols.size());
         for (Iterator i = symbols.iterator(); i.hasNext();) {
@@ -206,7 +208,7 @@
         return q;
     }
 
-    public TableReference translate(FromClause clause) throws MetaMatrixComponentException {
+    public TableReference translate(FromClause clause) {
         if (clause == null) return null;
         if (clause instanceof JoinPredicate) {
             return translate((JoinPredicate)clause);
@@ -218,7 +220,7 @@
         throw new AssertionError();
     }
 
-    Join translate(JoinPredicate join) throws MetaMatrixComponentException {
+    Join translate(JoinPredicate join) {
         List crits = join.getJoinCriteria();
         Criteria crit = null;
         if (crits.size() == 1) {
@@ -246,15 +248,15 @@
                             translate(crit));
     }
 
-    TableReference translate(SubqueryFromClause clause) throws MetaMatrixComponentException {        
+    TableReference translate(SubqueryFromClause clause) {        
         return new DerivedTable(translate((QueryCommand)clause.getCommand()), clause.getOutputName());
     }
 
-    NamedTable translate(UnaryFromClause clause) throws MetaMatrixComponentException {
+    NamedTable translate(UnaryFromClause clause) {
         return translate(clause.getGroup());
     }
 
-    public Condition translate(Criteria criteria) throws MetaMatrixComponentException {
+    public Condition translate(Criteria criteria) {
         if (criteria == null) return null;
         if (criteria instanceof CompareCriteria) {
             return translate((CompareCriteria)criteria);
@@ -278,7 +280,7 @@
         throw new AssertionError();
     }
 
-    org.teiid.connector.language.Comparison translate(CompareCriteria criteria) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Comparison translate(CompareCriteria criteria) {
         Operator operator = Operator.EQ;
         switch(criteria.getOperator()) {
             case CompareCriteria.EQ:    
@@ -306,7 +308,7 @@
                                         translate(criteria.getRightExpression()), operator);
     }
 
-    AndOr translate(CompoundCriteria criteria) throws MetaMatrixComponentException {
+    AndOr translate(CompoundCriteria criteria) {
         List nestedCriteria = criteria.getCriteria();
         int size = nestedCriteria.size();
         AndOr.Operator op = criteria.getOperator() == CompoundCriteria.AND?AndOr.Operator.AND:AndOr.Operator.OR;
@@ -317,15 +319,15 @@
         return result;
     }
 
-    Exists translate(ExistsCriteria criteria) throws MetaMatrixComponentException {
+    Exists translate(ExistsCriteria criteria) {
         return new Exists(translate((QueryCommand)criteria.getCommand()));
     }
 
-    IsNull translate(IsNullCriteria criteria) throws MetaMatrixComponentException {
+    IsNull translate(IsNullCriteria criteria) {
         return new IsNull(translate(criteria.getExpression()), criteria.isNegated());
     }
 
-    Like translate(MatchCriteria criteria) throws MetaMatrixComponentException {
+    Like translate(MatchCriteria criteria) {
         Character escapeChar = null;
         if(criteria.getEscapeChar() != MatchCriteria.NULL_ESCAPE_CHAR) {
             escapeChar = new Character(criteria.getEscapeChar());
@@ -336,7 +338,7 @@
                                     criteria.isNegated());
     }
 
-    In translate(SetCriteria criteria) throws MetaMatrixComponentException {
+    In translate(SetCriteria criteria) {
         List expressions = criteria.getValues();
         List translatedExpressions = new ArrayList();
         for (Iterator i = expressions.iterator(); i.hasNext();) {
@@ -347,7 +349,7 @@
                                   criteria.isNegated());
     }
 
-    SubqueryComparison translate(SubqueryCompareCriteria criteria) throws MetaMatrixComponentException {
+    SubqueryComparison translate(SubqueryCompareCriteria criteria) {
         Quantifier quantifier = Quantifier.ALL;
         switch(criteria.getPredicateQuantifier()) {
             case SubqueryCompareCriteria.ALL:   
@@ -389,17 +391,17 @@
                                   translate((QueryCommand)criteria.getCommand()));
     }
 
-    SubqueryIn translate(SubquerySetCriteria criteria) throws MetaMatrixComponentException {
+    SubqueryIn translate(SubquerySetCriteria criteria) {
         return new SubqueryIn(translate(criteria.getExpression()),
                                   criteria.isNegated(),
                                   translate((QueryCommand)criteria.getCommand()));
     }
 
-    Not translate(NotCriteria criteria) throws MetaMatrixComponentException {
+    Not translate(NotCriteria criteria) {
         return new Not(translate(criteria.getCriteria()));
     }
 
-    public org.teiid.connector.language.GroupBy translate(GroupBy groupBy) throws MetaMatrixComponentException {
+    public org.teiid.connector.language.GroupBy translate(GroupBy groupBy) {
         if(groupBy == null){
             return null;
         }
@@ -411,7 +413,7 @@
         return new org.teiid.connector.language.GroupBy(translatedItems);
     }
 
-    public org.teiid.connector.language.OrderBy translate(OrderBy orderBy) throws MetaMatrixComponentException {
+    public org.teiid.connector.language.OrderBy translate(OrderBy orderBy) {
         if(orderBy == null){
             return null;
         }
@@ -434,7 +436,7 @@
 
 
     /* Expressions */
-    public org.teiid.connector.language.Expression translate(Expression expr) throws MetaMatrixComponentException {
+    public org.teiid.connector.language.Expression translate(Expression expr) {
         if (expr == null) return null;
         if (expr instanceof Constant) {
             return translate((Constant)expr);
@@ -457,7 +459,7 @@
         return result;
     }
 
-    org.teiid.connector.language.Function translate(Function function) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Function translate(Function function) {
         Expression [] args = function.getArgs();
         List<org.teiid.connector.language.Expression> params = new ArrayList<org.teiid.connector.language.Expression>(args.length);
         if (args != null) {
@@ -468,7 +470,7 @@
         return new org.teiid.connector.language.Function(function.getName(), params, function.getType());
     }
 
-    SearchedCase translate(SearchedCaseExpression expr) throws MetaMatrixComponentException {
+    SearchedCase translate(SearchedCaseExpression expr) {
         ArrayList<SearchedWhenClause> whens = new ArrayList<SearchedWhenClause>();
         for (int i = 0; i < expr.getWhenCount(); i++) {
         	whens.add(new SearchedWhenClause(translate(expr.getWhenCriteria(i)), translate(expr.getThenExpression(i))));
@@ -479,11 +481,11 @@
     }
 
 
-    org.teiid.connector.language.Expression translate(ScalarSubquery ss) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Expression translate(ScalarSubquery ss) {
         return new org.teiid.connector.language.ScalarSubquery(translate((QueryCommand)ss.getCommand()));
     }
 
-    org.teiid.connector.language.Expression translate(SingleElementSymbol symbol) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Expression translate(SingleElementSymbol symbol) {
         if (symbol == null) return null;
         if (symbol instanceof ElementSymbol) {
             return translate((ElementSymbol)symbol);
@@ -495,11 +497,11 @@
         throw new AssertionError();
     }
 
-    org.teiid.connector.language.Expression translate(AliasSymbol symbol) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Expression translate(AliasSymbol symbol) {
         return translate(symbol.getSymbol());
     }
 
-    ColumnReference translate(ElementSymbol symbol) throws MetaMatrixComponentException {
+    ColumnReference translate(ElementSymbol symbol) {
         ColumnReference element = new ColumnReference(translate(symbol.getGroupSymbol()), symbol.getOutputName(), null, symbol.getType());
         if (element.getTable().getMetadataObject() == null) {
             return element;
@@ -513,20 +515,20 @@
         return element;
     }
 
-    AggregateFunction translate(AggregateSymbol symbol) throws MetaMatrixComponentException {
+    AggregateFunction translate(AggregateSymbol symbol) {
         return new AggregateFunction(symbol.getAggregateFunction(), 
                                 symbol.isDistinct(), 
                                 translate(symbol.getExpression()),
                                 symbol.getType());
     }
 
-    org.teiid.connector.language.Expression translate(ExpressionSymbol symbol) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Expression translate(ExpressionSymbol symbol) {
         return translate(symbol.getExpression());
     }
 
 
     /* Insert */
-    org.teiid.connector.language.Insert translate(Insert insert) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Insert translate(Insert insert) {
         List elements = insert.getVariables();
         List<ColumnReference> translatedElements = new ArrayList<ColumnReference>();
         for (Iterator i = elements.iterator(); i.hasNext();) {
@@ -552,13 +554,13 @@
     }
 
     /* Update */
-    org.teiid.connector.language.Update translate(Update update) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Update translate(Update update) {
         return new org.teiid.connector.language.Update(translate(update.getGroup()),
                               translate(update.getChangeList()),
                               translate(update.getCriteria()));
     }
     
-    List<org.teiid.connector.language.SetClause> translate(SetClauseList setClauseList) throws MetaMatrixComponentException {
+    List<org.teiid.connector.language.SetClause> translate(SetClauseList setClauseList) {
     	List<org.teiid.connector.language.SetClause> clauses = new ArrayList<org.teiid.connector.language.SetClause>(setClauseList.getClauses().size());
     	for (SetClause setClause : setClauseList.getClauses()) {
     		clauses.add(translate(setClause));
@@ -566,26 +568,26 @@
     	return clauses;
     }
     
-    org.teiid.connector.language.SetClause translate(SetClause setClause) throws MetaMatrixComponentException {
+    org.teiid.connector.language.SetClause translate(SetClause setClause) {
     	return new org.teiid.connector.language.SetClause(translate(setClause.getSymbol()), translate(setClause.getValue()));
     }
 
     /* Delete */
-    org.teiid.connector.language.Delete translate(Delete delete) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Delete translate(Delete delete) {
         org.teiid.connector.language.Delete deleteImpl = new org.teiid.connector.language.Delete(translate(delete.getGroup()),
                               translate(delete.getCriteria()));
         return deleteImpl;
     }
 
     /* Execute */
-    Call translate(StoredProcedure sp) throws MetaMatrixComponentException {
+    Call translate(StoredProcedure sp) {
         Procedure proc = null;
         if(sp.getProcedureID() != null) {
             try {
-                proc = this.metadataFactory.getProcedure(sp.getGroup().getName());
-            } catch(ConnectorException e) {
-                throw new MetaMatrixComponentException(e);
-            }
+				proc = this.metadataFactory.getProcedure(sp.getGroup().getName());
+			} catch (ConnectorException e) {
+				throw new MetaMatrixRuntimeException(e);
+			}
         }
         Class<?> returnType = null;
         List parameters = sp.getParameters();
@@ -623,7 +625,7 @@
         return call;
     }
 
-    public NamedTable translate(GroupSymbol symbol) throws MetaMatrixComponentException {
+    public NamedTable translate(GroupSymbol symbol) {
     	String alias = null;
         String fullGroup = symbol.getOutputName();
         if(symbol.getOutputDefinition() != null) {
@@ -636,10 +638,12 @@
 			return group;
 		}
         try {
-            group.setMetadataObject(metadataFactory.getGroup(symbol.getMetadataID()));
-        } catch(Exception e) {
-            throw new MetaMatrixComponentException(e);
-        }
+			group.setMetadataObject(metadataFactory.getGroup(symbol.getMetadataID()));
+		} catch (QueryMetadataException e) {
+			throw new MetaMatrixRuntimeException(e);
+		} catch (MetaMatrixComponentException e) {
+			throw new MetaMatrixRuntimeException(e);
+		}
         return group;
     }
 
@@ -653,7 +657,7 @@
 	}
     
     /* Batched Updates */
-    BatchedUpdates translate(BatchedUpdateCommand command) throws MetaMatrixComponentException {
+    BatchedUpdates translate(BatchedUpdateCommand command) {
         List updates = command.getUpdateCommands();
         List<org.teiid.connector.language.Command> translatedUpdates = new ArrayList<org.teiid.connector.language.Command>(updates.size());
         for (Iterator i = updates.iterator(); i.hasNext();) {
@@ -662,7 +666,7 @@
         return new BatchedUpdates(translatedUpdates);
     }
 
-    org.teiid.connector.language.Limit translate(Limit limit) throws MetaMatrixComponentException {
+    org.teiid.connector.language.Limit translate(Limit limit) {
         if (limit == null) {
             return null;
         }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -45,7 +45,7 @@
     }
     
     @Override
-    public Column getElement(String fullName) throws ConnectorException {
+    public Column getColumn(String fullName) throws ConnectorException {
 		try {
 			Object metadataId = metadata.getElementID(fullName);
 			return getElement(metadataId);
@@ -64,7 +64,7 @@
     }
     
     @Override
-    public Table getGroup(String fullName) throws ConnectorException {
+    public Table getTable(String fullName) throws ConnectorException {
 		try {
 			Object groupId = metadata.getGroupID(fullName);
 	    	return getGroup(groupId);

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AbstractWorkItem.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -40,16 +40,14 @@
     }
     
     private ThreadState threadState = ThreadState.MORE_WORK;
-    private volatile boolean release = false;
+    private volatile boolean release;
     
     public void run() {
     	try {
-    		assosiateSecurityContext();
     		startProcessing();
     		process();
     	} finally {
     		endProcessing();
-   			clearSecurityContext();
     	}
     }
     
@@ -131,10 +129,6 @@
 	
     protected abstract boolean isDoneProcessing();
     
-    protected abstract boolean assosiateSecurityContext();
-    
-    protected abstract void clearSecurityContext();
-    
     public abstract String toString();
     
 	@Override

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/AsyncRequestWorkItem.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,25 +0,0 @@
-package org.teiid.dqp.internal.process;
-
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.dqp.message.ResultsMessage;
-
-public class AsyncRequestWorkItem extends RequestWorkItem {
-
-	public AsyncRequestWorkItem(DQPCore dqpCore, RequestMessage requestMsg,
-			Request request, ResultsReceiver<ResultsMessage> receiver,
-			RequestID requestID, DQPWorkContext workContext) {
-		super(dqpCore, requestMsg, request, receiver, requestID, workContext);
-	}
-	
-	
-	@Override
-	protected void resumeProcessing() {
-		dqpCore.addWork(this);
-	}
-	
-	@Override
-	protected void pauseProcessing() {
-	}
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/ContainerServiceProvider.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,36 +0,0 @@
-/*
- * 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.dqp.internal.process;
-
-import javax.resource.spi.XATerminator;
-import javax.resource.spi.work.WorkManager;
-
-public interface ContainerServiceProvider {
-	
-	XATerminator getXATerminator();
-	
-	WorkManager getWorkManager();
-	
-	DQPConfiguration getDQPConfiguration();
-
-}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -43,31 +43,28 @@
 import org.teiid.adminapi.Admin;
 import org.teiid.adminapi.AdminException;
 import org.teiid.adminapi.impl.RequestMetadata;
-import org.teiid.adminapi.impl.SessionMetadata;
 import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
 import org.teiid.dqp.internal.cache.DQPContextCache;
 import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
 import org.teiid.logging.api.CommandLogMessage;
 import org.teiid.logging.api.CommandLogMessage.Event;
-import org.teiid.security.SecurityHelper;
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.security.SessionServiceException;
 import com.metamatrix.common.buffer.BufferManager;
 import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.common.lob.LobChunk;
 import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.queue.StatsCapturingWorkManager;
 import com.metamatrix.common.types.Streamable;
+import com.metamatrix.common.util.LogConstants;
 import com.metamatrix.common.xa.MMXid;
 import com.metamatrix.common.xa.XATransactionException;
 import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.core.log.MessageLevel;
 import com.metamatrix.core.util.Assertion;
 import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQP;
 import com.metamatrix.dqp.client.MetadataResult;
 import com.metamatrix.dqp.client.ResultsFuture;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
@@ -76,7 +73,6 @@
 import com.metamatrix.dqp.message.ResultsMessage;
 import com.metamatrix.dqp.service.AuthorizationService;
 import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.SessionService;
 import com.metamatrix.dqp.service.TransactionContext;
 import com.metamatrix.dqp.service.TransactionService;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -86,14 +82,16 @@
 /**
  * Implements the core DQP processing.
  */
-public class DQPCore implements ClientSideDQP {
+public class DQPCore implements DQP {
 	
 	private final static class FutureWork<T> implements Work, WorkListener {
 		private final ResultsReceiver<T> receiver;
 		private final Callable<T> toCall;
+		private DQPWorkContext workContext;
 
 		private FutureWork(ResultsReceiver<T> receiver,
 				Callable<T> processor) {
+			this.workContext = DQPWorkContext.getWorkContext();
 			this.receiver = receiver;
 			this.toCall = processor;
 		}
@@ -101,7 +99,7 @@
 		@Override
 		public void run() {
 			try {
-				receiver.receiveResults(toCall.call());
+				receiver.receiveResults(workContext.runInContext(toCall));
 			} catch (Throwable t) {
 				receiver.exceptionOccurred(t);
 			}
@@ -181,7 +179,6 @@
     private TransactionService transactionService;
     private AuthorizationService authorizationService;
     private BufferService bufferService;
-    private SessionService sessionService;
     private ConnectorManagerRepository connectorManagerRepository;
     
     // Query worker pool for processing plans
@@ -193,7 +190,6 @@
 	private Map<RequestID, RequestWorkItem> requests = new ConcurrentHashMap<RequestID, RequestWorkItem>();			
 	private Map<String, ClientState> clientState = Collections.synchronizedMap(new HashMap<String, ClientState>());
 	private DQPContextCache contextCache;
-	private SecurityHelper securityHelper;
     
     /**
      * perform a full shutdown and wait for 10 seconds for all threads to finish
@@ -205,7 +201,7 @@
 		} catch (InterruptedException e) {
 		}
     	// TODO: Should we be doing more cleanup here??
-		LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "Stopping the DQP"); //$NON-NLS-1$
+		LogManager.logDetail(LogConstants.CTX_DQP, "Stopping the DQP"); //$NON-NLS-1$
     }
     
     /**
@@ -308,8 +304,8 @@
 	
 	public ResultsFuture<ResultsMessage> processCursorRequest(long reqID,
 			int batchFirst, int fetchSize) throws MetaMatrixProcessingException {
-        if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
-            LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "DQP process cursor request from " + batchFirst);  //$NON-NLS-1$
+        if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+            LogManager.logDetail(LogConstants.CTX_DQP, "DQP process cursor request from " + batchFirst);  //$NON-NLS-1$
         }
 		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
         ResultsFuture<ResultsMessage> resultsFuture = new ResultsFuture<ResultsMessage>();
@@ -331,33 +327,48 @@
     	}
     	contextCache.removeRequestScopedCache(workItem.requestID.toString());
     }
-           
+    
     void addWork(Work work) {
+    	TransactionContext tc = null;
+    	if (work instanceof RequestWorkItem && this.transactionService != null) {
+    		tc = transactionService.getOrCreateTransactionContext(DQPWorkContext.getWorkContext().getConnectionID());
+    	}
     	try {
-			this.processWorkerPool.scheduleWork(this.workManager, work);
+			this.processWorkerPool.scheduleWork(work, tc, 0);
 		} catch (WorkException e) {
 			//TODO: cancel? close?
 			throw new MetaMatrixRuntimeException(e);
 		}
     }
     
+    void scheduleWork(final RequestWorkItem work, long delay) {
+    	try {
+			this.processWorkerPool.scheduleWork(new Work() {
+				
+				@Override
+				public void run() {
+					work.moreWork();
+				}
+				
+				@Override
+				public void release() {
+					
+				}
+			}, null, delay);
+		} catch (WorkException e) {
+			throw new MetaMatrixRuntimeException(e);
+		}
+    }
+    
     public void setWorkManager(WorkManager mgr) {
     	this.workManager = mgr;
     }
     
-    SecurityHelper getSecurityHelper() {
-    	return this.securityHelper;
-    }
-    
-    public void setSecurityHelper(SecurityHelper securityHelper) {
-		this.securityHelper = securityHelper;
-	}
-    
 	public ResultsFuture<?> closeLobChunkStream(int lobRequestId,
 			long requestId, String streamId)
 			throws MetaMatrixProcessingException {
-        if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
-            LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "Request to close the Lob stream with Stream id="+streamId+" instance id="+lobRequestId);  //$NON-NLS-1$//$NON-NLS-2$
+        if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+            LogManager.logDetail(LogConstants.CTX_DQP, "Request to close the Lob stream with Stream id="+streamId+" instance id="+lobRequestId);  //$NON-NLS-1$//$NON-NLS-2$
         }   
         DQPWorkContext workContext = DQPWorkContext.getWorkContext();
         RequestWorkItem workItem = safeGetWorkItem(workContext.getRequestID(requestId));
@@ -370,8 +381,8 @@
 	public ResultsFuture<LobChunk> requestNextLobChunk(int lobRequestId,
 			long requestId, String streamId)
 			throws MetaMatrixProcessingException {
-        if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
-            LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "Request for next Lob chunk with Stream id="+streamId+" instance id="+lobRequestId);  //$NON-NLS-1$//$NON-NLS-2$
+        if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+            LogManager.logDetail(LogConstants.CTX_DQP, "Request for next Lob chunk with Stream id="+streamId+" instance id="+lobRequestId);  //$NON-NLS-1$//$NON-NLS-2$
         }  
         RequestWorkItem workItem = getRequestWorkItem(DQPWorkContext.getWorkContext().getRequestID(requestId));
         ResultsFuture<LobChunk> resultsFuture = new ResultsFuture<LobChunk>();
@@ -426,7 +437,7 @@
 	            try {
 	                cancelRequest(reqId);
 	            } catch (MetaMatrixComponentException err) {
-	                LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_DQP, err, "Failed to cancel " + reqId); //$NON-NLS-1$
+	                LogManager.logWarning(LogConstants.CTX_DQP, err, "Failed to cancel " + reqId); //$NON-NLS-1$
 				}
 	        }
         }
@@ -435,7 +446,7 @@
             try {
                 transactionService.cancelTransactions(sessionId, false);
             } catch (XATransactionException err) {
-                LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_DQP, "rollback failed for requestID=" + sessionId); //$NON-NLS-1$
+                LogManager.logWarning(LogConstants.CTX_DQP, "rollback failed for requestID=" + sessionId); //$NON-NLS-1$
             } 
         }
         contextCache.removeSessionScopedCache(sessionId);
@@ -447,8 +458,8 @@
     }
     
     private boolean cancelRequest(RequestID requestID) throws MetaMatrixComponentException {
-        if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
-            LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "cancelQuery for requestID=" + requestID); //$NON-NLS-1$
+        if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+            LogManager.logDetail(LogConstants.CTX_DQP, "cancelQuery for requestID=" + requestID); //$NON-NLS-1$
         }
         
         boolean markCancelled = false;
@@ -460,7 +471,7 @@
     	if (markCancelled) {
             logMMCommand(workItem, Event.CANCEL, null);
     	} else {
-    		LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.failed_to_cancel")); //$NON-NLS-1$
+    		LogManager.logDetail(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.failed_to_cancel")); //$NON-NLS-1$
     	}
         return markCancelled;
     }
@@ -477,25 +488,25 @@
      * @throws MetaMatrixComponentException 
      */
     void closeRequest(RequestID requestID) throws MetaMatrixComponentException {
-        if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
-            LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "closeQuery for requestID=" + requestID); //$NON-NLS-1$
+        if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+            LogManager.logDetail(LogConstants.CTX_DQP, "closeQuery for requestID=" + requestID); //$NON-NLS-1$
         }
         
         RequestWorkItem workItem = safeGetWorkItem(requestID);
         if (workItem != null) {
         	workItem.requestClose();
         } else {
-        	LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, requestID + " close call ignored as the request has already been removed."); //$NON-NLS-1$
+        	LogManager.logDetail(LogConstants.CTX_DQP, requestID + " close call ignored as the request has already been removed."); //$NON-NLS-1$
         }
     }
     
     private void clearPlanCache(){
-        LogManager.logInfo(com.metamatrix.common.util.LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Clearing_prepared_plan_cache")); //$NON-NLS-1$
+        LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Clearing_prepared_plan_cache")); //$NON-NLS-1$
         this.prepPlanCache.clearAll();
     }
 
     private void clearCodeTableCache(){
-        LogManager.logInfo(com.metamatrix.common.util.LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Clearing_code_table_cache")); //$NON-NLS-1$
+        LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Clearing_code_table_cache")); //$NON-NLS-1$
         this.dataTierMgr.clearCodeTables();
     }
     
@@ -533,20 +544,6 @@
 		}
 	}
     
-	public Collection<SessionMetadata> getActiveSessions() throws SessionServiceException {
-		if (this.sessionService == null) {
-			return Collections.emptyList();
-		}
-		return this.sessionService.getActiveSessions();
-	}
-	
-	public int getActiveSessionsCount() throws SessionServiceException{
-		if (this.sessionService == null) {
-			return 0;
-		}
-		return this.sessionService.getActiveSessionsCount();
-	}	
-	
 	public Collection<org.teiid.adminapi.Transaction> getTransactions() {
 		if (this.transactionService == null) {
 			return Collections.emptyList();
@@ -562,7 +559,7 @@
 	}	
 	
     void logMMCommand(RequestWorkItem workItem, Event status, Integer rowCount) {
-    	if (!LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_COMMANDLOGGING, MessageLevel.INFO)) {
+    	if (!LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.INFO)) {
     		return;
     	}
     	
@@ -582,7 +579,7 @@
         } else {
             message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(), txnID, workContext.getConnectionID(), workContext.getUserName(), workContext.getVdbName(), workContext.getVdbVersion(), rowCount, status);
         }
-        LogManager.log(MessageLevel.DETAIL, com.metamatrix.common.util.LogConstants.CTX_COMMANDLOGGING, message);
+        LogManager.log(MessageLevel.DETAIL, LogConstants.CTX_COMMANDLOGGING, message);
     }
     
     ProcessorDataManager getDataTierManager() {
@@ -638,18 +635,17 @@
         prepPlanCache = new SessionAwareCache<PreparedPlan>(config.getPreparedPlanCacheMaxCount());
 		
         // Processor debug flag
-        LogManager.logInfo(com.metamatrix.common.util.LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Processor_debug_allowed_{0}", this.processorDebugAllowed)); //$NON-NLS-1$
+        LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Processor_debug_allowed_{0}", this.processorDebugAllowed)); //$NON-NLS-1$
                         
         //get buffer manager
         this.bufferManager = bufferService.getBufferManager();
         this.contextCache = bufferService.getContextCache();
 
-        this.processWorkerPool = new StatsCapturingWorkManager(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads());
+        this.processWorkerPool = new StatsCapturingWorkManager(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads(), this.workManager);
         
         dataTierMgr = new DataTierManagerImpl(this,
                                             this.connectorManagerRepository,
                                             this.bufferService,
-                                            this.workManager,
                                             this.maxCodeTables,
                                             this.maxCodeRecords,
                                             this.maxCodeTableRecords);    
@@ -723,11 +719,11 @@
 
 	// global txn
 	public ResultsFuture<?> commit(final MMXid xid, final boolean onePhase) throws XATransactionException {
-		final String threadId = DQPWorkContext.getWorkContext().getConnectionID();
 		Callable<Void> processor = new Callable<Void>() {
 			@Override
 			public Void call() throws Exception {
-				getTransactionService().commit(threadId, xid, onePhase, false);
+				DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+				getTransactionService().commit(workContext.getConnectionID(), xid, onePhase, workContext.getSession().isEmbedded());
 				return null;
 			}
 		};
@@ -735,14 +731,14 @@
 	}
 	// global txn
 	public ResultsFuture<?> end(MMXid xid, int flags) throws XATransactionException {
-		String threadId = DQPWorkContext.getWorkContext().getConnectionID();
-		this.getTransactionService().end(threadId, xid, flags, false);
+		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+		this.getTransactionService().end(workContext.getConnectionID(), xid, flags, workContext.getSession().isEmbedded());
 		return ResultsFuture.NULL_FUTURE;
 	}
 	// global txn
 	public ResultsFuture<?> forget(MMXid xid) throws XATransactionException {
-		String threadId = DQPWorkContext.getWorkContext().getConnectionID();
-		this.getTransactionService().forget(threadId, xid, false);
+		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+		this.getTransactionService().forget(workContext.getConnectionID(), xid, workContext.getSession().isEmbedded());
 		return ResultsFuture.NULL_FUTURE;
 	}
 		
@@ -751,7 +747,8 @@
 		Callable<Integer> processor = new Callable<Integer>() {
 			@Override
 			public Integer call() throws Exception {
-				return getTransactionService().prepare(DQPWorkContext.getWorkContext().getConnectionID(),xid, false);
+				DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+				return getTransactionService().prepare(workContext.getConnectionID(),xid, workContext.getSession().isEmbedded());
 			}
 		};
 		return addWork(processor);
@@ -771,7 +768,8 @@
 	// global txn
 	public ResultsFuture<Xid[]> recover(int flag) throws XATransactionException {
 		ResultsFuture<Xid[]> result = new ResultsFuture<Xid[]>();
-		result.getResultsReceiver().receiveResults(this.getTransactionService().recover(flag, false));
+		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+		result.getResultsReceiver().receiveResults(this.getTransactionService().recover(flag, workContext.getSession().isEmbedded()));
 		return result;
 	}
 	// global txn
@@ -779,7 +777,8 @@
 		Callable<Void> processor = new Callable<Void>() {
 			@Override
 			public Void call() throws Exception {
-				getTransactionService().rollback(DQPWorkContext.getWorkContext().getConnectionID(),xid, false);
+				DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+				getTransactionService().rollback(workContext.getConnectionID(),xid, workContext.getSession().isEmbedded());
 				return null;
 			}
 		};
@@ -788,8 +787,8 @@
 	// global txn
 	public ResultsFuture<?> start(MMXid xid, int flags, int timeout)
 			throws XATransactionException {
-		String threadId = DQPWorkContext.getWorkContext().getConnectionID();
-		this.getTransactionService().start(threadId, xid, flags, timeout, false);
+		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+		this.getTransactionService().start(workContext.getConnectionID(), xid, flags, timeout, workContext.getSession().isEmbedded());
 		return ResultsFuture.NULL_FUTURE;
 	}
 
@@ -816,15 +815,6 @@
 		return this.connectorManagerRepository;
 	}
 	
-	public void setSessionService(SessionService service) {
-		this.sessionService = service;
-		service.setDqp(this);
-	}
-	
-	public SessionService getSessionService() {
-		return this.sessionService;
-	}
-	
 	public AuthorizationService getAuthorizationService() {
 		return this.authorizationService;
 	}

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -23,10 +23,13 @@
 package org.teiid.dqp.internal.process;
 
 import java.io.Serializable;
+import java.util.concurrent.Callable;
 
 import javax.security.auth.Subject;
 
+import org.teiid.adminapi.impl.SessionMetadata;
 import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.security.SecurityHelper;
 
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.platform.security.api.SessionToken;
@@ -53,102 +56,82 @@
 		CONTEXTS.set(null);
 	}	
 	
-    private String vdbName;
-    private int vdbVersion;
-    private String appName;
-    private SessionToken sessionToken;
+	private SessionMetadata session = new SessionMetadata();
     private String clientAddress;
     private String clientHostname;
-    private Subject subject;
-	private String securityDomain;
-	private Object securityContext;
-	private VDBMetaData vdb;
-	private boolean admin;
+    private SecurityHelper securityHelper;
     
     public DQPWorkContext() {
 	}
+    
+    public SessionMetadata getSession() {
+		return session;
+	}
+    
+    public void setSession(SessionMetadata session) {
+		this.session = session;
+	}
+    
+    public void setSecurityHelper(SecurityHelper securityHelper) {
+		this.securityHelper = securityHelper;
+	}
 
     /**
      * @return
      */
     public String getUserName() {
-		if (this.sessionToken == null) {
-			return null;
-		}
-        return this.sessionToken.getUsername();
+		return session.getUserName();
     }
     
     public Subject getSubject() {
-        return this.subject;
+    	if (session.getLoginContext() != null) {
+    		return session.getLoginContext().getSubject();
+    	}
+    	return null;
     }
     
-    public void setSubject(Subject subject) {
-        this.subject = subject;
-    }
-
     /**
      * @return
      */
     public String getVdbName() {
-        return vdbName;
+        return session.getVDBName();
     }
 
     /**
      * @return
      */
     public int getVdbVersion() {
-        return vdbVersion;
+        return session.getVDBVersion();
     }
 
-    /**
-     * @param string
-     */
-    public void setVdbName(String vdbName) {
-        this.vdbName = vdbName;
-    }
-
-    /**
-     * @param string
-     */
-    public void setVdbVersion(int vdbVersion) {
-        this.vdbVersion = vdbVersion;
-    }
-
 	public String getConnectionID() {
 		return String.valueOf(getSessionId());
 	}
 	
 	public long getSessionId() {
-		if (this.sessionToken == null) {
-			return -1;
-		}
-		return this.sessionToken.getSessionID();
+		return this.session.getSessionId();
 	}
 
-	public void setAppName(String appName) {
-		this.appName = appName;
-	}
-
 	public String getAppName() {
-		return appName;
+		return session.getApplicationName();
 	}
 	
 	public RequestID getRequestID(long exeuctionId) {
 		return new RequestID(this.getConnectionID(), exeuctionId);
 	}
 	
-	public void setSessionToken(SessionToken sessionToken) {
-		this.sessionToken = sessionToken;
-	}
-
 	public SessionToken getSessionToken() {
-		return sessionToken;
+		return session.getSessionToken();
 	}
 
 	public void setClientAddress(String clientAddress) {
 		this.clientAddress = clientAddress;
 	}
 
+	/**
+	 * Get the client address from the socket transport - not as reported from the client
+	 * @return
+	 */
 	public String getClientAddress() {
 		return clientAddress;
 	}
@@ -157,51 +140,53 @@
 		this.clientHostname = clientHostname;
 	}
 
+	/**
+	 * Get the client hostname from the socket transport - not as reported from the client
+	 * @return
+	 */
 	public String getClientHostname() {
 		return clientHostname;
 	}
 	
-	public void reset() {
-		setSessionToken(null);
-		setAppName(null);
-		setVdbName(null);
-		setVdbVersion(0);
-		setSecurityContext(null);
-		setSecurityDomain(null);
-		setVdb(null);
-		setSubject(null);
-		setSessionToken(null);
-	}
-
-	public void setSecurityDomain(String securityDomain) {
-		this.securityDomain = securityDomain;
-	}
-	
 	public String getSecurityDomain() {
-		return this.securityDomain;
+		return this.session.getSecurityDomain();
 	}
 
 	public Object getSecurityContext() {
-		return this.securityContext;
+		return session.getSecurityContext();
 	}
 	
-	public void setSecurityContext(Object securityContext) {
-		this.securityContext = securityContext;
+	public VDBMetaData getVDB() {
+		return session.getVdb();
 	}
-
-	public void setVdb(VDBMetaData vdb) {
-		this.vdb = vdb;
-	}
 	
-	public VDBMetaData getVDB() {
-		return vdb;
+	public <V> V runInContext(Callable<V> callable) throws Exception {
+		DQPWorkContext.setWorkContext(this);
+		boolean associated = false;
+		if (securityHelper != null && this.getSubject() != null) {
+			associated = securityHelper.assosiateSecurityContext(this.getSecurityDomain(), this.getSecurityContext());			
+		}
+		try {
+			return callable.call();
+		} finally {
+			if (associated) {
+				securityHelper.clearSecurityContext(this.getSecurityDomain());			
+			}
+			DQPWorkContext.releaseWorkContext();
+		}
 	}
-
-	public void markAsAdmin() {
-		this.admin = true;
-	}
 	
-	public boolean isAdmin() {
-		return this.admin;
+	public void runInContext(final Runnable runnable) {
+		try {
+			runInContext(new Callable<Void>() {
+				@Override
+				public Void call() {
+					runnable.run();
+					return null;
+				}
+			});
+		} catch (Exception e) {
+		}
 	}
+
 }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -32,7 +32,6 @@
 import java.util.List;
 import java.util.Map;
 
-import javax.resource.spi.work.WorkManager;
 import javax.sql.rowset.serial.SerialBlob;
 import javax.sql.rowset.serial.SerialClob;
 
@@ -51,6 +50,7 @@
 import org.teiid.connector.metadata.runtime.Table;
 import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
 import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
 import org.teiid.dqp.internal.process.CodeTableCache.CacheKey;
 import org.teiid.metadata.CompositeMetadataStore;
 import org.teiid.metadata.TransformationMetadata;
@@ -60,13 +60,10 @@
 import com.metamatrix.common.buffer.BlockedException;
 import com.metamatrix.common.buffer.TupleBatch;
 import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.core.CoreConstants;
 import com.metamatrix.core.util.Assertion;
 import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.message.AtomicRequestID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.service.BufferService;
@@ -107,18 +104,14 @@
 	private DQPCore requestMgr;
     private BufferService bufferService;
     private ConnectorManagerRepository connectorManagerRepository;
-    private WorkManager workManager;
 
 	// Processor state
     private CodeTableCache codeTableCache;
     
-    public DataTierManagerImpl(DQPCore requestMgr, ConnectorManagerRepository connectorRepo, BufferService bufferService, WorkManager wm, int maxCodeTables, int maxCodeRecords, int maxCodeTableRecords) {
-
+    public DataTierManagerImpl(DQPCore requestMgr, ConnectorManagerRepository connectorRepo, BufferService bufferService, int maxCodeTables, int maxCodeRecords, int maxCodeTableRecords) {
 		this.requestMgr = requestMgr;
         this.connectorManagerRepository = connectorRepo;
         this.bufferService = bufferService;
-        this.workManager = wm;
-
         this.codeTableCache = new CodeTableCache(maxCodeTables, maxCodeRecords, maxCodeTableRecords);
 	}
     
@@ -134,9 +127,7 @@
 		}
 		
 		AtomicRequestMessage aqr = createRequest(processorId, command, modelName, connectorBindingId, nodeID);
-        DataTierTupleSource tupleSource = new DataTierTupleSource(aqr.getCommand().getProjectedSymbols(), aqr, this, aqr.getConnectorName(), workItem);
-        tupleSource.open();
-        return tupleSource;
+        return new DataTierTupleSource(aqr.getCommand().getProjectedSymbols(), aqr, this, aqr.getConnectorName(), workItem);
 	}
 
 	/**
@@ -354,30 +345,10 @@
 		return aqr;
 	}
 	
-	void executeRequest(AtomicRequestMessage aqr, String connectorName,ResultsReceiver<AtomicResultsMessage> receiver) throws MetaMatrixComponentException {
-		try {
-			getCM(connectorName).executeRequest(this.workManager, receiver, aqr);
-		} catch (ConnectorException e) {
-			throw new MetaMatrixComponentException(e);
-		}
+	ConnectorWork executeRequest(AtomicRequestMessage aqr, String connectorName) throws ConnectorException {
+		return getCM(connectorName).executeRequest(aqr);
 	}
 
-	public void closeRequest(AtomicRequestID request, String connectorName) {
-		getCM(connectorName).closeRequest(request);
-	}
-	
-	public void cancelRequest(AtomicRequestID request, String connectorName) {
-		getCM(connectorName).cancelRequest(request);
-	}
-
-	void requestBatch(AtomicRequestID request, String connectorName) throws MetaMatrixComponentException {
-		try {
-			getCM(connectorName).requstMore(request);
-		} catch (ConnectorException e) {
-			throw new MetaMatrixComponentException(e);
-		}
-	}
-
     /** 
      * Notify each waiting request that the code table data is now available.
      * @param requests

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -22,13 +22,16 @@
 
 package org.teiid.dqp.internal.process;
 
+import java.util.Arrays;
 import java.util.List;
 
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.DataNotAvailableException;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
+
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
 import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.core.util.Assertion;
 import com.metamatrix.dqp.exception.SourceWarning;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
@@ -38,7 +41,7 @@
  * This tuple source impl can only be used once; once it is closed, it 
  * cannot be reopened and reused.
  */
-public class DataTierTupleSource implements TupleSource, ResultsReceiver<AtomicResultsMessage> {
+public class DataTierTupleSource implements TupleSource {
 
     // Construction state
     private final List schema;
@@ -48,17 +51,11 @@
     private final RequestWorkItem workItem;
     
     // Data state
-    private List[] currentBatch;
-    private List[] nextBatch;
-    private int currentBatchCount = 0;
+    private ConnectorWork cwi;
     private int index = 0;
-    private boolean nextBatchIsLast = false;
-    private volatile boolean isLast = false;
     private int rowsProcessed = 0;
-    private boolean waitingForData = false;
-    private Throwable exception;
-    private volatile boolean supportsImplicitClose;
-    private volatile boolean isTransactional;
+    private AtomicResultsMessage arm;
+    private boolean closed;
     
     /**
      * Constructor for DataTierTupleSource.
@@ -79,142 +76,92 @@
     }
 
     public List nextTuple() throws MetaMatrixComponentException, MetaMatrixProcessingException {
-    	if (index < currentBatchCount) {
-            return this.currentBatch[index++];
-        } else if (isLast) {
-            return null;
-        } else {
-            // We're past the end of the current batch, so switch to the next
-            switchBatch();
-            // If the new batch is empty
-            if (currentBatchCount == 0) {
-                if (isLast) {
-                    return null;
-                }
-                throw BlockedException.INSTANCE;
-            }
-            return currentBatch[index++];
-        }
+    	if (this.arm == null) {
+    		open();
+    	}
+    	while (true) {
+	    	if (index < arm.getResults().length) {
+	            return this.arm.getResults()[index++];
+	        }
+	    	if (this.arm.getFinalRow() > 0) {
+	    		return null;
+	    	}
+	    	try {
+				receiveResults(this.cwi.more());
+			} catch (ConnectorException e) {
+	        	exceptionOccurred(e, true);
+			}
+    	}
     }
     
-    public void open() {
+    void open() throws MetaMatrixComponentException, MetaMatrixProcessingException {
         Assertion.isNull(workItem.getConnectorRequest(aqr.getAtomicRequestID()));
-        workItem.addConnectorRequest(aqr.getAtomicRequestID(), this);
-        synchronized (this) {
-        	this.waitingForData = true;
-	        try {
-	        	this.dataMgr.executeRequest(aqr, this.connectorName, this);
-	        } catch (MetaMatrixComponentException e) {
-	        	exceptionOccurred(e, true);
+        try {
+	        if (this.cwi == null) {
+	        	this.cwi = this.dataMgr.executeRequest(aqr, this.connectorName);
+		        workItem.addConnectorRequest(aqr.getAtomicRequestID(), this);
 	        }
+	        receiveResults(this.cwi.execute());
+        } catch (ConnectorException e) {
+        	exceptionOccurred(e, true);
         }
     }
     
-    /**
-     * Switches to the next batch.
-     * @throws BlockedException if we're still waiting for data from the connector
-     * @throws MetaMatrixComponentException if the request for the next batch failed.
-     * @since 4.3
-     */
-    private synchronized void switchBatch() throws MetaMatrixComponentException, MetaMatrixProcessingException {
-    	if (exception != null) {
-    		if (exception instanceof MetaMatrixComponentException) {
-    			throw (MetaMatrixComponentException)exception;
+    public void fullyCloseSource() {
+    	if (!closed) {
+    		if (cwi != null) {
+		    	workItem.closeAtomicRequest(this.aqr.getAtomicRequestID());
+				this.cwi.close();
     		}
-    		if (exception instanceof MetaMatrixProcessingException) {
-    			throw (MetaMatrixProcessingException)exception;
-    		}
-    		throw new MetaMatrixComponentException(exception);
+			closed = true;
     	}
-    	boolean shouldBlock = true;
-        if (nextBatch != null) {
-            // Switch the current batch
-            this.currentBatch = this.nextBatch;
-            this.isLast = this.nextBatchIsLast;
-            this.currentBatchCount = this.currentBatch.length;
-            this.index = 0;
-            this.nextBatch = null;
-            shouldBlock = false;
-        } 
-        // Request the next batch immediately
-        if (!this.isLast && !waitingForData) {
-            this.dataMgr.requestBatch(this.aqr.getAtomicRequestID(), this.connectorName);
-            
-            // update waitingForData
-            this.waitingForData = true;
-        }
-        if (shouldBlock) {
-        	throw BlockedException.INSTANCE;
-        }
     }
     
-    public void fullyCloseSource() {
-    	this.dataMgr.closeRequest(aqr.getAtomicRequestID(), this.connectorName);
+    public void cancelRequest() {
+    	if (this.cwi != null) {
+    		this.cwi.cancel();
+    	}
     }
-    
-    public void cancelRequest() throws MetaMatrixComponentException {
-    	this.dataMgr.cancelRequest(aqr.getAtomicRequestID(), this.connectorName);
-    }
 
     /**
      * @see TupleSource#closeSource()
      */
     public void closeSource() {
-    	if (this.supportsImplicitClose) {
-    		this.dataMgr.closeRequest(aqr.getAtomicRequestID(), this.connectorName);
+    	if (this.arm == null || this.arm.supportsImplicitClose()) {
+        	fullyCloseSource();
     	}
     }
 
-	public void exceptionOccurred(Throwable e) {
-		exceptionOccurred(e, false);
-	}
-    
-    private void exceptionOccurred(Throwable e, boolean removeState) {
-    
-		synchronized (this) {
-			if(workItem.requestMsg.supportsPartialResults()) {
-				nextBatch = new List[0];
-				nextBatchIsLast = true;
-		        SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), aqr.getConnectorName(), e, true);
-		        workItem.addSourceFailureDetails(sourceFailure);
-			} else {
-				this.exception = e;
-			}	
-			waitingForData = false;
+    void exceptionOccurred(Exception exception, boolean removeState) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+    	if (removeState) {
+			fullyCloseSource();
 		}
-		if (removeState) {
-			workItem.closeAtomicRequest(aqr.getAtomicRequestID());
-		}
-		this.workItem.moreWork();
+    	if(workItem.requestMsg.supportsPartialResults()) {
+			AtomicResultsMessage emptyResults = new AtomicResultsMessage(new List[0], null);
+			emptyResults.setWarnings(Arrays.asList(exception));
+			emptyResults.setFinalRow(this.rowsProcessed);
+			receiveResults(arm);
+		} else {
+    		if (exception instanceof MetaMatrixComponentException) {
+    			throw (MetaMatrixComponentException)exception;
+    		}
+    		if (exception instanceof MetaMatrixProcessingException) {
+    			throw (MetaMatrixProcessingException)exception;
+    		}
+    		throw new MetaMatrixComponentException(exception);
+		}	
 	}
 
-	public void receiveResults(AtomicResultsMessage response) {
-		boolean removeRequest = false;
-		synchronized (this) {
-	        // check to see if this is close of the atomic request message.
-	        if (response.isRequestClosed()) {
-	        	removeRequest = true;
-	        } else {
-		        supportsImplicitClose = response.supportsImplicitClose();
-		        isTransactional = response.isTransactional();
-		        
-		        nextBatch = response.getResults();    
-				nextBatchIsLast = response.getFinalRow() >= 0;
-		        rowsProcessed += nextBatch.length;
-	        }
-	        // reset waitingForData flag
-	        waitingForData = false;
-		}
+	void receiveResults(AtomicResultsMessage response) {
+		this.arm = response;
+        rowsProcessed += response.getResults().length;
+        index = 0;
 		if (response.getWarnings() != null) {
 			for (Exception warning : response.getWarnings()) {
 				SourceWarning sourceFailure = new SourceWarning(this.aqr.getModelName(), aqr.getConnectorName(), warning, true);
 		        workItem.addSourceFailureDetails(sourceFailure);
 			}
 		}
-		if (removeRequest) {
-        	workItem.closeAtomicRequest(this.aqr.getAtomicRequestID());
-		}
-		this.workItem.moreWork();
 	}
 	
 	public AtomicRequestMessage getAtomicRequestMessage() {
@@ -226,20 +173,18 @@
 	}
 	
 	public boolean isTransactional() {
-		return this.isTransactional;
+		if (this.arm == null) {
+			return false;
+		}
+		return this.arm.isTransactional();
 	}
 	
 	@Override
 	public int available() {
-		if (index < currentBatchCount) {
-			return currentBatchCount - index;
+		if (this.arm == null) {
+			return 0;
 		}
-		synchronized (this) {
-			if (nextBatch != null) {
-				return nextBatch.length;
-			}
-		}
-		return 0;
+		return this.arm.getResults().length - index;
 	}
 	
 }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -45,6 +45,7 @@
 import com.metamatrix.common.buffer.BufferManager;
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.util.LogConstants;
 import com.metamatrix.common.xa.XATransactionException;
 import com.metamatrix.core.id.IDGenerator;
 import com.metamatrix.core.id.IntegerIDFactory;
@@ -341,10 +342,8 @@
             if(ExecutionProperties.TXN_WRAP_ON.equals(requestMsg.getTxnAutoWrapMode())){ 
                 startAutoWrapTxn = true;
             } else if ( processingCommand.updatingModelCount(metadata) > 1) { 
-                if (ExecutionProperties.TXN_WRAP_AUTO.equals(requestMsg.getTxnAutoWrapMode())){
+                if (ExecutionProperties.TXN_WRAP_DETECT.equals(requestMsg.getTxnAutoWrapMode())){
                     startAutoWrapTxn = true;
-                } else if (ExecutionProperties.TXN_WRAP_OFF.equals(requestMsg.getTxnAutoWrapMode())) {
-                    LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, DQPPlugin.Util.getString("Request.potentially_unsafe")); //$NON-NLS-1$ 
                 }
             } 
             
@@ -353,7 +352,7 @@
                     throw new MetaMatrixComponentException(DQPPlugin.Util.getString("Request.transaction_not_supported")); //$NON-NLS-1$
                 }
                 try {
-                    tc = transactionService.start(tc);
+                    tc = transactionService.begin(tc);
                 } catch (XATransactionException err) {
                     throw new MetaMatrixComponentException(err);
                 }
@@ -449,7 +448,7 @@
             } finally {
                 String debugLog = analysisRecord.getDebugLog();
                 if(debugLog != null && debugLog.length() > 0) {
-                    LogManager.logInfo(com.metamatrix.common.util.LogConstants.CTX_DQP, debugLog);               
+                    LogManager.logInfo(LogConstants.CTX_DQP, debugLog);               
                 }
             }
             
@@ -457,7 +456,7 @@
                 analysisRecord.setQueryPlan(processPlan.getDescriptionProperties());
             }
             
-            LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, new Object[] { DQPPlugin.Util.getString("BasicInterceptor.ProcessTree_for__4"), requestId, processPlan }); //$NON-NLS-1$
+            LogManager.logDetail(LogConstants.CTX_DQP, new Object[] { DQPPlugin.Util.getString("BasicInterceptor.ProcessTree_for__4"), requestId, processPlan }); //$NON-NLS-1$
         } catch (QueryMetadataException e) {
             Object[] params = new Object[] { requestId};
             String msg = DQPPlugin.Util.getString("DQPCore.Unknown_query_metadata_exception_while_registering_query__{0}.", params); //$NON-NLS-1$
@@ -527,7 +526,7 @@
     public void processRequest() 
         throws QueryValidatorException, QueryParserException, QueryResolverException, MetaMatrixComponentException, QueryPlannerException {
                     
-    	LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, this.requestId, "executing", this.requestMsg.isPreparedStatement()?"prepared":"", this.requestMsg.getCommandString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+    	LogManager.logDetail(LogConstants.CTX_DQP, this.requestId, "executing", this.requestMsg.isPreparedStatement()?"prepared":"", this.requestMsg.getCommandString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     	
         initMetadata();
         

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -33,6 +33,7 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.teiid.connector.api.DataNotAvailableException;
 import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
 import org.teiid.logging.api.CommandLogMessage.Event;
 
@@ -46,6 +47,7 @@
 import com.metamatrix.common.lob.LobChunk;
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.util.LogConstants;
 import com.metamatrix.common.xa.XATransactionException;
 import com.metamatrix.core.MetaMatrixCoreException;
 import com.metamatrix.core.log.MessageLevel;
@@ -58,6 +60,7 @@
 import com.metamatrix.dqp.message.ResultsMessage;
 import com.metamatrix.dqp.service.TransactionContext;
 import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.service.TransactionContext.Scope;
 import com.metamatrix.query.analysis.AnalysisRecord;
 import com.metamatrix.query.analysis.QueryAnnotation;
 import com.metamatrix.query.execution.QueryExecPlugin;
@@ -160,14 +163,15 @@
 	protected void resumeProcessing() {
 		dqpCore.addWork(this);
 	}
-             
+	
 	@Override
 	protected void process() {
-		DQPWorkContext.setWorkContext(this.dqpWorkContext);
-		
-        LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "############# PW PROCESSING on", requestID, "with state", state, "###########"); //$NON-NLS-1$ //$NON-NLS-2$  //$NON-NLS-3$
-        
+        LogManager.logDetail(LogConstants.CTX_DQP, "Request Thread", requestID, "with state", state); //$NON-NLS-1$ //$NON-NLS-2$
         try {
+        	if (this.transactionState == TransactionState.ACTIVE && this.transactionContext.getTransaction() != null) {
+        		//there's no need to do this for xa transactions, as that is done by the workmanager
+        		this.transactionService.resume(this.transactionContext);
+            }
             if (this.state == ProcessingState.NEW) {
                 state = ProcessingState.PROCESSING;
         		processNew();
@@ -183,12 +187,15 @@
             	}
             }                  	            
         } catch (BlockedException e) {
-            LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "############# PW EXITING on", requestID, "- processor blocked ###########"); //$NON-NLS-1$ //$NON-NLS-2$
+            LogManager.logDetail(LogConstants.CTX_DQP, "Request Thread", requestID, "- processor blocked"); //$NON-NLS-1$ //$NON-NLS-2$
         } catch (QueryProcessor.ExpiredTimeSliceException e) {
-            LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "############# PW reenqueueing ", requestID, "- time slice expired ###########"); //$NON-NLS-1$ //$NON-NLS-2$
+            LogManager.logDetail(LogConstants.CTX_DQP, "Request Thread", requestID, "- time slice expired"); //$NON-NLS-1$ //$NON-NLS-2$
             this.moreWork();
+        } catch (DataNotAvailableException e) { 
+        	LogManager.logDetail(LogConstants.CTX_DQP, "Request Thread", requestID, "- data not available"); //$NON-NLS-1$ //$NON-NLS-2$
+            this.dqpCore.scheduleWork(this, e.getRetryDelay());
         } catch (Throwable e) {
-        	LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, e, "############# PW EXITING on", requestID, "- error occurred ###########"); //$NON-NLS-1$ //$NON-NLS-2$
+        	LogManager.logDetail(LogConstants.CTX_DQP, e, "Request Thread", requestID, "- error occurred"); //$NON-NLS-1$ //$NON-NLS-2$
             
             if (!isCanceled()) {
             	dqpCore.logMMCommand(this, Event.CANCEL, null);
@@ -201,9 +208,9 @@
                 		cause = cause.getCause();
                 	}
                 	StackTraceElement elem = cause.getStackTrace()[0];
-                    LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_DQP, DQPPlugin.Util.getString("ProcessWorker.processing_error", e.getMessage(), requestID, e.getClass().getName(), elem)); //$NON-NLS-1$
+                    LogManager.logWarning(LogConstants.CTX_DQP, DQPPlugin.Util.getString("ProcessWorker.processing_error", e.getMessage(), requestID, e.getClass().getName(), elem)); //$NON-NLS-1$
                 }else {
-                    LogManager.logError(com.metamatrix.common.util.LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("ProcessWorker.error", requestID)); //$NON-NLS-1$
+                    LogManager.logError(LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("ProcessWorker.error", requestID)); //$NON-NLS-1$
                 }                                
             }
             
@@ -220,8 +227,14 @@
         			this.processingException = new IllegalStateException("Request is already closed"); //$NON-NLS-1$
         		}
         		sendError();
-        	}        
-        	DQPWorkContext.releaseWorkContext();
+        	} 
+        	if (this.transactionState == TransactionState.ACTIVE && this.transactionContext.getTransaction() != null) {
+        		try {
+					this.transactionService.suspend(this.transactionContext);
+				} catch (XATransactionException e) {
+					LogManager.logDetail(LogConstants.CTX_DQP, e, "Error suspending active transaction"); //$NON-NLS-1$
+				}
+            }
         }
     }
 
@@ -260,8 +273,8 @@
 			sendResultsIfNeeded(null);
 		} else {
 			moreWork(false); // If the timeslice expired, then the processor can probably produce more batches.
-			if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
-				LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "############# PW EXITING on " + requestID + " - reenqueueing for more processing ###########"); //$NON-NLS-1$ //$NON-NLS-2$
+			if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+				LogManager.logDetail(LogConstants.CTX_DQP, "############# PW EXITING on " + requestID + " - reenqueueing for more processing ###########"); //$NON-NLS-1$ //$NON-NLS-2$
 			}
 		}
 	}
@@ -277,8 +290,8 @@
 				this.processor.closeProcessing();
 			}
 			
-			if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
-		        LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "Removing tuplesource for the request " + requestID); //$NON-NLS-1$
+			if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+		        LogManager.logDetail(LogConstants.CTX_DQP, "Removing tuplesource for the request " + requestID); //$NON-NLS-1$
 		    }
 			rowcount = resultsBuffer.getRowCount();
 			if (this.processor != null) {
@@ -314,7 +327,7 @@
             try {
         		this.transactionService.rollback(transactionContext);
             } catch (XATransactionException e1) {
-                LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_DQP, e1, DQPPlugin.Util.getString("ProcessWorker.failed_rollback")); //$NON-NLS-1$           
+                LogManager.logWarning(LogConstants.CTX_DQP, e1, DQPPlugin.Util.getString("ProcessWorker.failed_rollback")); //$NON-NLS-1$           
             } 
 		}
 		
@@ -359,7 +372,7 @@
 		resultsBuffer.setForwardOnly(isForwardOnly());
 		analysisRecord = request.analysisRecord;
 		transactionContext = request.transactionContext;
-		if (this.transactionContext != null && this.transactionContext.getXid() != null) {
+		if (this.transactionContext != null && this.transactionContext.getTransactionType() != Scope.NONE) {
 			this.transactionState = TransactionState.ACTIVE;
 		}
 	    if (analysisRecord.recordQueryPlan()) {
@@ -390,8 +403,8 @@
 				return result;
 			}
 		
-			if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
-				LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "[RequestWorkItem.sendResultsIfNeeded] requestID:", requestID, "resultsID:", this.resultsBuffer, "done:", doneProducingBatches );   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+			if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+				LogManager.logDetail(LogConstants.CTX_DQP, "[RequestWorkItem.sendResultsIfNeeded] requestID:", requestID, "resultsID:", this.resultsBuffer, "done:", doneProducingBatches );   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 			}
 	
 			//TODO: support fetching more than 1 batch
@@ -508,11 +521,11 @@
     private void sendError() {
     	synchronized (this) {
     		if (this.resultsReceiver == null) {
-    			LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, processingException, "Unable to send error to client as results were already sent.", requestID); //$NON-NLS-1$
+    			LogManager.logDetail(LogConstants.CTX_DQP, processingException, "Unable to send error to client as results were already sent.", requestID); //$NON-NLS-1$
     			return;
     		}
     	}
-		LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, processingException, "Sending error to client", requestID); //$NON-NLS-1$
+		LogManager.logDetail(LogConstants.CTX_DQP, processingException, "Sending error to client", requestID); //$NON-NLS-1$
         ResultsMessage response = new ResultsMessage(requestMsg);
         response.setException(processingException);
         setAnalysisRecords(response, analysisRecord);
@@ -569,7 +582,7 @@
 	                try {
 	                    transactionService.cancelTransactions(requestID.getConnectionID(), true);
 	                } catch (XATransactionException err) {
-	                    LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_DQP, "rollback failed for requestID=" + requestID.getConnectionID()); //$NON-NLS-1$
+	                    LogManager.logWarning(LogConstants.CTX_DQP, "rollback failed for requestID=" + requestID.getConnectionID()); //$NON-NLS-1$
 	                    throw new MetaMatrixComponentException(err);
 	                }
 	            }
@@ -593,15 +606,15 @@
         	return true;
         }
         
-		LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "Connector request not found. AtomicRequestID=", ari); //$NON-NLS-1$ 
+		LogManager.logDetail(LogConstants.CTX_DQP, "Connector request not found. AtomicRequestID=", ari); //$NON-NLS-1$ 
         return false;
     }
     
     public void requestClose() throws MetaMatrixComponentException {
     	synchronized (this) {
         	if (this.state == ProcessingState.CLOSE || this.closeRequested) {
-        		if (LogManager.isMessageToBeRecorded(com.metamatrix.common.util.LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
-        			LogManager.logDetail(com.metamatrix.common.util.LogConstants.CTX_DQP, "Request already closing" + requestID); //$NON-NLS-1$
+        		if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+        			LogManager.logDetail(LogConstants.CTX_DQP, "Request already closing" + requestID); //$NON-NLS-1$
         		}
         		return;
         	}
@@ -618,7 +631,7 @@
     
     public void closeAtomicRequest(AtomicRequestID atomicRequestId) {
         connectorInfo.remove(atomicRequestId);
-        LogManager.logTrace(com.metamatrix.common.util.LogConstants.CTX_DQP, new Object[] {"closed atomic-request:", atomicRequestId});  //$NON-NLS-1$
+        LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {"closed atomic-request:", atomicRequestId});  //$NON-NLS-1$
     }
     
 	public void addConnectorRequest(AtomicRequestID atomicRequestId, DataTierTupleSource connInfo) {
@@ -683,18 +696,4 @@
 		return processingTimestamp;
 	}
 	
-	@Override
-    protected boolean assosiateSecurityContext() {
-		if (dqpWorkContext.getSubject() != null) {
-        	return dqpCore.getSecurityHelper().assosiateSecurityContext(dqpWorkContext.getSecurityDomain(),dqpWorkContext.getSecurityContext());			
-		}
-		return false;
-	}
-    
-	@Override
-    protected void clearSecurityContext() {
-		if (dqpWorkContext.getSubject() != null) {
-        	dqpCore.getSecurityHelper().clearSecurityContext(dqpWorkContext.getSecurityDomain());			
-		}
-	}
 }
\ No newline at end of file

Copied: trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java (from rev 1957, trunk/engine/src/main/java/com/metamatrix/common/queue/StatsCapturingWorkManager.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java	                        (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -0,0 +1,294 @@
+/*
+ * 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.dqp.internal.process;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.resource.spi.work.ExecutionContext;
+import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkEvent;
+import javax.resource.spi.work.WorkException;
+import javax.resource.spi.work.WorkListener;
+import javax.resource.spi.work.WorkManager;
+import javax.resource.spi.work.WorkRejectedException;
+
+import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.LogConstants;
+import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.core.util.NamedThreadFactory;
+import com.metamatrix.query.QueryPlugin;
+
+/**
+ * StatsCapturingWorkManager acts as a wrapper to the passed in {@link WorkManager} to 
+ * capture statistics and implement an unbounded queue of work.
+ */
+public class StatsCapturingWorkManager {
+		
+	private static class WorkContext {
+		ExecutionContext context;
+		long startTimeout;
+		long submitted = System.currentTimeMillis();
+		
+		public WorkContext(ExecutionContext context, long startTimeout) {
+			this.context = context;
+			this.startTimeout = startTimeout;
+		}
+		
+		long getStartTimeout() {
+			if (startTimeout == 0) {
+				return 0;
+			}
+			return Math.max(1, startTimeout + submitted - System.currentTimeMillis());
+		}
+		
+	}
+	
+	private final class WorkWrapper implements Work {
+		private final Work work;
+		private final WorkContext workContext;
+		private final DQPWorkContext dqpWorkContext;
+
+		private WorkWrapper(Work work, WorkContext workContext, DQPWorkContext dqpWorkContext) {
+			this.work = work;
+			this.workContext = workContext;
+			this.dqpWorkContext = dqpWorkContext;
+		}
+
+		@Override
+		public void run() {
+			Thread t = Thread.currentThread();
+			synchronized (poolLock) {
+				threads.add(t);
+			}
+			String name = t.getName();
+			t.setName(name + "_" + poolName + threadCounter.getAndIncrement()); //$NON-NLS-1$
+			if (LogManager.isMessageToBeRecorded(LogConstants.CTX_RUNTIME, MessageLevel.TRACE)) {
+				LogManager.logTrace(LogConstants.CTX_RUNTIME, "Beginning work with virtual worker", t.getName()); //$NON-NLS-1$ 
+			}
+			boolean success = false;
+			try {
+				dqpWorkContext.runInContext(work);
+				success = true;
+			} finally {
+				synchronized (poolLock) {
+					WorkWrapper next = null;
+					if (success) {
+						completedCount++;
+						next = queue.poll();		
+					}
+					threads.remove(t);
+					if (next == null) {
+						activeCount--;
+						if (activeCount == 0 && terminated) {
+							poolLock.notifyAll();
+						}		
+					} else {
+						try {
+							if (next.workContext == null) {
+								delegate.scheduleWork(next);
+							} else {
+								delegate.scheduleWork(next, next.workContext.getStartTimeout(), next.workContext.context, next.work instanceof WorkListener?(WorkListener)next.work:null);
+							}
+						} catch (WorkException e) {
+							handleException(next.work, e);
+						}
+					}
+				}
+				t.setName(name);
+			}
+		}
+
+		@Override
+		public void release() {
+			this.work.release();
+		}
+	}
+	
+	private static void handleException(Work work, WorkException e) {
+		if (work instanceof WorkListener) {
+			((WorkListener)work).workRejected(new WorkEvent(work, WorkEvent.WORK_REJECTED, work, new WorkRejectedException(e)));
+		} else if (LogManager.isMessageToBeRecorded(LogConstants.CTX_RUNTIME, MessageLevel.DETAIL)) {
+			LogManager.logDetail(LogConstants.CTX_RUNTIME, e, "Exception adding work to the WorkManager"); //$NON-NLS-1$ 
+		}
+	}
+		
+	private static ScheduledThreadPoolExecutor stpe = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Scheduler")); //$NON-NLS-1$
+
+	private volatile int activeCount;
+	private volatile int highestActiveCount;
+	private volatile int highestQueueSize;
+	private volatile boolean terminated;
+	private volatile int submittedCount;
+	private volatile int completedCount;
+	
+	private Object poolLock = new Object();
+	private AtomicInteger threadCounter = new AtomicInteger();
+	
+	private String poolName;
+	private int maximumPoolSize;
+	private WorkManager delegate;
+	
+	private Queue<WorkWrapper> queue = new LinkedList<WorkWrapper>();
+	private Set<Thread> threads = Collections.synchronizedSet(Collections.newSetFromMap(new IdentityHashMap<Thread, Boolean>()));
+	private Map<Integer, ScheduledFuture<?>> futures = new HashMap<Integer, ScheduledFuture<?>>();
+	private int idCounter;
+	
+	public StatsCapturingWorkManager(String name, int maximumPoolSize, WorkManager delegate) {
+		this.maximumPoolSize = maximumPoolSize;
+		this.poolName = name;
+		this.delegate = delegate;
+	}
+	
+	public void scheduleWork(final Work arg0) throws WorkException {
+		scheduleWork(arg0, (WorkContext)null, DQPWorkContext.getWorkContext());
+	}
+
+	private void scheduleWork(final Work work, WorkContext workContext, DQPWorkContext dqpWorkContext) 
+	throws WorkRejectedException, WorkException {
+		boolean atMaxThreads = false;
+		boolean newMaxQueueSize = false;
+		synchronized (poolLock) {
+			checkForTermination();
+			submittedCount++;
+			atMaxThreads = activeCount == maximumPoolSize;
+			if (atMaxThreads) {
+				queue.add(new WorkWrapper(work, workContext, dqpWorkContext));
+				int queueSize = queue.size();
+				if (queueSize > highestQueueSize) {
+					newMaxQueueSize = true;
+					highestQueueSize = queueSize;
+				}
+			} else {
+				activeCount++;
+				highestActiveCount = Math.max(activeCount, highestActiveCount);
+			}
+		}
+		if (atMaxThreads) {
+			if (newMaxQueueSize && maximumPoolSize > 1) {
+				LogManager.logWarning(LogConstants.CTX_RUNTIME, QueryPlugin.Util.getString("WorkerPool.Max_thread", maximumPoolSize, poolName, highestQueueSize)); //$NON-NLS-1$
+			}
+			return;
+		}
+		if (workContext == null) {
+			delegate.scheduleWork(new WorkWrapper(work, null, dqpWorkContext));
+		} else {
+			delegate.scheduleWork(new WorkWrapper(work, null, dqpWorkContext), workContext.getStartTimeout(), workContext.context, work instanceof WorkListener?(WorkListener)work:null);
+		}
+	}
+
+	public void scheduleWork(final Work arg0, final ExecutionContext arg2, long delay) throws WorkException {
+		if (delay < 1) {
+			scheduleWork(arg0, new WorkContext(arg2, WorkManager.INDEFINITE), DQPWorkContext.getWorkContext());
+		} else {
+			synchronized (futures) {
+				final int id = idCounter++;
+				final DQPWorkContext dqpWorkContext = DQPWorkContext.getWorkContext();
+				ScheduledFuture<?> sf = stpe.schedule(new Runnable() {
+					
+					@Override
+					public void run() {
+						try {
+							futures.remove(id);
+							scheduleWork(arg0, new WorkContext(arg2, WorkManager.INDEFINITE), dqpWorkContext);
+						} catch (WorkException e) {
+							handleException(arg0, e);
+						}
+					}
+				}, delay, TimeUnit.MILLISECONDS);
+				this.futures.put(id, sf);
+			}			
+		}
+	}
+	
+	private void checkForTermination() throws WorkRejectedException {
+		if (terminated) {
+			throw new WorkRejectedException("Queue has been terminated"); //$NON-NLS-1$
+		}
+	}
+		
+	public WorkerPoolStatisticsMetadata getStats() {
+		WorkerPoolStatisticsMetadata stats = new WorkerPoolStatisticsMetadata();
+		stats.setName(poolName);
+		stats.setQueued(queue.size());
+		stats.setHighestQueued(highestQueueSize);
+		stats.setActiveThreads(this.activeCount);
+		stats.setMaxThreads(this.maximumPoolSize);
+		stats.setTotalSubmitted(this.submittedCount);
+		stats.setHighestActiveThreads(this.highestActiveCount);
+		stats.setTotalCompleted(this.completedCount);
+		return stats;		
+	}
+	
+	public void shutdown() {
+		this.terminated = true;
+	}
+	
+	public void shutdownNow() {
+		this.shutdown();
+		synchronized (poolLock) {
+			for (Thread t : threads) {
+				t.interrupt();
+			}
+			queue.clear();
+		}
+		synchronized (futures) {
+			for (ScheduledFuture<?> future : futures.values()) {
+				future.cancel(true);
+			}
+			futures.clear();
+		}
+	}
+	
+	public boolean isTerminated() {
+		return terminated;
+	}
+	
+	public boolean awaitTermination(long timeout, TimeUnit unit)
+			throws InterruptedException {
+		long timeoutMillis = unit.toMillis(timeout);
+		long finalMillis = System.currentTimeMillis() + timeoutMillis;
+		synchronized (poolLock) {
+			while (this.activeCount > 0 || !terminated) {
+				if (timeoutMillis < 1) {
+					return false;
+				}
+				poolLock.wait(timeoutMillis);
+				timeoutMillis = finalMillis - System.currentTimeMillis();
+			}
+		}
+		return true;
+	}
+
+}


Property changes on: trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/ContainerTransactionProvider.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,38 +0,0 @@
-/*
- * 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.dqp.internal.transaction;
-
-import javax.resource.spi.XATerminator;
-
-public class ContainerTransactionProvider implements TransactionProvider {
-	XATerminator terminator;
-		
-	public ContainerTransactionProvider(XATerminator terminator) {
-		this.terminator = terminator;
-	}
-
-	@Override
-	public XATerminator getXATerminator() {
-		return terminator;
-	}
-}

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionProvider.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,32 +0,0 @@
-/*
- * 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.dqp.internal.transaction;
-
-import javax.resource.spi.XATerminator;
-
-
-public interface TransactionProvider {
-	
-    XATerminator getXATerminator();
-
-}
\ No newline at end of file

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -31,7 +31,14 @@
 import java.util.Set;
 
 import javax.resource.NotSupportedException;
+import javax.resource.spi.XATerminator;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
 import javax.transaction.InvalidTransactionException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
@@ -46,6 +53,7 @@
 import com.metamatrix.dqp.DQPPlugin;
 import com.metamatrix.dqp.service.TransactionContext;
 import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.service.TransactionContext.Scope;
 
 public class TransactionServerImpl implements TransactionService {
 
@@ -54,7 +62,7 @@
         // (connection -> transaction for global and local)
         private Map<String, TransactionContext> threadToTransactionContext = new HashMap<String, TransactionContext>();
         // (MMXid -> global transactions keyed) 
-        private Map<Integer, TransactionContext> xidToTransactionContext = new HashMap<Integer, TransactionContext>();
+        private Map<Xid, TransactionContext> xidToTransactionContext = new HashMap<Xid, TransactionContext>();
         
         public synchronized TransactionContext getOrCreateTransactionContext(String threadId) {
             TransactionContext tc = threadToTransactionContext.get(threadId);
@@ -73,20 +81,16 @@
         }
 
         public synchronized TransactionContext getTransactionContext(MMXid xid) {
-            return xidToTransactionContext.get(xid.hashCode());
+            return xidToTransactionContext.get(xid);
         }
         
-        public synchronized TransactionContext getTransactionContext(int hash) {
-            return xidToTransactionContext.get(hash);
-        }
-        
         public synchronized TransactionContext removeTransactionContext(String threadId) {
             return threadToTransactionContext.remove(threadId);
         }
 
         public synchronized void removeTransactionContext(TransactionContext tc) {
             if (tc.getXid() != null) {
-                this.xidToTransactionContext.remove(tc.getXid().hashCode());
+                this.xidToTransactionContext.remove(tc.getXid());
             }
             if (tc.getThreadId() != null) {
                 this.threadToTransactionContext.remove(tc.getThreadId());
@@ -95,7 +99,7 @@
         
         public synchronized void addTransactionContext(TransactionContext tc) {
             if (tc.getXid() != null) {
-                this.xidToTransactionContext.put(tc.getXid().hashCode(), tc);
+                this.xidToTransactionContext.put(tc.getXid(), tc);
             }
             if (tc.getThreadId() != null) {
                 this.threadToTransactionContext.put(tc.getThreadId(), tc);
@@ -105,20 +109,16 @@
 
     private TransactionMapping transactions = new TransactionMapping();
     
-    private TransactionProvider provider;
-    private String processName = "embedded"; //$NON-NLS-1$
-    private XidFactory xidFactory;
+    private XATerminator xaTerminator;
+    private TransactionManager transactionManager;
 
-    public TransactionServerImpl() {
-    }
-
-    public void setProcessName(String processName) {
-		this.processName = processName;
+    public void setXaTerminator(XATerminator xaTerminator) {
+		this.xaTerminator = xaTerminator;
 	}
     
-    public void setTransactionProvider(TransactionProvider theProvider) {
-        this.provider = theProvider;
-    }
+    public void setTransactionManager(TransactionManager transactionManager) {
+		this.transactionManager = transactionManager;
+	}
 
     /**
      * Global Transaction 
@@ -130,7 +130,7 @@
         }		
         
         if (tc.shouldRollback()) {
-        	throw new XATransactionException(XAException.XAER_RMERR, DQPPlugin.Util.getString("TransactionServer.rollback_set", xid));
+        	throw new XATransactionException(XAException.XAER_RMERR, DQPPlugin.Util.getString("TransactionServer.rollback_set", xid)); //$NON-NLS-1$
         }
         
         // In the container this pass though
@@ -139,7 +139,7 @@
         }
         
         try {
-        	return this.provider.getXATerminator().prepare(tc.getXid());
+        	return this.xaTerminator.prepare(tc.getXid());
         } catch (XAException e) {
             throw new XATransactionException(e);
         }
@@ -151,16 +151,11 @@
     public void commit(final String threadId, MMXid xid, boolean onePhase, boolean singleTM) throws XATransactionException {
     	TransactionContext tc = checkXAState(threadId, xid, true, false);  
     	try {
-    		// In the case of single TM, the container directly commits the sources.
-        	if (!singleTM) {
-        		// In the case of onePhase containers call commit directly. If Teiid is also one phase let it pass through,
-        		// otherwise force the prepare.
-        		boolean singlePhase = tc.isOnePhase();
-        		if (onePhase && !singlePhase) {
-        			prepare(threadId, xid, singleTM);
-        		}
-        		this.provider.getXATerminator().commit(tc.getXid(), singlePhase);
+        	if (singleTM || (onePhase && XAResource.XA_RDONLY == prepare(threadId, xid, singleTM))) {
+        		return; //nothing to do
         	}
+        	//TODO: we have no way of knowing for sure if we can safely use the onephase optimization
+        	this.xaTerminator.commit(tc.getXid(), false); 
     	} catch (XAException e) {
             throw new XATransactionException(e);
         } finally {
@@ -176,7 +171,7 @@
     	try {
     		// In the case of single TM, the container directly roll backs the sources.
         	if (!singleTM) {
-        		this.provider.getXATerminator().rollback(tc.getXid());
+        		this.xaTerminator.rollback(tc.getXid());
         	}
     	} catch (XAException e) {
             throw new XATransactionException(e);
@@ -195,7 +190,7 @@
     	}
     	
     	try {
-			return this.provider.getXATerminator().recover(flag);
+			return this.xaTerminator.recover(flag);
 		} catch (XAException e) {
 			throw new XATransactionException(e);
 		}
@@ -210,7 +205,7 @@
         	if (singleTM) {
         		return;
         	}
-            this.provider.getXATerminator().forget(xid);
+            this.xaTerminator.forget(xid);
         } catch (XAException err) {
             throw new XATransactionException(err);
         } finally {
@@ -237,7 +232,7 @@
 					tc.setXid(xid);
 					tc.setTransactionType(TransactionContext.Scope.GLOBAL);
 				} catch (NotSupportedException e) {
-					throw new XATransactionException(XAException.XAER_INVAL, e.getMessage()); //$NON-NLS-1$
+					throw new XATransactionException(XAException.XAER_INVAL, e.getMessage());
 				}
                 break;
             }
@@ -320,87 +315,124 @@
     }
 
     private TransactionContext checkLocalTransactionState(String threadId, boolean transactionExpected) 
-    	throws InvalidTransactionException {
+    	throws XATransactionException {
 
         final TransactionContext tc = transactions.getOrCreateTransactionContext(threadId);
 
-        if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
-            if (tc.getTransactionType() != TransactionContext.Scope.LOCAL) {
-                throw new InvalidTransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
-            }
-            if (!transactionExpected) {
-                throw new InvalidTransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
-            }
-        } else if (transactionExpected) {
-            throw new InvalidTransactionException(DQPPlugin.Util.getString("TransactionServer.no_transaction", threadId)); //$NON-NLS-1$
+        try {
+	        if (tc.getTransactionType() != TransactionContext.Scope.NONE) {
+	            if (tc.getTransactionType() != TransactionContext.Scope.LOCAL) {
+	                throw new InvalidTransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
+	            }
+	            if (!transactionExpected) {
+	            	throw new InvalidTransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
+	            }
+	        } else if (transactionExpected) {
+	        	throw new InvalidTransactionException(DQPPlugin.Util.getString("TransactionServer.no_transaction", threadId)); //$NON-NLS-1$
+	        }
+        } catch (InvalidTransactionException e) {
+        	throw new XATransactionException(e);
         }
-
         return tc;
     }
+    
+    private void beginDirect(TransactionContext tc) throws XATransactionException {
+		try {
+			transactionManager.begin();
+			Transaction tx = transactionManager.getTransaction();
+			tc.setTransaction(tx);
+			tc.setCreationTime(System.currentTimeMillis());
+        } catch (javax.transaction.NotSupportedException err) {
+            throw new XATransactionException(err);
+        } catch (SystemException err) {
+            throw new XATransactionException(err);
+        }
+	}
+	
+	private void commitDirect(TransactionContext context)
+			throws XATransactionException {
+		try {
+			transactionManager.commit();
+		} catch (SecurityException e) {
+			throw new XATransactionException(e);
+		} catch (RollbackException e) {
+			throw new XATransactionException(e);
+		} catch (HeuristicMixedException e) {
+			throw new XATransactionException(e);
+		} catch (HeuristicRollbackException e) {
+			throw new XATransactionException(e);
+		} catch (SystemException e) {
+			throw new XATransactionException(e);
+		} finally {
+			transactions.removeTransactionContext(context);
+		}
+	}
 
+	private void rollbackDirect(TransactionContext tc)
+			throws XATransactionException {
+		try {
+			this.transactionManager.resume(tc.getTransaction());
+    		this.transactionManager.rollback();
+		} catch (SecurityException e) {
+			throw new XATransactionException(e);
+		} catch (SystemException e) {
+			throw new XATransactionException(e);
+		} catch (InvalidTransactionException e) {
+			throw new XATransactionException(e);
+		} finally {
+            transactions.removeTransactionContext(tc);
+        }
+	}
+	
+	public void suspend(TransactionContext context) throws XATransactionException {
+		try {
+			this.transactionManager.suspend();
+		} catch (SystemException e) {
+			throw new XATransactionException(e);
+		}
+	}
+	
+	public void resume(TransactionContext context) throws XATransactionException {
+		try {
+			this.transactionManager.resume(context.getTransaction());
+		} catch (InvalidTransactionException e) {
+			throw new XATransactionException(e);
+		} catch (SystemException e) {
+			throw new XATransactionException(e);
+		}
+	}
+
     /**
      * Local Transaction 
      */
     public TransactionContext begin(String threadId) throws XATransactionException {
-        try {
-            TransactionContext tc = checkLocalTransactionState(threadId, false);
-            tc.setXid(this.xidFactory.createXid());
-            tc.setCreationTime(System.currentTimeMillis());
-            tc.setTransactionType(TransactionContext.Scope.LOCAL);
-            return tc;
-        } catch (InvalidTransactionException err) {
-            throw new XATransactionException(err);
-        }
+        TransactionContext tc = checkLocalTransactionState(threadId, false);
+        beginDirect(tc);
+        tc.setTransactionType(TransactionContext.Scope.LOCAL);
+        return tc;
     }
 
     /**
      * Local Transaction 
      */    
     public void commit(String threadId) throws XATransactionException {
-        TransactionContext tc;
-        try {
-            tc = checkLocalTransactionState(threadId, true);
-        } catch (InvalidTransactionException err) {
-            throw new XATransactionException(err);
-        } 
+        TransactionContext tc = checkLocalTransactionState(threadId, true);
 
         if (tc.shouldRollback()) {
         	rollback(threadId);
+        } else {
+            commitDirect(tc);
         }
-        try {
-        	if (tc.isInTransaction()) {
-            	directCommit(tc);
-        	}
-        } catch (XAException e) {
-            throw new XATransactionException(e);
-        } finally {
-            transactions.removeTransactionContext(tc);
-        }
     }
 
     /**
      * Local Transaction 
      */    
     public void rollback(String threadId) throws XATransactionException {
-        TransactionContext tc;
-        try {
-            tc = checkLocalTransactionState(threadId, true);
-        } catch (InvalidTransactionException err) {
-            throw new XATransactionException(err);
-        } 
-        
-        try {
-        	if (tc.isInTransaction()) {
-        		this.provider.getXATerminator().rollback(tc.getXid());
-        	}
-        } catch (XAException e) {
-            throw new XATransactionException(e);
-        } finally {
-            transactions.removeTransactionContext(tc);
-        }
+        TransactionContext tc = checkLocalTransactionState(threadId, true);
+        rollbackDirect(tc);
     }
 
-
     public TransactionContext getOrCreateTransactionContext(String threadId) {
         return transactions.getOrCreateTransactionContext(threadId);
     }
@@ -408,12 +440,11 @@
     /**
      * Request level transaction
      */
-    public TransactionContext start(TransactionContext context) throws XATransactionException{
+    public TransactionContext begin(TransactionContext context) throws XATransactionException{
         if (context.getTransactionType() != TransactionContext.Scope.NONE) {
             throw new XATransactionException(DQPPlugin.Util.getString("TransactionServer.existing_transaction")); //$NON-NLS-1$
         }
-        context.setXid(this.xidFactory.createXid());
-        context.setCreationTime(System.currentTimeMillis());
+        beginDirect(context);
         context.setTransactionType(TransactionContext.Scope.REQUEST);
         return context;
     }
@@ -424,8 +455,6 @@
     public TransactionContext commit(TransactionContext context) throws XATransactionException {
         Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
         
-        //commit may be called multiple times by the processworker, if this is a subsequent call, then the current
-        //context will not be active
         TransactionContext tc = transactions.getTransactionContext(context.getThreadId());
         if (tc == null || tc.getTransactionType() == TransactionContext.Scope.NONE) {
             return tc;
@@ -433,68 +462,48 @@
         
         Assertion.assertTrue(!tc.shouldRollback());
         
-        try {
-        	if (tc.isInTransaction()) {
-            	directCommit(tc);
-        	}
-        } catch (XAException e) {
-            throw new XATransactionException(e);
-        } finally {
-            transactions.removeTransactionContext(context);
-        }
+        commitDirect(context);
         return context;
     }
 
-	private void directCommit(TransactionContext tc) throws XAException {
-		boolean commit = true;
-		boolean onePhase = tc.isOnePhase();
-		if (!onePhase) {
-			int prepare = this.provider.getXATerminator().prepare(tc.getXid());
-			commit = (prepare == XAResource.XA_OK);
-		}
-		
-		if (commit) {
-			this.provider.getXATerminator().commit(tc.getXid(), onePhase);
-		}
-	}
-
     /**
      * Request level transaction
      */    
     public TransactionContext rollback(TransactionContext context) throws XATransactionException {
         Assertion.assertTrue(context.getTransactionType() == TransactionContext.Scope.REQUEST);
-        try {
-	        this.provider.getXATerminator().rollback(context.getXid());
-        } catch (XAException e) {
-            throw new XATransactionException(e);
-        } finally {
-            transactions.removeTransactionContext(context);
-        }
+        rollbackDirect(context);
         return context;      
     }
 
-    /**
-     * Request level transaction
-     */
     public void cancelTransactions(String threadId, boolean requestOnly) throws XATransactionException {
         TransactionContext tc = transactions.getTransactionContext(threadId);
         
-        if (tc == null || tc.getTransactionType() == TransactionContext.Scope.NONE) {
+        if (tc == null || tc.getTransactionType() == TransactionContext.Scope.NONE 
+        		|| (requestOnly && tc.getTransactionType() != TransactionContext.Scope.REQUEST)) {
             return;
         }
         
-        if (requestOnly && tc.getTransactionType() != TransactionContext.Scope.REQUEST) {
+        if (tc.getTransactionType() == TransactionContext.Scope.GLOBAL) {
+        	tc.setRollbackOnly();
             return;
         }
         
-        tc.setRollbackOnly();
-        
-        if (requestOnly) {
-        	rollback(tc);
+        try {
+            try {
+				transactionManager.resume(tc.getTransaction());
+	            transactionManager.setRollbackOnly();
+			} catch (InvalidTransactionException e) {
+				throw new XATransactionException(e);
+			} catch (SystemException e) {
+				throw new XATransactionException(e);
+			}
+        } finally {
+        	try {
+				transactionManager.suspend();
+			} catch (SystemException e) {
+				throw new XATransactionException(e);
+			}
         }
-        else {
-        	rollback(threadId);
-        }
     }
 
 	@Override
@@ -505,46 +514,34 @@
 			txnSet.addAll(this.transactions.xidToTransactionContext.values());
 		}
 		Collection<org.teiid.adminapi.Transaction> result = new ArrayList<org.teiid.adminapi.Transaction>(txnSet.size());
-		for (TransactionContext TransactionContext : txnSet) {
-			if (TransactionContext.getXid() == null) {
+		for (TransactionContext transactionContext : txnSet) {
+			if (transactionContext.getTransactionType() == Scope.NONE) {
 				continue;
 			}
 			TransactionMetadata txnImpl = new TransactionMetadata();
-			txnImpl.setAssociatedSession(Long.parseLong(TransactionContext.getThreadId()));
-			txnImpl.setCreatedTime(TransactionContext.getCreationTime());
-			txnImpl.setScope(TransactionContext.getTransactionType().toString());
-			txnImpl.setXid(TransactionContext.getXid().toString());
+			txnImpl.setAssociatedSession(Long.parseLong(transactionContext.getThreadId()));
+			txnImpl.setCreatedTime(transactionContext.getCreationTime());
+			txnImpl.setScope(transactionContext.getTransactionType().toString());
+			if (transactionContext.getXid() != null) {
+				txnImpl.setId(transactionContext.getXid().toString());
+			} else {
+				txnImpl.setId(transactionContext.getTransaction().toString());
+			}
 			result.add(txnImpl);
 		}
 		return result;
 	}
 	
 	@Override
-	public void terminateTransaction(String xid) throws AdminException {
-		if (xid == null) {
+	public void terminateTransaction(String threadId) throws AdminException {
+		if (threadId == null) {
 			return;
 		}
-		TransactionContext context = this.transactions.getTransactionContext(xid.hashCode());
-		context.setRollbackOnly();
-		
 		try {
-			if (context.getTransactionType() == TransactionContext.Scope.REQUEST ) {
-				rollback(context);
-			}
-			
-			if (context.getTransactionType() == TransactionContext.Scope.LOCAL ) {
-				rollback(context.getThreadId());
-			}
-			
-			if (context.getTransactionType() == TransactionContext.Scope.GLOBAL ) {
-				throw new AdminProcessingException("Can not terminate global transactions!");
-			}			
+			cancelTransactions(threadId, false);
 		} catch (XATransactionException e) {
-			throw new AdminProcessingException(e.getMessage());
+			throw new AdminProcessingException(e);
 		}
 	}
 	
-	public void setXidFactory(XidFactory f) {
-		this.xidFactory = f;
-	}
 }

Deleted: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/XidFactory.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,41 +0,0 @@
-/*
- * 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.dqp.internal.transaction;
-
-import java.util.Random;
-
-import javax.transaction.xa.Xid;
-
-import com.metamatrix.common.xa.MMXid;
-
-public class XidFactory {
-	Random r = new Random(System.currentTimeMillis());
-	public Xid createXid() {
-		
-		byte[] global = new byte[10];
-		byte[] branch = new byte[10];
-		r.nextBytes(global);
-		r.nextBytes(branch);
-		
-		return new MMXid(78923, global, branch);
-	}
-}

Modified: trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -34,6 +34,7 @@
 
 import org.junit.Test;
 import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+import org.teiid.dqp.internal.process.StatsCapturingWorkManager;
 
 /**
  */
@@ -46,10 +47,10 @@
         final int WORK_ITEMS = 10;
         final int MAX_THREADS = 5;
 
-        final StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", MAX_THREADS); //$NON-NLS-1$
+        final StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", MAX_THREADS, manager); //$NON-NLS-1$
         
         for(int i=0; i<WORK_ITEMS; i++) {
-            pool.scheduleWork(manager, new FakeWorkItem(SINGLE_WAIT));
+            pool.scheduleWork(new FakeWorkItem(SINGLE_WAIT));
         }
         
         pool.shutdown();        
@@ -64,10 +65,10 @@
         final long SINGLE_WAIT = 50;
         final long NUM_THREADS = 5;
 
-        StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+        StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5, manager); //$NON-NLS-1$
         
         for(int i=0; i<NUM_THREADS; i++) {            
-        	pool.scheduleWork(manager, new FakeWorkItem(SINGLE_WAIT));
+        	pool.scheduleWork(new FakeWorkItem(SINGLE_WAIT));
             
             try {
                 Thread.sleep(SINGLE_WAIT*2);
@@ -84,9 +85,9 @@
     }
     
     @Test(expected=WorkRejectedException.class) public void testShutdown() throws Exception {
-    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5, manager); //$NON-NLS-1$
         pool.shutdown();
-    	pool.scheduleWork(manager, new FakeWorkItem(1));
+    	pool.scheduleWork(new FakeWorkItem(1));
     }
     
     /*@Test public void testScheduleCancel() throws Exception {
@@ -101,9 +102,9 @@
     }*/
     
     @Test public void testSchedule() throws Exception {
-    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5, manager); //$NON-NLS-1$
         final ArrayList<String> result = new ArrayList<String>(); 
-    	pool.scheduleWork(manager, new Work() {
+    	pool.scheduleWork(new Work() {
 			
 			@Override
 			public void run() {
@@ -155,9 +156,9 @@
     }*/
     
     @Test public void testFailingWork() throws Exception {
-    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5); //$NON-NLS-1$
+    	StatsCapturingWorkManager pool = new StatsCapturingWorkManager("test", 5, manager); //$NON-NLS-1$
     	final AtomicInteger count = new AtomicInteger();
-    	pool.scheduleWork(manager, new Work() {
+    	pool.scheduleWork(new Work() {
     		@Override
     		public void run() {
     			count.getAndIncrement();

Modified: trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -28,7 +28,6 @@
 import org.teiid.dqp.internal.process.DQPWorkContext;
 
 import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.platform.security.api.SessionToken;
 
 public class TestAtomicRequestMessage extends TestCase {
 
@@ -43,7 +42,7 @@
     public static AtomicRequestMessage example() {
         RequestMessage rm = new RequestMessage();
         DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setSessionToken(new SessionToken(2, "foo")); //$NON-NLS-1$
+        workContext.getSession().setSessionId(2);
         AtomicRequestMessage message = new AtomicRequestMessage(rm, workContext, 1000);
         message.setCommand(TestQueryImpl.helpExample(true));
         message.setFetchSize(100);

Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -28,13 +28,11 @@
 import java.util.Iterator;
 import java.util.List;
 
-import javax.resource.spi.work.WorkManager;
-
 import org.teiid.connector.api.ConnectorException;
 import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
 import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem;
 
-import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.common.types.DataTypeManager;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.AtomicResultsMessage;
@@ -51,12 +49,12 @@
     // Number of rows that will be generated for each query
     private int rows = 10;
     private SourceCapabilities caps;
+	public boolean throwExceptionOnExecute;
     
     public AutoGenDataService() {
     	super("FakeConnector");
         caps = new BasicSourceCapabilities();
     }
-    
 
     public void setRows(int rows) {
         this.rows = rows;
@@ -67,19 +65,40 @@
     }
 
     @Override
-	public void executeRequest(WorkManager workManager, ResultsReceiver<AtomicResultsMessage> resultListener, AtomicRequestMessage request)
-			throws ConnectorException{
-        List projectedSymbols = (request.getCommand()).getProjectedSymbols();               
+    public ConnectorWork executeRequest(AtomicRequestMessage message)
+    		throws ConnectorException {
+    	if (throwExceptionOnExecute) {
+    		throw new ConnectorException("Connector Exception"); //$NON-NLS-1$
+    	}
+        List projectedSymbols = (message.getCommand()).getProjectedSymbols();               
         List[] results = createResults(projectedSymbols);
                 
-        AtomicResultsMessage msg = ConnectorWorkItem.createResultsMessage(request, results, projectedSymbols);
+        final AtomicResultsMessage msg = ConnectorWorkItem.createResultsMessage(results, projectedSymbols);
         msg.setFinalRow(rows);
-        resultListener.receiveResults(msg);
-        AtomicResultsMessage closeMsg = ConnectorWorkItem.createResultsMessage(request, results, projectedSymbols);
-        closeMsg.setRequestClosed(true);
-        resultListener.receiveResults(closeMsg);
+        return new ConnectorWork() {
+			
+			@Override
+			public AtomicResultsMessage more() throws ConnectorException {
+				throw new RuntimeException("Should not be called"); //$NON-NLS-1$
+			}
+			
+			@Override
+			public AtomicResultsMessage execute() throws ConnectorException {
+				return msg;
+			}
+			
+			@Override
+			public void close() {
+				
+			}
+			
+			@Override
+			public void cancel() {
+				
+			}
+		};
     }
-
+    
     private List[] createResults(List symbols) {
         List[] rows = new List[this.rows];
 
@@ -150,6 +169,4 @@
         return caps;
     }
 
-
-
 }

Modified: trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -30,6 +30,7 @@
 import java.util.List;
 
 import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.SessionMetadata;
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.connector.metadata.runtime.Table;
 import org.teiid.dqp.internal.process.DQPWorkContext;
@@ -83,10 +84,13 @@
     
 	public static DQPWorkContext buildWorkContext(QueryMetadataInterface metadata, VDBMetaData vdb) {
 		DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName(vdb.getName()); 
-        workContext.setVdbVersion(vdb.getVersion()); 
-        workContext.setSessionToken(new SessionToken(5, "foo")); //$NON-NLS-1$
-        workContext.setVdb(vdb);
+		SessionMetadata session = new SessionMetadata();
+		workContext.setSession(session);
+		session.setVDBName(vdb.getName()); 
+		session.setVDBVersion(vdb.getVersion()); 
+		session.setSessionId(1);
+		session.setUserName("foo"); //$NON-NLS-1$
+		session.setVdb(vdb);
         workContext.getVDB().addAttchment(QueryMetadataInterface.class, metadata);
         DQPWorkContext.setWorkContext(workContext);
 		return workContext;

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -27,7 +27,6 @@
 
 import com.metamatrix.cache.Cache;
 import com.metamatrix.cache.FakeCache.FakeCacheFactory;
-import com.metamatrix.platform.security.api.SessionToken;
 
 
 public class TestDQPContextCache extends TestCase {
@@ -43,9 +42,10 @@
 	
 	private DQPWorkContext getContext() {
         DQPWorkContext workContext = new DQPWorkContext();
-        workContext.setVdbName("MyVDB"); //$NON-NLS-1$
-        workContext.setVdbVersion(1); //$NON-NLS-1$
-        workContext.setSessionToken(new SessionToken(1, "foo")); //$NON-NLS-1$
+        workContext.getSession().setVDBName("MyVDB"); //$NON-NLS-1$
+        workContext.getSession().setVDBVersion(1);
+		workContext.getSession().setSessionId(1);
+		workContext.getSession().setUserName("foo"); //$NON-NLS-1$
         return workContext;
 	}
 
@@ -55,17 +55,17 @@
 		Cache cache = this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString());
 		cache.put("key", "request-value"); //$NON-NLS-1$ //$NON-NLS-2$
 
-		cache = this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID()));		
+		cache = this.cacheContext.getSessionScopedCache(context.getConnectionID());		
 		cache.put("key", "session-value"); //$NON-NLS-1$ //$NON-NLS-2$
 	
 		assertEquals("request-value", this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
-		assertEquals("session-value", this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID())).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
+		assertEquals("session-value", this.cacheContext.getSessionScopedCache(context.getConnectionID()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
 	
 		// close the request
 		this.cacheContext.removeRequestScopedCache(context.getRequestID(12L).toString());
 		
 		assertNull(this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key")); //$NON-NLS-1$ 
-		assertEquals("session-value", this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID())).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
+		assertEquals("session-value", this.cacheContext.getSessionScopedCache(context.getConnectionID()).get("key")); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 		
 	

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -22,17 +22,18 @@
 
 package org.teiid.dqp.internal.datamgr.impl;
 
-import org.teiid.dqp.internal.transaction.TransactionProvider;
+import javax.resource.spi.XATerminator;
+import javax.transaction.TransactionManager;
+
 import org.teiid.dqp.internal.transaction.TransactionServerImpl;
-import org.teiid.dqp.internal.transaction.XidFactory;
 
 import com.metamatrix.core.util.SimpleMock;
 
 public class FakeTransactionService extends TransactionServerImpl {
 
 	public FakeTransactionService() {
-		this.setTransactionProvider(SimpleMock.createSimpleMock(TransactionProvider.class));
-		this.setXidFactory(new XidFactory());
+		this.setTransactionManager(SimpleMock.createSimpleMock(TransactionManager.class));
+		this.setXaTerminator(SimpleMock.createSimpleMock(XATerminator.class));
 	}
 	
 }

Copied: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java (from rev 1958, trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+/*
+ * Date: Sep 17, 2003
+ * Time: 3:48:54 PM
+ */
+package org.teiid.dqp.internal.datamgr.impl;
+
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
+import org.teiid.connector.api.Connector;
+import org.teiid.connector.api.ConnectorEnvironment;
+
+import com.metamatrix.dqp.message.AtomicRequestID;
+import com.metamatrix.dqp.message.AtomicRequestMessage;
+import com.metamatrix.dqp.message.RequestID;
+
+/**
+ * JUnit test for TestConnectorStateManager
+ */
+public final class TestConnectorManager extends TestCase {
+    private AtomicRequestMessage request;
+    private ConnectorManager csm;
+    
+	static ConnectorManager getConnectorManager(ConnectorEnvironment env) throws Exception {
+		final FakeConnector c = new FakeConnector();
+		c.setConnectorEnvironment(env);		
+		ConnectorManager cm = new ConnectorManager("FakeConnector") { //$NON-NLS-1$
+			Connector getConnector() {
+				return c;
+			}
+		};
+		cm.start();
+		return cm;
+	}
+
+    /**
+     * Constructor for TestConnectorStateManager.
+     * @param name
+     */
+    public TestConnectorManager(final String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
+        csm = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
+    }
+
+    void helpAssureOneState() throws Exception {
+    	csm.executeRequest(request);
+    	ConnectorWork state = csm.getState(request.getAtomicRequestID());
+    	assertEquals(state, csm.getState(request.getAtomicRequestID()));
+    }
+
+    public void testCreateAndAddRequestState() throws Exception {
+        helpAssureOneState();
+        assertEquals("Expected size of 1", 1, csm.size()); //$NON-NLS-1$
+    }
+
+    public void testIllegalCreate() throws Exception {
+        helpAssureOneState();
+        try {
+        	helpAssureOneState();
+        	fail("expected exception"); //$NON-NLS-1$
+        } catch (AssertionError e) {
+        	assertEquals("State already existed", e.getMessage()); //$NON-NLS-1$
+        }
+    }
+
+    public void testRemoveRequestState() throws Exception {
+        helpAssureOneState();
+        csm.removeState(request.getAtomicRequestID());
+        assertEquals("Expected size of 0", 0, csm.size()); //$NON-NLS-1$
+    }
+
+    public void testRemoveUnknownRequestState() throws Exception {
+        helpAssureOneState();
+        csm.removeState(new AtomicRequestID(new RequestID("ZZZZ", 3210), 5, 5)); //$NON-NLS-1$
+
+        assertEquals("Expected size of 1", 1, csm.size()); //$NON-NLS-1$
+    }
+        
+}
\ No newline at end of file

Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,90 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * Date: Sep 17, 2003
- * Time: 5:36:02 PM
- */
-package org.teiid.dqp.internal.datamgr.impl;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.teiid.connector.api.Connector;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
-
-import com.metamatrix.common.queue.FakeWorkManager;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-
-/**
- * JUnit test for TestConnectorManagerImpl
- */
-public final class TestConnectorManagerImpl {
-   
-	private ConnectorEnvironment helpGetAppProps() {
-		ConnectorEnvironment env = Mockito.mock(ConnectorEnvironment.class);
-		Mockito.stub(env.getMaxResultRows()).toReturn(10);
-		return env;
-    }
-	
-	static ConnectorManager getConnectorManager(ConnectorEnvironment env) throws Exception {
-		final FakeConnector c = new FakeConnector();
-		c.setConnectorEnvironment(env);		
-		ConnectorManager cm = new ConnectorManager("FakeConnector") {
-			Connector getConnector() {
-				return c;
-			}
-		};
-		cm.start();
-		return cm;
-	}	
-
-    // =========================================================================
-    //                         T E S T   C A S E S
-    // =========================================================================
-
-
-    @Test public void testReceive() throws Exception {
-    	ConnectorManager cm = getConnectorManager(helpGetAppProps());
-        AtomicRequestMessage request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
-        QueueResultsReceiver receiver = new QueueResultsReceiver();
-        cm.executeRequest(new FakeWorkManager(), receiver, request);
-        assertNotNull(receiver.getResults().poll(1000, TimeUnit.MILLISECONDS));
-        cm.stop();
-    }
-    
-    
-    @Test public void testDefect19049() throws Exception {
-        ConnectorManager cm = getConnectorManager(helpGetAppProps());
-        AtomicRequestMessage request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
-        QueueResultsReceiver receiver = new QueueResultsReceiver();
-        cm.executeRequest(new FakeWorkManager(),receiver, request);
-        assertNotNull(receiver.getResults().poll(1000, TimeUnit.MILLISECONDS));
-        cm.stop();
-    }
-}
\ No newline at end of file

Deleted: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorStateManager.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -1,123 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * Date: Sep 17, 2003
- * Time: 3:48:54 PM
- */
-package org.teiid.dqp.internal.datamgr.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-
-import junit.framework.TestCase;
-
-import org.mockito.Mockito;
-import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
-
-import com.metamatrix.common.queue.FakeWorkManager;
-import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.dqp.message.AtomicRequestID;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.message.RequestID;
-
-/**
- * JUnit test for TestConnectorStateManager
- */
-public final class TestConnectorStateManager extends TestCase {
-    private AtomicRequestMessage request;
-    private ConnectorManager csm;
-
-    /**
-     * Constructor for TestConnectorStateManager.
-     * @param name
-     */
-    public TestConnectorStateManager(final String name) {
-        super(name);
-    }
-
-    protected void setUp() throws Exception {
-        super.setUp();
-        request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
-        csm = TestConnectorManagerImpl.getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
-        csm.workItemFactory = new ConnectorWorkItemFactory(csm, true);
-    }
-
-    void helpAssureOneState() throws Exception {
-    	QueueResultsReceiver receiver = new QueueResultsReceiver();
-    	csm.executeRequest(new FakeWorkManager(), receiver, request);
-    	ConnectorWorkItem state = csm.getState(request.getAtomicRequestID());
-    	assertEquals(state, csm.getState(request.getAtomicRequestID()));
-    }
-
-    public void testCreateAndAddRequestState() throws Exception {
-        helpAssureOneState();
-        assertEquals("Expected size of 1", 1, csm.size()); //$NON-NLS-1$
-    }
-
-    public void testIllegalCreate() throws Exception {
-        helpAssureOneState();
-        try {
-        	helpAssureOneState();
-        	fail("expected exception"); //$NON-NLS-1$
-        } catch (AssertionError e) {
-        	assertEquals("State already existed", e.getMessage()); //$NON-NLS-1$
-        }
-    }
-
-    public void testRemoveRequestState() throws Exception {
-        helpAssureOneState();
-        csm.removeState(request.getAtomicRequestID());
-        assertEquals("Expected size of 0", 0, csm.size()); //$NON-NLS-1$
-    }
-
-    public void testRemoveUnknownRequestState() throws Exception {
-        helpAssureOneState();
-        csm.removeState(new AtomicRequestID(new RequestID("ZZZZ", 3210), 5, 5)); //$NON-NLS-1$
-
-        assertEquals("Expected size of 1", 1, csm.size()); //$NON-NLS-1$
-    }
-    
-    public void testStop() throws Exception {
-    	List<ResultsFuture<AtomicResultsMessage>> futures = new ArrayList<ResultsFuture<AtomicResultsMessage>>();
-    	for (int i=0; i<20; i++) {
-    		ResultsFuture<AtomicResultsMessage> future = new ResultsFuture<AtomicResultsMessage>();
-        	csm.executeRequest(new FakeWorkManager(),future.getResultsReceiver(), TestConnectorWorkItem.createNewAtomicRequestMessage(i, 1));
-        }
-
-        csm.stop();
-        
-        for (ResultsFuture<AtomicResultsMessage> resultsFuture : futures) {
-			assertTrue(resultsFuture.isDone());
-			try {
-				resultsFuture.get(1000, TimeUnit.MILLISECONDS);
-			} catch (ExecutionException e) {
-				
-			}
-		}
-    }
-    
-}
\ No newline at end of file

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -26,15 +26,11 @@
 
 import java.util.Arrays;
 import java.util.List;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
 
-import javax.resource.spi.work.WorkManager;
 import javax.transaction.xa.Xid;
 
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.teiid.connector.api.Connector;
 import org.teiid.connector.api.ConnectorEnvironment;
 import org.teiid.connector.api.ConnectorException;
 import org.teiid.connector.api.ProcedureExecution;
@@ -42,16 +38,11 @@
 import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
 import org.teiid.dqp.internal.process.DQPWorkContext;
 
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.queue.FakeWorkManager;
-import com.metamatrix.dqp.client.ResultsFuture;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.AtomicResultsMessage;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.service.TransactionContext;
-import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.resolver.QueryResolver;
@@ -71,23 +62,12 @@
 		return command;
 	}
 
-	static ConnectorManager getConnectorManager(ConnectorEnvironment env) {
-		final FakeConnector c = new FakeConnector();
-		c.setConnectorEnvironment(env);
-		
-		ConnectorManager cm = new ConnectorManager("FakeConnector") {
-			Connector getConnector() {
-				return c;
-			}			
-		};
-		return cm;
-	}
-
 	static AtomicRequestMessage createNewAtomicRequestMessage(int requestid, int nodeid) throws Exception {
 		RequestMessage rm = new RequestMessage();
 		
 		DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(EXAMPLE_BQT, FakeMetadataFactory.exampleBQTVDB());
-		workContext.setSessionToken(new SessionToken(1, "foo")); //$NON-NLS-1$
+		workContext.getSession().setSessionId(1);
+		workContext.getSession().setUserName("foo"); //$NON-NLS-1$
 		
 		AtomicRequestMessage request = new AtomicRequestMessage(rm, workContext, nodeid);
 		request.setCommand(helpGetCommand("SELECT BQT1.SmallA.INTKEY FROM BQT1.SmallA", EXAMPLE_BQT)); //$NON-NLS-1$
@@ -125,224 +105,22 @@
 		}
 	}
 
-	@Test public void testCancelBeforeNew() throws Exception {
-		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
-		// only one response is expected
-		FakeWorkManager wm = new FakeWorkManager();
-		ResultsFuture<AtomicResultsMessage> resultsFuture = new ResultsFuture<AtomicResultsMessage>();
-		ConnectorWorkItem state = new SynchConnectorWorkItem(request,getConnectorManager(Mockito.mock(ConnectorEnvironment.class)), resultsFuture.getResultsReceiver());
-
-		state.asynchCancel(); // cancel does not cause close, but the next
-								// processing will close
-		assertFalse(state.isDoneProcessing());
-
-		wm.doWork(state, 0, null, state);
-
-		AtomicResultsMessage arm = resultsFuture.get(1000, TimeUnit.MILLISECONDS);
-
-		assertTrue(arm.isRequestClosed());
-
-		/*
-		 * subsequent requests result in errors
-		 */
-		try {
-			state.requestMore();
-		} catch (Throwable e) {
-			// catches the assertion error
-		}
-	}
-
-	private final class AsynchMoreResultsReceiver implements
-			ResultsReceiver<AtomicResultsMessage> {
-		private final ConnectorManager manager;
-		int msgCount;
-		ConnectorWorkItem workItem;
-		Throwable exception;
-
-		private AsynchMoreResultsReceiver(ConnectorManager manager) {
-			this.manager = manager;
-		}
-
-		public void receiveResults(AtomicResultsMessage results) {
-			switch (msgCount++) {
-			case 0:
-				// request more during delivery
-				try {
-					((FakeConnector) manager.getConnector()).setReturnsFinalBatch(true);
-					workItem.requestMore();
-				} catch (ConnectorException e) {
-					exceptionOccurred(e);
-				}
-				break;
-			case 1:
-				if (results.isRequestClosed()) {
-					exception = new AssertionError("request should not yet be closed"); //$NON-NLS-1$
-				}
-				break;
-			case 2:
-				if (!results.isRequestClosed()) {
-					exception = new AssertionError("request be closed"); //$NON-NLS-1$
-				}
-				break;
-			default:
-				exception = new AssertionError("expected only 3 responses"); //$NON-NLS-1$
-			}
-		}
-
-		public void exceptionOccurred(Throwable e) {
-			exception = e;
-		}
-	}
-
-	 final static class QueueResultsReceiver implements
-			ResultsReceiver<AtomicResultsMessage> {
-		LinkedBlockingQueue<AtomicResultsMessage> results = new LinkedBlockingQueue<AtomicResultsMessage>();
-		Throwable exception;
-
-		public QueueResultsReceiver() {
-			
-		}
-
-		public void receiveResults(AtomicResultsMessage results) {
-			this.results.add(results);
-		}
-		
-		public LinkedBlockingQueue<AtomicResultsMessage> getResults() {
-			return results;
-		}
-
-		public void exceptionOccurred(Throwable e) {
-			exception = e;
-		}
-	}
-
-	 @Test public void testMoreAsynch() throws Throwable {
-		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
-		final ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
-		AsynchMoreResultsReceiver receiver = new AsynchMoreResultsReceiver(manager);
-		ConnectorWorkItem state = new SynchConnectorWorkItem(request, manager,
-				receiver);
-		receiver.workItem = state;
-		Thread t = runRequest(state);
-		t.join(0);
-		assertFalse(t.isAlive());
-		if (receiver.exception != null) {
-			throw receiver.exception;
-		}
-	}
-	
-	 @Test public void testSynchInterrupt() throws Exception {
-		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
-		final ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
-		QueueResultsReceiver receiver = new QueueResultsReceiver();
-		ConnectorWorkItem state = new SynchConnectorWorkItem(request, manager, receiver);
-		Thread t = runRequest(state);
-		t.interrupt();
-		t.join();
-		assertTrue(state.isCancelled());
-	}
-
-	 @Test public void testImplicitClose() throws Exception {
-		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
-		ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
-		FakeConnector connector = (FakeConnector) manager.getConnector();
-
-		connector.setReturnsFinalBatch(true);
-
-		ConnectorWorkItem state = new SynchConnectorWorkItem(request, manager,
-				new QueueResultsReceiver());
-
-		state.run();
-		assertTrue(state.isDoneProcessing());
-	}
-
-	@Test public void testCloseBeforeNew() throws Exception {
-		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
-		FakeWorkManager wm = new FakeWorkManager();
-		ResultsFuture<AtomicResultsMessage> resultsFuture = new ResultsFuture<AtomicResultsMessage>();
-		ConnectorWorkItem state = new SynchConnectorWorkItem(request,getConnectorManager(Mockito.mock(ConnectorEnvironment.class)), resultsFuture.getResultsReceiver());
-
-		state.requestClose();
-		assertFalse(resultsFuture.isDone());
-		
-		wm.doWork(state, 0, null, state);
-
-		AtomicResultsMessage arm = resultsFuture.get(1000,
-				TimeUnit.MILLISECONDS);
-		assertTrue(arm.isRequestClosed());
-		assertTrue(state.isDoneProcessing());
-	}
-	@Test public void testAsynchBasicMore() throws Exception {
-		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
-		FakeWorkManager wm = new FakeWorkManager();
-		ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
-		
-		FakeConnector connector = (FakeConnector) manager.getConnector();
-		QueueResultsReceiver resultsReceiver = new QueueResultsReceiver(); 
-		
-		FakeQueuingAsynchConnectorWorkItem state = new FakeQueuingAsynchConnectorWorkItem(request, manager, resultsReceiver, wm);
-		
-		wm.doWork(state, 0, null, state);
-		
-		assertFalse(state.isDoneProcessing());
-		connector.setReturnsFinalBatch(true);
-
-		state.requestMore();
-		wm.doWork(state, 0, null, state);
-		
-		assertTrue(state.isDoneProcessing());
-
-		assertEquals(3, resultsReceiver.results.size());
-		assertEquals(1, state.resumeCount);
-	}
-
-	@Test public void testAsynchKeepAlive() throws Exception {
-		AtomicRequestMessage request = createNewAtomicRequestMessage(1, 1);
-		ConnectorManager manager = getConnectorManager(Mockito.mock(ConnectorEnvironment.class));
-		FakeConnector connector = (FakeConnector) manager.getConnector();
-		QueueResultsReceiver resultsReceiver = new QueueResultsReceiver();
-		FakeWorkManager wm = new FakeWorkManager();
-		FakeQueuingAsynchConnectorWorkItem state = new FakeQueuingAsynchConnectorWorkItem(request, manager, resultsReceiver, wm);
-
-		wm.doWork(state, 0, null, state);
-
-		assertFalse(state.isDoneProcessing());
-
-		connector.setReturnsFinalBatch(true);
-		state.securityContext.keepExecutionAlive(true);
-
-		state.requestMore();
-		state.run();
-
-		assertFalse(state.isDoneProcessing());
-
-		assertEquals(2, resultsReceiver.results.size());
-		assertEquals(1, state.resumeCount);
-	}
-	
-	@Test public void testUpdateExecution() throws Throwable {
-		QueueResultsReceiver receiver = helpExecuteUpdate();
-		AtomicResultsMessage results = receiver.getResults().remove();
+    @Test public void testUpdateExecution() throws Throwable {
+		AtomicResultsMessage results = helpExecuteUpdate();
 		assertEquals(Integer.valueOf(1), results.getResults()[0].get(0));
 	}
 
-	private QueueResultsReceiver helpExecuteUpdate() throws Exception,
+	private AtomicResultsMessage helpExecuteUpdate() throws Exception,
 			Throwable {
 		Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$
 		AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
 		arm.setCommand(command);
-		QueueResultsReceiver receiver = new QueueResultsReceiver();
-		SynchConnectorWorkItem synchConnectorWorkItem = new SynchConnectorWorkItem(arm, getConnectorManager(Mockito.mock(ConnectorEnvironment.class)), receiver);
-		synchConnectorWorkItem.run();
-		if (receiver.exception != null) {
-			throw receiver.exception;
-		}
-		return receiver;
+		ConnectorWorkItem synchConnectorWorkItem = new ConnectorWorkItem(arm, TestConnectorManager.getConnectorManager(Mockito.mock(ConnectorEnvironment.class)));
+		return synchConnectorWorkItem.execute();
 	}
 	
 	@Test public void testExecutionWarning() throws Throwable {
-		QueueResultsReceiver receiver = helpExecuteUpdate();
-		AtomicResultsMessage results = receiver.getResults().remove();
+		AtomicResultsMessage results = helpExecuteUpdate();
 		assertEquals(1, results.getWarnings().size());
 	}
 
@@ -357,7 +135,7 @@
     	 */
     	ConnectorEnvironment env = Mockito.mock(ConnectorEnvironment.class);
     	Mockito.stub(env.isImmutable()).toReturn(true);
-		ConnectorManager cm = getConnectorManager(env);
+		ConnectorManager cm = TestConnectorManager.getConnectorManager(env);
 
 		// command must not be a SELECT
 		Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$
@@ -371,20 +149,10 @@
 				return Mockito.mock(Xid.class);
 			}} );
 		
-		QueueResultsReceiver receiver = new QueueResultsReceiver();
-		
-		SynchConnectorWorkItem synchConnectorWorkItem = new SynchConnectorWorkItem(requestMsg, cm, receiver);
-	
-		// This is the test
-		try {
-			synchConnectorWorkItem.run();
-			assertNotNull("Connection should not be null when IsImmutable is true", synchConnectorWorkItem.connection);   //$NON-NLS-1$ 
-		} catch ( Exception e ) {
-			LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_CONNECTOR, e.getMessage());			
-		}
+		new ConnectorWorkItem(requestMsg, cm);
     }
     
-	@Test public void testIsImmutablePropertyFails() throws Exception {
+	@Test(expected=ConnectorException.class) public void testIsImmutablePropertyFails() throws Exception {
     	/*
     	 * Setup:
     	 *  1. requestMsg.isTransactional() must be TRUE 
@@ -394,7 +162,7 @@
     	 */
     	ConnectorEnvironment env = Mockito.mock(ConnectorEnvironment.class);
     	Mockito.stub(env.isImmutable()).toReturn(false);
-		ConnectorManager cm = getConnectorManager(env);
+		ConnectorManager cm = TestConnectorManager.getConnectorManager(env);
         
 		// command must not be a SELECT
 		Command command = helpGetCommand("update bqt1.smalla set stringkey = 1 where stringkey = 2", EXAMPLE_BQT); //$NON-NLS-1$
@@ -408,41 +176,7 @@
 				return Mockito.mock(Xid.class);
 			}} );
 		
-		QueueResultsReceiver receiver = new QueueResultsReceiver();
-	
-		// This is the test
-		try {
-			SynchConnectorWorkItem synchConnectorWorkItem = new SynchConnectorWorkItem(requestMsg, cm, receiver);
-			synchConnectorWorkItem.run();
-			assertNull("Connection should be null when IsImmutable is false", synchConnectorWorkItem.connection);  //$NON-NLS-1$ 
-		} catch ( Exception e ) {
-			LogManager.logWarning(com.metamatrix.common.util.LogConstants.CTX_CONNECTOR, e.getMessage());			
-		}
+		new ConnectorWorkItem(requestMsg, cm);
     }
 
-	private static class FakeQueuingAsynchConnectorWorkItem extends
-			AsynchConnectorWorkItem {
-		int resumeCount;
-
-		FakeQueuingAsynchConnectorWorkItem(AtomicRequestMessage message, ConnectorManager manager, ResultsReceiver<AtomicResultsMessage> resultsReceiver, WorkManager wm) throws ConnectorException {
-			super(message, manager, resultsReceiver, wm);
-		}
-
-		@Override
-		protected void resumeProcessing() {
-			resumeCount++;
-		}
-	}
-
-	private Thread runRequest(final ConnectorWorkItem state) {
-		Thread t = new Thread() {
-			@Override
-			public void run() {
-				state.run();
-			}
-		};
-		t.start();
-		return t;
-	}
-
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -22,8 +22,9 @@
 
 package org.teiid.dqp.internal.datamgr.language;
 
+import junit.framework.TestCase;
+
 import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.AggregateFunction;
 import org.teiid.connector.language.Literal;
 import org.teiid.connector.language.SQLReservedWords;
 
@@ -31,8 +32,6 @@
 import com.metamatrix.query.sql.symbol.AggregateSymbol;
 import com.metamatrix.query.sql.symbol.Constant;
 
-import junit.framework.TestCase;
-
 public class TestAggregateImpl extends TestCase {
 
     /**

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -213,7 +213,8 @@
 
     private ResultsMessage helpExecute(String sql, String userName, int sessionid, boolean txnAutoWrap) throws Exception {
         RequestMessage reqMsg = exampleRequestMessage(sql);
-        DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(sessionid, userName));
+        DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
+        DQPWorkContext.getWorkContext().getSession().setUserName(userName);
         if (txnAutoWrap) {
         	reqMsg.setTxnAutoWrapMode(ExecutionProperties.TXN_WRAP_ON);
         }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -141,7 +141,8 @@
      
     	if (workContext == null) {
 	    	workContext = new DQPWorkContext();
-	    	workContext.setSessionToken(new SessionToken(Long.valueOf(id.getConnectionID()), "foo")); //$NON-NLS-1$
+	    	workContext.getSession().setSessionId(Long.valueOf(id.getConnectionID()));
+	    	workContext.getSession().setUserName("foo"); //$NON-NLS-1$
     	}
         RequestWorkItem workItem = new RequestWorkItem(rm, requestMsg, null, null, id, workContext);
         workItem.setOriginalCommand(originalCommand);

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -25,7 +25,6 @@
 import junit.framework.TestCase;
 
 import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.platform.security.api.SessionToken;
 
 public class TestDQPWorkContext extends TestCase {
 
@@ -40,10 +39,11 @@
 
 	public static DQPWorkContext example() {
 		DQPWorkContext message = new DQPWorkContext();
-		message.setVdbName("vdbName"); //$NON-NLS-1$
-		message.setVdbVersion(1); //$NON-NLS-1$
-		message.setAppName("querybuilder"); //$NON-NLS-1$
-		message.setSessionToken(new SessionToken(5, "userName")); //$NON-NLS-1$
+		message.getSession().setVDBName("vdbName"); //$NON-NLS-1$
+		message.getSession().setVDBVersion(1); 
+		message.getSession().setApplicationName("querybuilder"); //$NON-NLS-1$
+		message.getSession().setSessionId(5);
+		message.getSession().setUserName("userName"); //$NON-NLS-1$
 		return message;
 	}
 
@@ -53,7 +53,7 @@
 		assertEquals("5", copy.getConnectionID()); //$NON-NLS-1$
 		assertEquals("userName", copy.getUserName()); //$NON-NLS-1$
 		assertEquals("vdbName", copy.getVdbName()); //$NON-NLS-1$
-		assertEquals(1, copy.getVdbVersion()); //$NON-NLS-1$
+		assertEquals(1, copy.getVdbVersion());
 		assertEquals("querybuilder", copy.getAppName()); //$NON-NLS-1$
 	}
 

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -22,30 +22,20 @@
 
 package org.teiid.dqp.internal.process;
 
-import java.util.List;
-
-import javax.resource.spi.work.WorkManager;
-
 import junit.framework.TestCase;
 
 import org.mockito.Mockito;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
 import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
 import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
 
 import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.common.queue.FakeWorkManager;
-import com.metamatrix.dqp.message.AtomicRequestID;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
+import com.metamatrix.dqp.service.AutoGenDataService;
 import com.metamatrix.dqp.service.FakeBufferService;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
 import com.metamatrix.query.parser.QueryParser;
 import com.metamatrix.query.processor.dynamic.SimpleQueryProcessorFactory;
 import com.metamatrix.query.resolver.QueryResolver;
@@ -62,8 +52,7 @@
     private AtomicRequestMessage request;
     private Command command;
     private DataTierTupleSource info;
-    private int executeRequestFailOnCall = 10000;
-    private FakeConnectorManager connectorManager;
+    private AutoGenDataService connectorManager;
     private RequestWorkItem workItem;
     
     public TestDataTierManager(String name) {
@@ -84,7 +73,7 @@
         QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
         DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.exampleBQTVDB());
         
-        connectorManager = new FakeConnectorManager("FakeConnectorID", executeRequestFailOnCall);
+        connectorManager = new AutoGenDataService();
         rm = new DQPCore();
         rm.setTransactionService(new FakeTransactionService());
         
@@ -97,7 +86,6 @@
         dtm = new DataTierManagerImpl(rm,
                                   repo,
                                   bs,
-                                  new FakeWorkManager(),
                                   20,
                                   1000,
                                   1000);
@@ -111,7 +99,7 @@
         context = new CommandContext();
         context.setProcessorID(requestID);
         context.setVdbName("test"); //$NON-NLS-1$
-        context.setVdbVersion(1); //$NON-NLS-1$
+        context.setVdbVersion(1);
         context.setQueryProcessorFactory(new SimpleQueryProcessorFactory(bs.getBufferManager(), dtm, new DefaultCapabilitiesFinder(), null, metadata));
         workItem = TestDQPCoreRequestHandling.addRequest(rm, original, requestID, null, workContext);
         
@@ -120,154 +108,14 @@
         request.setConnectorName("FakeConnectorID"); //$NON-NLS-1$
 
         info = new DataTierTupleSource(command.getProjectedSymbols(), request, dtm, request.getConnectorName(), workItem);
-        workItem.addConnectorRequest(request.getAtomicRequestID(), info);
     }
     
-    private AtomicResultsMessage helpSetup(boolean isFirst, boolean isLast) throws Exception {
-        return helpSetup("SELECT * FROM BQT1.SmallA", isFirst, isLast); //$NON-NLS-1$
-    }
-
-    private AtomicResultsMessage helpSetup(String sql, boolean isFirst, boolean isLast) throws Exception {
-    	return helpSetup(sql, isFirst, isLast, 3);
-    }
-    
-    private AtomicResultsMessage helpSetup(String sql, boolean isFirst, boolean isLast, int nodeId) throws Exception {
-        helpSetup(sql, nodeId);        
-        
-        request.setCommand(command);
-
-        AtomicResultsMessage results = new AtomicResultsMessage(request, new List[0], new String[0]);
-        
-        if (isLast) {
-            results.setFinalRow(10);
-        }
-        return results;
-    }
-    
-    /**
-     * Defect 15646 - Ensure that when the final batch is received, the ConnectorRequestInfo object is removed from the RequestManager
-     * @throws Exception
-     * @since 4.2
-     */
-    public void testDeliverMessageNEWResponseFinal_Defect15646() throws Exception {
-        AtomicResultsMessage results = helpSetup(true, true);
-        info.receiveResults(results);
-        
+    public void testDataTierTupleSource() throws Exception {
+    	helpSetup(1);
+    	info.nextTuple();
         assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-        
-        DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
-        
-        connRequest.closeSource();
-        
-        assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-        
-        AtomicResultsMessage closeResult = new AtomicResultsMessage(request);
-        closeResult.setRequestClosed(true);
-        info.receiveResults(closeResult);
-        
-        assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));        
-    }
-
-    public void testDeliverMessageNEWResponseNonFinal() throws Exception {
-    	AtomicResultsMessage results = helpSetup(true, false);
-        info.receiveResults(results);
-        assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-    }
-
-    public void testDeliverMessageMOREResponseFinal_Defect15646() throws Exception {
-    	AtomicResultsMessage results = helpSetup(false, true);
-        info.receiveResults(results);
-        
-        assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-        
-        DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
-        
-        connRequest.closeSource();
-        
-        assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-        
-        AtomicResultsMessage closeResult = new AtomicResultsMessage(request);
-        closeResult.setRequestClosed(true);
-        info.receiveResults(closeResult);
-        
-        assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));                
-    }
-    
-    public void testExplicitClose() throws Exception {
-        String sql = "select ClobValue from LOB.LobTbl"; //$NON-NLS-1$
-        
-        AtomicResultsMessage results = helpSetup(sql, true, true);
-        results.setSupportsImplicitClose(false);
-        
-        info.receiveResults(results);
-        assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-        
-        DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
-        connRequest.closeSource();
-        assertFalse(this.connectorManager.closed);
-        
-        assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-        
-        // now explicit close and see it gone        
-        connRequest.fullyCloseSource();
-        
-        assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-        
-        AtomicResultsMessage closeResult = new AtomicResultsMessage(request);
-        closeResult.setRequestClosed(true);
-        info.receiveResults(closeResult);
-        
-        assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));        
-    }    
-    
-    
-    public void testImplictClose() throws Exception {
-        String sql = "select ClobValue from LOB.LobTbl"; //$NON-NLS-1$
-        
-        AtomicResultsMessage results = helpSetup(sql, true, true);
-        results.setSupportsImplicitClose(true);
-        
-        info.receiveResults(results);
-        
-        assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-
-        DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
-        connRequest.closeSource();
-        assertTrue(this.connectorManager.closed);
-        
-        assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-        
-        AtomicResultsMessage closeResult = new AtomicResultsMessage(request);
-        closeResult.setRequestClosed(true);
-        info.receiveResults(closeResult);
-
+        info.closeSource();
         assertNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-    } 
-    
-    public void testImplictCloseWithNotAllowedState() throws Exception {
-        String sql = "select ClobValue from LOB.LobTbl"; //$NON-NLS-1$
-        
-        AtomicResultsMessage results = helpSetup(sql, true, true);
-        results.setSupportsImplicitClose(false);
-        
-        info.receiveResults(results);
-        assertFalse(this.connectorManager.closed);
-        assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-        
-        DataTierTupleSource connRequest = workItem.getConnectorRequest(request.getAtomicRequestID());
-        
-        // now implicitly close the request then check to make sure it is not gone 
-        connRequest.closeSource();
-        assertFalse(this.connectorManager.closed);        
-        assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
-    }     
-    
-    
-    public void testDeliverMessageMOREResponseNonFinal() throws Exception {
-    	AtomicResultsMessage results = helpSetup(false, false);
-        info.receiveResults(results);
-        
-        assertNotNull(workItem.getConnectorRequest(request.getAtomicRequestID()));
     }
     
     public void testCodeTableResponseException() throws Exception {
@@ -282,60 +130,4 @@
         }
     }
     
-    public void testCodeTableResponse_MoreRequestFails() throws Exception {
-        executeRequestFailOnCall = 1;
-        
-        AtomicResultsMessage results = helpSetup("SELECT * FROM BQT1.SmallA", true, false, -1); //$NON-NLS-1$
-        
-        this.connectorManager.results = results;
-        
-        try {
-            dtm.lookupCodeValue(context, "BQT1.SmallA", "IntKey", "StringKey", "49");  //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-            fail("processor should have failed"); //$NON-NLS-1$
-        } catch (MetaMatrixException e) {
-            assertEquals("Force fail on executeRequest for call # 1", e.getMessage()); //$NON-NLS-1$
-        }
-    }
-    
-    private static class FakeConnectorManager extends ConnectorManager {
-        private int failOnCall = 10000;
-        private int calls = 0;
-        private boolean closed = false;
-        boolean throwExceptionOnExecute;
-        AtomicResultsMessage results;
-        
-        private FakeConnectorManager(String name, int failOnCallNumber) {
-        	super(name);
-            this.failOnCall = failOnCallNumber;
-        }
-        @Override
-		public void executeRequest(WorkManager workManager, ResultsReceiver<AtomicResultsMessage> resultListener, AtomicRequestMessage request)
-				throws ConnectorException {
-            if (closed) {
-                throw new ConnectorException("Already closed"); //$NON-NLS-1$
-            }
-            if (throwExceptionOnExecute) {
-            	resultListener.exceptionOccurred(new RuntimeException("Connector Exception")); //$NON-NLS-1$
-            } else {
-            	resultListener.receiveResults(results);
-            }
-        }
-
-		@Override
-		public void closeRequest(AtomicRequestID request) {
-			closed = true;
-		}
-		
-		@Override
-		public SourceCapabilities getCapabilities() throws ConnectorException{
-			return null;
-		}
-		@Override
-		public void requstMore(AtomicRequestID requestId) throws ConnectorException {
-            calls++;
-            if (calls == failOnCall) {
-                throw new ConnectorException("Force fail on executeRequest for call # " + calls); //$NON-NLS-1$
-            }            
-		}
-    }
 }

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -48,10 +48,10 @@
 	private final static ParseInfo pi = new ParseInfo();
 	
 	@BeforeClass public static void setUpOnce() {
-		token.setVdbName("foo"); //$NON-NLS-1$
-		token.setVdbVersion(1); //$NON-NLS-1$
-		token2.setVdbName("foo"); //$NON-NLS-1$
-		token2.setVdbVersion(2); //$NON-NLS-1$
+		token.getSession().setVDBName("foo"); //$NON-NLS-1$
+		token.getSession().setVDBVersion(1); 
+		token2.getSession().setVDBName("foo"); //$NON-NLS-1$
+		token2.getSession().setVDBVersion(2); 
 	}
     
     //====Tests====//

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -22,9 +22,7 @@
 
 package org.teiid.dqp.internal.process;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -44,7 +42,6 @@
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.message.RequestMessage.StatementType;
 import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.query.metadata.QueryMetadataInterface;
 import com.metamatrix.query.optimizer.TestOptimizer;
 import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
@@ -247,7 +244,7 @@
         }
        
         DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, vdb);
-        workContext.setSessionToken(new SessionToken(conn, "foo")); //$NON-NLS-1$ 
+        workContext.getSession().setSessionId(conn); 
         
         PreparedStatementRequest serverRequest = new PreparedStatementRequest(prepPlanCache) {
         	@Override

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -59,11 +59,6 @@
 public class TestRequest extends TestCase {
 
     private final static String QUERY = "SELECT * FROM pm1.g1";  //$NON-NLS-1$
-    private final static String VDB = "VDB";  //$NON-NLS-1$
-    private final static int VDB_VERSION = 1;  //$NON-NLS-1$
-    private final static String MODEL = "pm1";  //$NON-NLS-1$
-    private final static String BINDING_ID = "1";  //$NON-NLS-1$
-    private final static String BINDING_NAME = "BINDING";  //$NON-NLS-1$
     
     /**
      * Constructor for TestRequest.
@@ -146,7 +141,7 @@
         DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
         
         Request request = helpProcessMessage(message, null, workContext);
-        assertEquals("5", request.context.getEnvironmentProperties().get(ContextProperties.SESSION_ID)); //$NON-NLS-1$
+        assertEquals("1", request.context.getEnvironmentProperties().get(ContextProperties.SESSION_ID)); //$NON-NLS-1$
     }
 
     private Request helpProcessMessage(RequestMessage message, SessionAwareCache<PreparedPlan> cache, DQPWorkContext workContext) throws QueryValidatorException,

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestWorkItemState.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -85,15 +85,6 @@
 	    private void assertDoneState() {
 	        checkState(ThreadState.DONE);
 	    }
-
-		@Override
-		protected boolean assosiateSecurityContext() {
-			return false;
-		}
-
-		@Override
-		protected void clearSecurityContext() {
-		}
 	}
 	
     public TestWorkItemState(String name) {

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -22,22 +22,25 @@
 
 package org.teiid.dqp.internal.transaction;
 
+import static org.junit.Assert.*;
+
 import javax.resource.spi.XATerminator;
+import javax.transaction.TransactionManager;
 import javax.transaction.xa.XAResource;
 
-import junit.framework.TestCase;
-
+import org.junit.Before;
+import org.junit.Test;
 import org.mockito.Mockito;
 import org.teiid.adminapi.Transaction;
 
 import com.metamatrix.common.xa.MMXid;
 import com.metamatrix.common.xa.XATransactionException;
 import com.metamatrix.dqp.service.TransactionContext;
+public class TestTransactionServer {
 
-public class TestTransactionServer extends TestCase {
-
     private TransactionServerImpl server;
     private XATerminator xaTerminator;
+    private TransactionManager tm;
     
     private static final String THREAD1 = "1"; //$NON-NLS-1$
     private static final String THREAD2 = "2"; //$NON-NLS-1$
@@ -49,22 +52,20 @@
         2
     }, new byte[0]);
 
-    /**
-     * @see junit.framework.TestCase#setUp()
-     */
-    protected void setUp() throws Exception {
+    @Before public void setUp() throws Exception {
         server = new TransactionServerImpl();
-        TransactionProvider provider = Mockito.mock(TransactionProvider.class);
         xaTerminator = Mockito.mock(XATerminator.class);
-        Mockito.stub(provider.getXATerminator()).toReturn(xaTerminator);
-        server.setTransactionProvider(provider); 
-        server.setXidFactory(new XidFactory());
+        tm = Mockito.mock(TransactionManager.class);
+        javax.transaction.Transaction txn = Mockito.mock(javax.transaction.Transaction.class);
+        Mockito.stub(tm.getTransaction()).toReturn(txn);
+        server.setXaTerminator(xaTerminator);
+        server.setTransactionManager(tm);
     }
 
     /**
      * once in a local, cannot start a global
      */
-    public void testTransactionExclusion() throws Exception {
+    @Test public void testTransactionExclusion() throws Exception {
         server.begin(THREAD1);
 
         try {
@@ -79,7 +80,7 @@
     /**
      * once in a global, cannot start a local
      */
-    public void testTransactionExclusion1() throws Exception {
+    @Test public void testTransactionExclusion1() throws Exception {
         server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100, false);
 
         try {
@@ -94,7 +95,7 @@
     /**
      * global can only be started once
      */
-    public void testTransactionExclusion2() throws Exception {
+    @Test public void testTransactionExclusion2() throws Exception {
         server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
 
         try {
@@ -108,7 +109,7 @@
     /**
      * global cannot be nested
      */
-    public void testTransactionExclusion3() throws Exception {
+    @Test public void testTransactionExclusion3() throws Exception {
         server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
 
         try {
@@ -123,7 +124,7 @@
     /**
      * local cannot be nested
      */
-    public void testTransactionExclusion4() throws Exception {
+    @Test public void testTransactionExclusion4() throws Exception {
         server.begin(THREAD1);
 
         try {
@@ -138,7 +139,7 @@
     /**
      * global cannot be nested
      */
-    public void testTransactionExclusion5() throws Exception {
+    @Test public void testTransactionExclusion5() throws Exception {
         server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
         server.start(THREAD2, XID2, XAResource.TMNOFLAGS, 100,false);
         server.end(THREAD2, XID2, XAResource.TMSUCCESS,false);
@@ -152,9 +153,11 @@
         }
     }
 
-    public void testLocalCommit() throws Exception {
+    @Test public void testLocalCommit() throws Exception {
         server.begin(THREAD1);
         server.commit(THREAD1);
+        
+        Mockito.verify(tm).commit();
 
         try {
             server.commit(THREAD1);
@@ -163,48 +166,27 @@
         }
     }
 
-    public void testLocalSetRollback() throws Exception {
+    @Test public void testLocalSetRollback() throws Exception {
         TransactionContext tc = server.begin(THREAD1);
-        tc.incrementPartcipatingSourceCount("s1");
         tc.setRollbackOnly();
         
         server.commit(THREAD1);
         
-        Mockito.verify(xaTerminator).rollback(tc.getXid());
+        Mockito.verify(tm).rollback();
     }    
     
-    public void testSinglePhaseCommit() throws Exception {
-        TransactionContext tc = server.begin(THREAD1);
-        tc.incrementPartcipatingSourceCount("S1");
+    @Test public void testTwoPhaseCommit() throws Exception {
+    	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
+    	server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
+        server.commit(THREAD1, XID1, false, false);
         
-        server.commit(THREAD1);
-        
-        Mockito.verify(xaTerminator).commit(tc.getXid(), true);
-        
-        tc = server.begin(THREAD1);
-        tc.incrementPartcipatingSourceCount("S1");
-        tc.incrementPartcipatingSourceCount("S1");
-        
-        server.commit(THREAD1);
-        
-        Mockito.verify(xaTerminator).commit(tc.getXid(), true);        
-    }      
-    
-    public void testTwoPhaseCommit() throws Exception {
-        TransactionContext tc = server.begin(THREAD1);
-        tc.incrementPartcipatingSourceCount("S1");
-        tc.incrementPartcipatingSourceCount("S2");
-        
-        server.commit(THREAD1);
-        
-        Mockito.verify(xaTerminator).commit(tc.getXid(), false);
+        Mockito.verify(xaTerminator).commit(XID1, false);
     }     
     
-    public void testLocalRollback() throws Exception {
-        TransactionContext tc = server.begin(THREAD1);
-        tc.incrementPartcipatingSourceCount("s1");
+    @Test public void testLocalRollback() throws Exception {
+        server.begin(THREAD1);
         server.rollback(THREAD1);
-        Mockito.verify(xaTerminator).rollback(tc.getXid());
+        Mockito.verify(tm).rollback();
         
         try {
             server.rollback(THREAD1);
@@ -213,7 +195,7 @@
         }
     }
 
-    public void testConcurrentEnlistment() throws Exception {
+    @Test public void testConcurrentEnlistment() throws Exception {
         server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
 
         try {
@@ -225,7 +207,7 @@
         }
     }
 
-    public void testSuspend() throws Exception {
+    @Test public void testSuspend() throws Exception {
         server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
         server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
 
@@ -237,7 +219,7 @@
         }
     }
     
-    public void testSuspendResume() throws Exception {
+    @Test public void testSuspendResume() throws Exception {
         server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
         server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
         server.start(THREAD1, XID1, XAResource.TMRESUME, 100,false);
@@ -251,7 +233,7 @@
         }
     }
 
-    public void testUnknownFlags() throws Exception {
+    @Test public void testUnknownFlags() throws Exception {
         try {
             server.start(THREAD1, XID1, Integer.MAX_VALUE, 100,false);
             fail("exception expected"); //$NON-NLS-1$
@@ -260,7 +242,7 @@
         }
     }
 
-    public void testUnknownGlobalTransaction() throws Exception {
+    @Test public void testUnknownGlobalTransaction() throws Exception {
         try {
             server.end(THREAD1, XID1, XAResource.TMSUCCESS,false);
             fail("exception expected"); //$NON-NLS-1$
@@ -269,7 +251,7 @@
         }
     }
     
-    public void testPrepareWithSuspended() throws Exception {
+    @Test public void testPrepareWithSuspended() throws Exception {
         server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
         server.end(THREAD1, XID1, XAResource.TMSUSPEND,false);
 
@@ -281,11 +263,11 @@
         }
     }
     
-    public void testGetTransactionContext() throws Exception {
+    @Test public void testGetTransactionContext() throws Exception {
         assertSame(server.getOrCreateTransactionContext(THREAD1), server.getOrCreateTransactionContext(THREAD1));
     }
     
-    public void testGetTransactions() throws Exception {
+    @Test public void testGetTransactions() throws Exception {
     	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
         server.begin(THREAD2);
         
@@ -296,10 +278,10 @@
         
         Transaction t = server.getTransactions().iterator().next();
         assertEquals(Long.parseLong(THREAD1), t.getAssociatedSession());
-        assertNotNull(t.getXid());
+        assertNotNull(t.getId());
     }
     
-    public void testGlobalPrepare() throws Exception {
+    @Test public void testGlobalPrepare() throws Exception {
     	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
         TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
         server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
@@ -311,59 +293,47 @@
     	server.commit(THREAD1, XID1, true, false);
     }
     
-    public void testGlobalPrepareFail() throws Exception {
+    @Test public void testGlobalPrepareFail() throws Exception {
     	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
         server.end(THREAD1, XID1, XAResource.TMFAIL, false);
         
     	try {
 			server.prepare(THREAD1, XID1, false);
-			fail("should have failed to prepare as end resulted in TMFAIL");
-		} catch (Exception e) {
+			fail("should have failed to prepare as end resulted in TMFAIL"); //$NON-NLS-1$
+		} catch (XATransactionException e) {
 		}
-		
-		server.forget(THREAD1, XID1, false);
     }    
     
-    public void testGlobalOnePhaseCommit() throws Exception {
+    @Test public void testGlobalOnePhaseCommit() throws Exception {
     	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
     	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
     	
-    	tc.incrementPartcipatingSourceCount("S1");
-    	
         server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
         
         server.prepare(THREAD1, XID1, false);
 
 		
 		server.commit(THREAD1, XID1, true, false);
-		
-		// since there are two sources the commit is not single phase
-		Mockito.verify(xaTerminator).commit(tc.getXid(), true);
+		Mockito.verify(xaTerminator).commit(tc.getXid(), false);
     }  
     
-    public void testGlobalOnePhaseCommit_force_prepare_through() throws Exception {
+    @Test public void testGlobalOnePhaseCommit_force_prepare_through() throws Exception {
     	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
     	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
     	
-    	tc.incrementPartcipatingSourceCount("S1");
-    	
         server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
         
 		
 		server.commit(THREAD1, XID1, true, false);
 		
-		// since there are two sources the commit is not single phase
-		Mockito.verify(xaTerminator, Mockito.times(0)).prepare(tc.getXid());
-		Mockito.verify(xaTerminator).commit(tc.getXid(), true);
+		Mockito.verify(xaTerminator).prepare(tc.getXid());
+		Mockito.verify(xaTerminator).commit(tc.getXid(), false);
     }  
     
-    public void testGlobalOnePhaseCommit_force_prepare() throws Exception {
+    @Test public void testGlobalOnePhaseCommit_force_prepare() throws Exception {
     	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
     	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
     	
-    	tc.incrementPartcipatingSourceCount("S1");
-    	tc.incrementPartcipatingSourceCount("S2");
-    	
         server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
         
 		
@@ -375,13 +345,10 @@
     }  
     
     
-    public void testGlobalOnePhase_teiid_multiple() throws Exception {
+    @Test public void testGlobalOnePhase_teiid_multiple() throws Exception {
     	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
     	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
     	
-    	tc.incrementPartcipatingSourceCount("S1");
-    	tc.incrementPartcipatingSourceCount("S2");
-    	
         server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
         
         server.prepare(THREAD1, XID1, false);
@@ -393,12 +360,10 @@
 		Mockito.verify(xaTerminator).commit(tc.getXid(), false);
     }    
     
-    public void testGlobalOnePhaseRoolback() throws Exception {
+    @Test public void testGlobalOnePhaseRoolback() throws Exception {
     	server.start(THREAD1, XID1, XAResource.TMNOFLAGS, 100,false);
     	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
     	
-    	tc.incrementPartcipatingSourceCount("S1");
-    	
         server.end(THREAD1, XID1, XAResource.TMSUCCESS, false);
         
         server.prepare(THREAD1, XID1, false);
@@ -410,69 +375,34 @@
 		Mockito.verify(xaTerminator).rollback(tc.getXid());
     }     
     
-    public void testLocalCommit_rollback() throws Exception {
-        TransactionContext tc = server.begin(THREAD1);
-        tc.incrementPartcipatingSourceCount("s1");
-        tc.setRollbackOnly();
-        server.commit(THREAD1);
-
-        Mockito.verify(xaTerminator).rollback(tc.getXid());
-    }    
-    
-    public void testLocalCommit_not_in_Tx() throws Exception {
-        TransactionContext tc = server.begin(THREAD1);
-        server.commit(THREAD1);
-
-        Mockito.verify(xaTerminator,Mockito.times(0)).commit(tc.getXid(), true);
-    }       
-    
-    public void testRequestCommit() throws Exception{
+    @Test public void testRequestCommit() throws Exception{
     	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
-    	server.start(tc);
-    	tc.incrementPartcipatingSourceCount("s1");
+    	server.begin(tc);
     	server.commit(tc);
-    	Mockito.verify(xaTerminator,Mockito.times(0)).prepare(tc.getXid());
-    	Mockito.verify(xaTerminator).commit(tc.getXid(), true);
+    	Mockito.verify(tm).commit();
     }
     
-    public void testRequestCommit2() throws Exception{
+    @Test public void testRequestRollback() throws Exception{
     	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
-    	server.start(tc);
-    	tc.incrementPartcipatingSourceCount("s1");
-    	tc.incrementPartcipatingSourceCount("s2");
-    	server.commit(tc);
+    	server.begin(tc);
     	
-    	Mockito.verify(xaTerminator).prepare(tc.getXid());
-    	Mockito.verify(xaTerminator).commit(tc.getXid(), false);
-    }    
-    
-    public void testRequestRollback() throws Exception{
-    	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
-    	server.start(tc);
-    	tc.incrementPartcipatingSourceCount("s1");
-    	tc.incrementPartcipatingSourceCount("s2");
-    	
     	server.rollback(tc);
-    	Mockito.verify(xaTerminator).rollback(tc.getXid());
+    	Mockito.verify(tm).rollback();
     }     
     
-    public void testLocalCancel() throws Exception {
-        TransactionContext tc = server.begin(THREAD1);
-        tc.incrementPartcipatingSourceCount("S1");
-        tc.incrementPartcipatingSourceCount("S2");
+    @Test public void testLocalCancel() throws Exception {
+        server.begin(THREAD1);
         
         server.cancelTransactions(THREAD1, false);
         
-        Mockito.verify(xaTerminator).rollback(tc.getXid());
+        Mockito.verify(tm).setRollbackOnly();
     }  
     
-    public void testRequestCancel() throws Exception{
+    @Test public void testRequestCancel() throws Exception{
     	TransactionContext tc = server.getOrCreateTransactionContext(THREAD1);
-    	server.start(tc);
-    	tc.incrementPartcipatingSourceCount("s1");
-    	tc.incrementPartcipatingSourceCount("s2");
+    	server.begin(tc);
     	
-    	 server.cancelTransactions(THREAD1, true);
-    	Mockito.verify(xaTerminator).rollback(tc.getXid());
+    	server.cancelTransactions(THREAD1, true);
+    	Mockito.verify(tm).setRollbackOnly();
     }      
 }

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -35,7 +35,6 @@
 import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
 import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
 import org.teiid.connector.api.Connector;
-import org.teiid.connector.api.ConnectorException;
 import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
 import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
 import org.teiid.security.SecurityHelper;
@@ -63,14 +62,9 @@
 			if (connectorDefinition.equals(Connector.class.getName())) {
 				String connectorName = data.getJndiName();
 
-				ConnectorManager cm = null;
-				try {
-					cm = createConnectorManger("java:"+connectorName, data.getMaxSize()); //$NON-NLS-1$
-					cm.start();
-					cmGroup.addConnectorManager(cm);
-				} catch (ConnectorException e) {
-					throw new DeploymentException(e);
-				}
+				ConnectorManager cm = createConnectorManger("java:"+connectorName, data.getMaxSize()); //$NON-NLS-1$
+				cm.start();
+				cmGroup.addConnectorManager(cm);
 
 				// Add the references to the mgr as loaded.
 	            this.connectorManagerRepository.addConnectorManager("java:"+connectorName, cm);  //$NON-NLS-1$    

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -32,6 +32,7 @@
 
 import javax.resource.spi.XATerminator;
 import javax.resource.spi.work.WorkManager;
+import javax.transaction.TransactionManager;
 
 import org.jboss.managed.api.ManagedOperation.Impact;
 import org.jboss.managed.api.annotation.ManagementComponent;
@@ -48,14 +49,11 @@
 import org.teiid.adminapi.impl.SessionMetadata;
 import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
 import org.teiid.adminapi.jboss.AdminProvider;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
 import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
 import org.teiid.dqp.internal.process.DQPConfiguration;
 import org.teiid.dqp.internal.process.DQPCore;
 import org.teiid.dqp.internal.process.DQPWorkContext;
-import org.teiid.dqp.internal.transaction.ContainerTransactionProvider;
 import org.teiid.dqp.internal.transaction.TransactionServerImpl;
-import org.teiid.dqp.internal.transaction.XidFactory;
 import org.teiid.jboss.IntegrationPlugin;
 import org.teiid.logging.LogConfigurationProvider;
 import org.teiid.logging.LogListernerProvider;
@@ -74,14 +72,13 @@
 import com.metamatrix.common.util.LogConstants;
 import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQP;
 import com.metamatrix.dqp.client.DQPManagement;
 import com.metamatrix.dqp.service.AuthorizationService;
 import com.metamatrix.dqp.service.BufferService;
 import com.metamatrix.dqp.service.SessionService;
 import com.metamatrix.dqp.service.TransactionService;
 import com.metamatrix.platform.security.api.ILogon;
-import com.metamatrix.platform.security.api.SessionToken;
 
 @ManagementObject(isRuntime=true, componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
 public class RuntimeEngineDeployer extends DQPConfiguration implements DQPManagement, Serializable , ClientServiceRegistry  {
@@ -91,9 +88,10 @@
 	private transient SocketConfiguration adminSocketConfiguration;	
 	private transient SocketTransport jdbcSocket;	
 	private transient SocketTransport adminSocket;
-	private transient SecurityHelper securityHelper;
+	private transient TransactionServerImpl transactionServerImpl = new TransactionServerImpl();
 		
 	private transient DQPCore dqpCore = new DQPCore();
+	private transient SessionService sessionService;
 	private transient ILogon logon;
 	private transient Admin admin;
 	private transient ClientServiceRegistryImpl csr = new ClientServiceRegistryImpl();	
@@ -104,20 +102,25 @@
 		LogManager.setLogListener(new LogListernerProvider().get());
     }
 	
-	
 	@Override
 	public <T> T getClientService(Class<T> iface)
 			throws ComponentNotFoundException {
 		return this.csr.getClientService(iface);
 	}
 	
+	@Override
+	public SecurityHelper getSecurityHelper() {
+		return this.csr.getSecurityHelper();
+	}
+	
     public void start() {
+		dqpCore.setTransactionService((TransactionService)LogManager.createLoggingProxy(com.metamatrix.common.util.LogConstants.CTX_TXN_LOG, transactionServerImpl, new Class[] {TransactionService.class}, MessageLevel.DETAIL));
 
     	// create the necessary services
     	createClientServices();
     	
-    	this.csr.registerClientService(ILogon.class, proxyService(ILogon.class, logon), com.metamatrix.common.util.LogConstants.CTX_SESSION);
-    	this.csr.registerClientService(ClientSideDQP.class, proxyService(ClientSideDQP.class, this.dqpCore), com.metamatrix.common.util.LogConstants.CTX_DQP);
+    	this.csr.registerClientService(ILogon.class, logon, com.metamatrix.common.util.LogConstants.CTX_SESSION);
+    	this.csr.registerClientService(DQP.class, proxyService(DQP.class, this.dqpCore), com.metamatrix.common.util.LogConstants.CTX_DQP);
     	this.csr.registerClientService(Admin.class, proxyService(Admin.class, admin), com.metamatrix.common.util.LogConstants.CTX_ADMIN_API);
     	
     	if (this.jdbcSocketConfiguration.isEnabled()) {
@@ -163,7 +166,7 @@
 		
 		this.dqpCore.start(this);
 		
-		this.logon = new LogonImpl(this.dqpCore.getSessionService(), "teiid-cluster"); //$NON-NLS-1$
+		this.logon = new LogonImpl(this.sessionService, "teiid-cluster"); //$NON-NLS-1$
     	try {
     		this.admin = AdminProvider.getLocal();
     	} catch (AdminComponentException e) {
@@ -171,58 +174,28 @@
     	}		        
 	}    
 	
-    private TransactionService getTransactionService(String processName, XATerminator terminator) {
-		TransactionServerImpl txnService = new TransactionServerImpl();
-		txnService.setTransactionProvider(new ContainerTransactionProvider(terminator));
-		txnService.setProcessName(processName);
-		txnService.setXidFactory(new XidFactory());
-		return (TransactionService)LogManager.createLoggingProxy(com.metamatrix.common.util.LogConstants.CTX_TXN_LOG, txnService, new Class[] {TransactionService.class}, MessageLevel.DETAIL);
-    }	
-	
+	/**
+	 * Creates an proxy to validate the incoming session
+	 */
 	private <T> T proxyService(final Class<T> iface, final T instance) {
 
 		return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new InvocationHandler() {
 
 			public Object invoke(Object arg0, Method arg1, Object[] arg2) throws Throwable {
-				
 				Throwable exception = null;
-				ClassLoader current = Thread.currentThread().getContextClassLoader();
 				try {
-					if (!(iface.equals(ILogon.class))) {					
-						logon.assertIdentity(SessionToken.getSession());
-						assosiateSecurityContext();
-					}
-					
+					sessionService.validateSession(DQPWorkContext.getWorkContext().getSessionId());
 					return arg1.invoke(instance, arg2);
 				} catch (InvocationTargetException e) {
 					exception = e.getTargetException();
 				} catch(Throwable t){
 					exception = t;
-				} finally {
-					clearSecurityContext();
-					DQPWorkContext.releaseWorkContext();
-					Thread.currentThread().setContextClassLoader(current);
 				}
 				throw ExceptionUtil.convertException(arg1, exception);
 			}
 		}));
-	}	
-	
-    private boolean assosiateSecurityContext() {
-		DQPWorkContext context = DQPWorkContext.getWorkContext();
-		if (context.getSubject() != null) {
-        	return securityHelper.assosiateSecurityContext(context.getSecurityDomain(), context.getSecurityContext());			
-		}
-		return false;
 	}
-    
-    private void clearSecurityContext() {
-		DQPWorkContext context = DQPWorkContext.getWorkContext();
-		if (context.getSubject() != null) {
-			securityHelper.clearSecurityContext(context.getSecurityDomain());			
-		}
-	}	   
-    
+	
 	public void setJdbcSocketConfiguration(SocketConfiguration socketConfig) {
 		this.jdbcSocketConfiguration = socketConfig;
 	}
@@ -232,9 +205,13 @@
 	}
     
     public void setXATerminator(XATerminator xaTerminator){
-       this.dqpCore.setTransactionService(getTransactionService("localhost", xaTerminator)); //$NON-NLS-1$
-    }    
+    	this.transactionServerImpl.setXaTerminator(xaTerminator);
+    }   
     
+    public void setTransactionManager(TransactionManager transactionManager) {
+    	this.transactionServerImpl.setTransactionManager(transactionManager);
+    }
+    
     public void setWorkManager(WorkManager mgr) {
     	this.dqpCore.setWorkManager(mgr);
     }
@@ -244,7 +221,8 @@
 	}
 	
 	public void setSessionService(SessionService service) {
-		this.dqpCore.setSessionService(service);
+		this.sessionService = service;
+		service.setDqp(this.dqpCore);
 	}
 	
 	public void setBufferService(BufferService service) {
@@ -256,8 +234,7 @@
 	}
 	
 	public void setSecurityHelper(SecurityHelper helper) {
-		this.securityHelper = helper;
-		this.dqpCore.setSecurityHelper(helper);
+		this.csr.setSecurityHelper(helper);
 	}
 	
 	@Override
@@ -278,17 +255,17 @@
 		if ("runtime".equalsIgnoreCase(identifier)) { //$NON-NLS-1$
 			return this.dqpCore.getWorkManagerStatistics();
 		}
-		ConnectorManager cm = this.dqpCore.getConnectorManagerRepository().getConnectorManager(identifier);
+		/*ConnectorManager cm = this.dqpCore.getConnectorManagerRepository().getConnectorManager(identifier);
 		if (cm != null) {
 			return cm.getWorkManagerStatistics();
-		}
+		}*/
 		return null;
 	}
 	
 	@Override
     @ManagementOperation(description="Terminate a Session",params={@ManagementParameter(name="terminateeId",description="The session to be terminated")})
     public void terminateSession(long terminateeId) {
-		this.dqpCore.getSessionService().terminateSession(terminateeId, SessionToken.getSession().getSessionID());
+		this.sessionService.terminateSession(terminateeId, DQPWorkContext.getWorkContext().getSessionId());
     }
     
 	@Override
@@ -317,7 +294,7 @@
 	@ManagementOperation(description="Active sessions", impact=Impact.ReadOnly)
 	public Collection<SessionMetadata> getActiveSessions() throws AdminException {
 		try {
-			return this.dqpCore.getActiveSessions();
+			return this.sessionService.getActiveSessions();
 		} catch (SessionServiceException e) {
 			throw new AdminComponentException(e);
 		}
@@ -327,7 +304,7 @@
 	@ManagementProperty(description="Active session count", use={ViewUse.STATISTIC}, readOnly=true)
 	public int getActiveSessionsCount() throws AdminException{
 		try {
-			return this.dqpCore.getActiveSessionsCount();
+			return this.sessionService.getActiveSessionsCount();
 		} catch (SessionServiceException e) {
 			throw new AdminComponentException(e);
 		}

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/pom.xml	2010-03-12 21:47:08 UTC (rev 1961)
@@ -340,8 +340,15 @@
 				<groupId>javax.resource</groupId>
 				<artifactId>connector-api</artifactId>
 				<version>1.5</version>
+				<scope>provided</scope>
 			</dependency>
 			<dependency>
+				<groupId>javax.transaction</groupId>
+                <artifactId>jta</artifactId>
+				<version>1.1</version>
+				<scope>provided</scope>
+			</dependency>
+			<dependency>
 				<groupId>log4j</groupId>
 				<artifactId>log4j</artifactId>
 				<version>1.2.14</version>

Modified: trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -96,7 +96,7 @@
 		long currentTime = System.currentTimeMillis();
 		for (SessionMetadata info : sessionCache.values()) {
 			try {
-    			if (currentTime - info.getLastPingTime() > ServerConnection.PING_INTERVAL * 5) {
+    			if (!info.isEmbedded() && currentTime - info.getLastPingTime() > ServerConnection.PING_INTERVAL * 5) {
     				LogManager.logInfo(LogConstants.CTX_SESSION, RuntimePlugin.Util.getString( "SessionServiceImpl.keepaliveFailed", info.getSessionId())); //$NON-NLS-1$
     				closeSession(info.getSessionId());
     			} else if (sessionExpirationTimeLimit > 0 && currentTime - info.getCreatedTime() > sessionExpirationTimeLimit) {
@@ -126,7 +126,7 @@
 
         // try to log out of the context.
         try {
-        	LoginContext context = info.getAttachment(LoginContext.class);
+        	LoginContext context = info.getLoginContext();
         	if (context != null) {
         		context.logout();
         	}
@@ -204,10 +204,10 @@
         }
         
         // these are local no need for monitoring.
-        newSession.addAttchment(LoginContext.class, loginContext);
-        newSession.addAttchment("SecurityContext", securityContext);
-        newSession.addAttchment(VDBMetaData.class, vdb);
-        newSession.addAttchment(SessionToken.class, new SessionToken(id, userName));
+        newSession.setLoginContext(loginContext);
+        newSession.setSecurityContext(securityContext);
+        newSession.setVdb(vdb);
+        newSession.setSessionToken(new SessionToken(id, userName));
         LogManager.logDetail(LogConstants.CTX_SESSION, new Object[] {"Logon successful for \"", userName, "\" - created SessionID \"", "" + id, "\"" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
         this.sessionCache.put(newSession.getSessionId(), newSession);
         return newSession;
@@ -333,14 +333,6 @@
 		this.sessionCache.clear();
 	}
 
-	@Override
-	public void setLocalSession(long sessionID) {
-		SessionMetadata info = this.sessionCache.get(sessionID);
-		if (info != null) {
-			info.setLastPingTime(Long.MAX_VALUE);
-		}
-	}
-
 	public void setVDBRepository(VDBRepository repo) {
 		this.vdbRepository = repo;
 	}

Copied: trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java (from rev 1955, trunk/client/src/main/java/org/teiid/transport/ClientServiceRegistry.java)
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java	                        (rev 0)
+++ trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -0,0 +1,35 @@
+/*
+ * 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.transport;
+
+import org.teiid.security.SecurityHelper;
+
+import com.metamatrix.api.exception.ComponentNotFoundException;
+
+public interface ClientServiceRegistry {
+	
+	<T> T getClientService(Class<T> iface) throws ComponentNotFoundException;
+	
+	SecurityHelper getSecurityHelper();
+
+}


Property changes on: trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -25,11 +25,12 @@
 import java.util.HashMap;
 
 import org.teiid.runtime.RuntimePlugin;
+import org.teiid.security.SecurityHelper;
 
 import com.metamatrix.api.exception.ComponentNotFoundException;
 import com.metamatrix.core.util.ReflectionHelper;
 
-public class ClientServiceRegistryImpl {
+public class ClientServiceRegistryImpl implements ClientServiceRegistry {
 
 	public static class ClientService {
 		private Object instance;
@@ -55,6 +56,7 @@
 	}
 	
     private HashMap<String, ClientService> clientServices = new HashMap<String, ClientService>();
+    private SecurityHelper securityHelper;
 
     public <T> T getClientService(Class<T> iface) throws ComponentNotFoundException {
     	ClientService cs = getClientService(iface.getName());
@@ -72,5 +74,14 @@
 	public <T> void registerClientService(Class<T> iface, T instance, String loggingContext) {
 		this.clientServices.put(iface.getName(), new ClientService(instance, loggingContext, new ReflectionHelper(iface)));
 	}	
+	
+	@Override
+	public SecurityHelper getSecurityHelper() {
+		return this.securityHelper;
+	}
+	
+	public void setSecurityHelper(SecurityHelper securityHelper) {
+		this.securityHelper = securityHelper;
+	}
 		
 }

Copied: trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java (from rev 1955, trunk/client/src/main/java/org/teiid/transport/LocalServerConnection.java)
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java	                        (rev 0)
+++ trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -0,0 +1,145 @@
+/*
+ * 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.transport;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.security.LogonException;
+import com.metamatrix.client.ExceptionUtil;
+import com.metamatrix.common.comm.CommonCommPlugin;
+import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.exception.CommunicationException;
+import com.metamatrix.common.comm.exception.ConnectionException;
+import com.metamatrix.common.comm.platform.CommPlatformPlugin;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.platform.security.api.ILogon;
+import com.metamatrix.platform.security.api.LogonResult;
+
+public class LocalServerConnection implements ServerConnection {
+	private static final String TEIID_RUNTIME = "teiid/engine-deployer"; //$NON-NLS-1$
+	
+	private final LogonResult result;
+	private boolean shutdown;
+	private ClientServiceRegistry csr;
+    private DQPWorkContext workContext = new DQPWorkContext();
+
+	public LocalServerConnection(Properties connectionProperties) throws CommunicationException, ConnectionException{
+		try {
+			InitialContext ic = new InitialContext();
+			csr = (ClientServiceRegistry)ic.lookup(TEIID_RUNTIME);
+		} catch (NamingException e) {
+			throw new MetaMatrixRuntimeException(e);
+		}
+		workContext.setSecurityHelper(csr.getSecurityHelper());
+		this.result = authenticate(connectionProperties);
+	}
+	
+	public synchronized LogonResult authenticate(Properties connProps) throws ConnectionException, CommunicationException {
+        try {
+        	connProps.setProperty(ServerConnection.LOCAL_CONNECTION, Boolean.TRUE.toString()); 
+        	LogonResult logonResult = this.getService(ILogon.class).logon(connProps);
+        	return logonResult;
+        } catch (LogonException e) {
+            // Propagate the original message as it contains the message we want
+            // to give to the user
+            throw new ConnectionException(e, e.getMessage());
+        } catch (MetaMatrixComponentException e) {
+        	if (e.getCause() instanceof CommunicationException) {
+        		throw (CommunicationException)e.getCause();
+        	}
+            throw new CommunicationException(e, CommPlatformPlugin.Util.getString("PlatformServerConnectionFactory.Unable_to_find_a_component_used_in_logging_on_to_MetaMatrix")); //$NON-NLS-1$
+        } 	
+	}	
+	
+	public <T> T getService(final Class<T> iface) {
+		return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new InvocationHandler() {
+
+			public Object invoke(Object arg0, final Method arg1, final Object[] arg2) throws Throwable {
+				if (!isOpen()) {
+					throw ExceptionUtil.convertException(arg1, new MetaMatrixComponentException(CommonCommPlugin.Util.getString("LocalTransportHandler.Transport_shutdown"))); //$NON-NLS-1$
+				}
+				try {
+					final T service = csr.getClientService(iface);
+					return workContext.runInContext(new Callable<Object>() {
+						public Object call() throws Exception {
+							return arg1.invoke(service, arg2);						
+						}
+					});
+				} catch (InvocationTargetException e) {
+					throw e.getTargetException();
+				} catch (Throwable e) {
+					throw ExceptionUtil.convertException(arg1, e);
+				}
+			}
+		}));
+	}
+
+	public boolean isOpen() {
+		return !shutdown;
+	}
+
+	public void close() {
+		shutdown(true);
+	}
+	
+	private void shutdown(boolean logoff) {
+		if (shutdown) {
+			return;
+		}
+		
+		if (logoff) {
+			try {
+				//make a best effort to send the logoff
+				Future<?> writeFuture = this.getService(ILogon.class).logoff();
+				if (writeFuture != null) {
+					writeFuture.get(5000, TimeUnit.MILLISECONDS);
+				}
+			} catch (Exception e) {
+				//ignore
+			}
+		}
+		this.shutdown = true;
+	}
+
+	public LogonResult getLogonResult() {
+		return result;
+	}
+
+	@Override
+	public boolean isSameInstance(ServerConnection conn) throws CommunicationException {
+		return (conn instanceof LocalServerConnection);
+	}
+}


Property changes on: trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -24,11 +24,9 @@
 
 import java.util.Properties;
 
-import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 
 import org.teiid.adminapi.impl.SessionMetadata;
-import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.dqp.internal.process.DQPWorkContext;
 import org.teiid.security.Credentials;
 
@@ -72,12 +70,11 @@
         boolean adminConnection = Boolean.parseBoolean(connProps.getProperty(MMURL.CONNECTION.ADMIN));
 		try {
 			SessionMetadata sessionInfo = service.createSession(user,credential, applicationName, connProps, adminConnection);
-	        
-			long sessionID = updateDQPContext(sessionInfo, adminConnection);
+	        updateDQPContext(sessionInfo);
 			if (Boolean.parseBoolean(connProps.getProperty(ServerConnection.LOCAL_CONNECTION))) {
-				service.setLocalSession(sessionID);
+				sessionInfo.setEmbedded(true);
 			}
-			return new LogonResult(sessionInfo.getAttachment(SessionToken.class), sessionInfo.getVDBName(), sessionInfo.getVDBVersion(), clusterName);
+			return new LogonResult(sessionInfo.getSessionToken(), sessionInfo.getVDBName(), sessionInfo.getVDBVersion(), clusterName);
 		} catch (LoginException e) {
 			throw new LogonException(e.getMessage());
 		} catch (SessionServiceException e) {
@@ -85,40 +82,16 @@
 		}
 	}
 
-	private long updateDQPContext(SessionMetadata s, boolean adminConnection) {
+	private long updateDQPContext(SessionMetadata s) {
 		long sessionID = s.getSessionId();
 		
 		DQPWorkContext workContext = DQPWorkContext.getWorkContext();
-		if (workContext == null) {
-			workContext = new DQPWorkContext();
-		}
-		workContext.setSessionToken(s.getAttachment(SessionToken.class));
-		workContext.setAppName(s.getApplicationName());
-		
-		LoginContext loginContext = s.getAttachment(LoginContext.class);
-		if (loginContext != null) {
-			workContext.setSubject(loginContext.getSubject());
-			workContext.setSecurityDomain(s.getSecurityDomain());
-			workContext.setSecurityContext(s.getAttachment("SecurityContext"));
-		}
-		
-		VDBMetaData vdb = s.getAttachment(VDBMetaData.class);
-		if (vdb != null) {
-			workContext.setVdbName(vdb.getName());
-			workContext.setVdbVersion(vdb.getVersion());		
-			workContext.setVdb(vdb);
-		}
-		
-		if (adminConnection) {
-			workContext.markAsAdmin();
-		}
-		DQPWorkContext.setWorkContext(workContext);
+		workContext.setSession(s);
 		return sessionID;
 	}
 		
 	public ResultsFuture<?> logoff() throws InvalidSessionException {
 		this.service.closeSession(DQPWorkContext.getWorkContext().getSessionId());
-		DQPWorkContext.getWorkContext().reset();
 		return ResultsFuture.NULL_FUTURE;
 	}
 
@@ -145,10 +118,10 @@
 			throw new InvalidSessionException();
 		}
 		
-		SessionToken st = sessionInfo.getAttachment(SessionToken.class);
+		SessionToken st = sessionInfo.getSessionToken();
 		if (!st.equals(checkSession)) {
 			throw new InvalidSessionException();
 		}
-		this.updateDQPContext(sessionInfo, false);
+		this.updateDQPContext(sessionInfo);
 	}
 }

Modified: trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -33,7 +33,6 @@
 import javax.crypto.SealedObject;
 
 import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.dqp.internal.process.DQPWorkContext;
 import org.teiid.runtime.RuntimePlugin;
 import org.teiid.transport.ClientServiceRegistryImpl.ClientService;
 
@@ -46,9 +45,8 @@
 import com.metamatrix.common.util.crypto.CryptoException;
 import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.platform.security.api.SessionToken;
 
-public class ServerWorkItem {
+public class ServerWorkItem implements Runnable {
 	
 	private final ClientInstance socketClientInstance;
 	private final Serializable messageKey;
@@ -65,10 +63,9 @@
 	/**
 	 * main entry point for remote method calls.
 	 */
-	public void process() {
+	public void run() {
 		Message result = null;
 		String loggingContext = null;
-		DQPWorkContext.setWorkContext(this.socketClientInstance.getWorkContext());
 		final boolean encrypt = message.getContents() instanceof SealedObject;
         try {
             message.setContents(this.socketClientInstance.getCryptor().unsealObject(message.getContents()));
@@ -78,7 +75,6 @@
 			final ServiceInvocationStruct serviceStruct = (ServiceInvocationStruct)message.getContents();
 			final ClientService clientService = this.csr.getClientService(serviceStruct.targetClass);			
 			loggingContext = clientService.getLoggingContext();
-			SessionToken.setSession(this.socketClientInstance.getWorkContext().getSessionToken());
 			Method m = clientService.getReflectionHelper().findBestMethodOnTarget(serviceStruct.methodName, serviceStruct.args);
 			Object methodResult;
 			try {
@@ -113,9 +109,6 @@
 			Message holder = new Message();
 			holder.setContents(processException(t, loggingContext));
 			result = holder;
-		} finally {
-			DQPWorkContext.releaseWorkContext();
-			SessionToken.setSession(null);
 		}
 		
 		if (result != null) {

Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -61,6 +61,7 @@
     public SocketClientInstance(ObjectChannel objectSocket, ClientServiceRegistryImpl csr, boolean isClientEncryptionEnabled) {
         this.objectSocket = objectSocket;
         this.csr = csr;
+        this.workContext.setSecurityHelper(csr.getSecurityHelper());
         this.usingEncryption = isClientEncryptionEnabled;
         SocketAddress address = this.objectSocket.getRemoteAddress();
         if (address instanceof InetSocketAddress) {
@@ -138,8 +139,8 @@
 		if (LogManager.isMessageToBeRecorded(LogConstants.CTX_TRANSPORT, MessageLevel.DETAIL)) { 
 			LogManager.logDetail(LogConstants.CTX_TRANSPORT, "processing message:" + packet); //$NON-NLS-1$
         }
-		ServerWorkItem work = new ServerWorkItem(this, packet.getMessageKey(), packet, this.csr);
-		work.process();
+		final ServerWorkItem work = new ServerWorkItem(this, packet.getMessageKey(), packet, this.csr);
+		this.workContext.runInContext(work);
 	}
 
 	public void shutdown() throws CommunicationException {

Modified: trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -51,7 +51,7 @@
 		session.setUserName(userName);
 		session.setApplicationName(applicationName);
 		session.setSessionId(1);
-		session.addAttchment(SessionToken.class, new SessionToken(1, userName));
+		session.setSessionToken(new SessionToken(1, userName));
 
 		Mockito.stub(ssi.createSession(userName, null, applicationName,p, false)).toReturn(session);
 

Modified: trunk/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -51,7 +51,7 @@
 import com.metamatrix.common.comm.platform.socket.client.UrlServerDiscovery;
 import com.metamatrix.common.util.crypto.Cryptor;
 import com.metamatrix.common.util.crypto.NullCryptor;
-import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.DQP;
 import com.metamatrix.dqp.client.ResultsFuture;
 import com.metamatrix.platform.security.api.ILogon;
 import com.metamatrix.platform.security.api.LogonResult;
@@ -105,7 +105,7 @@
 				InterruptedException {
 			ServerWorkItem workItem = new ServerWorkItem(this, messageKey, message, server);
 			this.listener = listener;
-			workItem.process();
+			workItem.run();
 		}
 
 		public void shutdown() {
@@ -192,13 +192,13 @@
 		} catch (MetaMatrixProcessingException e) {
 			
 		}
-		ClientSideDQP dqp = connection.getService(ClientSideDQP.class);
+		DQP dqp = connection.getService(DQP.class);
 		try {
 			ResultsFuture<?> future = dqp.begin();
 			future.get();
 			fail("exception expected"); //$NON-NLS-1$
 		} catch (Exception e) {
-			assertTrue(e.getMessage().endsWith("Component not found: com.metamatrix.dqp.client.ClientSideDQP")); //$NON-NLS-1$
+			assertTrue(e.getMessage().indexOf("Component not found:") != -1); //$NON-NLS-1$
 		}
 	}
 

Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java	2010-03-12 17:17:23 UTC (rev 1960)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java	2010-03-12 21:47:08 UTC (rev 1961)
@@ -122,7 +122,7 @@
     public interface TXN_AUTO_WRAP_OPTIONS {
 	    public static final String AUTO_WRAP_OFF = ExecutionProperties.TXN_WRAP_OFF;  //$NON-NLS-1$	    
 	    public static final String AUTO_WRAP_ON = ExecutionProperties.TXN_WRAP_ON;  //$NON-NLS-1$
-	    public static final String AUTO_WRAP_AUTO = ExecutionProperties.TXN_WRAP_AUTO;  //$NON-NLS-1$
+	    public static final String AUTO_WRAP_AUTO = ExecutionProperties.TXN_WRAP_DETECT;  //$NON-NLS-1$
 	  
     }
 



More information about the teiid-commits mailing list