[teiid-commits] teiid SVN: r3724 - in trunk: api/src/main/java/org/teiid/translator and 36 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Dec 7 15:42:06 EST 2011


Author: shawkins
Date: 2011-12-07 15:42:04 -0500 (Wed, 07 Dec 2011)
New Revision: 3724

Added:
   trunk/api/src/main/java/org/teiid/translator/ReusableExecution.java
   trunk/client/src/main/java/org/teiid/jdbc/RequestOptions.java
   trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java
Removed:
   trunk/engine/src/main/java/org/teiid/query/util/ContextProperties.java
   trunk/engine/src/test/java/org/teiid/dqp/message/TestAtomicRequestMessage.java
Modified:
   trunk/api/src/main/java/org/teiid/CommandContext.java
   trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java
   trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
   trunk/client/src/main/java/org/teiid/client/RequestMessage.java
   trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
   trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
   trunk/client/src/main/java/org/teiid/jdbc/TeiidPreparedStatement.java
   trunk/client/src/main/java/org/teiid/jdbc/TeiidStatement.java
   trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties
   trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
   trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
   trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml
   trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml
   trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ProcedureBatchHandler.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.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/message/AtomicRequestMessage.java
   trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
   trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
   trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
   trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java
   trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
   trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
   trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeExecutionContextImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorWorkItem.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestExecutionContextImpl.java
   trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.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/multisource/TestMultiSourcePlanToProcessConverter.java
   trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java
   trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
   trunk/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java
   trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/AllCapabilities.java
   trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
   trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
   trunk/engine/src/test/java/org/teiid/query/processor/relational/TestRelationalNodeStatistics.java
   trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
   trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
   trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
   trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
   trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
   trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestRelate.java
   trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java
Log:
TEIID-1801 TEIID-1604 adding support for continuous plans and beginning to rationalize the context objects

Modified: trunk/api/src/main/java/org/teiid/CommandContext.java
===================================================================
--- trunk/api/src/main/java/org/teiid/CommandContext.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/api/src/main/java/org/teiid/CommandContext.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -24,7 +24,6 @@
 
 import java.io.Serializable;
 import java.util.Map;
-import java.util.Properties;
 import java.util.TimeZone;
 
 import javax.security.auth.Subject;
@@ -64,14 +63,6 @@
 	String getConnectionID();
 	
 	/**
-	 * Get the environment properties.  The returned properties are associated only with the currently executing command.
-	 * The only built-in key/value in the properties is the key "sessionid" with the same value as getConnectionID()
-	 * @return
-	 * @deprecated
-	 */
-	Properties getEnvironmentProperties();
-	
-	/**
 	 * Get the next random double value 
 	 * @return
 	 */

Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -27,6 +27,7 @@
 
 import javax.security.auth.Subject;
 
+import org.teiid.CommandContext;
 import org.teiid.adminapi.Session;
 import org.teiid.jdbc.TeiidSQLWarning;
 
@@ -167,4 +168,10 @@
      * resumed.
      */
     void dataAvailable();
+    
+    /**
+     * Get the CommandContext
+     * @return
+     */
+    CommandContext getCommandContext();
 }

Added: trunk/api/src/main/java/org/teiid/translator/ReusableExecution.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ReusableExecution.java	                        (rev 0)
+++ trunk/api/src/main/java/org/teiid/translator/ReusableExecution.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -0,0 +1,45 @@
+/*
+ * 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.translator;
+
+import org.teiid.language.Command;
+
+/**
+ * Additional methods that may optionally be implemented for an {@link Execution}
+ */
+public interface ReusableExecution<C> extends Execution {
+	
+	/**
+	 * Called to reinitialized the execution for use.
+	 * @param c
+	 * @param executionContext
+	 * @param connection
+	 */
+	void reset(Command c, ExecutionContext executionContext, C connection);
+	
+	/**
+	 * Called when the execution is no longer used.
+	 */
+	void dispose();
+	
+}
\ No newline at end of file


Property changes on: trunk/api/src/main/java/org/teiid/translator/ReusableExecution.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html	2011-12-07 20:42:04 UTC (rev 3724)
@@ -29,6 +29,13 @@
   <LI><B>CallableStatement Named Parameters</B> - you can now use CallableStatement named parameter get/set methods.  
   <LI><B>New Translator capabilities</B> - translators may indicate which convert functions they support and restrict non-join comparisons
   to only literals. 
+  <LI><B>New Translator capabilities</B>
+    <UL>
+      <LI>translators may indicate which convert functions they support
+      <LI>restrict non-join comparisons to only literals.
+      <LI>return ReusableExecution instances for processing nodes that issue multiple queries. 
+    </UL>
+  <LI><B>Continuous Asynch Queries</B> to process plans in a streamed window fashion the TeiidStatement/TeiidPreparedStatement methods now take a RequestOptions object to specify continuous mode.  See the Client and Developers Guides for more. 
 </UL>
 
 <h2><a name="Compatibility">Compatibility Issues</a></h2>
@@ -47,6 +54,8 @@
   enable the pre-8.0 behavior.  The BigDecimal form of the AVG function now uses the same precision and scale logic as the division system function, rather than using a
   fixed scale of 9.
   <li>BigDecimal division that returns a quotient that is equal to zero will have a scale of zero as well. Prior releases would typically return a zero value with a scale of 16.
+  <li>The env function no longer returns the value for the session id, the session_id() function should be used instead.
+  <li>The CommandContext no longer provides getEnvironmentProperties()
 </ul>
 
 <h4>from 7.5</h4>

Modified: trunk/client/src/main/java/org/teiid/client/RequestMessage.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/RequestMessage.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/client/src/main/java/org/teiid/client/RequestMessage.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -34,6 +34,7 @@
 import org.teiid.core.TeiidProcessingException;
 import org.teiid.core.util.ExternalizeUtil;
 import org.teiid.jdbc.JDBCPlugin;
+import org.teiid.jdbc.RequestOptions;
 
 
 /**
@@ -89,7 +90,13 @@
     private long executionId;
     private int transactionIsolation;
     private boolean noExec;
+    
+    /*
+     * Used by embedded connections, could change if we add support
+     * for an asynch socket transport
+     */
     private transient boolean sync;
+    private RequestOptions requestOptions;
     
     public RequestMessage() {
     }
@@ -403,5 +410,16 @@
 		out.writeInt(transactionIsolation);
 		out.writeBoolean(noExec);
 	}
+
+	public RequestOptions getRequestOptions() {
+		if (this.requestOptions == null) {
+			this.requestOptions = new RequestOptions();
+		}
+		return this.requestOptions;
+	}
 	
+	public void setRequestOptions(RequestOptions requestOptions) {
+		this.requestOptions = requestOptions;
+	}
+	
 }

Modified: trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -28,17 +28,7 @@
 import java.math.BigDecimal;
 import java.net.URL;
 import java.nio.charset.Charset;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.NClob;
-import java.sql.Ref;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.RowId;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Types;
+import java.sql.*;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collections;
@@ -173,7 +163,7 @@
     }
     
     @Override
-    public void submitExecute(String sql, StatementCallback callback) throws TeiidSQLException {
+    public void submitExecute(String sql, StatementCallback callback, RequestOptions options) throws TeiidSQLException {
     	String msg = JDBCPlugin.Util.getString("JDBC.Method_not_supported"); //$NON-NLS-1$
         throw new TeiidSQLException(msg);
     }
@@ -197,18 +187,19 @@
     }
     
     @Override
-    public void submitExecute(StatementCallback callback) throws SQLException {
+    public void submitExecute(StatementCallback callback, RequestOptions options)
+    		throws SQLException {
     	NonBlockingRowProcessor processor = new NonBlockingRowProcessor(this, callback);
-    	submitExecute(ResultsMode.EITHER).addCompletionListener(processor);
+    	submitExecute(ResultsMode.EITHER, options).addCompletionListener(processor);
     }
     
-    public ResultsFuture<Boolean> submitExecute(ResultsMode mode) throws SQLException {
-        return executeSql(new String[] {this.prepareSql}, false, mode, false);
+    public ResultsFuture<Boolean> submitExecute(ResultsMode mode, RequestOptions options) throws SQLException {
+        return executeSql(new String[] {this.prepareSql}, false, mode, false, options);
     }
 
 	@Override
     public boolean execute() throws SQLException {
-        executeSql(new String[] {this.prepareSql}, false, ResultsMode.EITHER, true);
+        executeSql(new String[] {this.prepareSql}, false, ResultsMode.EITHER, true, null);
         return hasResultSet();
     }
     
@@ -218,7 +209,7 @@
    	     	return new int[0];
     	}
 	   	try{
-	   		executeSql(new String[] {this.prepareSql}, true, ResultsMode.UPDATECOUNT, true);
+	   		executeSql(new String[] {this.prepareSql}, true, ResultsMode.UPDATECOUNT, true, null);
 	   	}finally{
 	   		batchParameterList.clear();
 	   	}
@@ -227,13 +218,13 @@
 
 	@Override
     public ResultSet executeQuery() throws SQLException {
-        executeSql(new String[] {this.prepareSql}, false, ResultsMode.RESULTSET, true);
+        executeSql(new String[] {this.prepareSql}, false, ResultsMode.RESULTSET, true, null);
         return resultSet;
     }
 
 	@Override
     public int executeUpdate() throws SQLException {
-        executeSql(new String[] {this.prepareSql}, false, ResultsMode.UPDATECOUNT, true);
+        executeSql(new String[] {this.prepareSql}, false, ResultsMode.UPDATECOUNT, true, null);
         return this.updateCounts[0];
     }
     

Added: trunk/client/src/main/java/org/teiid/jdbc/RequestOptions.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/RequestOptions.java	                        (rev 0)
+++ trunk/client/src/main/java/org/teiid/jdbc/RequestOptions.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -0,0 +1,48 @@
+/*
+ * 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.jdbc;
+
+
+public class RequestOptions {
+	
+	/**
+	 * true indicates that the query should be re-executed upon completion, such that
+	 * the current Executions and CommandContext are reused.
+	 * Continuous queries must be forward-only and return a result set.
+	 */
+	private boolean continuous;
+	
+	public boolean isContinuous() {
+		return continuous;
+	}
+	
+	public RequestOptions continuous(boolean isContinuous) {
+		this.continuous = isContinuous;
+		return this;
+	}
+	
+	public void setContinuous(boolean continuous) {
+		this.continuous = continuous;
+	}
+
+}


Property changes on: trunk/client/src/main/java/org/teiid/jdbc/RequestOptions.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/client/src/main/java/org/teiid/jdbc/StatementImpl.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -28,18 +28,7 @@
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.SQLWarning;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TimeZone;
-import java.util.TreeMap;
+import java.util.*;
 import java.util.concurrent.ExecutionException;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -311,18 +300,18 @@
     }
     
     @Override
-    public void submitExecute(String sql, StatementCallback callback) throws SQLException {
+    public void submitExecute(String sql, StatementCallback callback, RequestOptions options) throws SQLException {
     	NonBlockingRowProcessor processor = new NonBlockingRowProcessor(this, callback);
-    	submitExecute(sql).addCompletionListener(processor);
+    	submitExecute(sql, options).addCompletionListener(processor);
     }
     
-    public ResultsFuture<Boolean> submitExecute(String sql) throws SQLException {
-    	return executeSql(new String[] {sql}, false, ResultsMode.EITHER, false);
+    public ResultsFuture<Boolean> submitExecute(String sql, RequestOptions options) throws SQLException {
+    	return executeSql(new String[] {sql}, false, ResultsMode.EITHER, false, options);
     }
 
 	@Override
     public boolean execute(String sql) throws SQLException {
-        executeSql(new String[] {sql}, false, ResultsMode.EITHER, true);
+        executeSql(new String[] {sql}, false, ResultsMode.EITHER, true, null);
         return hasResultSet();
     }
     
@@ -332,20 +321,20 @@
             return new int[0];
         }
         String[] commands = batchedUpdates.toArray(new String[batchedUpdates.size()]);
-        executeSql(commands, true, ResultsMode.UPDATECOUNT, true);
+        executeSql(commands, true, ResultsMode.UPDATECOUNT, true, null);
         return updateCounts;
     }
 
 	@Override
     public ResultSet executeQuery(String sql) throws SQLException {
-        executeSql(new String[] {sql}, false, ResultsMode.RESULTSET, true);
+        executeSql(new String[] {sql}, false, ResultsMode.RESULTSET, true, null);
         return resultSet;
     }
 
 	@Override
     public int executeUpdate(String sql) throws SQLException {
         String[] commands = new String[] {sql};
-        executeSql(commands, false, ResultsMode.UPDATECOUNT, true);
+        executeSql(commands, false, ResultsMode.UPDATECOUNT, true, null);
         return this.updateCounts[0];
     }
 
@@ -405,10 +394,24 @@
 	}
     
 	@SuppressWarnings("unchecked")
-	protected ResultsFuture<Boolean> executeSql(String[] commands, boolean isBatchedCommand, ResultsMode resultsMode, boolean synch)
+	protected ResultsFuture<Boolean> executeSql(String[] commands, boolean isBatchedCommand, ResultsMode resultsMode, boolean synch, RequestOptions options)
         throws SQLException {
         checkStatement();
         resetExecutionState();
+        if (options != null) {
+        	if (options.isContinuous()) {
+        		if (this.getResultSetType() != ResultSet.TYPE_FORWARD_ONLY) {
+	        		String msg = JDBCPlugin.Util.getString("JDBC.forward_only_resultset"); //$NON-NLS-1$
+	                throw new TeiidSQLException(msg);
+        		}
+        		if (resultsMode == ResultsMode.EITHER) {
+        			resultsMode = ResultsMode.RESULTSET;
+        		} else if (resultsMode == ResultsMode.UPDATECOUNT) {
+	        		String msg = JDBCPlugin.Util.getString("JDBC.forward_only_resultset"); //$NON-NLS-1$
+	                throw new TeiidSQLException(msg);
+        		}
+        	}
+        }
         if (logger.isLoggable(Level.FINER)) {
 			logger.finer("Executing: requestID " + getCurrentRequestID() + " commands: " + Arrays.toString(commands) + " expecting: " + resultsMode); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 		}
@@ -535,6 +538,7 @@
         }
         
         final RequestMessage reqMessage = createRequestMessage(commands, isBatchedCommand, resultsMode);
+        reqMessage.setRequestOptions(options);
     	ResultsFuture<ResultsMessage> pendingResult = execute(reqMessage, synch);
     	final ResultsFuture<Boolean> result = new ResultsFuture<Boolean>();
     	pendingResult.addCompletionListener(new ResultsFuture.CompletionListener<ResultsMessage>() {

Modified: trunk/client/src/main/java/org/teiid/jdbc/TeiidPreparedStatement.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/TeiidPreparedStatement.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/client/src/main/java/org/teiid/jdbc/TeiidPreparedStatement.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -38,8 +38,9 @@
      * Note that a single Statement may only have 1 asynch query executing at a time.
      * 
      * @param callback
+     * @param options
      * @throws SQLException 
      */
-    void submitExecute(StatementCallback callback) throws SQLException;
+    void submitExecute(StatementCallback callback, RequestOptions options) throws SQLException;
 
 }

Modified: trunk/client/src/main/java/org/teiid/jdbc/TeiidStatement.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/TeiidStatement.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/client/src/main/java/org/teiid/jdbc/TeiidStatement.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -108,7 +108,8 @@
      * Note that a single Statement may only have 1 asynch query executing at a time.
      * 
      * @param callback
+     * @param options
      * @throws SQLException 
      */
-    void submitExecute(String sql, StatementCallback callback) throws SQLException;
+    void submitExecute(String sql, StatementCallback callback, RequestOptions options) throws SQLException;
 }

Modified: trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties
===================================================================
--- trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/client/src/main/resources/org/teiid/jdbc/i18n.properties	2011-12-07 20:42:04 UTC (rev 3724)
@@ -156,4 +156,6 @@
 gss_auth_failed=GSS Authentication failed
 setup_failed=Protocol error.  Session setup failed.
 client_prop_missing=Client URL connection property missing "{0}". Please add the property to connection URL.
-system_prop_missing=System property "{0}" missing, please add using -D option on the VM startup script.
\ No newline at end of file
+system_prop_missing=System property "{0}" missing, please add using -D option on the VM startup script.
+
+JDBC.forward_only_resultset=Continuous queries must be forward only and return a result set.
\ No newline at end of file

Modified: trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java
===================================================================
--- trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/client/src/test/java/org/teiid/jdbc/TestStatement.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -110,12 +110,12 @@
 		Properties p = new Properties();
 		Mockito.stub(conn.getExecutionProperties()).toReturn(p);
 		StatementImpl statement = new StatementImpl(conn, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
-		statement.submitExecute("start transaction"); //$NON-NLS-1$
+		statement.submitExecute("start transaction", null); //$NON-NLS-1$
 		Mockito.verify(conn).setAutoCommit(false);
-		statement.submitExecute("commit"); //$NON-NLS-1$
+		statement.submitExecute("commit", null); //$NON-NLS-1$
 		Mockito.verify(conn).submitSetAutoCommitTrue(true);
-		statement.submitExecute("start transaction"); //$NON-NLS-1$
-		statement.submitExecute("rollback"); //$NON-NLS-1$
+		statement.submitExecute("start transaction", null); //$NON-NLS-1$
+		statement.submitExecute("rollback", null); //$NON-NLS-1$
 		Mockito.verify(conn).submitSetAutoCommitTrue(false);
 	}
 	
@@ -127,11 +127,11 @@
 		Mockito.stub(statement.getDQP()).toReturn(dqp);
 		ResultsFuture<ResultsMessage> future = new ResultsFuture<ResultsMessage>();
 		Mockito.stub(dqp.executeRequest(Mockito.anyLong(), (RequestMessage) Mockito.anyObject())).toReturn(future);
-		statement.submitExecute("select 'hello world'");
+		statement.submitExecute("select 'hello world'", null);
 		Thread.sleep(300);
 		Mockito.verify(dqp).cancelRequest(0);
 		statement.setQueryTimeoutMS(1);
-		statement.submitExecute("select 'hello world'");
+		statement.submitExecute("select 'hello world'", null);
 		Thread.sleep(300);
 		Mockito.verify(dqp, Mockito.times(2)).cancelRequest(0);
 	}

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -47,7 +47,7 @@
                                                                             "Payload",  //$NON-NLS-1$
                                                                             "ConnectionID",   //$NON-NLS-1$
                                                                             "Connector", //$NON-NLS-1$
-                                                                            "RequestID",  //$NON-NLS-1$ 
+                                                                            1, 
                                                                             "PartID",  //$NON-NLS-1$ 
                                                                             "ExecCount");     //$NON-NLS-1$ 
     
@@ -367,29 +367,29 @@
     }
 
     @Test public void testVisitIDeleteWithComment() throws Exception {
-        String expected = "DELETE /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ FROM g1 WHERE 100 >= 200 AND 500 < 600"; //$NON-NLS-1$
+        String expected = "DELETE /*teiid sessionid:ConnectionID, requestid:ConnectionID.1.PartID*/ FROM g1 WHERE 100 >= 200 AND 500 < 600"; //$NON-NLS-1$
         assertEquals(expected, getStringWithContext(TestDeleteImpl.example()));
     }
 
     @Test public void testVisitIInsertWithComment() throws Exception {
-        String expected = "INSERT /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ INTO g1 (e1, e2, e3, e4) VALUES (1, 2, 3, 4)"; //$NON-NLS-1$
+        String expected = "INSERT /*teiid sessionid:ConnectionID, requestid:ConnectionID.1.PartID*/ INTO g1 (e1, e2, e3, e4) VALUES (1, 2, 3, 4)"; //$NON-NLS-1$
         assertEquals(expected, getStringWithContext(TestInsertImpl.example("g1"))); //$NON-NLS-1$
     }  
     
     @Test public void testVisitISelectWithComment() throws Exception {
-        String expected = "SELECT /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC"; //$NON-NLS-1$
+        String expected = "SELECT /*teiid sessionid:ConnectionID, requestid:ConnectionID.1.PartID*/ g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC"; //$NON-NLS-1$
         assertEquals(expected, getStringWithContext(TestQueryImpl.example(false)));
-        expected = "SELECT /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC"; //$NON-NLS-1$
+        expected = "SELECT /*teiid sessionid:ConnectionID, requestid:ConnectionID.1.PartID*/ DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY g1.e1, g1.e2 DESC, g1.e3, g1.e4 DESC"; //$NON-NLS-1$
         assertEquals(expected, getStringWithContext(TestQueryImpl.example(true)));
     }
     
     @Test public void testVisitIUpdateWithComment() throws Exception {
-        String expected = "UPDATE /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ g1 SET e1 = 1, e2 = 1, e3 = 1, e4 = 1 WHERE 1 = 1"; //$NON-NLS-1$
+        String expected = "UPDATE /*teiid sessionid:ConnectionID, requestid:ConnectionID.1.PartID*/ g1 SET e1 = 1, e2 = 1, e3 = 1, e4 = 1 WHERE 1 = 1"; //$NON-NLS-1$
         assertEquals(expected, getStringWithContext(TestUpdateImpl.example()));
     }    
     
     @Test public void testVisitIProcedureWithComment() throws Exception {
-        String expected = "{ /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/  call sq3(?,?)}"; //$NON-NLS-1$
+        String expected = "{ /*teiid sessionid:ConnectionID, requestid:ConnectionID.1.PartID*/  call sq3(?,?)}"; //$NON-NLS-1$
         assertEquals(expected, getStringWithContext(TestProcedureImpl.example()));
     }  
     

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -22,14 +22,13 @@
 
 package org.teiid.translator.jdbc;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import javax.xml.bind.JAXBException;
 import javax.xml.stream.XMLStreamException;
 
 import junit.framework.Assert;
@@ -42,8 +41,8 @@
 import org.teiid.language.Command;
 import org.teiid.metadata.FunctionMethod;
 import org.teiid.query.function.metadata.FunctionMetadataReader;
-import org.teiid.translator.TranslatorException;
 import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TranslatorException;
 
 
 public class TranslationHelper {

Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -705,7 +705,7 @@
         String output = "SELECT /*+ ALL_ROWS */ PARTS.PART_NAME, ROWNUM FROM PARTS"; //$NON-NLS-1$
                
         String hint = "/*+ ALL_ROWS */"; //$NON-NLS-1$
-        ExecutionContext context = new ExecutionContextImpl(null, 1, hint, null, "", null, null, null); //$NON-NLS-1$
+        ExecutionContext context = new ExecutionContextImpl(null, 1, hint, null, "", 1, null, null); //$NON-NLS-1$
         
         helpTestVisitor(getTestVDB(),
             input, 
@@ -720,7 +720,7 @@
         String output = "SELECT PARTS.PART_NAME, ROWNUM FROM PARTS"; //$NON-NLS-1$
                
         String hint = "/*+ ALL_ROWS */ something else"; //$NON-NLS-1$
-        ExecutionContext context = new ExecutionContextImpl(null, 1, hint, null, "", null, null, null); //$NON-NLS-1$
+        ExecutionContext context = new ExecutionContextImpl(null, 1, hint, null, "", 1, null, null); //$NON-NLS-1$
         
         helpTestVisitor(getTestVDB(),
             input, 

Modified: trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml
===================================================================
--- trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/jdbc-extensions.xml	2011-12-07 20:42:04 UTC (rev 3724)
@@ -389,7 +389,7 @@
         </section>
        </section>
        
-	<section>
+	<section id="non_blocking">
 		<title>Non-blocking Statement Execution</title>	
 		<para>JDBC query execution can indefinitely block the calling thread when a statement is executed or a resultset is being iterated.  
 		In some situations you may wish to have your calling threads held in these blocked states.  When using embedded connections, you may optionally use the 
@@ -416,10 +416,22 @@
     @Override
     public void onComplete(Statement s) throws Exception {
         s.close();
-    }
+    }, new RequestOptions()
 );</programlisting>
 		</example>
 		<note><para>The non-blocking logic is limited to statement execution only.  Other JDBC operations, such as connection creation or batched executions do not yet have non-blocking options.</para></note>
+		
+		<section>
+			<title>Continous Execution</title>
+			<para>The <code>RequestOptions</code> object may be used to specify a special type of continuous asynch execution via the <code>continuous</code> or <code>setContinuous</code> methods.  
+			In continuous mode the statement will be continously re-executed.  This is intended for consuming real-time or other data streams processed through a SQL plan.  
+			A continuous query will only terminate on an error or when the statement is explicitly closed.  The SQL for a continuous query is no different than any other statement.  
+			Care should be taken to ensure that retrivals from non-continuous sources is appropriately cached for reuse, such as by using materialized views or session scoped temp tables.  
+			A continous query must return a result set, must be executed with a forward-only resultset, and cannot be used in the scope of a transaction.  Since resource consumptions is expected to be
+			different in a continuous plan, it does not count against the server max active plan limit.
+			Typically custom sources will be used to provide data streams.  See the Developer's Guide, in particular the section on ReusableExecutions for more.</para>
+		</section>	
+		
 	</section>
  
 </chapter>
\ No newline at end of file

Modified: trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml
===================================================================
--- trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml	2011-12-07 20:42:04 UTC (rev 3724)
@@ -306,31 +306,61 @@
 				be retrieved via the getOutputParameterValues() method.
 			</para>
 		</section>
-         
-		<section>
+
+		<section id="asynchronous_executions">
 			<title>Asynchronous Executions</title>
-    <para>
-        In some scenarios, a translator needs to execute
-        asynchronously and allow the executing thread to perform other work. To allow this, you should Throw a
-        <code>DataNotAvailableExecption</code>
-        during a retrival method, rather than explicitly waiting or sleeping for the results.
-        <note>
-            <para>
-                A <code>DataNotAvailableException</code> should not be thrown by the execute method. The
-                <code>DataNotAvailableException</code> may take a delay parameter in its
-                constructor to indicate how long the system should wait befor polling
-                for results. Any non-negative value indicates a time until the next polling should be performed.
-                The
-                <code>DataNotAvailableException.NO_POLLING</code>
-                exception (or any DataNotAvailableException with a negative delay) can be thrown to indicate that
-                the execution will call <code>ExecutionContext.dataAvailable()</code> to indicate processing should resume.
-           </para>
-       </note>
-    </para>
-    <note>
-        <para>Since the exection and the associated connection are not closed until the work has completed, care should be taken if using asynchronous executions that hold a lot of state.</para>
-    </note>
+			<para>
+				In some scenarios, a translator needs to execute
+				asynchronously and allow the executing thread to perform other work. To allow this,
+				you should Throw a <code>DataNotAvailableExecption</code>
+				during a retrival method, rather than explicitly waiting or sleeping
+				for the results.
+				<note>
+					<para>
+						A <code>DataNotAvailableException</code>
+						should not be thrown by the execute method. The
+						<code>DataNotAvailableException</code>
+						may take a delay parameter in its
+						constructor to indicate how long the system should wait befor polling
+						for results. Any non-negative value indicates a time until the next
+						polling should be performed.
+						The <code>DataNotAvailableException.NO_POLLING</code>
+						exception (or any DataNotAvailableException with a negative delay)
+						can be thrown to indicate that
+						the execution will call
+						<code>ExecutionContext.dataAvailable()</code>
+						to indicate processing should resume.
+					</para>
+				</note>
+			</para>
+			<note>
+				<para>Since the exection and the associated connection are not closed
+					until the work has completed, care should be taken if using
+					asynchronous executions that hold a lot of state.</para>
+			</note>
 		</section>
+		
+		<section>
+			<title>Reusable Executions</title>
+			<para>
+				A translator may return instances of <code>ReusableExecution</code>s for the expected <code>Execution</code> objects.
+				There can be one <code>ReusableExecution</code> per query execting node in the processing plan. 
+				The lifecycle of a <code>ReusableExecution</code> is different that a normal <code>Execution</code>.
+				After a normal creation/execute/close cycle the <code>ReusableExecution.reset</code> is called for another execution cycle.
+				This may occur indefinitely dependin on how many times a processing node executes its query.  
+				The behavior of the <code>close</code> is no different than a regular <code>Execution</code>, 
+				that is it may not be called until the end of the statement if lobs are detected and any connection associated with the 
+				<code>Execution</code> will also be closed.  When the user command is finished, the <code>ReusableExecution.dispose()</code> 
+				method will be called.
+			</para>
+			<para>				
+				In general <code>ReusableExecution</code>s are most useful for continuous query execution and will also be implemented using the
+				<code>ExecutionCotext.dataAvailable()</code> method for <xref linkend="asynchronous_executions"/>.
+				See the Client Developer's Guide for executing continuous statements.  In continuous mode the user query will be continously re-executed.  
+				A ReusableExecution allows the same Execution object to be associated with the processing plan for a given processing node for the lifetime
+				of the user query.  This can simplify asynch resource management, such as establishing queue listeners.
+			</para>
+		</section>
         
 		<section>
 			<title>Bulk Execution</title>

Modified: trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml	2011-12-07 20:42:04 UTC (rev 3724)
@@ -1875,9 +1875,7 @@
     	<title>ENV</title>
     	<para>Retrieve a system environment property.</para>
     	<para><synopsis>ENV(key)</synopsis></para>
-    	<para>The only key specific to the current session is 'sessionid'.  
-                However the preferred mechanism for getting the session id is with the session_id() function.  
-                To prevent untrusted access to system properties, this function is not enabled by default.  The ENV function may be enabled via the allowEnvFunction property in the &teiid-beans; file.</para>
+    	<para>To prevent untrusted access to system properties, this function is not enabled by default.  The ENV function may be enabled via the allowEnvFunction property in the &teiid-deployer-beans; file.</para>
     	<para>key, return value are strings</para>
      </section>
      <section>

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorManager.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -20,10 +20,6 @@
  * 02110-1301 USA.
  */
 
-/*
- * Date: Aug 25, 2003
- * Time: 3:53:37 PM
- */
 package org.teiid.dqp.internal.datamgr;
 
 import java.util.Arrays;
@@ -40,10 +36,10 @@
 import org.teiid.dqp.message.AtomicRequestID;
 import org.teiid.dqp.message.AtomicRequestMessage;
 import org.teiid.logging.CommandLogMessage;
-import org.teiid.logging.CommandLogMessage.Event;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
 import org.teiid.logging.MessageLevel;
+import org.teiid.logging.CommandLogMessage.Event;
 import org.teiid.metadata.Datatype;
 import org.teiid.metadata.FunctionMethod;
 import org.teiid.metadata.MetadataFactory;
@@ -51,7 +47,6 @@
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
 import org.teiid.query.optimizer.capabilities.SourceCapabilities;
-import org.teiid.query.optimizer.capabilities.SourceCapabilities.Scope;
 import org.teiid.query.sql.lang.Command;
 import org.teiid.resource.spi.WrappedConnection;
 import org.teiid.translator.ExecutionContext;
@@ -60,7 +55,7 @@
 
 
 /**
- * The <code>ConnectorManager</code> manages a {@link org.teiid.translator.BasicExecutionFactory Connector}
+ * The <code>ConnectorManager</code> manages an {@link ExecutionFactory}
  * and its associated workers' state.
  */
 public class ConnectorManager  {
@@ -69,7 +64,6 @@
 
 	private String translatorName;
 	private String connectionName;
-	private String modelName;
 	
     // known requests
     private ConcurrentHashMap<AtomicRequestID, ConnectorWorkItem> requestStates = new ConcurrentHashMap<AtomicRequestID, ConnectorWorkItem>();
@@ -143,7 +137,6 @@
 		checkStatus();
 		ExecutionFactory<Object, Object> translator = getExecutionFactory();
 		BasicSourceCapabilities resultCaps = CapabilitiesConverter.convertCapabilities(translator, Arrays.asList(translatorName, connectionName));
-		resultCaps.setScope(Scope.SCOPE_GLOBAL);
 		cachedCapabilities = resultCaps;
 		return resultCaps;
     }
@@ -166,9 +159,9 @@
      * Remove the state associated with
      * the given <code>RequestID</code>.
      */
-    void removeState(AtomicRequestID id) {
+    boolean removeState(AtomicRequestID id) {
     	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {id, "Remove State"}); //$NON-NLS-1$
-        requestStates.remove(id);
+        return requestStates.remove(id) != null;
     }
 
     int size() {
@@ -282,11 +275,4 @@
     	return this.connectionName;
     }
     
-    public void setModelName(String modelName) {
-    	this.modelName = modelName;
-    }
-    
-    public String getModelName() {
-    	return this.modelName;
-    }
 }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -30,7 +30,6 @@
 
 import org.teiid.adminapi.impl.VDBMetaData;
 import org.teiid.client.ResizingArrayList;
-import org.teiid.common.buffer.BlockedException;
 import org.teiid.core.TeiidProcessingException;
 import org.teiid.core.util.Assertion;
 import org.teiid.dqp.internal.process.RequestWorkItem;
@@ -38,7 +37,6 @@
 import org.teiid.dqp.message.AtomicRequestMessage;
 import org.teiid.dqp.message.AtomicResultsMessage;
 import org.teiid.language.Call;
-import org.teiid.language.QueryExpression;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
 import org.teiid.logging.CommandLogMessage.Event;
@@ -48,6 +46,7 @@
 import org.teiid.query.metadata.TempMetadataAdapter;
 import org.teiid.query.metadata.TempMetadataStore;
 import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.QueryCommand;
 import org.teiid.query.sql.lang.StoredProcedure;
 import org.teiid.resource.spi.WrappedConnection;
 import org.teiid.translator.DataNotAvailableException;
@@ -55,10 +54,10 @@
 import org.teiid.translator.ExecutionFactory;
 import org.teiid.translator.ProcedureExecution;
 import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.ReusableExecution;
 import org.teiid.translator.TranslatorException;
 import org.teiid.translator.UpdateExecution;
 
-
 public class ConnectorWorkItem implements ConnectorWork {
 	
 	/* Permanent state members */
@@ -74,7 +73,6 @@
     private ExecutionContextImpl securityContext;
     private volatile ResultSetExecution execution;
     private ProcedureBatchHandler procedureBatchHandler;
-    private org.teiid.language.Command translatedCommand;
     private int expectedColumns;
         
     /* End state information */    
@@ -89,18 +87,13 @@
         this.requestMsg = message;
         this.manager = manager;
         AtomicRequestID requestID = this.requestMsg.getAtomicRequestID();
-        this.securityContext = new ExecutionContextImpl(requestMsg.getWorkContext().getVdbName(),
-                requestMsg.getWorkContext().getVdbVersion(),                
-                requestMsg.getExecutionPayload(),                                                                       
-                requestMsg.getWorkContext().getSessionId(),                                                                      
+        this.securityContext = new ExecutionContextImpl(message.getCommandContext(),                                                                      
                 requestMsg.getConnectorName(),
-                requestMsg.getRequestID().toString(),
                 Integer.toString(requestID.getNodeID()),
                 Integer.toString(requestID.getExecutionId())
                 );
         this.securityContext.setGeneralHint(message.getGeneralHint());
         this.securityContext.setHint(message.getHint());
-        this.securityContext.setUser(requestMsg.getWorkContext().getSubject());
         this.securityContext.setBatchSize(this.requestMsg.getFetchSize());
         this.securityContext.setSession(requestMsg.getWorkContext().getSession());
         
@@ -146,6 +139,9 @@
     
     public void close() {
     	this.securityContext.setRequestWorkItem(null);
+    	if (!manager.removeState(this.id)) {
+    		return; //already closed
+    	}
     	LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Processing Close :", this.requestMsg.getCommand()}); //$NON-NLS-1$
     	if (!error) {
             manager.logSRCCommand(this.requestMsg, this.securityContext, Event.END, this.rowCount);
@@ -162,8 +158,6 @@
         		this.connector.closeConnection(connection, connectionFactory);
         	} catch (Throwable e) {
         		LogManager.logError(LogConstants.CTX_CONNECTOR, e, e.getMessage());
-        	} finally {
-        		manager.removeState(this.id);
         	}
 		    LogManager.logDetail(LogConstants.CTX_CONNECTOR, new Object[] {this.id, "Closed connection"}); //$NON-NLS-1$
         } 
@@ -196,7 +190,7 @@
 		return new TranslatorException(t);
     }
     
-	public AtomicResultsMessage execute() throws TranslatorException, BlockedException {
+	public AtomicResultsMessage execute() throws TranslatorException {
         if(isCancelled()) {
     		throw new TranslatorException("Request canceled"); //$NON-NLS-1$
     	}
@@ -214,56 +208,25 @@
 					throw new TranslatorException(QueryPlugin.Util.getString("failed_to_unwrap_connection")); //$NON-NLS-1$
 				}	
 			}
-			
+
 	        // Translate the command
 	        Command command = this.requestMsg.getCommand();
 	        this.expectedColumns = command.getProjectedSymbols().size();
 	        LanguageBridgeFactory factory = new LanguageBridgeFactory(queryMetadata);
-	        this.translatedCommand = factory.translate(command);
-	
-	        RuntimeMetadata rmd = new RuntimeMetadataImpl(queryMetadata);
-	        
-	        // Create the execution based on mode
-	        final Execution exec = connector.createExecution(this.translatedCommand, this.securityContext, rmd, (unwrapped == null) ? this.connection:unwrapped);
-	        if (this.translatedCommand instanceof Call) {
-	        	this.execution = Assertion.isInstanceOf(exec, ProcedureExecution.class, "Call Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
-	        	StoredProcedure proc = (StoredProcedure)command;
-	        	if (proc.returnParameters()) {
-	        		this.procedureBatchHandler = new ProcedureBatchHandler((Call)this.translatedCommand, (ProcedureExecution)exec);
-	        	}
-	        } else if (this.translatedCommand instanceof QueryExpression){
-	        	this.execution = Assertion.isInstanceOf(exec, ResultSetExecution.class, "QueryExpression Executions are expected to be ResultSetExecutions"); //$NON-NLS-1$
-	        } else {
-	        	Assertion.isInstanceOf(exec, 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 TranslatorException {
-	        			exec.cancel();
-	        		}
-	        		@Override
-	        		public void close() {
-	        			exec.close();
-	        		}
-	        		@Override
-	        		public void execute() throws TranslatorException {
-	        			exec.execute();
-	        		}
-	        		@Override
-	        		public List<?> next() throws TranslatorException,
-	        				DataNotAvailableException {
-	        			if (results == null) {
-	        				results = ((UpdateExecution)exec).getUpdateCounts();
-	        			}
-	        			if (index < results.length) {
-	        				return Arrays.asList(results[index++]);
-	        			}
-	        			return null;
-	        		}
-	        	};
-	        }
+	        org.teiid.language.Command translatedCommand = factory.translate(command);
+
+			Execution exec = this.requestMsg.getCommandContext().getReusableExecution(this.securityContext.getPartIdentifier());
+			if (exec != null) {
+				((ReusableExecution)exec).reset(translatedCommand, this.securityContext, connection);
+			} else {
+		        RuntimeMetadata rmd = new RuntimeMetadataImpl(queryMetadata);
+		        exec = connector.createExecution(translatedCommand, this.securityContext, rmd, (unwrapped == null) ? this.connection:unwrapped);
+		        if (exec instanceof ReusableExecution<?>) {
+		        	this.requestMsg.getCommandContext().putReusableExecution(this.securityContext.getPartIdentifier(), (ReusableExecution<?>) exec);
+		        }
+			}
+	        setExecution(command, translatedCommand, exec);
+			
 	        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); 
@@ -277,6 +240,49 @@
     		throw handleError(t);
     	}
 	}
+
+	private void setExecution(Command command,
+			org.teiid.language.Command translatedCommand, final Execution exec) {
+		if (translatedCommand instanceof Call) {
+			this.execution = Assertion.isInstanceOf(exec, ProcedureExecution.class, "Call Executions are expected to be ProcedureExecutions"); //$NON-NLS-1$
+			StoredProcedure proc = (StoredProcedure)command;
+			if (proc.returnParameters()) 			{
+				this.procedureBatchHandler = new ProcedureBatchHandler((Call)translatedCommand, (ProcedureExecution)exec);
+			}
+		} else if (command instanceof QueryCommand){
+			this.execution = Assertion.isInstanceOf(exec, ResultSetExecution.class, "QueryExpression Executions are expected to be ResultSetExecutions"); //$NON-NLS-1$
+		} else {
+			Assertion.isInstanceOf(exec, 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 TranslatorException {
+					exec.cancel();
+				}
+				@Override
+				public void close() {
+					exec.close();
+				}
+				@Override
+				public void execute() throws TranslatorException {
+					exec.execute();
+				}
+				@Override
+				public List<?> next() throws TranslatorException,
+						DataNotAvailableException {
+					if (results == null) {
+						results = ((UpdateExecution)exec).getUpdateCounts();
+					}
+					if (index < results.length) {
+						return Arrays.asList(results[index++]);
+					}
+					return null;
+				}
+			};
+		}
+	}
     
     protected AtomicResultsMessage handleBatch() throws TranslatorException {
     	Assertion.assertTrue(!this.lastBatch);
@@ -354,7 +360,7 @@
 		return response;
 	}
 
-    public static AtomicResultsMessage createResultsMessage(List[] batch) {
+    public static AtomicResultsMessage createResultsMessage(List<?>[] batch) {
         return new AtomicResultsMessage(batch);
     }    
             

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -23,6 +23,7 @@
 package org.teiid.dqp.internal.datamgr;
 
 import java.io.Serializable;
+import java.lang.ref.WeakReference;
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.LinkedList;
@@ -34,29 +35,18 @@
 import org.teiid.common.buffer.BufferManager;
 import org.teiid.core.util.HashCodeUtil;
 import org.teiid.dqp.internal.process.RequestWorkItem;
+import org.teiid.dqp.message.RequestID;
+import org.teiid.query.util.CommandContext;
 import org.teiid.translator.ExecutionContext;
 
 
 /**
  */
 public class ExecutionContextImpl implements ExecutionContext {
-
-    // Orginal request non-atomic request id
-    private String requestID;   
     //  Access Node ID
     private String partID;
     // currentConnector ID
     private String connectorName;    
-    // current VDB 
-    private String vdbName;
-    // Current VDB's version
-    private int vdbVersion;
-    // User Name
-    private Subject user;
-    // Payload setup on the Statement object
-    private Serializable executionPayload;
-    // ID of the parent JDBC Connection which is executing the statement
-    private String requestConnectionID;
     // Execute count of the query
     private String executeCount;
     // keep the execution object alive during the processing. default:false 
@@ -67,31 +57,44 @@
     private int batchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
 	private List<Exception> warnings = new LinkedList<Exception>();
 	private Session session;
-	private RequestWorkItem worktItem;
+	private WeakReference<RequestWorkItem> worktItem;
 	private boolean dataAvailable;
 	private String generalHint;
 	private String hint;
+	private CommandContext commandContext;
+	
+	public ExecutionContextImpl(String vdbName, int vdbVersion,  Serializable executionPayload, 
+            String originalConnectionID, String connectorName, long requestId, String partId, String execCount) {
+		commandContext = new CommandContext();
+		commandContext.setVdbName(vdbName);
+		commandContext.setVdbVersion(vdbVersion);
+		commandContext.setCommandPayload(executionPayload);
+		commandContext.setConnectionID(originalConnectionID);
+		commandContext.setRequestId(new RequestID(originalConnectionID, requestId));
+		this.connectorName = connectorName;
+        this.partID = partId;        
+        this.executeCount = execCount;
+	}
     
-    public ExecutionContextImpl(String vdbName, int vdbVersion,  Serializable executionPayload, 
-                                String originalConnectionID, String connectorName, String requestId, String partId, String execCount) {
-        
-        this.vdbName = vdbName;
-        this.vdbVersion = vdbVersion;
-        this.executionPayload = executionPayload;
+    public ExecutionContextImpl(CommandContext commandContext, String connectorName, String partId, String execCount) {
         this.connectorName = connectorName;
-        this.requestID = requestId;
         this.partID = partId;        
-        this.requestConnectionID = originalConnectionID;
         this.executeCount = execCount;
+        this.commandContext = commandContext;
     }
     
+    @Override
+    public org.teiid.CommandContext getCommandContext() {
+    	return this.commandContext;
+    }
+    
     public String getConnectorIdentifier() {
         return this.connectorName;
     }
     
     @Override
     public String getRequestIdentifier() {
-        return this.requestID;
+        return this.commandContext.getRequestId();
     }
 
     @Override
@@ -105,29 +108,25 @@
     }
     @Override
     public String getVirtualDatabaseName() {
-        return this.vdbName;
+        return this.commandContext.getVdbName();
     }
     @Override
     public int getVirtualDatabaseVersion() {
-        return this.vdbVersion;
+        return this.commandContext.getVdbVersion();
     }
     @Override
     public Subject getSubject() {
-        return this.user;
+        return this.commandContext.getSubject();
     }
     
-    public void setUser(Subject user) {
-        this.user = user;
-    }
-
     @Override
     public Serializable getExecutionPayload() {
-        return executionPayload;
+        return this.commandContext.getCommandPayload();
     }
     
     @Override
 	public String getConnectionIdentifier() {
-		return requestConnectionID;
+		return this.commandContext.getConnectionID();
 	}
     @Override
     public void keepExecutionAlive(boolean alive) {
@@ -164,17 +163,17 @@
     }
 
     public int hashCode() {
-        return HashCodeUtil.hashCode(HashCodeUtil.hashCode(0, requestID), partID);
+        return HashCodeUtil.hashCode(HashCodeUtil.hashCode(0, getRequestIdentifier()), partID);
     }
 
     public String toString() {
     	String userName = null;
-    	if (this.user != null) {
-	    	for(Principal p:this.user.getPrincipals()) {
+    	if (this.getSubject() != null) {
+	    	for(Principal p:this.getSubject().getPrincipals()) {
 	    		userName = p.getName();
 	    	}
     	}
-        return "ExecutionContext<vdb=" + this.vdbName + ", version=" + this.vdbVersion + ", user=" + userName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+        return "ExecutionContext<vdb=" + this.getVirtualDatabaseName() + ", version=" + this.getVirtualDatabaseVersion() + ", user=" + userName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
 	
     @Override
@@ -222,12 +221,12 @@
 	}
 
 	public void setRequestWorkItem(RequestWorkItem item) {
-		this.worktItem = item;
+		this.worktItem = new WeakReference<RequestWorkItem>(item);
 	}
 	
 	@Override
 	public synchronized void dataAvailable() {
-		RequestWorkItem requestWorkItem = this.worktItem;
+		RequestWorkItem requestWorkItem = this.worktItem.get();
 		dataAvailable = true;
 		if (requestWorkItem != null) {
 			requestWorkItem.moreWork();

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ProcedureBatchHandler.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ProcedureBatchHandler.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/ProcedureBatchHandler.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -43,7 +43,7 @@
 	private ProcedureExecution procExec;
 	private int paramCols = 0;
 	private int resultSetCols = 0;
-	private List filler;
+	private List<?> filler;
     
 	public ProcedureBatchHandler(Call proc, ProcedureExecution procExec) {
 		this.proc = proc;
@@ -65,20 +65,20 @@
         }
 	}
 	
-	List padRow(List row) throws TranslatorException {
+	List<?> padRow(List<?> row) throws TranslatorException {
         if (row.size() != resultSetCols) {
             throw new TranslatorException(QueryPlugin.Util.getString("ConnectorWorker.ConnectorWorker_result_set_unexpected_columns", new Object[] {proc, new Integer(resultSetCols), new Integer(row.size())})); //$NON-NLS-1$
         }
         if (paramCols == 0) {
         	return row;
         }
-        List result = new ArrayList(resultSetCols + paramCols);
+        List<Object> result = new ArrayList<Object>(resultSetCols + paramCols);
         result.addAll(row);
         result.addAll(filler);
         return result;
 	}
 	
-	List getParameterRow() throws TranslatorException {
+	List<?> getParameterRow() throws TranslatorException {
 		if (paramCols == 0) {
 			return null;
 		}

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	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -67,15 +67,15 @@
 import org.teiid.dqp.message.RequestID;
 import org.teiid.dqp.service.BufferService;
 import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionService;
 import org.teiid.dqp.service.TransactionContext.Scope;
-import org.teiid.dqp.service.TransactionService;
 import org.teiid.events.EventDistributor;
 import org.teiid.jdbc.EnhancedTimer;
 import org.teiid.logging.CommandLogMessage;
-import org.teiid.logging.CommandLogMessage.Event;
 import org.teiid.logging.LogConstants;
 import org.teiid.logging.LogManager;
 import org.teiid.logging.MessageLevel;
+import org.teiid.logging.CommandLogMessage.Event;
 import org.teiid.metadata.MetadataRepository;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.tempdata.TempTableDataManager;
@@ -401,11 +401,14 @@
 	}
 
 	private void startActivePlan(RequestWorkItem workItem, boolean addToQueue) {
-		workItem.active = true;
+		boolean continuous = workItem.requestMsg.getRequestOptions().isContinuous();
+		workItem.active = !continuous;
 		if (addToQueue) {
 			this.addWork(workItem);
 		}
-		this.currentlyActivePlans++;
+		if (!continuous) {
+			this.currentlyActivePlans++;
+		}
 	}
 	
     void finishProcessing(final RequestWorkItem workItem) {

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	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -181,6 +181,7 @@
 		}
 		
 		AtomicRequestMessage aqr = createRequest(context.getProcessorID(), command, modelName, connectorBindingId, nodeID);
+		aqr.setCommandContext(context);
 		SourceHint sh = context.getSourceHint();
 		if (sh != null) {
 			aqr.setGeneralHint(sh.getGeneralHint());

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	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -26,7 +26,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.Executor;
 
@@ -87,7 +86,6 @@
 import org.teiid.query.tempdata.GlobalTableStore;
 import org.teiid.query.tempdata.TempTableStore;
 import org.teiid.query.util.CommandContext;
-import org.teiid.query.util.ContextProperties;
 import org.teiid.query.validator.AbstractValidationVisitor;
 import org.teiid.query.validator.ValidationVisitor;
 import org.teiid.query.validator.Validator;
@@ -221,9 +219,6 @@
 
         RequestID reqID = workContext.getRequestID(this.requestMsg.getExecutionId());
         
-        Properties props = new Properties();
-        props.setProperty(ContextProperties.SESSION_ID, workContext.getSessionId());
-        
         this.context =
             new CommandContext(
                 reqID,
@@ -232,7 +227,6 @@
                 requestMsg.getExecutionPayload(), 
                 workContext.getVdbName(), 
                 workContext.getVdbVersion(),
-                props,
                 this.requestMsg.getShowPlan() != ShowPlan.OFF);
         this.context.setProcessorBatchSize(bufferManager.getProcessorBatchSize());
         this.context.setGlobalTableStore(this.globalTables);
@@ -367,6 +361,7 @@
         tc.setIsolationLevel(requestMsg.getTransactionIsolation());
         this.transactionContext = tc;
         this.processor = new QueryProcessor(processPlan, context, bufferManager, processorDataManager);
+    	this.processor.setContinuous(this.requestMsg.getRequestOptions().isContinuous());
     }
 
     /**

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	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -77,6 +77,7 @@
 import org.teiid.query.sql.lang.SPParameter;
 import org.teiid.query.sql.lang.StoredProcedure;
 import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.util.CommandContext;
 
 public class RequestWorkItem extends AbstractWorkItem implements PrioritizedRunnable {
 	
@@ -275,7 +276,7 @@
                 state = ProcessingState.PROCESSING;
         		processNew();
                 if (isCanceled) {
-                	this.processingException = new TeiidProcessingException(SQLStates.QUERY_CANCELED, QueryPlugin.Util.getString("QueryProcessor.request_cancelled", this.requestID)); //$NON-NLS-1$
+                	setCanceledException();
                     state = ProcessingState.CLOSE;
                 } 
         	}
@@ -317,6 +318,10 @@
         }
     }
 
+	private void setCanceledException() {
+		this.processingException = new TeiidProcessingException(SQLStates.QUERY_CANCELED, QueryPlugin.Util.getString("QueryProcessor.request_cancelled", this.requestID)); //$NON-NLS-1$
+	}
+
 	private void handleThrowable(Throwable e) {
 		LogManager.logDetail(LogConstants.CTX_DQP, e, "Request Thread", requestID, "- error occurred"); //$NON-NLS-1$ //$NON-NLS-2$
 		
@@ -424,6 +429,9 @@
 					for (DataTierTupleSource connectorRequest : getConnectorRequests()) {
 						connectorRequest.fullyCloseSource();
 				    }
+					
+					CommandContext cc = this.processor.getContext();
+					cc.close();
 				}
 	
 				this.resultsBuffer = null;
@@ -451,6 +459,13 @@
 					suspend();
 				}
 			}
+			
+	        synchronized (this) {
+		        if (this.processingException == null && this.resultsReceiver != null) {
+		        	//sanity check to ensure that something will be sent to the client
+		        	setCanceledException();
+		        }
+			}
 		} catch (Throwable t) {
 			handleThrowable(t);
 		} finally {
@@ -478,7 +493,7 @@
 				
 		boolean cachable = false;
 		CacheID cacheId = null;
-		boolean canUseCached = (requestMsg.useResultSetCache() || 
+		boolean canUseCached = !requestMsg.getRequestOptions().isContinuous() && (requestMsg.useResultSetCache() || 
 				QueryParser.getQueryParser().parseCacheHint(requestMsg.getCommandString()) != null);
 		
 		if (rsCache != null) {
@@ -554,6 +569,9 @@
 		analysisRecord = request.analysisRecord;
 		transactionContext = request.transactionContext;
 		if (this.transactionContext != null && this.transactionContext.getTransactionType() != Scope.NONE) {
+			if (this.requestMsg.getRequestOptions().isContinuous()) {
+				throw new IllegalStateException("Continuous requests are not allowed to be transactional."); //$NON-NLS-1$
+			}
 			this.transactionState = TransactionState.ACTIVE;
 		}
 		if (requestMsg.isNoExec()) {
@@ -562,6 +580,9 @@
             this.cid = null;
 		}
 	    this.returnsUpdateCount = request.returnsUpdateCount;
+	    if (this.returnsUpdateCount && this.requestMsg.getRequestOptions().isContinuous()) {
+			throw new IllegalStateException("Continuous requests are not allowed to be updates."); //$NON-NLS-1$
+	    }
 		request = null;
 	}
 	
@@ -633,7 +654,7 @@
     		} else if (!fromBuffer){
     			result = !isForwardOnly();
     		}
-	        int finalRowCount = this.resultsBuffer.isFinal()?this.resultsBuffer.getRowCount():(batch.getTerminationFlag()?batch.getEndRow():-1);
+	        int finalRowCount = (this.resultsBuffer.isFinal()&&!this.requestMsg.getRequestOptions().isContinuous())?this.resultsBuffer.getRowCount():(batch.getTerminationFlag()?batch.getEndRow():-1);
 	        
 	        response = createResultsMessage(batch.getTuples(), this.originalCommand.getProjectedSymbols());
 	        response.setFirstRow(batch.getBeginRow());

Modified: trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestMessage.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestMessage.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestMessage.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -24,7 +24,6 @@
  */
 package org.teiid.dqp.message;
 
-import java.io.Serializable;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.teiid.client.RequestMessage;
@@ -33,13 +32,14 @@
 import org.teiid.dqp.service.TransactionContext;
 import org.teiid.dqp.service.TransactionContext.Scope;
 import org.teiid.query.sql.lang.Command;
+import org.teiid.query.util.CommandContext;
 
 
 /**
  * This class defines a request message for the Connector layer. This is uniquely identified
  * by AtomicRequestID.
  */
-public class AtomicRequestMessage implements Serializable {
+public class AtomicRequestMessage {
     static final long serialVersionUID = -4060941593023225562L;
 
 	/**
@@ -76,7 +76,6 @@
     private boolean partialResultsFlag;
     
     private RequestID requestID;
-    private Serializable executionPayload;
     
     private boolean exceptionOnMaxRows;
     private int maxRows;
@@ -86,13 +85,9 @@
     private DQPWorkContext workContext;
     private String generalHint;
     private String hint;
+    private CommandContext commandContext;
     
-    public AtomicRequestMessage() {
-        // This is only to honor the externalizable interface..
-	}
-    
     public AtomicRequestMessage(RequestMessage requestMessage, DQPWorkContext parent, int nodeId){
-    	this.executionPayload = requestMessage.getExecutionPayload();
     	this.workContext = parent;
     	this.requestID = new RequestID(parent.getSessionId(), requestMessage.getExecutionId());
         this.atomicRequestId = new AtomicRequestID(this.requestID, nodeId, EXECUTION_COUNT.getAndIncrement());
@@ -193,14 +188,6 @@
         return atomicRequestId.toString();
     }
 
-	public void setExecutionPayload(Serializable executionPayload) {
-		this.executionPayload = executionPayload;
-	}
-
-	public Serializable getExecutionPayload() {
-		return executionPayload;
-	}
-
 	public void setRequestID(RequestID requestID) {
 		this.requestID = requestID;
 	}
@@ -232,5 +219,13 @@
 	public void setHint(String hint) {
 		this.hint = hint;
 	}
+	
+	public CommandContext getCommandContext() {
+		return commandContext;
+	}
+	
+	public void setCommandContext(CommandContext commandContext) {
+		this.commandContext = commandContext;
+	}
 
 }

Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -1266,13 +1266,9 @@
     }
 
     // ================= Function - ENV ========================
-    public static Object env(CommandContext context, String propertyName) {
+    public static Object env(String propertyName) {
         // All context property keys must be lowercase - we lowercase the incoming key here to match regardless of case
         String propertyNameNocase = propertyName.toLowerCase();
-        Properties envProps = context.getEnvironmentProperties();
-        if(envProps != null && envProps.containsKey(propertyNameNocase)) {
-            return envProps.getProperty(propertyNameNocase);
-        }
         String value = System.getProperty(propertyName);
         if (value == null) {
             value = System.getProperty(propertyNameNocase);

Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -1,7 +1,11 @@
 package org.teiid.query.function.metadata;
 
 import java.io.InputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
 
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
@@ -31,7 +35,6 @@
 		 XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
 		 FunctionMetadataReader fmr = new FunctionMetadataReader();
 		 while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
-			 System.out.println(reader.getLocalName());
 			 switch (Namespace.forUri(reader.getNamespaceURI())) {
 			 	case XMI: {
                     Element element = Element.forName(reader.getLocalName());

Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -840,7 +840,7 @@
                 new FunctionParameter[] {
                     new FunctionParameter("variablename", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Env_varname")) //$NON-NLS-1$ //$NON-NLS-2$
                      },
-                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Env_result")), false, Determinism.SESSION_DETERMINISTIC ) );                     //$NON-NLS-1$ //$NON-NLS-2$
+                new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Env_result")), false, Determinism.DETERMINISTIC ) );                     //$NON-NLS-1$ //$NON-NLS-2$
     }
     
     private void addSessionIdFunction() {

Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -37,7 +37,6 @@
 
 	private static final long serialVersionUID = -1779069588746365579L;
 	
-	private Scope scope = Scope.SCOPE_GLOBAL;
     private Map<Capability, Boolean> capabilityMap = new HashMap<Capability, Boolean>();
     private Map<String, Boolean> functionMap = new TreeMap<String, Boolean>(String.CASE_INSENSITIVE_ORDER);
     private Map<Capability, Object> propertyMap = new HashMap<Capability, Object>();
@@ -82,16 +81,8 @@
         functionMap.put(function, Boolean.valueOf(supports));
     }
 
-    public Scope getScope() {
-        return this.scope;
-    }
-
-    public void setScope(Scope scope) {
-        this.scope = scope;
-    }
-    
     public String toString() {
-        return "BasicSourceCapabilities<"+scope+", caps=" + capabilityMap + ", funcs=" + functionMap + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+        return "BasicSourceCapabilities<caps=" + capabilityMap + ", funcs=" + functionMap + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
     }
     
     /**

Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -349,23 +349,7 @@
 
     }
 
-    public enum Scope {
-        /**
-         * A legal value for the {@link #SCOPE} property.
-         */
-        SCOPE_GLOBAL,
-        /**
-         * A legal value for the {@link #SCOPE} property.
-         */
-        SCOPE_PER_USER
-    }
-
     /**
-     * Determine the scope of these capabilities.
-     */
-    Scope getScope();
-
-    /**
      * Returns true if the capability is supported. The capability constants are all defined in this interface with the meaning of
      * supporting that capability.
      * 

Modified: trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -68,6 +68,8 @@
     private volatile boolean requestCanceled;
     private static final int DEFAULT_WAIT = 50;       
     private boolean processorClosed;
+    private boolean continuous;
+    private int rowOffset = 1;
          
     /**
      * Construct a processor with all necessary information to process.
@@ -137,7 +139,19 @@
 	        		throw new TeiidProcessingException("Query timed out"); //$NON-NLS-1$
 	        	}
 	            result = processPlan.nextBatch();
-	
+
+	            if (continuous) {
+	        		result.setRowOffset(rowOffset);
+	        		rowOffset = result.getEndRow() + 1;
+
+	        		if (result.getTerminationFlag()) {
+	        			result.setTerminationFlag(false);
+		        		this.processPlan.close();
+		        		this.processPlan.reset();
+		        		this.open = false;	
+	        		}
+	            }
+        		
 	        	if(result.getTerminationFlag()) {
 	        		done = true;
 	        		break;
@@ -264,4 +278,8 @@
 	public BufferManager getBufferManager() {
 		return bufferMgr;
 	}
+	
+	public void setContinuous(boolean continuous) {
+		this.continuous = continuous;
+	}
 }

Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -28,10 +28,10 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Random;
 import java.util.Set;
 import java.util.TimeZone;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executor;
 
 import javax.security.auth.Subject;
@@ -51,6 +51,8 @@
 import org.teiid.dqp.message.RequestID;
 import org.teiid.dqp.service.TransactionContext;
 import org.teiid.dqp.service.TransactionService;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
 import org.teiid.metadata.FunctionMethod.Determinism;
 import org.teiid.query.QueryPlugin;
 import org.teiid.query.eval.SecurityFunctionEvaluator;
@@ -64,6 +66,7 @@
 import org.teiid.query.sql.util.VariableContext;
 import org.teiid.query.tempdata.GlobalTableStore;
 import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.translator.ReusableExecution;
 
 /** 
  * Defines the context that a command is processing in.  For example, this defines
@@ -90,8 +93,6 @@
 	    
 	    private int vdbVersion;
 	    
-	    private Properties environmentProperties;
-	    
 	    /** Indicate whether statistics should be collected for relational node processing*/
 	    private boolean collectNodeStatistics;
 	    
@@ -138,6 +139,7 @@
 		private TransactionService transactionService;
 		private SourceHint sourceHint;
 		private Executor executor = ExecutorUtils.getDirectExecutor();
+		Map<String, ReusableExecution<?>> reusableExecutions;
 	}
 	
 	private GlobalState globalState = new GlobalState();
@@ -153,14 +155,13 @@
      * Construct a new context.
      */
     public CommandContext(Object processorID, String connectionID, String userName, 
-        Serializable commandPayload, String vdbName, int vdbVersion, Properties envProperties, boolean collectNodeStatistics) {
+        Serializable commandPayload, String vdbName, int vdbVersion, boolean collectNodeStatistics) {
         setProcessorID(processorID);
         setConnectionID(connectionID);
         setUserName(userName);
         setCommandPayload(commandPayload);
         setVdbName(vdbName);
         setVdbVersion(vdbVersion);  
-        setEnvironmentProperties(envProperties);        
         setCollectNodeStatistics(collectNodeStatistics);
     }
 
@@ -171,7 +172,7 @@
         String vdbName, int vdbVersion) {
 
         this(processorID, connectionID, userName, null, vdbName, 
-            vdbVersion, null, false);            
+            vdbVersion, false);            
              
     }
 
@@ -289,14 +290,6 @@
         this.globalState.vdbVersion = vdbVersion;
     }
 
-    public Properties getEnvironmentProperties() {
-        return globalState.environmentProperties;
-    }
-
-    public void setEnvironmentProperties(Properties properties) {
-    	globalState.environmentProperties = properties;
-    }
-    
     public Serializable getCommandPayload() {
         return this.globalState.commandPayload;
     }
@@ -650,4 +643,30 @@
 		this.globalState.executor = e;
 	}
 	
+	public ReusableExecution<?> getReusableExecution(String nodeId) {
+		if (this.globalState.reusableExecutions == null) {
+			return null;
+		}
+		return this.globalState.reusableExecutions.get(nodeId);
+	}
+	
+	public void putReusableExecution(String nodeId, ReusableExecution<?> execution) {
+		if (this.globalState.reusableExecutions == null) {
+			this.globalState.reusableExecutions = new ConcurrentHashMap<String, ReusableExecution<?>>();
+		}
+		this.globalState.reusableExecutions.put(nodeId, execution);
+	}
+
+	public void close() {
+		if (this.globalState.reusableExecutions != null) {
+			for (ReusableExecution<?> reusableExecution : this.globalState.reusableExecutions.values()) {
+				try {
+					reusableExecution.dispose();
+				} catch (Exception e) {
+					LogManager.logWarning(LogConstants.CTX_DQP, e, "Unhandled exception disposing reusable execution"); //$NON-NLS-1$
+				}
+			}
+		}
+	}
+	
 }

Deleted: trunk/engine/src/main/java/org/teiid/query/util/ContextProperties.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/ContextProperties.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/main/java/org/teiid/query/util/ContextProperties.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -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.query.util;
-
-/**
- * Defines constants that are used within the DQP, provided to the query engine as 
- * properties in the CommandContext for access via the ENV function.
- */
-public interface ContextProperties {
-
-    // !!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    // ALL constants defined here for use with the CommandContext and that should be 
-    // retrievable by the env() system function MUST be defined in all lower-case or
-    // they will not work. 
-        
-    public static final String SESSION_ID = "sessionid"; //$NON-NLS-1$
-
-}

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeExecutionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeExecutionContextImpl.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/FakeExecutionContextImpl.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -24,7 +24,6 @@
 
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.teiid.dqp.internal.datamgr.ExecutionContextImpl;
 import org.teiid.translator.ExecutionContext;
 
 /**
@@ -43,15 +42,15 @@
 				"ExecutionPayload" + unique, //$NON-NLS-1$            
 				"ConnectionID" + unique, //$NON-NLS-1$
 				"ConnectorID" + unique, //$NON-NLS-1$
-				"RequestID" + unique, //$NON-NLS-1$
+				unique,
 				"PartID" + unique, //$NON-NLS-1$
 				"ExecCount" + unique); //$NON-NLS-1$
 	}
 
 	public FakeExecutionContextImpl(ExecutionContext c) {
 		super(c.getVirtualDatabaseName(), c.getVirtualDatabaseVersion(), c.getExecutionPayload(), c
-				.getConnectionIdentifier(), c.getConnectorIdentifier(), c
-				.getRequestIdentifier(), c.getPartIdentifier(), c
+				.getConnectionIdentifier(), c.getConnectorIdentifier(), Long.valueOf(c
+				.getRequestIdentifier()), c.getPartIdentifier(), c
 				.getExecutionCountIdentifier());
 	}
 

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorWorkItem.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorWorkItem.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestConnectorWorkItem.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -33,10 +33,6 @@
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.teiid.client.RequestMessage;
-import org.teiid.dqp.internal.datamgr.ConnectorManager;
-import org.teiid.dqp.internal.datamgr.ConnectorWorkItem;
-import org.teiid.dqp.internal.datamgr.LanguageBridgeFactory;
-import org.teiid.dqp.internal.datamgr.ProcedureBatchHandler;
 import org.teiid.dqp.internal.process.DQPWorkContext;
 import org.teiid.dqp.message.AtomicRequestMessage;
 import org.teiid.dqp.message.AtomicResultsMessage;
@@ -50,6 +46,7 @@
 import org.teiid.query.sql.lang.StoredProcedure;
 import org.teiid.query.sql.symbol.Constant;
 import org.teiid.query.unittest.RealMetadataFactory;
+import org.teiid.query.util.CommandContext;
 import org.teiid.translator.ProcedureExecution;
 import org.teiid.translator.TranslatorException;
 
@@ -77,6 +74,7 @@
 		request.setRequestID(new RequestID(requestid));
 		request.setConnectorName("testing"); //$NON-NLS-1$
 		request.setFetchSize(5);
+		request.setCommandContext(new CommandContext());
 		return request;
 	}
 

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestExecutionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestExecutionContextImpl.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/TestExecutionContextImpl.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -22,35 +22,28 @@
 
 package org.teiid.dqp.internal.datamgr;
 
+import org.junit.Test;
 import org.teiid.core.util.UnitTestUtil;
-import org.teiid.dqp.internal.datamgr.ExecutionContextImpl;
 
-
-import junit.framework.TestCase;
-
 /**
  */
-public class TestExecutionContextImpl extends TestCase {
+public class TestExecutionContextImpl {
 
-    public TestExecutionContextImpl(String name) {
-        super(name);
-    }
-
-    public ExecutionContextImpl createContext(String requestID, String partID) {
-        return new ExecutionContextImpl("vdb", 1, null,   //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+    public ExecutionContextImpl createContext(long requestID, String partID) {
+        return new ExecutionContextImpl("vdb", 1, null,   //$NON-NLS-1$
                                         "Connection", "Connector", requestID, partID, "0"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     
-    public void testEqivalenceSemanticsSame() {
-        UnitTestUtil.helpTestEquivalence(0, createContext("100", "1"), createContext("100", "1")); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-4$
+    @Test public void testEqivalenceSemanticsSame() {
+        UnitTestUtil.helpTestEquivalence(0, createContext(100, "1"), createContext(100, "1")); //$NON-NLS-2$ //$NON-NLS-1$ 
     }
 
-    public void testEqivalenceSemanticsDifferentPart() {
-        UnitTestUtil.helpTestEquivalence(1, createContext("100", "1"), createContext("100", "2")); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-4$
+    @Test public void testEqivalenceSemanticsDifferentPart() {
+        UnitTestUtil.helpTestEquivalence(1, createContext(100, "1"), createContext(100, "2")); //$NON-NLS-2$ //$NON-NLS-1$ 
     }
 
-    public void testEqivalenceSemanticsDifferentRequest() {
-        UnitTestUtil.helpTestEquivalence(1, createContext("100", "1"), createContext("200", "1")); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-4$
+    @Test public void testEqivalenceSemanticsDifferentRequest() {
+        UnitTestUtil.helpTestEquivalence(1, createContext(100, "1"), createContext(200, "1")); //$NON-NLS-2$ //$NON-NLS-1$ 
     }
 
 }

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	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -225,20 +225,6 @@
         helpExecute(sql, userName);
     }
 
-    @Test public void testEnvSessionId() throws Exception {
-        String sql = "SELECT env('sessionid') as SessionID"; //$NON-NLS-1$
-        String userName = "1"; //$NON-NLS-1$
-        ResultsMessage rm = helpExecute(sql, userName);
-        assertEquals("1", rm.getResultsList().get(0).get(0)); //$NON-NLS-1$
-    }
-    
-    @Test public void testEnvSessionIdMixedCase() throws Exception {
-        String sql = "SELECT env('sEsSIonId') as SessionID"; //$NON-NLS-1$
-        String userName = "1"; //$NON-NLS-1$
-        ResultsMessage rm = helpExecute(sql, userName);
-        assertEquals("1", rm.getResultsList().get(0).get(0)); //$NON-NLS-1$
-    }
-    
     @Test public void testTxnAutoWrap() throws Exception {
     	String sql = "SELECT * FROM BQT1.SmallA"; //$NON-NLS-1$
     	helpExecute(sql, "a", 1, true); //$NON-NLS-1$

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	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -155,13 +155,12 @@
     
     @Test public void testSessionSpecificFunction() throws Exception { 
         // Create query 
-    	System.setProperty("foo", "foo"); //$NON-NLS-1$ //$NON-NLS-2$
-        String preparedSql = "SELECT env('foo'), e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE e2=?"; //$NON-NLS-1$
+        String preparedSql = "SELECT session_id(), e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1 WHERE e2=?"; //$NON-NLS-1$
         
         // Create expected results
         List[] expected = new List[] { 
-            Arrays.asList(new Object[] { "foo",   new Integer(0),     Boolean.FALSE,  new Double(2.0) }), //$NON-NLS-1$
-            Arrays.asList(new Object[] { "foo",   new Integer(0),     Boolean.FALSE,  new Double(2.0) }) //$NON-NLS-1$
+            Arrays.asList(new Object[] { "6",   new Integer(0),     Boolean.FALSE,  new Double(2.0) }), //$NON-NLS-1$
+            Arrays.asList(new Object[] { "6",   new Integer(0),     Boolean.FALSE,  new Double(2.0) }) //$NON-NLS-1$
         };    
     
         List<?> values = Arrays.asList((short)0);

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	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -44,7 +44,6 @@
 import org.teiid.query.tempdata.TempTableStore;
 import org.teiid.query.tempdata.TempTableStore.TransactionMode;
 import org.teiid.query.unittest.RealMetadataFactory;
-import org.teiid.query.util.ContextProperties;
 
 
 
@@ -125,7 +124,7 @@
         DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB());
         
         Request request = helpProcessMessage(message, null, workContext);
-        assertEquals("1", request.context.getEnvironmentProperties().get(ContextProperties.SESSION_ID)); //$NON-NLS-1$
+        assertEquals("1", request.context.getConnectionID()); //$NON-NLS-1$
     }
 
     private Request helpProcessMessage(RequestMessage message, SessionAwareCache<PreparedPlan> cache, DQPWorkContext workContext) throws TeiidComponentException,

Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -114,7 +114,7 @@
         IDGenerator idGenerator = new IDGenerator();
         
         Properties props = new Properties();
-        CommandContext context = new CommandContext("0", "test", "user", null, vdb.getName(), vdb.getVersion(), props, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        CommandContext context = new CommandContext("0", "test", "user", null, vdb.getName(), vdb.getVersion(), false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         context.setPlanToProcessConverter(new MultiSourcePlanToProcessConverter(metadata, idGenerator, analysis, finder, multiSourceModels, dqpContext, context));
 
         ProcessorPlan plan = QueryOptimizer.optimizePlan(command, wrapper, idGenerator, finder, analysis, context);

Deleted: trunk/engine/src/test/java/org/teiid/dqp/message/TestAtomicRequestMessage.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/message/TestAtomicRequestMessage.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/dqp/message/TestAtomicRequestMessage.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -1,66 +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.message;
-
-import static org.junit.Assert.*;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.teiid.client.RequestMessage;
-import org.teiid.core.util.UnitTestUtil;
-import org.teiid.dqp.internal.datamgr.TestQueryImpl;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
- at Ignore(value="Serialization of language objects has been turned off")
-public class TestAtomicRequestMessage {
-
-    public static AtomicRequestMessage example() {
-        RequestMessage rm = new RequestMessage();
-        DQPWorkContext workContext = new DQPWorkContext();
-        workContext.getSession().setSessionId(String.valueOf(2));
-        AtomicRequestMessage message = new AtomicRequestMessage(rm, workContext, 1000);
-        message.setCommand(TestQueryImpl.helpExample(true));
-        message.setFetchSize(100);
-        message.setPartialResults(true);
-        message.setRequestID(new RequestID(5000L));
-        
-        //AtomicRequestMessage-specific stuff
-        message.setConnectorName("connectorBindingID"); //$NON-NLS-1$
-        return message;
-    }
-
-    @Test public void testSerialize() throws Exception {
-    	AtomicRequestMessage example = example();
-    	AtomicRequestMessage copy = UnitTestUtil.helpSerialize(example);
-
-        assertEquals(TestQueryImpl.helpExample(true), copy.getCommand());
-        assertEquals(100, copy.getFetchSize());
-
-        assertEquals(example.getProcessingTimestamp(), copy.getProcessingTimestamp());
-        assertEquals(new RequestID(5000L), copy.getRequestID());
-        assertEquals("2", copy.getWorkContext().getSessionId()); //$NON-NLS-1$
-        //AtomicRequestMessage-specific stuff
-        assertEquals("connectorBindingID", copy.getConnectorName()); //$NON-NLS-1$
-        assertEquals(1000, copy.getAtomicRequestID().getNodeID());
-    }
-}

Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -30,7 +30,6 @@
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.util.Calendar;
-import java.util.Properties;
 
 import org.junit.Test;
 import org.teiid.api.exception.query.FunctionExecutionException;
@@ -1119,22 +1118,14 @@
     }
     
     @Test public void testEnv() throws Exception {
-        Properties p = new Properties();
-        String envProperty = "EnvProperty"; //$NON-NLS-1$
         String systemProperty = "SystemProperty"; //$NON-NLS-1$        
-        p.setProperty(envProperty.toLowerCase(), envProperty);
 
-        // set an environment property
-        CommandContext context = new CommandContext();
-        context.setEnvironmentProperties(p);
-
         // set the system property
         System.setProperty(systemProperty, systemProperty);
         System.setProperty(systemProperty.toLowerCase(), systemProperty+"_lowercase"); //$NON-NLS-1$
         
-        assertEquals(envProperty, FunctionMethods.env(context, envProperty));
-        assertEquals(systemProperty, FunctionMethods.env(context, systemProperty));
-        assertEquals(systemProperty+"_lowercase", FunctionMethods.env(context, systemProperty.toUpperCase())); //$NON-NLS-1$
+        assertEquals(systemProperty, FunctionMethods.env(systemProperty));
+        assertEquals(systemProperty+"_lowercase", FunctionMethods.env(systemProperty.toUpperCase())); //$NON-NLS-1$
     }
     
     @Test(expected=FunctionExecutionException.class) public void testParseIntStrictness() throws Exception {

Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -1210,12 +1210,7 @@
     }
     
     @Test public void testInvokeEnv() throws Exception {
-        CommandContext c = new CommandContext();
-        Properties props = new Properties();
-        props.setProperty("env_test", "env_value"); //$NON-NLS-1$ //$NON-NLS-2$
-        c.setEnvironmentProperties(props);
-        helpInvokeMethod("env", new Class<?>[] {String.class}, new Object[] {"env_test"}, c, "env_value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$        
-        helpInvokeMethod("env", new Class<?>[] {String.class}, new Object[] {null}, c, null); //$NON-NLS-1$ 
+        helpInvokeMethod("env", new Class<?>[] {String.class}, new Object[] {null}, null); //$NON-NLS-1$ 
     }
     
     @Test public void testInvokeCommandPayload() throws Exception {

Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestBatchedUpdatePlanner.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -215,7 +215,6 @@
         private FakeCapabilities(boolean supportsBatching) {
             this.supportsBatching = supportsBatching;
         }
-        public Scope getScope() {return null;}
         public boolean supportsCapability(Capability capability) {
             return !capability.equals(Capability.BATCHED_UPDATES) || supportsBatching;
         }

Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/AllCapabilities.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/AllCapabilities.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/AllCapabilities.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -43,10 +43,6 @@
         return null;
     }
 
-	public Scope getScope() {
-		return Scope.SCOPE_GLOBAL;
-	}
-	
 	@Override
 	public boolean supportsConvert(int sourceType, int targetType) {
 		return true;

Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -349,7 +349,7 @@
 		Properties props = new Properties();
 		props.setProperty("soap_host", "my.host.com"); //$NON-NLS-1$ //$NON-NLS-2$
 		props.setProperty("soap_port", "12345"); //$NON-NLS-1$ //$NON-NLS-2$
-		CommandContext context = new CommandContext("0", "test", "user", null, "myvdb", 1, props, DEBUG); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+		CommandContext context = new CommandContext("0", "test", "user", null, "myvdb", 1, DEBUG); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
         context.setProcessorBatchSize(BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE);
         context.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
         context.setPreparedPlanCache(new SessionAwareCache<PreparedPlan>());
@@ -4755,7 +4755,7 @@
 			
 		// Create expected results
 		List[] expected = new List[] { 
-			Arrays.asList(new Object[] { "http://my.host.com:12345/metamatrix-soap/services/DataService" }), //$NON-NLS-1$ 
+			Arrays.asList(new Object[] { "http://soap_host/metamatrix-soap/services/DataService" }), //$NON-NLS-1$ 
 		};    
            
 		// Plan query

Modified: trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -51,16 +51,7 @@
 import org.teiid.query.sql.lang.Query;
 import org.teiid.query.sql.lang.QueryCommand;
 import org.teiid.query.sql.lang.SubqueryContainer;
-import org.teiid.query.sql.symbol.CaseExpression;
-import org.teiid.query.sql.symbol.Constant;
-import org.teiid.query.sql.symbol.ElementSymbol;
-import org.teiid.query.sql.symbol.Expression;
-import org.teiid.query.sql.symbol.Function;
-import org.teiid.query.sql.symbol.ScalarSubquery;
-import org.teiid.query.sql.symbol.SearchedCaseExpression;
-import org.teiid.query.sql.symbol.SingleElementSymbol;
-import org.teiid.query.sql.symbol.TestCaseExpression;
-import org.teiid.query.sql.symbol.TestSearchedCaseExpression;
+import org.teiid.query.sql.symbol.*;
 import org.teiid.query.sql.util.ValueIterator;
 import org.teiid.query.unittest.RealMetadataFactory;
 import org.teiid.query.util.CommandContext;
@@ -320,31 +311,6 @@
         assertEquals(context.getUserName(), new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList()) );       
     } 
     
-    /*
-     * This is the only test that depends upon the the testsrc/metamatrix.properties
-     * and testsrc/config.xml. If the implementation is changed, please update/remove
-     * these files.
-     * @throws Exception
-     */
-    @Test public void testEnv() throws Exception {
-        Function func = new Function("env", new Expression[] {}); //$NON-NLS-1$
-        FunctionDescriptor desc = RealMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("env", new Class[] {String.class} );         //$NON-NLS-1$
-        func.setFunctionDescriptor(desc);
-        
-        FakeDataManager dataMgr = new FakeDataManager();
-        
-        Properties props = new Properties();
-        props.setProperty("http_host", "testHostName"); //$NON-NLS-1$ //$NON-NLS-2$
-        props.setProperty("http_port", "8000"); //$NON-NLS-1$ //$NON-NLS-2$
-        CommandContext context = new CommandContext(new Long(1), null, null, null, null, 0, props, false);
-        
-        func.setArgs(new Expression[] {new Constant("http_host")}); //$NON-NLS-1$
-        assertEquals("testHostName", new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList())); //$NON-NLS-1$
-               
-        func.setArgs(new Expression[] {new Constant("http_port")}); //$NON-NLS-1$
-        assertEquals("8000", new Evaluator(Collections.emptyMap(), dataMgr, context).evaluate(func, Collections.emptyList())); //$NON-NLS-1$
-    }
-    
     public void helpTestCommandPayload(Serializable payload, String property, String expectedValue) throws Exception {
         Function func = new Function("commandpayload", new Expression[] {}); //$NON-NLS-1$
         
@@ -358,7 +324,7 @@
         func.setFunctionDescriptor(desc);
         
         FakeDataManager dataMgr = new FakeDataManager();       
-        CommandContext context = new CommandContext(new Long(-1), null, "user", payload, "vdb", 1, null, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
+        CommandContext context = new CommandContext(new Long(-1), null, "user", payload, "vdb", 1, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
 
         if(property != null) {
             func.setArgs(new Expression[] {new Constant(property)}); 

Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestRelationalNodeStatistics.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/relational/TestRelationalNodeStatistics.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestRelationalNodeStatistics.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -111,7 +111,7 @@
         
         FakeRelationalNode fakeNode = new FakeRelationalNode(1, data, 100);
         fakeNode.setElements(elements);
-        CommandContext context = new CommandContext("pid", "group", null, null, null, 1, null, true); //$NON-NLS-1$ //$NON-NLS-2$
+        CommandContext context = new CommandContext("pid", "group", null, null, null, 1, true); //$NON-NLS-1$ //$NON-NLS-2$
         fakeNode.initialize(context, BufferManagerFactory.getStandaloneBufferManager(), null);
         return fakeNode;
     }

Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -31,7 +31,6 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 import java.util.TimeZone;
 
 import org.junit.Before;
@@ -67,7 +66,6 @@
 import org.teiid.query.sql.visitor.CorrelatedReferenceCollectorVisitor;
 import org.teiid.query.unittest.RealMetadataFactory;
 import org.teiid.query.util.CommandContext;
-import org.teiid.query.util.ContextProperties;
 
 
 @SuppressWarnings("nls")
@@ -1078,16 +1076,13 @@
     }
 
 
-    //note that the env is now treated as deterministic, however it is really only deterministic within a session
-    @Test public void testRewriteExecEnv() throws Exception {
-        Command command = QueryParser.getQueryParser().parseCommand("exec pm1.sq2(env('sessionid'))");             //$NON-NLS-1$
+    @Test public void testRewriteExec() throws Exception {
+        Command command = QueryParser.getQueryParser().parseCommand("exec pm1.sq2(session_id())");             //$NON-NLS-1$
         
         QueryResolver.resolveCommand(command, RealMetadataFactory.example1Cached());
         
-        CommandContext context = new CommandContext();
-        Properties props = new Properties();
-        props.setProperty(ContextProperties.SESSION_ID, "1"); //$NON-NLS-1$
-        context.setEnvironmentProperties(props);
+        CommandContext context = new CommandContext();
+        context.setConnectionID("1");
         Command rewriteCommand = QueryRewriter.rewrite(command, RealMetadataFactory.example1Cached(), context);
         
         assertEquals("EXEC pm1.sq2('1')", rewriteCommand.toString()); //$NON-NLS-1$

Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -260,7 +260,6 @@
 				try {
 					ExecutionFactory<Object, Object> ef = getExecutionFactory(name, repo, getTranslatorRepository(), deployment, map, new HashSet<String>());
 					cm.setExecutionFactory(ef);
-					cm.setModelName(model.getName());
 					cmr.addConnectorManager(source, cm);
 				} catch (TranslatorNotFoundException e) {
 					if (e.getCause() != null) {

Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -93,7 +93,6 @@
 				model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
 				cm = new ConnectorManager(translatorName, dsName); 
 				cm.setExecutionFactory(ef);
-				cm.setModelName(modelName);
 				cmr.addConnectorManager(sourceName, cm);
 				dsReplaced = true;
 			}

Modified: trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -258,7 +258,7 @@
 				}
 				
 				final PreparedStatementImpl stmt = this.connection.prepareStatement(sql);
-                this.executionFuture = stmt.submitExecute(ResultsMode.RESULTSET);
+                this.executionFuture = stmt.submitExecute(ResultsMode.RESULTSET, null);
                 this.executionFuture.addCompletionListener(new ResultsFuture.CompletionListener<Boolean>() {
 	        		@Override
 	        		public void onCompletion(ResultsFuture<Boolean> future) {
@@ -341,7 +341,7 @@
     private void sqlExecute(final String sql, final ResultsFuture<Integer> completion) throws SQLException {
     	String modfiedSQL = fixSQL(sql); 
     	final StatementImpl stmt = connection.createStatement();
-        executionFuture = stmt.submitExecute(modfiedSQL);
+        executionFuture = stmt.submitExecute(modfiedSQL, null);
         executionFuture.addCompletionListener(new ResultsFuture.CompletionListener<Boolean>() {
     		@Override
     		public void onCompletion(ResultsFuture<Boolean> future) {
@@ -479,7 +479,7 @@
         		stmt.setMaxRows(maxRows);
         	}
         	
-            this.executionFuture = stmt.submitExecute(ResultsMode.EITHER);
+            this.executionFuture = stmt.submitExecute(ResultsMode.EITHER, null);
             executionFuture.addCompletionListener(new ResultsFuture.CompletionListener<Boolean>() {
         		@Override
         		public void onCompletion(ResultsFuture<Boolean> future) {

Modified: trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/runtime/src/test/java/org/teiid/deployers/TestCompositeVDB.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -65,14 +65,14 @@
     	metaGroup.addStore(metadataStore);
     	
     	ConnectorManagerRepository cmr = new ConnectorManagerRepository();
-    	cmr.addConnectorManager("source", getConnectorManager("bqt1", "FakeTranslator", "FakeConnection", getFuncsOne()));
-    	cmr.addConnectorManager("source2", getConnectorManager("bqt2", "FakeTranslator2", "FakeConnection2", getFuncsTwo()));
+    	cmr.addConnectorManager("source", getConnectorManager("FakeTranslator", "FakeConnection", getFuncsOne()));
+    	cmr.addConnectorManager("source2", getConnectorManager("FakeTranslator2", "FakeConnection2", getFuncsTwo()));
     	
     	CompositeVDB cvdb = new CompositeVDB(vdbMetaData, metaGroup, null, null, RealMetadataFactory.SFM.getSystemFunctions(),cmr);
 		return cvdb;
 	}
 	
-	private static ConnectorManager getConnectorManager(String modelName, String translatorName, String connectionName,  List<FunctionMethod> funcs) {
+	private static ConnectorManager getConnectorManager(String translatorName, String connectionName, List<FunctionMethod> funcs) {
 		final ExecutionFactory<Object, Object> ef = Mockito.mock(ExecutionFactory.class);
 		
 		Mockito.stub(ef.getPushDownFunctions()).toReturn(funcs);
@@ -82,7 +82,6 @@
 				return ef;
 			}
 		};
-		cm.setModelName(modelName); 
 		cm.start();
 		return cm;
 	}

Added: trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java	                        (rev 0)
+++ trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -0,0 +1,176 @@
+/*
+ * 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 static org.junit.Assert.*;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.internal.progress.OngoingStubbing;
+import org.teiid.client.util.ResultsFuture;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.dqp.internal.datamgr.ConnectorManager;
+import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
+import org.teiid.jdbc.FakeServer;
+import org.teiid.jdbc.RequestOptions;
+import org.teiid.jdbc.StatementCallback;
+import org.teiid.jdbc.TeiidStatement;
+import org.teiid.language.Command;
+import org.teiid.language.QueryExpression;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.ReusableExecution;
+import org.teiid.translator.TranslatorException;
+
+ at SuppressWarnings("nls")
+public class TestExecutionReuse {
+
+	private static final int EXEC_COUNT = 3;
+	private static FakeServer server;
+	
+	private static class FakeReusableExecution implements ResultSetExecution, ReusableExecution<Object> {
+
+		@Override
+		public List<?> next() throws TranslatorException,
+				DataNotAvailableException {
+			return null;
+		}
+
+		@Override
+		public void cancel() throws TranslatorException {
+		}
+
+		@Override
+		public void close() {
+		}
+
+		@Override
+		public void execute() throws TranslatorException {
+		}
+
+		@Override
+		public void dispose() {
+		}
+
+		@Override
+		public void reset(Command c, ExecutionContext executionContext,
+				Object connection) {
+		}
+		
+	}
+	
+	private static FakeReusableExecution execution;
+	
+	@Before public void setup() throws DataNotAvailableException, TranslatorException {
+		execution = Mockito.mock(FakeReusableExecution.class);
+		OngoingStubbing stubbing = Mockito.stub(execution.next()).toReturn((List) Arrays.asList((Object)null)).toReturn(null);
+		for (int i = 1; i < EXEC_COUNT; i++) {
+			stubbing.toReturn((List<Object>) Arrays.asList((Object)null)).toReturn(null);
+		}
+	}
+    
+    @BeforeClass public static void oneTimeSetUp() throws Exception {
+    	DQPConfiguration config = new DQPConfiguration();
+    	config.setUserRequestSourceConcurrency(1);
+    	server = new FakeServer(config);
+		server.setConnectorManagerRepository(new ConnectorManagerRepository() {
+			private ConnectorManager cm = new ConnectorManager("x", "y") {
+				private ExecutionFactory<Object, Object> ef = new ExecutionFactory<Object, Object>() {
+					
+					@Override
+					public ResultSetExecution createResultSetExecution(
+							QueryExpression command,
+							ExecutionContext executionContext,
+							RuntimeMetadata metadata, Object connection)
+							throws TranslatorException {
+						return execution;
+					};
+				};
+				@Override
+				public ExecutionFactory<Object, Object> getExecutionFactory() {
+					return ef;
+				}
+				
+				@Override
+				protected Object getConnectionFactory()
+						throws TranslatorException {
+					return null;
+				}
+			};
+			@Override
+			public ConnectorManager getConnectorManager(String connectorName) {
+				return cm;
+			}
+		});
+		server.deployVDB("PartsSupplier", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
+    }
+    
+    @AfterClass public static void oneTimeTearDown() throws Exception {
+    	server.stop();
+    }
+    
+	@Test public void testReusableAsynchContinuous() throws Exception {
+		Connection c = server.createConnection("jdbc:teiid:partssupplier");
+		Statement s = c.createStatement();
+		TeiidStatement ts = s.unwrap(TeiidStatement.class);
+		final ResultsFuture<Integer> result = new ResultsFuture<Integer>(); 
+		ts.submitExecute("select part_id from parts", new StatementCallback() {
+			int rowCount;
+			@Override
+			public void onRow(Statement s, ResultSet rs) throws SQLException {
+				rowCount++;
+				if (rowCount == EXEC_COUNT) {
+					s.close();
+				}
+			}
+			
+			@Override
+			public void onException(Statement s, Exception e) {
+				result.getResultsReceiver().receiveResults(rowCount);
+			}
+			
+			@Override
+			public void onComplete(Statement s) {
+				result.getResultsReceiver().receiveResults(rowCount);
+			}
+		}, new RequestOptions().continuous(true));
+		assertEquals(EXEC_COUNT, result.get().intValue());
+		Mockito.verify(execution, Mockito.times(1)).dispose();
+		Mockito.verify(execution, Mockito.times(EXEC_COUNT)).execute();
+		Mockito.verify(execution, Mockito.times(EXEC_COUNT)).close();
+		Mockito.verify(execution, Mockito.times(EXEC_COUNT - 1)).reset((Command)Mockito.anyObject(), (ExecutionContext)Mockito.anyObject(), Mockito.anyObject());
+	}
+
+}


Property changes on: trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestExecutionReuse.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestRelate.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestRelate.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestRelate.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -42,6 +42,7 @@
 
 import org.h2.jdbcx.JdbcConnectionPool;
 import org.h2.jdbcx.JdbcDataSource;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.teiid.core.util.UnitTestUtil;
@@ -87,6 +88,10 @@
     	}
     }
     
+    @AfterClass public static void oneTimeTearDown() throws Exception {
+    	server.stop();
+    }
+    
 	private void compareResults(SQLXML[] docs)
 	throws SQLException, IOException {
 		StackTraceElement ste = new Exception().getStackTrace()[1];

Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java	2011-12-07 20:31:15 UTC (rev 3723)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java	2011-12-07 20:42:04 UTC (rev 3724)
@@ -38,6 +38,7 @@
 import org.teiid.core.util.UnitTestUtil;
 import org.teiid.jdbc.AbstractMMQueryTestCase;
 import org.teiid.jdbc.FakeServer;
+import org.teiid.jdbc.RequestOptions;
 import org.teiid.jdbc.StatementCallback;
 import org.teiid.jdbc.TeiidStatement;
 import org.teiid.jdbc.TestMMDatabaseMetaData;
@@ -211,10 +212,37 @@
 			public void onComplete(Statement s) {
 				result.getResultsReceiver().receiveResults(rowCount);
 			}
-		});
+		}, new RequestOptions());
 		assertEquals(4, result.get().intValue());
 	}
 	
+	@Test public void testAsynchContinuous() throws Exception {
+		Statement s = this.internalConnection.createStatement();
+		TeiidStatement ts = s.unwrap(TeiidStatement.class);
+		final ResultsFuture<Integer> result = new ResultsFuture<Integer>(); 
+		ts.submitExecute("select * from SYS.Schemas", new StatementCallback() {
+			int rowCount;
+			@Override
+			public void onRow(Statement s, ResultSet rs) throws SQLException {
+				rowCount++;
+				if (rowCount == 1024) {
+					s.close();
+				}
+			}
+			
+			@Override
+			public void onException(Statement s, Exception e) {
+				result.getResultsReceiver().receiveResults(rowCount);
+			}
+			
+			@Override
+			public void onComplete(Statement s) {
+				result.getResultsReceiver().receiveResults(rowCount);
+			}
+		}, new RequestOptions().continuous(true));
+		assertEquals(1024, result.get().intValue());
+	}
+	
 	@Test public void testCallableParametersByName() throws Exception {
 		CallableStatement cs = this.internalConnection.prepareCall("{? = call logMsg(?, ?, ?)}");
 		ParameterMetaData pmd = cs.getParameterMetaData();



More information about the teiid-commits mailing list