[teiid-commits] teiid SVN: r1273 - in trunk/runtime/src/main/java: org/teiid/transport and 1 other directory.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Mon Aug 24 17:06:57 EDT 2009


Author: rareddy
Date: 2009-08-24 17:06:57 -0400 (Mon, 24 Aug 2009)
New Revision: 1273

Modified:
   trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
   trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
Log:
TEIID-666: Session service not being used for "terminateSession". Previously Embedded did not have any session service, so it went directly to the DQP, now that it has session service the calls to terminate must flow through session service.

Modified: trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java	2009-08-24 21:01:26 UTC (rev 1272)
+++ trunk/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java	2009-08-24 21:06:57 UTC (rev 1273)
@@ -99,7 +99,7 @@
     
 	@Override
 	public ServerConnection createConnection(Properties connectionProperties) throws CommunicationException, ConnectionException {
-        return new LocalServerConnection(connectionProperties, this.clientServices);
+        return new LocalServerConnection(connectionProperties, this.clientServices, (SessionServiceInterface)findService(DQPServiceNames.SESSION_SERVICE));
 	}
         
     /**
@@ -125,7 +125,9 @@
 	        // create the deploy directories
 	        File deployDirectory = new File(teiidHome, props.getProperty(DQPEmbeddedProperties.DQP_DEPLOYDIR, "deploy")); //$NON-NLS-1$
 	        props.setProperty(DQPEmbeddedProperties.DQP_DEPLOYDIR, deployDirectory.getCanonicalPath());
-	        deployDirectory.mkdirs();
+	        if (!deployDirectory.exists()) {
+	        	deployDirectory.mkdirs();
+	        }
 	        
 	        // if there is no separate vdb-definitions specified then use the deploy directory as the location of the vdb
 	        String vdbDefinitions = props.getProperty(DQPEmbeddedProperties.VDB_DEFINITION);
@@ -136,8 +138,9 @@
 	        // create log directory
 	        File logDirectory = new File(teiidHome, props.getProperty(DQPEmbeddedProperties.DQP_LOGDIR, "log")); //$NON-NLS-1$
 	        props.setProperty(DQPEmbeddedProperties.DQP_LOGDIR, logDirectory.getCanonicalPath());
-	        deployDirectory.mkdirs();
-	    	        
+	        if (!logDirectory.exists()) {
+	        	logDirectory.mkdirs();
+	        }
 		} catch (IOException e) {
 			throw new ApplicationInitializationException(e);
 		}

Modified: trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java	2009-08-24 21:01:26 UTC (rev 1272)
+++ trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java	2009-08-24 21:06:57 UTC (rev 1273)
@@ -27,9 +27,14 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 import org.teiid.dqp.internal.process.DQPWorkContext;
 
+import com.metamatrix.admin.api.exception.security.InvalidSessionException;
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.security.LogonException;
 import com.metamatrix.client.ExceptionUtil;
@@ -41,6 +46,7 @@
 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.SessionServiceInterface;
 
 public class LocalServerConnection implements ServerConnection {
 	
@@ -49,9 +55,10 @@
 	private DQPWorkContext workContext;
 	private ClassLoader classLoader;
 	ClientServiceRegistry clientServices;
+	SessionServiceInterface sessionService;
 	
 
-	public LocalServerConnection(Properties connectionProperties, ClientServiceRegistry clientServices) throws CommunicationException, ConnectionException{
+	public LocalServerConnection(Properties connectionProperties, ClientServiceRegistry clientServices, SessionServiceInterface sessionService) throws CommunicationException, ConnectionException{
 	
 		this.clientServices = clientServices;		
 		
@@ -62,6 +69,8 @@
 		this.result = authenticate(connectionProperties);
 		
 		this.classLoader = Thread.currentThread().getContextClassLoader();
+		
+		this.sessionService = sessionService;
 	}
 
 	public synchronized LogonResult authenticate(Properties connProps) throws ConnectionException, CommunicationException {
@@ -86,14 +95,18 @@
 
 		return (T) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new InvocationHandler() {
 
-			public Object invoke(Object arg0, Method arg1, Object[] arg2)
-					throws Throwable {
+			public Object invoke(Object arg0, Method arg1, Object[] arg2) throws Throwable {
 				if (!isOpen()) {
 					throw ExceptionUtil.convertException(arg1, new MetaMatrixComponentException(JDBCPlugin.Util.getString("LocalTransportHandler.session_inactive"))); //$NON-NLS-1$
-				}
+				}							
 				ClassLoader current = Thread.currentThread().getContextClassLoader();
 				Thread.currentThread().setContextClassLoader(classLoader);
 				DQPWorkContext.setWorkContext(workContext);
+				
+				if (!(iface.equals(ILogon.class))) {					
+					sessionService.validateSession(workContext.getSessionId());
+				}
+				
 				try {
 					return arg1.invoke(clientServices.getClientService(iface), arg2);
 				} catch (InvocationTargetException e) {
@@ -113,6 +126,23 @@
 		if (shutdown) {
 			return;
 		}
+		
+		try {
+			//make a best effort to send the logoff
+			Future<?> writeFuture = getService(ILogon.class).logoff();
+			if (writeFuture != null) {
+				writeFuture.get(5000, TimeUnit.MILLISECONDS);
+			}
+		} catch (InvalidSessionException e) {
+			//ignore
+		} catch (InterruptedException e) {
+			//ignore
+		} catch (ExecutionException e) {
+			//ignore
+		} catch (TimeoutException e) {
+			//ignore
+		}
+		
 		this.shutdown = true;
 	}
 



More information about the teiid-commits mailing list