[teiid-commits] teiid SVN: r1743 - in branches/JCA: client/src/main/java/com/metamatrix/common/comm/api and 9 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Jan 13 16:42:44 EST 2010


Author: rareddy
Date: 2010-01-13 16:42:42 -0500 (Wed, 13 Jan 2010)
New Revision: 1743

Added:
   branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
   branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
   branches/JCA/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java
Removed:
   branches/JCA/runtime/src/main/java/org/teiid/Server.java
   branches/JCA/runtime/src/main/java/org/teiid/ServerMBean.java
   branches/JCA/runtime/src/main/java/org/teiid/Shutdown.java
Modified:
   branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
   branches/JCA/build/kit-jboss-container/deploy/teiid-runtime.rar
   branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java
   branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java
   branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
   branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
   branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
   branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
   branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
   branches/JCA/runtime/src/main/java/org/teiid/ConnectionInfo.java
   branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java
   branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java
   branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java
   branches/JCA/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
   branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
   branches/JCA/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java
   branches/JCA/runtime/src/main/java/org/teiid/transport/SocketTransport.java
   branches/JCA/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties
Log:
TEIID-833, TEIID-862: Teiid runtime as the JCA connector and it is finally tied with a runtime deployer of the connector so that it will be started and stopped correctly with connector lifecycle

Modified: branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml	2010-01-13 21:42:42 UTC (rev 1743)
@@ -23,7 +23,7 @@
         <annotation>@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding(name="teiid/admin")</annotation>
     </bean>
 
-    <bean name="container-helper" class="org.teiid.jboss.JBossContainerHelper">
+    <bean name="ContainerHelper" class="org.teiid.jboss.JBossContainerHelper">
         <annotation>@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding(name="teiid/container-helper")</annotation>
         <property name="VDBRepository"><inject bean="VDBRepository"/></property>
         <property name="authorizationService"><inject bean="AuthorizationService"/></property>
@@ -41,6 +41,7 @@
     
     <bean name="SessionService" class="com.metamatrix.platform.security.session.service.SessionServiceImpl">
         <property name="VDBRepository"><inject bean="VDBRepository"/></property>
+        <!-- Comma separated list of domains to be used -->
         <property name="securityDomains">teiid-security</property>
         <property name="sessionMaxLimit">5000</property>
         <property name="sessionExpirationTimeLimit">0</property>
@@ -54,7 +55,40 @@
         <property name="bufferMemorySizeInMB">64</property>
         <property name="processorBatchSize">2000</property>
         <property name="connectorBatchSize">2000</property>
+        <property name="cacheFactory"><inject bean="TeiidCache"/></property>
     </bean>
+    
+    <bean name="RuntimeEngineDeployer" class="org.teiid.jboss.deployers.RuntimeEngineDeployer">
+        <property name="containerHelper"><inject bean="ContainerHelper"/></property>
+        <property name="socketConfiguration"><inject bean="SocketConfiguration"/></property>
+    </bean>
+    
+    <bean name="SocketConfiguration" class="org.teiid.transport.SocketConfiguration">
+        <property name="enabled">true</property>
+        <property name="bindAddress">localhost</property>
+        <property name="portNumber">31000</property>
+        <!-- Max number of threads dedicated to Admin and initial request processing (default 15) -->
+        <property name="maxSocketThreads">15</property>
+        <!-- SO_RCVBUF size, 0 indicates that system default should be used (default 0) -->
+        <property name="inputBufferSize">0</property>
+        <!-- SO_SNDBUF size, 0 indicates that system default should be used (default 0) -->
+        <property name="outputBufferSize">0</property>
+        <property name="SSLConfiguration"><inject bean="SSLConfiguration"/></property>
+    </bean>
+    
+    <bean name="SSLConfiguration" class="org.teiid.transport.SSLConfiguration">
+        <property name="sslEnabled">false</property>
+        <property name="keystoreFilename">cert.keystore</property>
+        <property name="keystorePassword">passwd</property>
+        <property name="keystoreType">JKS</property>
+        <property name="sslProtocol">SSLv3</property>
+        <property name="keymanagementAlgorithm">false</property>
+        <property name="truststoreFilename">cert.truststore</property>
+        <property name="truststorePassword">passwd</property>
+        <!--  1-way, 2-way, anonymous -->
+        <property name="authenticationMode">1-way</property>
+        <property name="clientEncryptionEnabled">true</property>
+    </bean>
             
     <!-- teiid's default security domain, replace this with your own if needs to be any other JAAS domain  -->
     <application-policy xmlns="urn:jboss:security-beans:1.0" name="teiid-security">

Modified: branches/JCA/build/kit-jboss-container/deploy/teiid-runtime.rar
===================================================================
(Binary files differ)

Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionFactory.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -40,4 +40,7 @@
      */
 	ServerConnection getConnection(Properties connectionProperties) throws CommunicationException, ConnectionException;
 	
+	<T> T getService(Class<T> clazz);
+	
+	<T> void setService(Class<T> type, T instance);
 }

Modified: branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerConnectionFactory.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -286,4 +286,13 @@
 	public void setMaxCachedInstances(int maxCachedInstances) {
 		this.maxCachedInstances = maxCachedInstances;
 	}
+
+	@Override
+	public <T> T getService(Class<T> clazz) {
+		return null;
+	}
+
+	@Override
+	public <T> void setService(Class<T> type, T instance) {
+	}
 }

Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -55,7 +55,6 @@
 import org.teiid.dqp.internal.cache.DQPContextCache;
 import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
 
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
 import com.metamatrix.common.comm.api.ResultsReceiver;
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.common.queue.StatsCapturingWorkManager;
@@ -262,7 +261,7 @@
     /**
      * initialize this <code>ConnectorManager</code>.
      */
-    public synchronized void start() throws ApplicationLifecycleException {
+    public synchronized void start() throws ConnectorException {
     	if (this.state != ConnectorStatus.NOT_INITIALIZED) {
     		return;
     	}
@@ -272,19 +271,16 @@
 
      	ConnectorEnvironment connectorEnv = null;
 		
-     	try {
-			connectorEnv = getConnector().getConnectorEnvironment();
-		} catch (ConnectorException e) {
-			throw new ApplicationLifecycleException(e.getCause(), e.getMessage());
-		}
+		connectorEnv = getConnector().getConnectorEnvironment();
     	
     	if (!connectorEnv.isSynchWorkers() && connectorEnv.isXaCapable()) {
-    		throw new ApplicationLifecycleException(DQPPlugin.Util.getString("ConnectorManager.xa_capbility_not_supported", this.connectorName)); //$NON-NLS-1$
+    		throw new ConnectorException(DQPPlugin.Util.getString("ConnectorManager.xa_capbility_not_supported", this.connectorName)); //$NON-NLS-1$
     	}
 
 		this.workItemFactory = new ConnectorWorkItemFactory(this, connectorEnv.isSynchWorkers());
     	this.state = ConnectorStatus.OPEN;
     }
+    
     /**
      * Stop this connector.
      */

Added: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java	                        (rev 0)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+public interface DQPConfiguration {
+	
+    //Constants
+    static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
+    static final int DEFAULT_MAX_CODE_TABLES = 200;
+    static final int DEFAULT_MAX_CODE_RECORDS = 200000;
+    static final int DEFAULT_FETCH_SIZE = 2000;
+    static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
+    static final String DEFAULT_MAX_RESULTSET_CACHE_SIZE = "50"; //$NON-NLS-1$
+    static final String DEFAULT_MAX_RESULTSET_CACHE_AGE = "3600000"; //$NON-NLS-1$
+    static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
+    static final int DEFAULT_MAX_PROCESS_WORKERS = 15;
+	
+	String getProcessName();
+	
+	int getMaxThreads();
+	
+	int getTimeSliceInMilli();
+	
+	boolean isOptionDebugAllowed();
+	
+	int getMaxRowsFetchSize();
+	
+	int getLobChunkSizeInKB();
+	
+	int getPreparedPlanCacheMaxCount();
+	
+	int getCodeTablesMaxCount();
+	
+	int getCodeTablesMaxRowsPerTable();
+	
+	int getCodeTablesMaxRows();
+	
+	String getBindAddress();
+	
+	int getPortNumber();
+}

Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -29,7 +29,6 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.resource.spi.work.Work;
@@ -37,7 +36,6 @@
 import javax.resource.spi.work.WorkManager;
 import javax.transaction.xa.Xid;
 
-
 import org.teiid.adminapi.Admin;
 import org.teiid.adminapi.AdminException;
 import org.teiid.adminapi.impl.RequestMetadata;
@@ -50,14 +48,11 @@
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.api.exception.security.SessionServiceException;
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
 import com.metamatrix.common.buffer.BufferManager;
 import com.metamatrix.common.lob.LobChunk;
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.common.queue.StatsCapturingWorkManager;
 import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.util.PropertiesUtils;
 import com.metamatrix.common.xa.MMXid;
 import com.metamatrix.common.xa.XATransactionException;
 import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -67,7 +62,6 @@
 import com.metamatrix.dqp.client.ClientSideDQP;
 import com.metamatrix.dqp.client.MetadataResult;
 import com.metamatrix.dqp.client.ResultsFuture;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
 import com.metamatrix.dqp.message.AtomicRequestMessage;
 import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
@@ -121,23 +115,12 @@
     private WorkManager workManager;
     private StatsCapturingWorkManager processWorkerPool;
     
-    //Constants
-    private static final int DEFAULT_MAX_CODE_TABLE_RECORDS = 10000;
-    private static final int DEFAULT_MAX_CODE_TABLES = 200;
-    private static final int DEFAULT_MAX_CODE_RECORDS = 200000;
-    private static final int DEFAULT_FETCH_SIZE = 2000;
-    private static final int DEFAULT_PROCESSOR_TIMESLICE = 2000;
-    private static final String DEFAULT_MAX_RESULTSET_CACHE_SIZE = "50"; //$NON-NLS-1$
-    private static final String DEFAULT_MAX_RESULTSET_CACHE_AGE = "3600000"; //$NON-NLS-1$
-    private static final String PROCESS_PLAN_QUEUE_NAME = "QueryProcessorQueue"; //$NON-NLS-1$
-    private static final int DEFAULT_MAX_PROCESS_WORKERS = 15;
-
     // System properties for Code Table
-    private int maxCodeTableRecords = DEFAULT_MAX_CODE_TABLE_RECORDS;
-    private int maxCodeTables = DEFAULT_MAX_CODE_TABLES;
-    private int maxCodeRecords = DEFAULT_MAX_CODE_RECORDS;
+    private int maxCodeTableRecords = DQPConfiguration.DEFAULT_MAX_CODE_TABLE_RECORDS;
+    private int maxCodeTables = DQPConfiguration.DEFAULT_MAX_CODE_TABLES;
+    private int maxCodeRecords = DQPConfiguration.DEFAULT_MAX_CODE_RECORDS;
     
-    private int maxFetchSize = DEFAULT_FETCH_SIZE;
+    private int maxFetchSize = DQPConfiguration.DEFAULT_FETCH_SIZE;
     
     // Resources
     private BufferManager bufferManager;
@@ -151,7 +134,7 @@
     private ConnectorManagerRepository connectorManagerRepository;
     
     // Query worker pool for processing plans
-    private int processorTimeslice = DEFAULT_PROCESSOR_TIMESLICE;
+    private int processorTimeslice = DQPConfiguration.DEFAULT_PROCESSOR_TIMESLICE;
     private boolean processorDebugAllowed;
     
     private int chunkSize = Streamable.STREAMING_BATCH_SIZE_IN_BYTES;
@@ -159,13 +142,12 @@
 	private Map<RequestID, RequestWorkItem> requests = new ConcurrentHashMap<RequestID, RequestWorkItem>();			
 	private Map<String, ClientState> clientState = Collections.synchronizedMap(new HashMap<String, ClientState>());
 	private DQPContextCache contextCache;
-    private CacheFactory cacheFactory;
     
     /**
      * perform a full shutdown and wait for 10 seconds for all threads to finish
-     * @throws ApplicationLifecycleException 
      */
-    public void stop() throws ApplicationLifecycleException {
+    public void stop() {
+    	// TODO: Should we be doing more cleanup here??
 		LogManager.logDetail(LogConstants.CTX_DQP, "Stopping the DQP"); //$NON-NLS-1$
     }
     
@@ -612,18 +594,18 @@
 		return chunkSize;
 	}
 	
-	public void start(Properties props) {
-		PropertiesUtils.setBeanProperties(this, props, null);
+	public void start(DQPConfiguration config) {
 		
 		Assertion.isNotNull(this.workManager);
-        this.processorTimeslice = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.PROCESS_TIMESLICE, DEFAULT_PROCESSOR_TIMESLICE);
-        this.maxFetchSize = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_FETCH_SIZE, DEFAULT_FETCH_SIZE);
-        this.processorDebugAllowed = PropertiesUtils.getBooleanProperty(props, DQPEmbeddedProperties.PROCESSOR_DEBUG_ALLOWED, true);
-        this.maxCodeTableRecords = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_CODE_TABLE_RECORDS_PER_TABLE, DEFAULT_MAX_CODE_TABLE_RECORDS);
-        this.maxCodeTables = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_CODE_TABLES, DEFAULT_MAX_CODE_TABLES);
-        this.maxCodeRecords = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_CODE_TABLE_RECORDS, DEFAULT_MAX_CODE_RECORDS);
+
+		this.processorTimeslice = config.getTimeSliceInMilli();
+        this.maxFetchSize = config.getMaxRowsFetchSize();
+        this.processorDebugAllowed = config.isOptionDebugAllowed();
+        this.maxCodeTableRecords = config.getCodeTablesMaxRowsPerTable();
+        this.maxCodeTables = config.getCodeTablesMaxCount();
+        this.maxCodeRecords = config.getCodeTablesMaxRows();
         
-        this.chunkSize = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.STREAMING_BATCH_SIZE, 100) * 1024;
+        this.chunkSize = config.getLobChunkSizeInKB() * 1024;
         
         //result set cache
         /*if(PropertiesUtils.getBooleanProperty(props, DQPEmbeddedProperties.USE_RESULTSET_CACHE, false)){ 
@@ -633,8 +615,8 @@
         }*/
 
         //prepared plan cache
-        int maxSizeTotal = PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.MAX_PLAN_CACHE_SIZE, PreparedPlanCache.DEFAULT_MAX_SIZE_TOTAL);
-        prepPlanCache = new PreparedPlanCache(maxSizeTotal);
+        
+        prepPlanCache = new PreparedPlanCache(config.getPreparedPlanCacheMaxCount());
 		
         // Processor debug flag
         LogManager.logInfo(LogConstants.CTX_DQP, DQPPlugin.Util.getString("DQPCore.Processor_debug_allowed_{0}", this.processorDebugAllowed)); //$NON-NLS-1$
@@ -642,9 +624,8 @@
         //get buffer manager
         this.bufferManager = bufferService.getBufferManager();
         this.contextCache = bufferService.getContextCache();
-        this.cacheFactory = bufferService.getCacheFactory();
 
-        this.processWorkerPool = new StatsCapturingWorkManager(PROCESS_PLAN_QUEUE_NAME, PropertiesUtils.getIntProperty(props, DQPEmbeddedProperties.PROCESS_POOL_MAX_THREADS, DEFAULT_MAX_PROCESS_WORKERS));
+        this.processWorkerPool = new StatsCapturingWorkManager(DQPConfiguration.PROCESS_PLAN_QUEUE_NAME, config.getMaxThreads());
         
         dataTierMgr = new DataTierManagerImpl(this,
                                             this.connectorManagerRepository,
@@ -658,7 +639,6 @@
 	
 	public void setBufferService(BufferService service) {
 		this.bufferService = service;
-		setCacheFactory(service.getCacheFactory());
 		setContextCache(service.getContextCache());
 	}
 	
@@ -756,10 +736,6 @@
 		return processor.processMessage(workContext.getRequestID(requestID), workContext, preparedSql, allowDoubleQuotedVariable);
 	}
 	
-	public void setCacheFactory(CacheFactory cacheFactory) {
-		this.cacheFactory = cacheFactory;
-	}
-	
 	public void setConnectorManagerRepository(ConnectorManagerRepository repo) {
 		this.connectorManagerRepository = repo;
 	}

Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -27,7 +27,6 @@
 import static org.junit.Assert.assertTrue;
 
 import java.sql.ResultSet;
-import java.util.Properties;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
@@ -42,7 +41,6 @@
 import org.teiid.dqp.internal.datamgr.impl.FakeWorkManager;
 
 import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.dqp.message.RequestID;
 import com.metamatrix.dqp.message.RequestMessage;
 import com.metamatrix.dqp.message.ResultsMessage;
 import com.metamatrix.dqp.service.AutoGenDataService;
@@ -69,7 +67,7 @@
         core.setConnectorManagerRepository(repo);
         core.setTransactionService(new FakeTransactionService());
         
-        core.start(new Properties());
+        core.start(Mockito.mock(DQPConfiguration.class));
     }
     
     @After public void tearDown() throws Exception {

Modified: branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/ConnectorBindingDeployer.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -34,11 +34,10 @@
 import org.jboss.managed.api.factory.ManagedObjectFactory;
 import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
 import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.teiid.connector.api.ConnectorException;
 import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
 import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
 
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-
 public class ConnectorBindingDeployer extends AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> implements ManagedObjectCreator {
 	protected Logger log = Logger.getLogger(getClass());
 	private ManagedObjectFactory mof;
@@ -66,7 +65,7 @@
 					cm = createConnectorManger("java:"+connectorName);
 					cm.start();
 					cmGroup.addConnectorManager(cm);
-				} catch (ApplicationLifecycleException e) {
+				} catch (ConnectorException e) {
 					throw new DeploymentException(e);
 				}
 

Added: branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java	                        (rev 0)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -0,0 +1,177 @@
+/*
+ * 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.jboss.deployers;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.work.WorkManager;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentGroup;
+import org.jboss.resource.metadata.mcf.ManagedConnectionFactoryDeploymentMetaData;
+import org.teiid.ContainerHelper;
+import org.teiid.ContainerUtil;
+import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.internal.process.DQPConfiguration;
+import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.internal.process.DQPManagementView;
+import org.teiid.dqp.internal.transaction.ContainerTransactionProvider;
+import org.teiid.dqp.internal.transaction.TransactionServerImpl;
+import org.teiid.dqp.internal.transaction.XidFactory;
+import org.teiid.transport.LogonImpl;
+import org.teiid.transport.SocketConfiguration;
+import org.teiid.transport.SocketTransport;
+
+import com.metamatrix.common.comm.ClientServiceRegistry;
+import com.metamatrix.common.comm.ClientServiceRegistryImpl;
+import com.metamatrix.common.comm.api.ServerConnectionFactory;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.core.log.MessageLevel;
+import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.service.AuthorizationService;
+import com.metamatrix.dqp.service.BufferService;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.platform.security.api.ILogon;
+import com.metamatrix.platform.security.api.service.SessionService;
+
+public class RuntimeEngineDeployer extends AbstractSimpleRealDeployer<ManagedConnectionFactoryDeploymentGroup> {
+	protected Logger log = Logger.getLogger(getClass());
+	private ContainerHelper containerHelper;
+	private SocketTransport socketTransport;
+	private SocketConfiguration socketConfiguration;
+	private ClientServiceRegistry clientServiceRegistry;
+	
+	public RuntimeEngineDeployer() {
+		super(ManagedConnectionFactoryDeploymentGroup.class);
+		setRelativeOrder(3000);
+	}
+
+	@Override
+	public void deploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) throws DeploymentException {
+		List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
+		
+		for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
+			String connectorDefinition = data.getConnectionDefinition();
+			if (connectorDefinition.equals("com.metamatrix.common.comm.api.ServerConnectionFactory")) {
+				
+				ServerConnectionFactory scf = (ServerConnectionFactory)ContainerUtil.lookup("java:teiid/runtime-engine");
+				startEngine(scf);
+	            
+	            log.info("Teiid Engine Started = " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
+			}
+		}
+	}
+   
+
+	@Override
+	public void undeploy(DeploymentUnit unit, ManagedConnectionFactoryDeploymentGroup group) {
+		super.undeploy(unit, group);
+		List<ManagedConnectionFactoryDeploymentMetaData> deployments = group.getDeployments();
+
+		for (ManagedConnectionFactoryDeploymentMetaData data : deployments) {
+			String connectorDefinition = data.getConnectionDefinition();
+			if (connectorDefinition.equals("com.metamatrix.common.comm.api.ServerConnectionFactory")) {
+				stopEngine();				
+				log.info("Teiid Engine Stopped = " + new Date(System.currentTimeMillis()).toString()); //$NON-NLS-1$
+			}
+		}
+	}
+	
+	public void setContainerHelper(ContainerHelper helper) {
+		this.containerHelper = helper;
+	}
+	
+	public void setSocketConfiguration(SocketConfiguration socketConfig) {
+		this.socketConfiguration = socketConfig;
+	}
+	
+    private void startEngine(ServerConnectionFactory scf) {
+    	DQPConfiguration config = scf.getService(DQPConfiguration.class);
+    	ClientServiceRegistry services = createClientServices(config, scf.getService(WorkManager.class), scf.getService(XATerminator.class));
+    	scf.setService(ClientServiceRegistry.class, services);
+    	
+    	this.clientServiceRegistry = services;
+    	
+    	// Start the socket transport
+    	if (config.getBindAddress() != null) {
+    		this.socketConfiguration.setBindAddress(config.getBindAddress());
+    	}
+    	if (config.getPortNumber() > 0) {
+    		this.socketConfiguration.setPortNumber(config.getPortNumber());
+    	}
+    	
+    	this.socketTransport = new SocketTransport(this.socketConfiguration);
+    	this.socketTransport.setClientServiceRegistry(services);
+    	this.socketTransport.setWorkManager(scf.getService(WorkManager.class));
+    	this.socketTransport.start();
+    	
+	}	
+    
+    private void stopEngine() {
+    	
+    	// Stop DQP
+    	DQPCore dqp = (DQPCore)this.clientServiceRegistry.getClientService(ClientSideDQP.class);
+    	dqp.stop();
+    	
+    	// Stop socket transport
+    	if (this.socketTransport != null) {
+    		this.socketTransport.stop();
+    		this.socketTransport = null;
+    	}
+    }
+    
+	private ClientServiceRegistry createClientServices(DQPConfiguration config, WorkManager workMgr, XATerminator terminator) {
+		
+		DQPCore dqp = new DQPCore();
+        dqp.setTransactionService(getTransactionService("localhost", terminator));
+        dqp.setWorkManager(workMgr);
+        dqp.setAuthorizationService(this.containerHelper.getService(AuthorizationService.class));
+        dqp.setBufferService(this.containerHelper.getService(BufferService.class));
+        dqp.setSessionService(this.containerHelper.getService(SessionService.class));
+        dqp.setConnectorManagerRepository(this.containerHelper.getService(ConnectorManagerRepository.class));
+		dqp.start(config); 	
+		
+		DQPManagementView holder = this.containerHelper.getService(DQPManagementView.class);
+		holder.setDQP(dqp);
+		
+    	ClientServiceRegistry services  = new ClientServiceRegistryImpl();
+    	services.registerClientService(ILogon.class, new LogonImpl(dqp.getSessionService(), "teiid-cluster"), com.metamatrix.common.util.LogConstants.CTX_SERVER);
+    	
+    	services.registerClientService(ClientSideDQP.class, dqp, LogConstants.CTX_QUERY_SERVICE);
+    	
+		return services;
+	}    
+	
+    private TransactionService getTransactionService(String processName, XATerminator terminator) {
+		TransactionServerImpl txnService = new TransactionServerImpl();
+		txnService.setTransactionProvider(new ContainerTransactionProvider(terminator));
+		txnService.setProcessName(processName);
+		txnService.setXidFactory(new XidFactory());
+		return (TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, txnService, new Class[] {TransactionService.class}, MessageLevel.DETAIL);
+    }	
+}

Modified: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -37,7 +37,6 @@
 
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
 import com.metamatrix.common.config.api.ConnectorBinding;
 import com.metamatrix.common.config.api.ConnectorBindingType;
 import com.metamatrix.common.config.model.BasicConnectorBinding;
@@ -655,7 +654,7 @@
      * @see com.metamatrix.dqp.embedded.services.EmbeddedBaseDQPService#stopService()
      * @since 4.3
      */
-    public void stopService() throws ApplicationLifecycleException {       
+    public void stopService() {       
     	for(VDBArchive vdb: loadedVDBs.values()) {
     		vdb.close();
     	}

Modified: branches/JCA/runtime/src/main/java/org/teiid/ConnectionInfo.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/ConnectionInfo.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/java/org/teiid/ConnectionInfo.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -27,16 +27,13 @@
 import javax.resource.spi.ConnectionRequestInfo;
 
 import com.metamatrix.common.comm.ClientServiceRegistry;
-import com.metamatrix.platform.security.api.service.SessionService;
 
 public class ConnectionInfo implements ConnectionRequestInfo {
 	Properties properties;
 	ClientServiceRegistry clientServices;
-	SessionService sessionService;
 	
-	public ConnectionInfo(Properties properties,ClientServiceRegistry clientServices,	SessionService sessionService) {
+	public ConnectionInfo(Properties properties,ClientServiceRegistry clientServices) {
 		this.properties = properties;
 		this.clientServices = clientServices;
-		this.sessionService = sessionService;
 	}
 }

Deleted: branches/JCA/runtime/src/main/java/org/teiid/Server.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/Server.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/java/org/teiid/Server.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -1,230 +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;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.channels.FileChannel;
-import java.util.Properties;
-
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.ApplicationInfo;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.util.LogConstants;
-
-public class Server extends TeiidConnectionFactory implements ServerMBean  {
-	
-	private Properties props;
-	
-	public Server(Properties props) {
-		super(null, null, null);
-		this.props = props;
-	}
-		
-//	private void start() {
-//		try {			
-//			// start the engine.
-//			initialize(this.props);
-//			
-//			getJMXServer().register(TYPE, NAME, this); 
-//									
-//		} catch (FailedToRegisterException e) {
-//			throw new MetaMatrixRuntimeException(e.getCause());
-//		} catch (MetaMatrixCoreException e) {
-//			throw new MetaMatrixRuntimeException(e);
-//		} 
-//	}
-//	
-//	private void stopS(boolean restart) {
-// 		if (isAlive()) {
-//			shutdown(restart);
-//		}
-// 		
-// 		try {
-//			getJMXServer().unregister(TYPE, NAME);
-//		} catch (FailedToRegisterException e) {
-//			// ignore
-//		}
-//	}
-		
-	private static boolean duplicateProcess(Properties props) {
-		try {
-			String teiidHome = props.getProperty(DQPEmbeddedProperties.TEIID_HOME);
-			String workDir = props.getProperty(DQPEmbeddedProperties.DQP_WORKDIR, "work"); //$NON-NLS-1$
-			String processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME); 
-			
-			String parent = new File(teiidHome, workDir).getCanonicalPath();
-			File f = new File(parent, "teiid_"+processName+".pid"); //$NON-NLS-1$ //$NON-NLS-2$ 			
-			FileChannel channel = new RandomAccessFile(f, "rw").getChannel(); //$NON-NLS-1$
-			return (channel.tryLock() == null); 
-		} catch (IOException e) {
-			// ignore
-		}
-		return true;
-	}	
-	
-	static Properties loadConfiguration(String configFile) {
-		File f = new File (configFile);
-		if (!f.exists()) {
-			System.out.println("Missing the bootstrap properties file, failed to start"); //$NON-NLS-1$
-			System.exit(-3);			
-		}
-		
-		Properties props = null;
-		try {
-			FileReader bootProperties = new FileReader(f); 
-			props = new Properties(System.getProperties());
-			props.load(bootProperties);
-			
-			// enable socket communication by default.
-			props.setProperty(DQPEmbeddedProperties.ENABLE_SOCKETS, Boolean.TRUE.toString());
-			props.setProperty(DQPEmbeddedProperties.BOOTURL, f.getCanonicalPath());
-			props.setProperty(DQPEmbeddedProperties.TEIID_HOME, System.getProperty(DQPEmbeddedProperties.TEIID_HOME,f.getParentFile().getCanonicalPath()));
-			props = PropertiesUtils.resolveNestedProperties(props);
-		} catch (IOException e) {
-			System.out.println("Failed to load bootstrap properties file."); //$NON-NLS-1$
-			e.printStackTrace();
-			System.exit(-3);
-		}	
-		return props;
-	}
-	
-	@Override
-	public void shutdown() {
-//	      new Thread(){
-//	         public void run(){
-//	        	 System.out.println("Server being shutdown..."); //$NON-NLS-1$
-//	        	 stopS(false);	        	 
-//	         }
-//	      }.start();		
-	}
-
-	@Override
-	public void halt() {
-	      new Thread() {
-	         public void run() {
-	            System.err.println("Killing the Teiid Server now!"); //$NON-NLS-1$
-	            Runtime.getRuntime().halt(-4);
-	         }
-	      }.start();
-	}
-	
-	@Override
-	public void restart() {
-//	      new Thread(){
-//		         public void run(){
-//		        	 System.out.println("Server being shutdown..."); //$NON-NLS-1$
-//		        	 stopS(true);	        	 
-//		         }
-//		      }.start();		
-		
-	}
-	/**
-	 * Start the Server Mode
-	 * @param args
-	 */
-	public static void main(String[] args) {
-		if (args.length < 1) {
-			System.out.println("Usage:Server <boot-properties-file>"); //$NON-NLS-1$
-			System.exit(-1);
-		}
-		
-		long startTime = System.currentTimeMillis();
-		
-		// load configuration
-		Properties props = loadConfiguration(args[0]);
-		
-		// check for duplicate process
-		String processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
-		if (duplicateProcess(props)) {
-			System.out.println(DQPEmbeddedPlugin.Util.getString("DQPEmbeddedManager.duplicate_process", processName)); //$NON-NLS-1$
-			System.exit(-2);			
-		}
-		
-		// load the server
-		Server s = new Server(props);
-		//s.start();
-		
-		String port = props.getProperty(DQPEmbeddedProperties.SERVER_PORT);
-		long time = System.currentTimeMillis() - startTime;
-		
-		System.out.println("Teiid Server started on port = "+ port + " in "+time/1000+" Secs"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 
-		
-		if (LogManager.isMessageToBeRecorded(LogConstants.CTX_PROCESS_INFO_LOG, MessageLevel.INFO)) {
-			s.logProcessInfo();
-		}
-		
-		// wait.
-		while(s.isAlive()) {
-	        try {
-				Thread.sleep(5000);
-			} catch (InterruptedException e) {
-				break;
-			}				
-		}
-
-		// if for some reason engine is still alive kill it.
-		if (s.isAlive()) {
-			//s.stopS(false);
-		}
-
-		// exit code to restart the process.
-//		if (s.shouldRestart()) {
-//			System.exit(10);
-//		}
-	}
-	
-    public void logProcessInfo() {
-        ApplicationInfo info = ApplicationInfo.getInstance();
-        StringBuffer sb = new StringBuffer("Process Information"); //$NON-NLS-1$
-
-        sb.append('\n');
-        sb.append(" Process Name:               " + props.getProperty(DQPEmbeddedProperties.PROCESSNAME) ); //$NON-NLS-1$
-        sb.append('\n');
-        sb.append(" Hostname:              " + getAddress().getCanonicalHostName() ); //$NON-NLS-1$
-        sb.append('\n');
-        sb.append(" Version:               ").append(ApplicationInfo.getInstance().getReleaseNumber()); //$NON-NLS-1$
-        sb.append('\n');
-        sb.append(" Build Date:            ").append(ApplicationInfo.getInstance().getBuildDate()); //$NON-NLS-1$
-                        
-        sb.append("\n---- System Properties ----\n");  //$NON-NLS-1$             
-        sb.append(PropertiesUtils.prettyPrint(System.getProperties()));
-
-        sb.append("\n---- Deploy Properties ----\n");  //$NON-NLS-1$                             
-        sb.append(PropertiesUtils.prettyPrint(props));
-                    
-        sb.append("\n# of Processors: " + java.lang.Runtime.getRuntime().availableProcessors());//$NON-NLS-1$  
-        sb.append("\nMax Avail memory: " + java.lang.Runtime.getRuntime().maxMemory());//$NON-NLS-1$               
-        sb.append("\nFree memory: " + java.lang.Runtime.getRuntime().freeMemory());//$NON-NLS-1$  
-        
-        sb.append(info.getClasspathInfo());
-        
-        LogManager.logInfo(LogConstants.CTX_PROCESS_INFO_LOG, sb.toString());
-    }
-
-}

Deleted: branches/JCA/runtime/src/main/java/org/teiid/ServerMBean.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/ServerMBean.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/java/org/teiid/ServerMBean.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid;
-
-
-public interface ServerMBean {
-	public static final String NAME = "Server"; //$NON-NLS-1$
-	//public static final JMXUtil.MBeanType TYPE = JMXUtil.MBeanType.SERVER;
-	
-	boolean isAlive();
-	
-	void shutdown();
-	
-	void halt();
-	
-	void restart();
-}

Deleted: branches/JCA/runtime/src/main/java/org/teiid/Shutdown.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/Shutdown.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/java/org/teiid/Shutdown.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -1,66 +0,0 @@
-package org.teiid;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.Properties;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-
-public class Shutdown {
-
-	public static void main(String[] args) throws Exception {
-		if (args.length < 2) {
-			System.out.println("Usage:Shutdown <boot-properties-file> <jmxPort>"); //$NON-NLS-1$
-			System.exit(-1);
-		}
-		
-		Properties props = Server.loadConfiguration(args[0]);
-		
-//		JMXUtil jmx = new JMXUtil(props.getProperty(DQPEmbeddedProperties.PROCESSNAME));
-		
-	    JMXServiceURL serviceURL = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:"+args[1]+"/jmxrmi"); //$NON-NLS-1$ //$NON-NLS-2$
-	    JMXConnector connector = JMXConnectorFactory.connect(serviceURL); 
-	    MBeanServerConnection mbsc = connector.getMBeanServerConnection(); 
-
-//		ServerProxyHandler handler = new ServerProxyHandler(mbsc, jmx.buildName(ServerMBean.TYPE, ServerMBean.NAME));
-//		Class<?>[] ifaces = { ServerMBean.class };
-//		ClassLoader tcl = Thread.currentThread().getContextClassLoader();
-//		ServerMBean server = (ServerMBean) Proxy.newProxyInstance(tcl, ifaces,handler);
-//		server.shutdown();
-	}
-	
-	/**
-	 * Taken from JBoss AS Shutdown.java class.
-	 */
-	private static class ServerProxyHandler implements InvocationHandler {
-		ObjectName serverName;
-		MBeanServerConnection server;
-
-		ServerProxyHandler(MBeanServerConnection server, ObjectName serverName) {
-			this.server = server;
-			this.serverName = serverName;
-		}
-
-		public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-			String methodName = method.getName();
-			Class<?>[] sigTypes = method.getParameterTypes();
-			String[] sig = new String[sigTypes.length];
-			for (int s = 0; s < sigTypes.length; s++) {
-				sig[s] = sigTypes[s].getName();
-			}
-			Object value = null;
-			try {
-				value = server.invoke(serverName, methodName, args, sig);
-			} catch (UndeclaredThrowableException e) {
-				throw e.getUndeclaredThrowable();
-			}
-			return value;
-		}
-	}
-
-}

Modified: branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidConnectionFactory.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -22,56 +22,26 @@
 
 package org.teiid;
 
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Date;
 import java.util.Properties;
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionManager;
+import javax.resource.spi.XATerminator;
+import javax.resource.spi.work.WorkManager;
 
 import org.teiid.adminapi.Admin;
 import org.teiid.adminapi.impl.BaseAdmin;
-import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
-import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.dqp.internal.process.DQPCore;
-import org.teiid.dqp.internal.process.DQPManagementView;
-import org.teiid.dqp.internal.transaction.ContainerTransactionProvider;
-import org.teiid.dqp.internal.transaction.TransactionServerImpl;
-import org.teiid.dqp.internal.transaction.XidFactory;
-import org.teiid.transport.AdminAuthorizationInterceptor;
-import org.teiid.transport.LogonImpl;
-import org.teiid.transport.SocketListenerStats;
-import org.teiid.transport.SocketTransport;
+import org.teiid.dqp.internal.process.DQPConfiguration;
 
 import com.metamatrix.admin.objects.MMProcess;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
 import com.metamatrix.common.comm.ClientServiceRegistry;
-import com.metamatrix.common.comm.ClientServiceRegistryImpl;
 import com.metamatrix.common.comm.api.ServerConnection;
 import com.metamatrix.common.comm.api.ServerConnectionFactory;
 import com.metamatrix.common.comm.exception.CommunicationException;
 import com.metamatrix.common.comm.exception.ConnectionException;
 import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.NetUtils;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.dqp.client.ClientSideDQP;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.jdbc.JDBCPlugin;
 import com.metamatrix.jdbc.LogConfigurationProvider;
 import com.metamatrix.jdbc.LogListernerProvider;
-import com.metamatrix.platform.security.api.ILogon;
-import com.metamatrix.platform.security.api.service.SessionService;
 
 
 /** 
@@ -80,137 +50,58 @@
  * already alive.
  */
 public class TeiidConnectionFactory implements ServerConnectionFactory {
-    private DQPCore dqp;
     
 	private TeiidResourceAdapter ra;
 	private TeiidManagedConnectionFactory mcf;
 	private ConnectionManager cxManager;
-	private Properties bootProperties;
-	private SocketTransport socketTransport;
-	private long starttime = -1L;
-	private InetAddress address;
-	ClientServiceRegistry clientServices = null;
+	private ClientServiceRegistry clientServices = null;
 
     
 	public TeiidConnectionFactory(TeiidResourceAdapter ra, TeiidManagedConnectionFactory mcf, ConnectionManager cxmanager) {
 		this.ra = ra;
 		this.mcf = mcf;
 		this.cxManager = cxmanager;
+		// TODO: this does not belong here
 		LogManager.setLogConfiguration(new LogConfigurationProvider().get());
 		LogManager.setLogListener(new LogListernerProvider().get());
 	}
 	
 	@Override
 	public ServerConnection getConnection(Properties connectionProperties) throws CommunicationException, ConnectionException {
-		// unfortunately we can only offer the managed connections for the Embedded, for socket connections those requests come
-		// directly to this class and will not be managed
 		try {
-			if (clientServices == null) {
-				clientServices =  createClientServices();
-			}
-			return (ServerConnection)cxManager.allocateConnection(this.mcf, new ConnectionInfo(connectionProperties, clientServices, this.dqp.getSessionService()));
+			return (ServerConnection)cxManager.allocateConnection(this.mcf, new ConnectionInfo(connectionProperties, this.clientServices));
 		} catch (ResourceException e) {
 			throw new ConnectionException(e);
 		}        
 	}
+	
+	public <T> T getService(Class<T> type) {
+		if (type.equals(WorkManager.class)) {
+			return type.cast(this.ra.getWorkManager());
+		}
+		
+		if (type.equals(XATerminator.class)) {
+			return type.cast(this.ra.getXATerminator());
+		}
+		
+		if (type.equals(DQPConfiguration.class)) {
+			return type.cast(mcf);
+		}
+		
+		throw new IllegalArgumentException(type + " Sevice is not available");
+	}
+	
+	public <T> void setService(Class<T> type, T instance) {
+		if (type.equals(ClientServiceRegistry.class)) {
+			this.clientServices = (ClientServiceRegistry)instance;
+		}
+	}
         
     /**
-     * When the DQP is restarted using the admin API, it only shuts it down, it gets
-     * restarted when the next time connection is made, however this factory may be
-     * holding on to a previous transport handler, so we need to check if the DQP is 
-     * still alive and create a new one if necessary. 
-     * @param props
-     * @throws ApplicationInitializationException 
-     * @since 4.3
-     */
-     public void initialize(Properties props) {
-    	this.bootProperties = props;
-		this.address = resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
-    	
-    	// Since the loading of the engine connection factory and all required services can not tied to load
-		// in a dependent manner, provide a proxy until such time.
-		ClientServiceRegistry clientServicesProxy = (ClientServiceRegistry)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {ClientServiceRegistry.class}, new InvocationHandler() {
-			@Override
-			public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-				if (clientServices == null) {
-					clientServices =  createClientServices();
-				}
-				return method.invoke(clientServices, args);
-			}
-		});
-        
-    	// start socket transport
-        boolean enableSocketTransport = PropertiesUtils.getBooleanProperty(this.bootProperties, DQPEmbeddedProperties.ENABLE_SOCKETS, false);
-        if (enableSocketTransport) {
-	        this.socketTransport = new SocketTransport(this.bootProperties, clientServicesProxy, this.ra.getWorkManager(), this.address);
-	        this.socketTransport.start();
-        }    	
-        
-        this.starttime = System.currentTimeMillis();
-        DQPEmbeddedPlugin.logInfo("DQPEmbeddedManager.start_dqp", new Object[] {new Date(System.currentTimeMillis()).toString()}); //$NON-NLS-1$
-		
-    }
-     
-    private TransactionService getTransactionService(String processName) {
-		TransactionServerImpl txnService = new TransactionServerImpl();
-		txnService.setTransactionProvider(new ContainerTransactionProvider(this.ra.getXATerminator()));
-		txnService.setProcessName(processName);
-		txnService.setXidFactory(new XidFactory());
-		return (TransactionService)LogManager.createLoggingProxy(LogConstants.CTX_TXN_LOG, txnService, new Class[] {TransactionService.class}, MessageLevel.DETAIL);
-    }
-
-    public synchronized boolean isAlive() {
-        return (dqp != null);
-    }
-    
-    public synchronized DQPCore getDQP() {
-        if (!isAlive()) {
-            throw new MetaMatrixRuntimeException(JDBCPlugin.Util.getString("LocalTransportHandler.Transport_shutdown")); //$NON-NLS-1$
-        }
-        return this.dqp;
-    }    
-    
-    public void shutdown() {
-        // shutdown the socket transport.
-        if (this.socketTransport != null) {
-        	this.socketTransport.stop();
-        	this.socketTransport = null;
-        }    	
-    }
-    
-    /**
      * ConnectionFactory and DQPCore lifecycles need to be tied together, but when this class starts
      * all services may not be up, however by the time a user logs in for a connection all the services will be up. 
      * So, send a proxy of this service first and replace with actual one later.
      */
-	private ClientServiceRegistry createClientServices() {
-		// start the DQP
-		String processName = bootProperties.getProperty(DQPEmbeddedProperties.PROCESSNAME, "embedded"); //$NON-NLS-1$
-		String clusterName = this.bootProperties.getProperty(DQPEmbeddedProperties.CLUSTERNAME, "teiid-cluster"); //$NON-NLS-1$
-		ContainerHelper helper = ContainerUtil.lookup("teiid/container-helper");
-		
-		DQPManagementView holder = helper.getService(DQPManagementView.class);
-		this.dqp = new DQPCore();
-        this.dqp.setTransactionService(getTransactionService(processName));
-        this.dqp.setWorkManager(this.ra.getWorkManager());
-        this.dqp.setAuthorizationService(helper.getService(AuthorizationService.class));
-        this.dqp.setBufferService(helper.getService(BufferService.class));
-        this.dqp.setSessionService(helper.getService(SessionService.class));
-        this.dqp.setConnectorManagerRepository(helper.getService(ConnectorManagerRepository.class));
-		this.dqp.start(bootProperties); 	
-		holder.setDQP(this.dqp);
-		
-    	ClientServiceRegistry services  = new ClientServiceRegistryImpl();
-    	services.registerClientService(ILogon.class, new LogonImpl(this.dqp.getSessionService(), clusterName), com.metamatrix.common.util.LogConstants.CTX_SERVER);
-    	
-    	Admin roleCheckedServerAdmin = wrapAdminService(Admin.class, getAdminAPI(), this.dqp.getAuthorizationService());
-		services.registerClientService(Admin.class, roleCheckedServerAdmin, com.metamatrix.common.util.LogConstants.CTX_ADMIN);
-    	
-    	services.registerClientService(ClientSideDQP.class, this.dqp, LogConstants.CTX_QUERY_SERVICE);
-    	
-		return services;
-	}
-	
 	private Admin getAdminAPI() {
 		Admin admin = ContainerUtil.lookup("teiid/admin");
 		if (admin instanceof BaseAdmin) {
@@ -219,64 +110,43 @@
 		return admin;
 	}
 	
-	@SuppressWarnings("unchecked")
-	private <T> T wrapAdminService(Class<T> iface, T impl, AuthorizationService authService) {
-		return (T)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {iface}, new AdminAuthorizationInterceptor(authService, impl));
-	}	
-	
- 	private InetAddress resolveHostAddress(String bindAddress) {
-		try {
-			if (bindAddress == null) {
-				return NetUtils.getInstance().getInetAddress();
-			}
-			return NetUtils.resolveHostByName(bindAddress);	
-		} catch (UnknownHostException e) {
-			throw new MetaMatrixRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
-		}
-	}	
- 	
-    public InetAddress getAddress() {
-		return address;
-	} 	
+   
     
-    public long getStartTime() {
-    	return this.starttime;
-    }    
-    
 	public MMProcess getProcess() {
 		
-		Properties props = this.bootProperties;
-		
-		String hostName = getAddress().getHostName();
-		String processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
-
-		String[] identifierParts = new String[] {hostName, processName};
-		MMProcess process = new MMProcess(identifierParts);
-        
-		Runtime rt = Runtime.getRuntime();
-		
-		process.setEnabled(true);
-		process.setCreated(new Date(getStartTime()));
-		process.setInetAddress(getAddress());
-		process.setFreeMemory(rt.freeMemory());
-		process.setTotalMemory(rt.totalMemory());
-		process.setProperties(PropertiesUtils.clone(props));
-		process.setStartTime(new Date(this.starttime));
-		
-		if (this.socketTransport != null) {
-	        SocketListenerStats socketStats = this.socketTransport.getStats();
-	        if (socketStats != null) {
-	            process.setSockets(socketStats.sockets);
-	            process.setMaxSockets(socketStats.maxSockets);
-	            process.setObjectsRead(socketStats.objectsRead);
-	            process.setObjectsWritten(socketStats.objectsWritten);
-	        }
-	        
-	        WorkerPoolStatisticsMetadata workerStats = this.socketTransport.getProcessPoolStats();
-	        process.setQueueWorkerPool(workerStats);
-	        
-	        process.setPort(this.socketTransport.getPort());
-		}
-		return process;
+//		Properties props = this.bootProperties;
+//		
+//		String hostName = getAddress().getHostName();
+//		String processName = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
+//
+//		String[] identifierParts = new String[] {hostName, processName};
+//		MMProcess process = new MMProcess(identifierParts);
+//        
+//		Runtime rt = Runtime.getRuntime();
+//		
+//		process.setEnabled(true);
+//		process.setCreated(new Date(getStartTime()));
+//		process.setInetAddress(getAddress());
+//		process.setFreeMemory(rt.freeMemory());
+//		process.setTotalMemory(rt.totalMemory());
+//		process.setProperties(PropertiesUtils.clone(props));
+//		process.setStartTime(new Date(this.starttime));
+//		
+//		if (this.socketTransport != null) {
+//	        SocketListenerStats socketStats = this.socketTransport.getStats();
+//	        if (socketStats != null) {
+//	            process.setSockets(socketStats.sockets);
+//	            process.setMaxSockets(socketStats.maxSockets);
+//	            process.setObjectsRead(socketStats.objectsRead);
+//	            process.setObjectsWritten(socketStats.objectsWritten);
+//	        }
+//	        
+//	        WorkerPoolStatisticsMetadata workerStats = this.socketTransport.getProcessPoolStats();
+//	        process.setQueueWorkerPool(workerStats);
+//	        
+//	        process.setPort(this.socketTransport.getPort());
+//		}
+//		return process;
+		return null;
 	}        
 }

Modified: branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnection.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -77,7 +77,7 @@
 	public Object getConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
 		ConnectionInfo ci = (ConnectionInfo)arg1;
 		try {
-			this.conn = new WrappedConnection(new LocalServerConnection(ci.properties, ci.clientServices, ci.sessionService));
+			this.conn = new WrappedConnection(new LocalServerConnection(ci.properties, ci.clientServices));
 			this.conn.setManagedConnection(this);
 			return this.conn;
 		} catch (CommunicationException e) {

Modified: branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/java/org/teiid/TeiidManagedConnectionFactory.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -22,12 +22,7 @@
 
 package org.teiid;
 
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
 import java.io.PrintWriter;
-import java.net.URL;
-import java.util.Properties;
 import java.util.Set;
 
 import javax.resource.ResourceException;
@@ -39,16 +34,29 @@
 import javax.resource.spi.ResourceAdapterAssociation;
 import javax.security.auth.Subject;
 
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
+import org.teiid.dqp.internal.process.DQPConfiguration;
+import org.teiid.dqp.internal.process.PreparedPlanCache;
 
-public class TeiidManagedConnectionFactory implements ManagedConnectionFactory,ResourceAdapterAssociation {
+public class TeiidManagedConnectionFactory implements ManagedConnectionFactory,ResourceAdapterAssociation, DQPConfiguration {
+	private static final long serialVersionUID = -3728121947515526429L;
+
 	private TeiidResourceAdapter ra;
 	private PrintWriter log;
-	private String deployPropertiesFile;
 	private TeiidConnectionFactory connFactory;
-	private String teiidHome;
 	
+	private String processName = "localhost";
+	private int maxThreads = DEFAULT_MAX_PROCESS_WORKERS;
+	private int timeSliceInMilli = DEFAULT_PROCESSOR_TIMESLICE;
+	private boolean optionDebugAllowed = true;
+	private int maxRowsFetchSize = DEFAULT_FETCH_SIZE;
+	private int lobChunkSizeInKB = 100;
+	private int preparedPlanCacheMaxCount = PreparedPlanCache.DEFAULT_MAX_SIZE_TOTAL;
+	private int codeTablesMaxCount = DEFAULT_MAX_CODE_TABLES;
+	private int codeTablesMaxRowsPerTable = DEFAULT_MAX_CODE_TABLE_RECORDS;
+	private int codeTablesMaxRows = DEFAULT_MAX_CODE_RECORDS;
+	private String bindAddress = "localhost";
+	private int portNumber = 31000;
+	
 	@Override
 	public Object createConnectionFactory() throws ResourceException {
 		return new ResourceException("Resource Adapter does not currently support running in a non-managed environment.");
@@ -56,13 +64,8 @@
 
 	@Override
 	public Object createConnectionFactory(ConnectionManager arg0) throws ResourceException {
-		try {
-			connFactory =  new TeiidConnectionFactory(this.ra, this, arg0);
-			connFactory.initialize(getDeployProperties());
-			return connFactory;
-		}  catch (IOException e) {
-			throw new ResourceException(e);
-		}
+		this.connFactory =  new TeiidConnectionFactory(this.ra, this, arg0);
+		return this.connFactory;
 	}
 
 	@Override
@@ -95,37 +98,110 @@
 		this.ra = (TeiidResourceAdapter)arg0;
 	}
 
-	public void setDeployPropertiesFile(String arg0) {
-		this.deployPropertiesFile = arg0;
-	}	
-	
-	public void setTeiidHome(String arg0) {
-		this.teiidHome = arg0;
+	public String getProcessName() {
+		return processName;
 	}
-	
-	public Properties getDeployProperties() throws IOException {
-		Properties props = new Properties(System.getProperties());
-		if (this.deployPropertiesFile == null || this.deployPropertiesFile.trim().length() == 0) {
-			throw new IOException("deploy.properties property value not specified");
-		}
-		
-		URL url = this.getClass().getResource(this.deployPropertiesFile);
-		if (url != null) {
-			props.load(url.openStream());
-		}
-		else {
-			File f = new File(this.deployPropertiesFile);
-			if (!f.exists()) {
-				throw new IOException("deploy.properties not found at location=" + this.deployPropertiesFile);
-			}
-			props.load(new FileReader(f));
-		}
-		
-		// enable socket communication by default.
-		props.setProperty(DQPEmbeddedProperties.ENABLE_SOCKETS, Boolean.TRUE.toString());
-		props.setProperty(DQPEmbeddedProperties.BOOTURL, this.teiidHome);
-		props.setProperty(DQPEmbeddedProperties.TEIID_HOME, this.teiidHome);
-		props = PropertiesUtils.resolveNestedProperties(props);
-		return props;		
+
+	public void setProcessName(String processName) {
+		this.processName = processName;
 	}
+
+	@Override
+	public int getMaxThreads() {
+		return maxThreads;
+	}
+
+	public void setMaxThreads(Integer maxThreads) {
+		this.maxThreads = maxThreads;
+	}
+
+	@Override
+	public int getTimeSliceInMilli() {
+		return timeSliceInMilli;
+	}
+
+	public void setTimeSliceInMilli(Integer timeSliceInMilli) {
+		this.timeSliceInMilli = timeSliceInMilli;
+	}
+
+	@Override
+	public boolean isOptionDebugAllowed() {
+		return optionDebugAllowed;
+	}
+
+	public void setOptionDebugAllowed(Boolean optionDebugAllowed) {
+		this.optionDebugAllowed = optionDebugAllowed;
+	}
+
+	@Override
+	public int getMaxRowsFetchSize() {
+		return maxRowsFetchSize;
+	}
+
+	public void setMaxRowsFetchSize(Integer maxRowsFetchSize) {
+		this.maxRowsFetchSize = maxRowsFetchSize;
+	}
+
+	@Override
+	public int getLobChunkSizeInKB() {
+		return lobChunkSizeInKB;
+	}
+
+	public void setLobChunkSizeInKB(Integer lobChunkSizeInKB) {
+		this.lobChunkSizeInKB = lobChunkSizeInKB;
+	}
+
+	@Override
+	public int getPreparedPlanCacheMaxCount() {
+		return preparedPlanCacheMaxCount;
+	}
+
+	public void setPreparedPlanCacheMaxCount(Integer preparedPlanCacheMaxCount) {
+		this.preparedPlanCacheMaxCount = preparedPlanCacheMaxCount;
+	}
+
+	@Override
+	public int getCodeTablesMaxCount() {
+		return codeTablesMaxCount;
+	}
+
+	public void setCodeTablesMaxCount(Integer codeTablesMaxCount) {
+		this.codeTablesMaxCount = codeTablesMaxCount;
+	}
+
+	@Override
+	public int getCodeTablesMaxRowsPerTable() {
+		return codeTablesMaxRowsPerTable;
+	}
+
+	public void setCodeTablesMaxRowsPerTable(Integer codeTablesMaxRowsPerTable) {
+		this.codeTablesMaxRowsPerTable = codeTablesMaxRowsPerTable;
+	}
+
+	@Override
+	public int getCodeTablesMaxRows() {
+		return codeTablesMaxRows;
+	}
+
+	public void setCodeTablesMaxRows(Integer codeTablesMaxRows) {
+		this.codeTablesMaxRows = codeTablesMaxRows;
+	}
+
+	@Override
+	public String getBindAddress() {
+		return bindAddress;
+	}
+
+	public void setBindAddress(String bindAddress) {
+		this.bindAddress = bindAddress;
+	}
+
+	@Override
+	public int getPortNumber() {
+		return portNumber;
+	}
+
+	public void setPortNumber(Integer portNumber) {
+		this.portNumber = portNumber;
+	}
 }

Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -46,7 +46,6 @@
 import com.metamatrix.jdbc.JDBCPlugin;
 import com.metamatrix.platform.security.api.ILogon;
 import com.metamatrix.platform.security.api.LogonResult;
-import com.metamatrix.platform.security.api.service.SessionService;
 
 public class LocalServerConnection implements ServerConnection {
 	
@@ -54,12 +53,10 @@
 	private boolean shutdown;
 	private DQPWorkContext workContext;
 	private ClientServiceRegistry clientServices;
-	private SessionService sessionService;
 	private ILogon logon;
 
-	public LocalServerConnection(Properties connectionProperties, ClientServiceRegistry clientServices, SessionService sessionService) throws CommunicationException, ConnectionException{
+	public LocalServerConnection(Properties connectionProperties, ClientServiceRegistry clientServices) throws CommunicationException, ConnectionException{
 		this.clientServices = clientServices;		
-		this.sessionService = sessionService;
 		this.workContext = new DQPWorkContext();
 		DQPWorkContext.setWorkContext(this.workContext);
 		this.logon = this.getService(ILogon.class);
@@ -68,8 +65,8 @@
 	
 	public synchronized LogonResult authenticate(Properties connProps) throws ConnectionException, CommunicationException {
         try {
+        	connProps.setProperty("localConnection", "true");
         	LogonResult logonResult = this.logon.logon(connProps);
-        	this.sessionService.setLocalSession(logonResult.getSessionID());
         	return logonResult;
         } catch (LogonException e) {
             // Propagate the original message as it contains the message we want
@@ -98,7 +95,7 @@
 				try {
 					DQPWorkContext.setWorkContext(workContext);
 					if (!(iface.equals(ILogon.class))) {					
-						sessionService.validateSession(result.getSessionID());
+						logon.assertIdentity(result.getSessionToken());
 					}
 					return arg1.invoke(clientServices.getClientService(iface), arg2);
 				} catch (InvocationTargetException e) {

Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -74,6 +74,9 @@
 			SessionMetadata sessionInfo = service.createSession(user,credential, applicationName, connProps);
 			long sessionID = updateDQPContext(sessionInfo);
 			LogManager.logDetail(LogConstants.CTX_SESSION, new Object[] {"Logon successful for \"", user, "\" - created SessionID \"", "" + sessionID, "\"" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			if (connProps.getProperty("localConnection", "false").equalsIgnoreCase("true")) {
+				service.setLocalSession(sessionID);
+			}
 			return new LogonResult(sessionInfo.getAttachment(SessionToken.class), sessionInfo.getVDBName(), sessionInfo.getVDBVersion(), clusterName);
 		} catch (LoginException e) {
 			throw new LogonException(e.getMessage());

Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -25,35 +25,17 @@
 import java.io.IOException;
 import java.security.GeneralSecurityException;
 import java.util.Arrays;
-import java.util.Properties;
 
 import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
 
 import com.metamatrix.common.comm.platform.socket.SocketUtil;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.common.util.crypto.CryptoException;
-import com.metamatrix.common.util.crypto.CryptoUtil;
-import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.core.util.Assertion;
 
 
 public class SSLConfiguration {
 
-    private static final String SSL_ENABLED = "ssl.enabled"; //$NON-NLS-1$
-    
-    private static final String KEYSTORE_FILENAME = "ssl.keystore.filename"; //$NON-NLS-1$
-    private static final String KEYSTORE_PASSWORD = "ssl.keystore.Password"; //$NON-NLS-1$
-    private static final String KEYSTORE_TYPE = "ssl.keystoretype"; //$NON-NLS-1$
-    private static final String SSL_PROTOCOL = "ssl.protocol"; //$NON-NLS-1$
-    private static final String KEY_MANAGER_ALGORITHM = "ssl.keymanagementalgorithm"; //$NON-NLS-1$
-    
-    private static final String TRUSTSTORE_FILENAME = "ssl.truststore.filename"; //$NON-NLS-1$
-    private static final String TRUSTSTORE_PASSWORD = "ssl.truststore.Password"; //$NON-NLS-1$
-    private static final String AUTHENTICATION_MODE = "ssl.authenticationMode"; //$NON-NLS-1$
-    private static final String CLIENT_ENCRYPTION_ENABLED = "client.encryption.enabled"; //$NON-NLS-1$
-    
     private static final String ONEWAY = "1-way"; //$NON-NLS-1$ - one way is the default
     private static final String TWOWAY = "2-way"; //$NON-NLS-1$
     private static final String ANONYMOUS = "anonymous"; //$NON-NLS-1$
@@ -64,9 +46,9 @@
     /*
      * External SSL resource settings
      */
-    private boolean ssl_enabled;
+    private boolean sslEnabled = false;
     private String sslProtocol = DEFAULT_SSL_PROTOCOL;
-    private String keyManagerFactoryAlgorithm;
+    private String keyManagerFactoryAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
     private String keyStoreType = DEFAULT_KEYSTORE_TYPE;
     private String keyStoreFileName;
     private String keyStorePassword = ""; //$NON-NLS-1$
@@ -77,39 +59,10 @@
     /*
      * Client encryption property.  This may belong somewhere else
      */
-    boolean client_encryption_enabled = false;
+    boolean clientEncryptionEnabled = true;
     
-    public void init(Properties props) {
-        ssl_enabled = PropertiesUtils.getBooleanProperty(props, SSL_ENABLED, false);
-        client_encryption_enabled = PropertiesUtils.getBooleanProperty(props, CLIENT_ENCRYPTION_ENABLED, true);
-        
-        if (ssl_enabled) {
-	        keyStoreFileName = props.getProperty(KEYSTORE_FILENAME);
-	        try {
-	            keyStorePassword = CryptoUtil.stringDecrypt(props.getProperty(KEYSTORE_PASSWORD, "")); //$NON-NLS-1$
-	        } catch (CryptoException err) {
-	            throw new MetaMatrixRuntimeException(err);
-	        }
-	
-	        keyStoreType = props.getProperty(KEYSTORE_TYPE, DEFAULT_KEYSTORE_TYPE);
-	                 
-	        keyManagerFactoryAlgorithm = props.getProperty(KEY_MANAGER_ALGORITHM, KeyManagerFactory.getDefaultAlgorithm());
-	    
-	        authenticationMode = props.getProperty(AUTHENTICATION_MODE);
-	
-	        trustStoreFileName = props.getProperty(TRUSTSTORE_FILENAME);
-	        try {
-	            trustStorePassword = CryptoUtil.stringDecrypt(props.getProperty(TRUSTSTORE_PASSWORD, "")); //$NON-NLS-1$
-	        } catch (CryptoException err) {
-	            throw new MetaMatrixRuntimeException(err);
-	        }
-	        
-	        sslProtocol = props.getProperty(SSL_PROTOCOL, DEFAULT_SSL_PROTOCOL);
-        }
-    } 
-    
     public SSLEngine getServerSSLEngine() throws IOException, GeneralSecurityException {
-        if (!isServerSSLEnabled()) {
+        if (!isSslEnabled()) {
         	return null;
         }
         
@@ -140,12 +93,51 @@
         return result;
     }
 
-    public boolean isServerSSLEnabled() {
-        return this.ssl_enabled;
+    public boolean isSslEnabled() {
+        return this.sslEnabled;
     }
     
     public boolean isClientEncryptionEnabled() {
-        return this.client_encryption_enabled;
+        return this.clientEncryptionEnabled;
     }
     
+    public void setSslEnabled(boolean value) {
+    	this.sslEnabled = value;
+    }
+    
+    public void setKeystoreFilename(String value) {
+    	this.keyStoreFileName = value;
+    }
+    
+    public void setKeystorePassword(String value) {
+    	this.keyStorePassword = value;
+    }
+    
+    public void setKeystoreType(String value) {
+    	this.keyStoreType = value;
+    }
+    
+    public void setSslProtocol(String value) {
+    	this.sslProtocol = value;
+    }
+    
+    public void setKeymanagementAlgorithm(String value) {
+    	this.keyManagerFactoryAlgorithm = value;
+    }
+    
+    public void setTruststoreFilename(String value) {
+    	this.trustStoreFileName = value;
+    }
+    
+    public void setTruststorePassword(String value) {
+    	this.trustStorePassword = value;
+    }
+    
+    public void setAuthenticationMode(String value) {
+    	this.authenticationMode = value;
+    }
+    
+    public void setClientEncryptionEnabled(boolean value) {
+    	this.clientEncryptionEnabled = value;
+    }
 }

Added: branches/JCA/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java	                        (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.transport;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import com.metamatrix.common.util.NetUtils;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class SocketConfiguration {
+	private int outputBufferSize;
+	private int inputBufferSize;
+	private int maxSocketThreads;
+	private int portNumber;
+	private InetAddress hostAddress;
+	private SSLConfiguration sslConfiguration;
+	private boolean enabled;
+	
+	
+	public void setBindAddress(String addr) {
+		this.hostAddress = resolveHostAddress(addr);
+	}
+	
+	public void setPortNumber(int port) {
+		this.portNumber = port;
+	}
+	
+	public void setMaxSocketThreads(int value) {
+		this.maxSocketThreads = value;
+	}
+	
+	public void setInputBufferSize(int value) {
+		this.inputBufferSize = value;
+	}
+	
+	public void setOutputBufferSize(int value) {
+		this.outputBufferSize = value;
+	}
+	
+	public void setSSLConfiguration(SSLConfiguration value) {
+		this.sslConfiguration = value;
+	}	
+ 	
+ 	private InetAddress resolveHostAddress(String bindAddress) {
+		try {
+			if (bindAddress == null) {
+				return NetUtils.getInstance().getInetAddress();
+			}
+			return NetUtils.resolveHostByName(bindAddress);	
+		} catch (UnknownHostException e) {
+			throw new MetaMatrixRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
+		}
+	}
+
+	public boolean isEnabled() {
+		return enabled;
+	}
+
+	public void setEnabled(boolean enabled) {
+		this.enabled = enabled;
+	}
+
+	public int getOutputBufferSize() {
+		return outputBufferSize;
+	}
+
+	public int getInputBufferSize() {
+		return inputBufferSize;
+	}
+
+	public int getMaxSocketThreads() {
+		return maxSocketThreads;
+	}
+
+	public int getPortNumber() {
+		return portNumber;
+	}
+
+	public InetAddress getHostAddress() {
+		return hostAddress;
+	}
+
+	public SSLConfiguration getSSLConfiguration() {
+		return sslConfiguration;
+	}	 	
+}

Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/SocketTransport.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/SocketTransport.java	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/SocketTransport.java	2010-01-13 21:42:42 UTC (rev 1743)
@@ -22,10 +22,8 @@
 package org.teiid.transport;
 
 import java.io.IOException;
-import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.security.GeneralSecurityException;
-import java.util.Properties;
 
 import javax.resource.spi.work.WorkManager;
 
@@ -34,10 +32,8 @@
 import com.metamatrix.common.comm.ClientServiceRegistry;
 import com.metamatrix.common.log.LogManager;
 import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.common.util.PropertiesUtils;
 import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
 
 /**
  * This class starts a Socket for DQP connections and listens on the port and hands out the connections to the 
@@ -45,45 +41,33 @@
  */
 public class SocketTransport {
         
-    private static final int DEFAULT_SERVER_PORT = 31000;
-    private static final int DEFAULT_MAX_THREADS = 15;
-    private static final int DEFAULT_INPUT_BUFFER_SIZE = 0;
-    private static final int DEFAULT_OUTPUT_BUFFER_SIZE = 0;
-	
-	private Properties props; 
 	private SocketListener listener;
-	
-	protected ClientServiceRegistry clientServices;
+	private ClientServiceRegistry clientServices;
 	private WorkManager workManager;
-	private InetAddress hostAddress;
+	private SocketConfiguration config;
 	
-	public SocketTransport(Properties props, ClientServiceRegistry serivices, WorkManager workMgr, InetAddress hostAddress) {
-		this.props = props;
-		this.clientServices = serivices;
-		this.workManager = workMgr;
-		this.hostAddress = hostAddress;
+	public SocketTransport(SocketConfiguration config) {
+		this.config = config;
 	}
 	
     public void start() {
-        int socketPort = PropertiesUtils.getIntProperty(this.props, DQPEmbeddedProperties.SERVER_PORT, DEFAULT_SERVER_PORT);
-        int maxThreads = PropertiesUtils.getIntProperty(this.props, DQPEmbeddedProperties.MAX_THREADS, DEFAULT_MAX_THREADS);
-        int inputBufferSize = PropertiesUtils.getIntProperty(this.props, DQPEmbeddedProperties.INPUT_BUFFER_SIZE, DEFAULT_INPUT_BUFFER_SIZE);
-        int outputBufferSize = PropertiesUtils.getIntProperty(this.props, DQPEmbeddedProperties.OUTPUT_BUFFER_SIZE, DEFAULT_OUTPUT_BUFFER_SIZE);
-        String bindAddress = this.hostAddress.getHostAddress();
+        String bindAddress = this.config.getHostAddress().getHostAddress();
         
         try {
-			SSLConfiguration helper = new SSLConfiguration();
-			helper.init(this.props);
+        	if (this.config.isEnabled()) {
+				LogManager.logDetail(LogConstants.CTX_SERVER, DQPEmbeddedPlugin.Util.getString("SocketTransport.1", new Object[] {bindAddress, String.valueOf(this.config.getPortNumber())})); //$NON-NLS-1$
+				this.listener = new SocketListener(this.config.getPortNumber(), bindAddress, this.clientServices, this.config.getInputBufferSize(), this.config.getOutputBufferSize(), this.config.getMaxSocketThreads(), this.config.getSSLConfiguration().getServerSSLEngine(), this.config.getSSLConfiguration().isClientEncryptionEnabled(), this.workManager);
+        	}
+        	else {
+        		LogManager.logDetail(LogConstants.CTX_SERVER, DQPEmbeddedPlugin.Util.getString("SocketTransport.3")); //$NON-NLS-1$
+        	}
 			
-			LogManager.logDetail(LogConstants.CTX_SERVER, DQPEmbeddedPlugin.Util.getString("SocketTransport.1", new Object[] {bindAddress, String.valueOf(socketPort)})); //$NON-NLS-1$
-			this.listener = new SocketListener(socketPort, bindAddress, this.clientServices, inputBufferSize, outputBufferSize, maxThreads, helper.getServerSSLEngine(), helper.isClientEncryptionEnabled(), this.workManager);
-			
 		} catch (UnknownHostException e) {
-			throw new MetaMatrixRuntimeException(e, DQPEmbeddedPlugin.Util.getString("SocketTransport.2",new Object[] {bindAddress, String.valueOf(socketPort)})); //$NON-NLS-1$
+			throw new MetaMatrixRuntimeException(e, DQPEmbeddedPlugin.Util.getString("SocketTransport.2",new Object[] {bindAddress, String.valueOf(this.config.getPortNumber())})); //$NON-NLS-1$
 		} catch (IOException e) {
-			throw new MetaMatrixRuntimeException(e, DQPEmbeddedPlugin.Util.getString("SocketTransport.2",new Object[] {bindAddress, String.valueOf(socketPort)})); //$NON-NLS-1$
+			throw new MetaMatrixRuntimeException(e, DQPEmbeddedPlugin.Util.getString("SocketTransport.2",new Object[] {bindAddress, String.valueOf(this.config.getPortNumber())})); //$NON-NLS-1$
 		} catch (GeneralSecurityException e) {
-			throw new MetaMatrixRuntimeException(e, DQPEmbeddedPlugin.Util.getString("SocketTransport.2",new Object[] {bindAddress, String.valueOf(socketPort)})); //$NON-NLS-1$
+			throw new MetaMatrixRuntimeException(e, DQPEmbeddedPlugin.Util.getString("SocketTransport.2",new Object[] {bindAddress, String.valueOf(this.config.getPortNumber())})); //$NON-NLS-1$
 		}        
     }
     
@@ -102,4 +86,13 @@
     public SocketListenerStats getStats() {
     	return this.listener.getStats();
     }    
+ 	
+ 	public void setClientServiceRegistry(ClientServiceRegistry services) {
+ 		this.clientServices = services;
+ 	}
+ 	
+ 	public void setWorkManager(WorkManager mgr) {
+ 		this.workManager = mgr;
+ 	}
+ 	
 }

Modified: branches/JCA/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties
===================================================================
--- branches/JCA/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties	2010-01-13 18:55:39 UTC (rev 1742)
+++ branches/JCA/runtime/src/main/resources/com/metamatrix/dqp/embedded/i18n.properties	2010-01-13 21:42:42 UTC (rev 1743)
@@ -273,3 +273,4 @@
 
 SocketTransport.1=Bound to address {0} listening on port {1}
 SocketTransport.2=Problem starting server binding to address {0} and listening on port {1}
+SocketTransport.3=Socket transport is not enabled for Teiid. 



More information about the teiid-commits mailing list