Author: rareddy
Date: 2009-12-23 17:55:47 -0500 (Wed, 23 Dec 2009)
New Revision: 1703
Added:
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
Removed:
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMSession.java
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionID.java
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
Modified:
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java
branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/LogonResult.java
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java
branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/RuntimeStateAdmin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/Session.java
branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/Transaction.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerConnection.java
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
branches/JCA/jboss-embedded/
branches/JCA/jboss-integration/pom.xml
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
branches/JCA/runtime/pom.xml
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
branches/JCA/runtime/src/main/java/org/teiid/transport/AdminAuthorizationInterceptor.java
branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/TestAdminAuthInterceptor.java
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java
branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
Log:
TEIID-910: adding sessions
Deleted: branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMSession.java
===================================================================
---
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMSession.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMSession.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -1,273 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.admin.objects;
-
-import java.util.Date;
-
-import org.teiid.adminapi.Session;
-
-import com.metamatrix.admin.AdminPlugin;
-import com.metamatrix.core.util.DateUtil;
-
-/**
- * MetaMatrix Session
- *
- */
-public class MMSession extends MMAdminObject implements Session {
-
- private static final long serialVersionUID = 4939105946380675244L;
- private String userName = ""; //$NON-NLS-1$;
- private String applicationName = ""; //$NON-NLS-1$
- private String sessionID;
- private String vdbName = ""; //$NON-NLS-1$
- private String vdbVersion = ""; //$NON-NLS-1$
- private String ipAddress = ""; //$NON-NLS-1$
- private String hostName = ""; //$NON-NLS-1$
- private long lastPingTime;
- private int sessionState;
-
-
-
- /**
- * constructor
- * @param identifierParts
- */
- public MMSession(String[] identifierParts) {
- super(identifierParts);
- this.sessionID = getIdentifier();
- }
-
-
- /**
- * Convert a Session to a String
- *
- * @see java.lang.Object#toString()
- * @since 4.3
- */
- public String toString() {
- StringBuffer result = new StringBuffer();
- result.append(AdminPlugin.Util.getString("MMSession.MMSession")).append(getIdentifier());
//$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.User_Name")).append(userName);
//$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.Application")).append(applicationName);
//$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.ID")).append(sessionID);
//$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.VDB_Name")).append(vdbName);
//$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.VDB_Version")).append(vdbVersion);
//$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.Last_Ping_Time")).append(getLastPingTimeString());
//$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMSession.State")).append(getStateAsString());
//$NON-NLS-1$
-
result.append(AdminPlugin.Util.getString("MMSession.IPAddress")).append(ipAddress);
//$NON-NLS-1$
-
result.append(AdminPlugin.Util.getString("MMSession.HostName")).append(hostName);
//$NON-NLS-1$
-
- return result.toString();
- }
-
- /**
- * Get the Last time Client has checked to see if the server is still available
- *
- * @return Date of the last ping to the server.
- */
- public Date getLastPingTime() {
- return new Date(lastPingTime);
- }
-
-
- /**
- * Get the Time the User logged into the System as a String
- *
- * @return String
- */
- public String getLastPingTimeString() {
- return DateUtil.getDateAsString(getLastPingTime());
- }
-
- /**
- * Set the Last time Client has checked to see if the server is still available
- * @param lastPingTime
- */
- public void setLastPingTime(long lastPingTime) {
- this.lastPingTime = lastPingTime;
- }
-
-
-
- /**
- * Get the SessionState
- *
- * @return String with the SessionState
- */
- public String getStateAsString() {
- String result = ""; //$NON-NLS-1$
- switch (sessionState) {
- case STATE_EXPIRED :
- result = EXPIRED_STATE_DESC;
- break;
- case STATE_ACTIVE :
- result = ACTIVE_STATE_DESC;
- break;
- case STATE_CLOSED :
- result = CLOSED_STATE_DESC;
- break;
- case STATE_TERMINATED :
- result = TERMINATED_STATE_DESC;
- break;
- case STATE_PASSIVATED :
- result = PASSIVATED_STATE_DESC;
- break;
- default :
- result = UNKNOWN_STATE_DESC;
- }
- return result;
- }
-
-
- /**
- * Set the SessionState
- * @param state
- */
- public void setSessionState(int state) {
- this.sessionState = state;
- }
-
- /**
- * Get the Application Name
- *
- * @return String of the Application Name
- */
- public String getApplicationName() {
- return applicationName;
- }
-
- /**
- * Set the ApplicationName
- * @param name
- */
- public void setApplicationName(String name) {
- this.applicationName = name;
- }
-
- /**
- * Get the unique MetaMatrix session
- * within a given MetaMatrix System
- *
- * @return Strings of the Session ID
- */
- public String getSessionID() {
- return sessionID;
- }
-
- /**
- * Get the State of the Session
- *
- * @return int of the Session's state
- */
- public int getState() {
- return sessionState;
- }
-
- /**
- * Get User Name for this Session
- *
- * @return String of UserName
- */
- public String getUserName() {
- return userName;
- }
-
- /**
- * Set User Name for this Session
- * @param userName
- */
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- /**
- * Get the VDB Name for this Session
- *
- * @return String name of the VDB
- */
- public String getVDBName() {
- return vdbName;
- }
-
- /**
- * Set VDBName for this Session
- * @param vdbName
- */
- public void setVDBName(String vdbName) {
- this.vdbName = vdbName;
- }
-
- /**
- * Get the VDB Version for this Session
- *
- * @return String name/number of the VDB Version
- */
- public String getVDBVersion() {
- return vdbVersion;
- }
-
- /**
- * Set VDBVersion for this Session
- * @param vdbVersion
- */
- public void setVDBVersion(String vdbVersion) {
- this.vdbVersion = vdbVersion;
- }
-
- /**
- * Set IPAddress for this Session
- * @param ipAddress
- */
- public void setIPAddress(String ipAddress) {
- this.ipAddress = ipAddress;
- }
-
-
- /**
- * Get the IPAddress for this Session
- * @return IPAddress
- */
- public String getIPAddress() {
- return this.ipAddress;
- }
-
- /**
- * Set information defined by the client at runtime
- * @param clientMachineName
- */
- public void setHostName(String clientMachineName) {
- this.hostName = clientMachineName;
- }
-
-
- /**
- * Get the host name of the machine the client is
- * accessing from
- * @return IPAddress
- */
- public String getHostName() {
- return this.hostName;
- }
-
-
-}
Modified:
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java
===================================================================
---
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/TransactionImpl.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -32,7 +32,7 @@
public class TransactionImpl extends MMAdminObject implements Transaction {
private static final long serialVersionUID = -8588785315218789068L;
- private String associatedSession;
+ private long associatedSession;
private String scope;
private MMXid xid;
@@ -40,11 +40,11 @@
super(id);
}
- public String getAssociatedSession() {
+ public long getAssociatedSession() {
return associatedSession;
}
- public void setAssociatedSession(String associatedSession) {
+ public void setAssociatedSession(long associatedSession) {
this.associatedSession = associatedSession;
}
Modified: branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java
===================================================================
---
branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ClientSideDQP.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -34,7 +34,6 @@
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.message.ResultsMessage;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
public interface ClientSideDQP {
@@ -56,7 +55,7 @@
MetadataResult getMetadata(long requestID, String preparedSql, boolean
allowDoubleQuotedVariable) throws MetaMatrixComponentException,
MetaMatrixProcessingException;
- void terminateConnection(MetaMatrixSessionID sessionId) throws
MetaMatrixComponentException;
+ void terminateConnection(long sessionId) throws MetaMatrixComponentException;
// local transaction
void begin() throws XATransactionException;
Modified:
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/LogonResult.java
===================================================================
---
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/LogonResult.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/LogonResult.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -23,7 +23,6 @@
package com.metamatrix.platform.security.api;
import java.io.Serializable;
-import java.util.Properties;
import java.util.TimeZone;
@@ -38,18 +37,19 @@
private static final long serialVersionUID = 4481443514871448269L;
private TimeZone timeZone = TimeZone.getDefault();
- private final Properties productInfo;
private String clusterName;
private SessionToken sessionToken;
+ private String vdbName;
+ private int vdbVersion;
public LogonResult() {
- this.productInfo = new Properties();
}
- public LogonResult(SessionToken token, Properties productInfo, String clusterName) {
- this.productInfo = productInfo;
+ public LogonResult(SessionToken token, String vdbName, int vdbVersion, String
clusterName) {
this.clusterName = clusterName;
this.sessionToken = token;
+ this.vdbName = vdbName;
+ this.vdbVersion = vdbVersion;
}
/**
@@ -57,7 +57,7 @@
* @return
* @since 4.3
*/
- public MetaMatrixSessionID getSessionID() {
+ public long getSessionID() {
return this.sessionToken.getSessionID();
}
@@ -65,9 +65,6 @@
return timeZone;
}
- public String getProductInfo(String key) {
- return this.productInfo.getProperty(key);
- }
public String getUserName() {
return this.sessionToken.getUsername();
@@ -80,5 +77,13 @@
public SessionToken getSessionToken() {
return sessionToken;
}
+
+ public String getVdbName() {
+ return vdbName;
+ }
+
+ public int getVdbVersion() {
+ return vdbVersion;
+ }
}
Deleted:
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionID.java
===================================================================
---
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionID.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionID.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.security.api;
-
-import java.io.Serializable;
-
-/**
- * This immutable class represents an identifier for a unique session.
- */
-public final class MetaMatrixSessionID implements
- Serializable {
-
- public final static long serialVersionUID = -7872739911360962975L;
-
- private long id;
-
- public MetaMatrixSessionID(long id) {
- this.id = id;
- }
-
- /**
- * Returns true if the specified object is semantically equal to this instance. Note:
this method is consistent with
- * <code>compareTo()</code>.
- *
- * @param obj
- * the object that this instance is to be compared to.
- * @return whether the object is equal to this object.
- */
- public boolean equals(Object obj) {
- // Check if instances are identical ...
- if (this == obj) {
- return true;
- }
-
- // Check if object can be compared to this one
- // (this includes checking for null ) ...
- if (obj instanceof MetaMatrixSessionID) {
- MetaMatrixSessionID that = (MetaMatrixSessionID)obj;
- return this.id == that.id;
- }
-
- // Otherwise not comparable ...
- return false;
- }
-
- /**
- * Returns the hash code value for this object.
- *
- * @return a hash code value for this object.
- */
- public final int hashCode() {
- return (int)id;
- }
-
- /**
- * Returns a string representing the current state of the object.
- *
- * @return the string representation of this instance.
- */
- public final String toString() {
- return String.valueOf(id);
- }
-
-}
-
Modified:
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java
===================================================================
---
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/client/src/main/java/com/metamatrix/platform/security/api/SessionToken.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -38,7 +38,7 @@
public final static long serialVersionUID = -2853708320435636107L;
/** The session ID */
- private MetaMatrixSessionID sessionID;
+ private long sessionID;
private String userName;
private UUID secret;
@@ -46,7 +46,7 @@
* Fake SessionToken representing a trusted user
*/
public SessionToken() {
- this.sessionID = new MetaMatrixSessionID(-1);
+ this.sessionID = -1L;
this.userName = "trusted"; //$NON-NLS-1$
this.secret = new UUID(1,1);
}
@@ -61,7 +61,7 @@
* (String) the userName for this session
* @throws IllegalArgumentException
*/
- public SessionToken(MetaMatrixSessionID id, String userName) {
+ public SessionToken(long id, String userName) {
this.sessionID = id;
this.userName = userName;
this.secret = UUID.randomUUID();
@@ -76,20 +76,11 @@
*
* @return the session ID
*/
- public MetaMatrixSessionID getSessionID() {
+ public long getSessionID() {
return this.sessionID;
}
/**
- * Returns unique session identifier
- *
- * @return the session ID value
- */
- public String getSessionIDValue() {
- return this.sessionID.toString();
- }
-
- /**
* Get the principal name for this session's user.
*
* @return the user name
@@ -119,7 +110,7 @@
return false;
}
SessionToken that = (SessionToken) obj;
- return (this.sessionID.equals(that.sessionID))
+ return (this.sessionID == that.sessionID)
&& this.userName.equals(that.userName)
&& this.secret.equals(that.secret);
}
@@ -132,14 +123,14 @@
* @see Object#equals(Object)
*/
public int hashCode() {
- return this.sessionID.hashCode();
+ return new Long(this.sessionID).hashCode();
}
/**
* Returns a string representing the current state of the object.
*/
public String toString() {
- return "SessionToken[" + getUsername() + "," + getSessionIDValue()
+ "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return "SessionToken[" + getUsername() + "," + this.sessionID +
"]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/**
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java 2009-12-23
17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -93,20 +93,6 @@
Collection<ConnectorBinding> getConnectorBindingsInVDB(String vdbName, int
vdbVersion) throws AdminException;
/**
- * Get the Extension Modules that correspond to the specified identifier pattern
- * @param extensionModuleIdentifier - the unique identifier for {@link
ExtensionModule}
- * <ul>
- * <li> <code>"*"</code> - for all extension modules
in the system
- * <li> <code>"name*"</code> - for all the extension
modules in that begin with given name
- * <li><code>"name"</code> - for a single extension
module identified by given name
- * </ul>
- * @return Collection of {@link ExtensionModule}
- * @throws AdminException if there's a system error.
- * @since 4.3
- */
- Collection<ExtensionModule> getExtensionModules(String
extensionModuleIdentifier) throws AdminException;
-
- /**
* Get the Queue Worker Pools that correspond to the specified identifier pattern.
*
* @param identifier - an identfier for the queues {@link QueueWorkerPool}
@@ -158,18 +144,11 @@
Collection<Cache> getCaches(String identifier) throws AdminException;
/**
- * Get the Sessions that correspond to the specified identifier pattern
- * @param identifier - an unique identifier for {@link Session}
- * <ul>
- * <li> <code>"*"</code> - for all current sessions
of the system
- * <li> <code>"number*"</code> - for all the
sessions that begin with given number
- * <li><code>"number"</code> - for a single current
session in the system
- * </ul>
+ * Get all the current Sessions.
* @return Collection of {@link Session}
* @throws AdminException if there's a system error.
- * @since 4.3
*/
- Collection<Session> getSessions(String identifier) throws AdminException;
+ Collection<Session> getSessions() throws AdminException;
/**
* Get the Requests that correspond to the specified identifier pattern
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/RuntimeStateAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/RuntimeStateAdmin.java 2009-12-23
17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/RuntimeStateAdmin.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -69,7 +69,7 @@
* @throws AdminException if there's a system error.
* @since 4.3
*/
- void terminateSession(String identifier) throws AdminException;
+ void terminateSession(long sessionId) throws AdminException;
/**
* Cancel Request
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/Session.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/Session.java 2009-12-23 17:10:18
UTC (rev 1702)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/Session.java 2009-12-23 22:55:47
UTC (rev 1703)
@@ -22,104 +22,24 @@
package org.teiid.adminapi;
-import java.util.Date;
/**
- * A Session is a lasting connection between a client and a MetaMatrix System.
+ * A Session is a lasting connection between a client and a Teiid System.
*
* A user may be allowed to have multiple sessions active simultaneously.
*
- * <p>a Session identifier gets automatically assigned
- * to a connection when user logs into the system</p>
- *
- * @since 4.3
*/
-public interface Session extends
- AdminObject {
+public interface Session extends AdminObject {
-
/**
- * The session is open (active).
- */
- public static final int STATE_ACTIVE = 1;
-
- /**
- * The ejb server has passivated the session - it may become
- *open again in the future
- */
- public static final int STATE_PASSIVATED = 2;
-
- /**
- * The session is closed - this state cannot change once it
- *is reached.
- */
- public static final int STATE_CLOSED = 3;
-
- /**
- * The session has expired - this state cannot change once it
- *is reached.
- */
- public static final int STATE_EXPIRED = 4;
-
- /**
- * The session is terminated - this state cannot change once it
- *is reached.
- */
- public static final int STATE_TERMINATED = 5;
-
- /**
- * The description when the session has expired - this state cannot change once it
- * is reached.
- */
- public static final String EXPIRED_STATE_DESC = "Expired"; //$NON-NLS-1$
-
- /**
- * The description when the session is open (active).
- */
- public static final String ACTIVE_STATE_DESC = "Active";//$NON-NLS-1$
-
- /**
- * The description when the session is closed - this state cannot change once it
- * is reached.
- */
- public static final String CLOSED_STATE_DESC = "Closed";//$NON-NLS-1$
-
- /**
- * The description when the session is terminated - this state cannot change once it
- *is reached.
- */
- public static final String TERMINATED_STATE_DESC =
"Terminated";//$NON-NLS-1$
-
- /**
- * The description when the ejb server has passivated the session - it may become
- * open again in the future
- */
- public static final String PASSIVATED_STATE_DESC =
"Passivated";//$NON-NLS-1$
-
- /**
- * The description when the state of the session is not known.
- */
- public static final String UNKNOWN_STATE_DESC = "Unknown";//$NON-NLS-1$
-
-
-
-
- /**
* Get the Last time Client has check to see if the server is still available
*
* @return Date of the last ping to the server.
*/
- public Date getLastPingTime();
+ public long getLastPingTime();
/**
- * Get the Session State as a String.
- *
- * @return SessionState
- */
- public String getStateAsString();
-
- /**
* Get the Application Name
*
* @return String of the Application Name
@@ -127,21 +47,14 @@
public String getApplicationName();
/**
- * Get the unique MetaMatrix session
- * within a given MetaMatrix System
+ * Get the unique Teiid session
+ * within a given Teiid System
*
* @return String of the Session ID
*/
- public String getSessionID();
+ public long getSessionId();
/**
- * Get the State of the Session
- *
- * @return int of the Session's state
- */
- public int getState();
-
- /**
* Get User Name for this Session
*
* @return String of UserName
@@ -160,7 +73,7 @@
*
* @return String name/number of the VDB Version
*/
- public String getVDBVersion();
+ public int getVDBVersion();
/**
* Get the IPAddress for this Session
@@ -174,13 +87,19 @@
* accessing from
* @return
*/
- public String getHostName() ;
+ public String getClientHostName();
/**
* Get the time the {@link Session} was created.
* @return
*/
- public Date getCreatedDate();
+ public long getCreatedTime();
+
+ /**
+ * Security Domain user logged into currently
+ * @return
+ */
+ public String getSecurityDomain();
}
\ No newline at end of file
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2009-12-23
17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -202,14 +202,7 @@
return null;
}
- @Override
- public Collection<ExtensionModule> getExtensionModules(
- String extensionModuleIdentifier) throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
-
@Override
public Collection<QueueWorkerPool> getQueueWorkerPools(String identifier)
throws AdminException {
@@ -224,12 +217,6 @@
return null;
}
- @Override
- public Collection<Session> getSessions(String identifier)
- throws AdminException {
- // rameshTODO Auto-generated method stub
- return null;
- }
@Override
public Collection<Request> getSourceRequests(String identifier)
@@ -285,12 +272,6 @@
@Override
- public void terminateSession(String identifier) throws AdminException {
- // rameshTODO Auto-generated method stub
-
- }
-
- @Override
public void terminateTransaction(Xid transactionId) throws AdminException {
// rameshTODO Auto-generated method stub
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/Transaction.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/Transaction.java 2009-12-23
17:10:18 UTC (rev 1702)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/Transaction.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -33,7 +33,7 @@
* May be null for an unassociated Global transaction.
* @return
*/
- String getAssociatedSession();
+ long getAssociatedSession();
/**
* Get the scope for the transaction. Will be one of GLOBAL, LOCAL, or REQUEST
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
---
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -86,6 +86,15 @@
}
+ public Object addAttchment(String key, Object attachment) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type");
+ Object result = this.attachments.put(key, attachment);
+ if (result == null)
+ return null;
+ return result;
+ }
+
/**
* Remove attachment
*
@@ -103,6 +112,14 @@
return type.cast(result);
}
+ public Object removeAttachment(String key) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type");
+ Object result = this.attachments.remove(key);
+ if (result == null)
+ return null;
+ return result;
+ }
/**
* Get attachment
*
@@ -119,4 +136,13 @@
return null;
return type.cast(result);
}
+
+ public Object getAttachment(String key) {
+ if (key == null)
+ throw new IllegalArgumentException("Null type");
+ Object result = this.attachments.get(key);
+ if (result == null)
+ return null;
+ return result;
+ }
}
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
(rev 0)
+++
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -0,0 +1,151 @@
+/*
+ * 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.adminapi.impl;
+
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementObjectID;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.teiid.adminapi.Session;
+
+
+/**
+ * Add and delete properties also in the Mapper class for correct wrapping for profile
service.
+ */
+@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="session"))
+(a)MetaMapping(SessionMetadataMapper.class)
+public class SessionMetadata extends AdminObjectImpl implements Session {
+
+ private static final long serialVersionUID = 918638989081830034L;
+ private String applicationName;
+ private long lastPingTime;
+ private long createdTime;
+ private String ipAddress;
+ private String clientHostName;
+ private String userName;
+ private String vdbName;
+ private int vdbVersion;
+ private long sessionId;
+ private String securityDomain;
+
+ @Override
+ @ManagementProperty(description="Application assosiated with Session",
readOnly=true)
+ public String getApplicationName() {
+ return this.applicationName;
+ }
+
+ public void setApplicationName(String applicationName) {
+ this.applicationName = applicationName;
+ }
+
+ @Override
+ @ManagementProperty(description="When session created", readOnly=true)
+ public long getCreatedTime() {
+ return this.createdTime;
+ }
+
+ public void setCreatedTime(long createdTime) {
+ this.createdTime = createdTime;
+ }
+
+ @Override
+ @ManagementProperty(description="Host name from where the session created",
readOnly=true)
+ public String getClientHostName() {
+ return this.clientHostName;
+ }
+
+ public void setClientHostName(String clientHostname) {
+ this.clientHostName = clientHostname;
+ }
+
+ @Override
+ @ManagementProperty(description="IP address from where session is created",
readOnly=true)
+ public String getIPAddress() {
+ return this.ipAddress;
+ }
+
+ public void setIPAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ @Override
+ @ManagementProperty(description="Last ping time", readOnly=true)
+ public long getLastPingTime() {
+ return this.lastPingTime;
+ }
+
+ public void setLastPingTime(long lastPingTime) {
+ this.lastPingTime = lastPingTime;
+ }
+
+ @Override
+ @ManagementProperty(description="Session ID", readOnly=true)
+ @ManagementObjectID(type="session")
+ public long getSessionId() {
+ return this.sessionId;
+ }
+
+ public void setSessionId(long sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ @Override
+ @ManagementProperty(description="User name assosiated with session",
readOnly=true)
+ public String getUserName() {
+ return this.userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+ @Override
+ @ManagementProperty(description="VDB name assosiated with session",
readOnly=true)
+ public String getVDBName() {
+ return this.vdbName;
+ }
+
+ public void setVDBName(String vdbName) {
+ this.vdbName = vdbName;
+ }
+
+ @Override
+ @ManagementProperty(description="VDB version name assosiated with session",
readOnly=true)
+ public int getVDBVersion() {
+ return this.vdbVersion;
+ }
+
+ public void setVDBVersion(int vdbVersion) {
+ this.vdbVersion = vdbVersion;
+ }
+
+ @Override
+ @ManagementProperty(description="Security Domain that session logged into",
readOnly=true)
+ public String getSecurityDomain() {
+ return this.securityDomain;
+ }
+
+ public void setSecurityDomain(String domain) {
+ this.securityDomain = domain;
+ }
+}
Added:
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
(rev 0)
+++
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -0,0 +1,115 @@
+/*
+ * 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.adminapi.impl;
+
+import java.lang.reflect.Type;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.CompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.plugins.types.MutableCompositeMetaType;
+import org.jboss.metatype.spi.values.MetaMapper;
+import org.teiid.adminapi.VDB;
+
+public class SessionMetadataMapper extends MetaMapper<SessionMetadata> {
+ private static final MutableCompositeMetaType metaType;
+ private static final MetaValueFactory metaValueFactory =
MetaValueFactory.getInstance();
+
+ static {
+ metaType = new MutableCompositeMetaType(VDB.class.getName(), "The Session domain
meta data");
+ metaType.addItem("applicationName", "applicationName",
SimpleMetaType.STRING);
+ metaType.addItem("createdTime", "createdTime",
SimpleMetaType.LONG_PRIMITIVE);
+ metaType.addItem("clientHostName", "clientHostName",
SimpleMetaType.STRING);
+ metaType.addItem("IPAddress", "IPAddress", SimpleMetaType.STRING);
+ metaType.addItem("lastPingTime", "lastPingTime",
SimpleMetaType.LONG_PRIMITIVE);
+ metaType.addItem("sessionId", "sessionId",
SimpleMetaType.LONG_PRIMITIVE);
+ metaType.addItem("userName", "userName", SimpleMetaType.STRING);
+ metaType.addItem("VDBName", "VDBName", SimpleMetaType.STRING);
+ metaType.addItem("VDBVersion", "VDBVersion",
SimpleMetaType.INTEGER_PRIMITIVE);
+ metaType.addItem("securityDomain", "SecurityDomain",
SimpleMetaType.STRING);
+ metaType.freeze();
+ }
+
+ @Override
+ public Type mapToType() {
+ return SessionMetadata.class;
+ }
+
+ @Override
+ public MetaType getMetaType() {
+ return metaType;
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, SessionMetadata object) {
+ if (object == null)
+ return null;
+ if (metaType instanceof CompositeMetaType) {
+ CompositeMetaType composite = (CompositeMetaType) metaType;
+ CompositeValueSupport session = new CompositeValueSupport(composite);
+
+ session.set("applicationName", SimpleValueSupport.wrap(object.getName()));
+ session.set("createdTime",
SimpleValueSupport.wrap(object.getCreatedTime()));
+ session.set("clientHostName",
SimpleValueSupport.wrap(object.getClientHostName()));
+ session.set("IPAddress", SimpleValueSupport.wrap(object.getIPAddress()));
+ session.set("lastPingTime",
SimpleValueSupport.wrap(object.getLastPingTime()));
+ session.set("sessionId", SimpleValueSupport.wrap(object.getSessionId()));
+ session.set("userName", SimpleValueSupport.wrap(object.getUserName()));
+ session.set("VDBName",SimpleValueSupport.wrap(object.getVDBName()));
+ session.set("VDBVersion", SimpleValueSupport.wrap(object.getVDBVersion()));
+ session.set("securityDomain",
SimpleValueSupport.wrap(object.getSecurityDomain()));
+
+ return session;
+ }
+ throw new IllegalArgumentException("Cannot convert session " + object);
+ }
+
+ @Override
+ public SessionMetadata unwrapMetaValue(MetaValue metaValue) {
+ if (metaValue == null)
+ return null;
+
+ if (metaValue instanceof CompositeValue) {
+ CompositeValue compositeValue = (CompositeValue) metaValue;
+
+ SessionMetadata session = new SessionMetadata();
+ session.setApplicationName((String)
metaValueFactory.unwrap(compositeValue.get("applicationName")));
+ session.setCreatedTime((Long)
metaValueFactory.unwrap(compositeValue.get("createdTime")));
+ session.setClientHostName((String)
metaValueFactory.unwrap(compositeValue.get("clientHostName")));
+ session.setIPAddress((String)
metaValueFactory.unwrap(compositeValue.get("IPAddress")));
+ session.setLastPingTime((Long)
metaValueFactory.unwrap(compositeValue.get("lastPingTime")));
+ session.setSessionId((Long)
metaValueFactory.unwrap(compositeValue.get("sessionId")));
+ session.setUserName((String)
metaValueFactory.unwrap(compositeValue.get("userName")));
+ session.setVDBName((String)
metaValueFactory.unwrap(compositeValue.get("VDBName")));
+ session.setVDBVersion((Integer)
metaValueFactory.unwrap(compositeValue.get("VDBVersion")));
+ session.setSecurityDomain((String)
metaValueFactory.unwrap(compositeValue.get("securityDomain")));
+ return session;
+ }
+ throw new IllegalStateException("Unable to unwrap session " + metaValue);
+ }
+
+}
Modified:
branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerConnection.java
===================================================================
---
branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerConnection.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/client/src/test/java/com/metamatrix/common/comm/platform/socket/client/TestSocketServerConnection.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -45,7 +45,6 @@
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.LogonResult;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
/**
@@ -82,7 +81,7 @@
Properties connectionProperties)
throws LogonException,
MetaMatrixComponentException {
- return new LogonResult(new SessionToken(new MetaMatrixSessionID(1),
"fooUser"), new Properties(), "fake"); //$NON-NLS-1$ //$NON-NLS-2$
+ return new LogonResult(new SessionToken(1, "fooUser"), "foo", 1,
"fake"); //$NON-NLS-1$ //$NON-NLS-2$
}
//## JDBC4.0-begin ##
@@ -152,7 +151,7 @@
public void testLogon() throws Exception {
SocketServerConnection connection = createConnection(null);
- assertEquals("1", connection.getLogonResult().getSessionID().toString());
//$NON-NLS-1$
+ assertEquals(1, connection.getLogonResult().getSessionID()); //$NON-NLS-1$
}
/**
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
---
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -236,7 +236,7 @@
* @throws SQLException
*/
public String getConnectionId() {
- return this.serverConn.getLogonResult().getSessionID().toString();
+ return String.valueOf(this.serverConn.getLogonResult().getSessionID());
}
long currentRequestId() {
@@ -479,12 +479,12 @@
checkConnection();
//get the virtual database name to which we are connected.
- return this.serverConn.getLogonResult().getProductInfo(MMURL.JDBC.VDB_NAME);
+ return this.serverConn.getLogonResult().getVdbName();
}
- public String getVDBVersion() throws SQLException {
+ public int getVDBVersion() throws SQLException {
checkConnection();
- return this.serverConn.getLogonResult().getProductInfo(MMURL.JDBC.VDB_VERSION);
+ return this.serverConn.getLogonResult().getVdbVersion();
}
/**
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java
===================================================================
---
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/api/Connection.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -41,6 +41,6 @@
*/
Admin getAdminAPI() throws SQLException;
- String getVDBVersion() throws SQLException;
+ int getVDBVersion() throws SQLException;
}
Modified:
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
===================================================================
---
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -22,24 +22,23 @@
package com.metamatrix.jdbc;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.stub;
import java.sql.SQLException;
import java.util.Properties;
import junit.framework.TestCase;
-import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.platform.security.api.LogonResult;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class TestMMConnection extends TestCase {
protected static final String STD_DATABASE_NAME = "QT_Ora9DS";
//$NON-NLS-1$
- protected static final String STD_DATABASE_VERSION = "1";
//$NON-NLS-1$
+ protected static final int STD_DATABASE_VERSION = 1; //$NON-NLS-1$
static String serverUrl =
"jdbc:metamatrix:QT_Ora9DS@mm://localhost:7001;version=1;user=metamatrixadmin;password=mm";
//$NON-NLS-1$
@@ -52,12 +51,9 @@
stub(mock.getService(ClientSideDQP.class)).toReturn(mock(ClientSideDQP.class));
Properties props = new Properties();
props.setProperty(BaseDataSource.VDB_NAME, STD_DATABASE_NAME);
- props.setProperty(BaseDataSource.VDB_VERSION, STD_DATABASE_VERSION);
+ props.setProperty(BaseDataSource.VDB_VERSION,
String.valueOf(STD_DATABASE_VERSION));
props.setProperty(BaseDataSource.USER_NAME, "metamatrixadmin");
//$NON-NLS-1$
- Properties productInfo = new Properties();
- productInfo.setProperty(MMURL.JDBC.VDB_NAME, STD_DATABASE_NAME);
- productInfo.setProperty(MMURL.JDBC.VDB_VERSION, STD_DATABASE_VERSION);
- stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(new
MetaMatrixSessionID(1), "metamatrixadmin"), productInfo, "fake"));
//$NON-NLS-1$
+ stub(mock.getLogonResult()).toReturn(new LogonResult(new SessionToken(1,
"metamatrixadmin"), STD_DATABASE_NAME,STD_DATABASE_VERSION , "fake"));
//$NON-NLS-1$
return new MMConnection(mock, props, serverUrl);
}
Deleted:
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java
===================================================================
---
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/MetaMatrixSessionInfo.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -1,177 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.security.api;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-import javax.security.auth.login.LoginContext;
-
-import org.teiid.adminapi.impl.VDBMetaData;
-
-/**
- * This class represents an immutable informational object describing
- * the attributes of a unique MetaMatrix session within a given MetaMatrix System.
- */
-public class MetaMatrixSessionInfo implements Serializable, Cloneable {
-
- public final static long serialVersionUID = -9120197553960136239L;
-
- private SessionToken sessionToken; // immutable
- private long lastPingTime;
- private long timeCreated;
- private String applicationName;
- private Properties productInfo;
- private String clientIp;
- private String clientHostname;
- private transient LoginContext loginContext;
- private String securityDomain;
- private Object securityContext;
- private VDBMetaData vdb;
- /**
- * Master constructor, allows a MetaMatrixSessionInfo to be created with
- * any state and any timestamps.
- */
- public MetaMatrixSessionInfo(MetaMatrixSessionID sessionID,
- String userName, LoginContext context, String securityDomain,
- Object securityContext, long timeCreated, String applicationName,
- Properties productInfo, String clientIp, String clientHostname, VDBMetaData vdb) {
- this.timeCreated = timeCreated;
- this.lastPingTime = timeCreated;
- this.applicationName = applicationName;
- this.sessionToken = new SessionToken(sessionID, userName);
- this.productInfo = productInfo;
- this.clientIp = clientIp;
- this.clientHostname = clientHostname;
- this.loginContext = context;
- this.securityDomain = securityDomain;
- this.securityContext = securityContext;
- this.vdb = vdb;
- }
-
- public MetaMatrixSessionID getSessionID() {
- return this.sessionToken.getSessionID();
- }
-
- public String getUserName() {
- return this.sessionToken.getUsername();
- }
-
- public String getApplicationName() {
- return this.applicationName;
- }
-
- public long getTimeCreated() {
- return this.timeCreated;
- }
-
- /**
- * Get the time the server was last pinged by this session.
- * Note that the session's "last ping time" will only be acurate
- * if the session is in the ACTIVE state.
- * @return The time the server was last pinged by this session.
- */
- public long getLastPingTime() {
- return lastPingTime;
- }
-
- /**
- * Used <i><b>ONLY</b></i> by the session service to set the
- * time this session last initiated a server ping.
- * @param lastPingTime The last time this session pinged the server.
- */
- public void setLastPingTime(long lastPingTime) {
- this.lastPingTime = lastPingTime;
- }
-
- public SessionToken getSessionToken(){
- return this.sessionToken;
- }
-
- /**
- * Return a cloned instance of this object.
- * @return the object that is the clone of this instance.
- */
- public Object clone() {
- try {
- // Everything is immutable, so bit-wise copy (of references) is okay!
- return super.clone();
- } catch ( CloneNotSupportedException e ) {
- }
- return null;
- }
-
- /**
- * Returns a string representing the current state of the object.
- */
- public String toString() {
- StringBuffer s = new StringBuffer();
- s.append("MetaMatrixSessionInfo[ "); //$NON-NLS-1$
- s.append(this.sessionToken.toString());
- s.append(", "); //$NON-NLS-1$
- s.append("application:"); //$NON-NLS-1$
- s.append(this.applicationName);
- s.append(", created:"); //$NON-NLS-1$
- s.append(this.timeCreated);
- s.append(", last pinged server:"); //$NON-NLS-1$
- s.append(this.lastPingTime);
- s.append("]"); //$NON-NLS-1$
- return s.toString();
- }
-
- /**
- * @return Returns the productInfo.
- * @since 4.3
- */
- public String getProductInfo(String key) {
- return this.productInfo.getProperty(key);
- }
-
- public Properties getProductInfo() {
- return this.productInfo;
- }
-
- public String getClientIp() {
- return clientIp;
- }
-
- public String getClientHostname() {
- return clientHostname;
- }
-
- public LoginContext getLoginContext() {
- return this.loginContext;
- }
-
- public String getSecurityDomain() {
- return this.securityDomain;
- }
-
- public Object getSecurityContext() {
- return this.securityContext;
- }
-
- public VDBMetaData getVDB() {
- return this.vdb;
- }
-}
Modified:
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java
===================================================================
---
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/main/java/com/metamatrix/platform/security/api/service/SessionService.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -27,12 +27,12 @@
import javax.security.auth.login.LoginException;
+import org.teiid.adminapi.impl.SessionMetadata;
+
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.platform.security.api.Credentials;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
/**
* <p>
@@ -64,7 +64,7 @@
/**
* Create a session for the given user authenticating against the given
<code>Credentials</code>.
*/
- public MetaMatrixSessionInfo createSession(String userName,
+ public SessionMetadata createSession(String userName,
Credentials credentials,
String applicationName,
Properties properties)
@@ -79,7 +79,7 @@
* session
* @throws SessionServiceException
*/
- void closeSession(MetaMatrixSessionID sessionID) throws InvalidSessionException;
+ void closeSession(long sessionID) throws InvalidSessionException;
/**
* Terminates the specified session. This is an administrative action.
@@ -93,14 +93,14 @@
* does not have authority to terminate the
<code>terminatedSessionID</code> session
* @throws SessionServiceException
*/
- boolean terminateSession(MetaMatrixSessionID terminatedSessionID, MetaMatrixSessionID
adminSessionID);
+ boolean terminateSession(long terminatedSessionID, long adminSessionID);
/**
* Get the collection of active user sessions on the system.
* @return The collection of MetaMatrixSessionInfo objects of active users on
* the system - possibly empty, never null.
*/
- Collection<MetaMatrixSessionInfo> getActiveSessions() throws
SessionServiceException;
+ Collection<SessionMetadata> getActiveSessions() throws
SessionServiceException;
/**
* Get the number of active user sessions on the system.
@@ -117,7 +117,7 @@
* session
* @throws SessionServiceException
*/
- MetaMatrixSessionInfo validateSession(MetaMatrixSessionID sessionID)
+ SessionMetadata validateSession(long sessionID)
throws InvalidSessionException, SessionServiceException;
/**
@@ -127,7 +127,7 @@
* @param VDBVersion The version of the VDB.
* @throws SessionServiceException when transaction with database fails or unexpected
exception happens
*/
- Collection<MetaMatrixSessionInfo> getSessionsLoggedInToVDB(String VDBName,
String VDBVersion)
+ Collection<SessionMetadata> getSessionsLoggedInToVDB(String VDBName, int
VDBVersion)
throws SessionServiceException;
/**
@@ -135,10 +135,10 @@
*
* @param sessionID - identifies the client
*/
- public void pingServer(MetaMatrixSessionID sessionID) throws
InvalidSessionException;
+ public void pingServer(long sessionID) throws InvalidSessionException;
- public void setLocalSession(MetaMatrixSessionID sessionID);
+ public void setLocalSession(long sessionID);
- MetaMatrixSessionInfo getActiveSession(MetaMatrixSessionID sessionID);
+ SessionMetadata getActiveSession(long sessionID);
}
Modified:
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
===================================================================
---
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -260,7 +260,7 @@
case SERVICE:
return contextCache.getServiceScopedCache(getConnectorIdentifier());
case SESSION:
- return
contextCache.getSessionScopedCache(context.getSessionToken().getSessionIDValue());
+ return
contextCache.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID()));
case VDB:
return contextCache.getVDBScopedCache(context.getVdbName(),
context.getVdbVersion());
case GLOBAL:
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 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -38,13 +38,11 @@
import javax.resource.spi.work.WorkManager;
import javax.transaction.xa.Xid;
-import org.teiid.ContainerUtil;
import org.teiid.dqp.internal.cache.CacheID;
import org.teiid.dqp.internal.cache.DQPContextCache;
import org.teiid.dqp.internal.cache.ResultSetCache;
import org.teiid.dqp.internal.cache.ResultSetCacheUtil;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
-import org.teiid.metadata.TransformationMetadata;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
@@ -77,7 +75,6 @@
import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.service.SessionService;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.processor.ProcessorDataManager;
@@ -400,9 +397,9 @@
* @since 4.2
*/
@Override
- public void terminateConnection(MetaMatrixSessionID id) throws
MetaMatrixComponentException {
+ public void terminateConnection(long id) throws MetaMatrixComponentException {
- String sessionId = id.toString();
+ String sessionId = String.valueOf(id);
// sometimes there will not be any atomic requests pending, in that
// situation we still need to clear the master request from our map
Modified:
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
---
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -29,7 +29,6 @@
import org.teiid.adminapi.impl.VDBMetaData;
import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class DQPWorkContext implements Serializable {
@@ -115,15 +114,12 @@
}
public String getConnectionID() {
- if (this.sessionToken == null) {
- return null;
- }
- return this.sessionToken.getSessionIDValue();
+ return String.valueOf(getSessionId());
}
- public MetaMatrixSessionID getSessionId() {
+ public long getSessionId() {
if (this.sessionToken == null) {
- return null;
+ return -1;
}
return this.sessionToken.getSessionID();
}
Modified:
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
===================================================================
---
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -508,7 +508,7 @@
continue;
}
TransactionImpl txnImpl = new TransactionImpl(processName,
TransactionContext.getXid().toString());
- txnImpl.setAssociatedSession(TransactionContext.getThreadId());
+ txnImpl.setAssociatedSession(Long.parseLong(TransactionContext.getThreadId()));
txnImpl.setCreated(new Date(TransactionContext.getCreationTime()));
txnImpl.setScope(TransactionContext.getTransactionType().toString());
txnImpl.setXid((MMXid)TransactionContext.getXid());
Modified:
branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
===================================================================
---
branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -30,7 +30,6 @@
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class TestAtomicRequestMessage extends TestCase {
@@ -46,7 +45,7 @@
public static AtomicRequestMessage example() {
RequestMessage rm = new RequestMessage();
DQPWorkContext workContext = new DQPWorkContext();
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(2),
"foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(2, "foo")); //$NON-NLS-1$
AtomicRequestMessage message = new AtomicRequestMessage(rm, workContext, 1000);
message.setCommand(TestQueryImpl.helpExample());
message.setFetchSize(100);
Modified:
branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
---
branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -37,7 +37,6 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.vdb.ModelType;
import com.metamatrix.dqp.message.ParameterInfo;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.mapping.relational.QueryNode;
import com.metamatrix.query.mapping.xml.MappingAttribute;
@@ -72,7 +71,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName(vdb.getName());
workContext.setVdbVersion(vdb.getVersion());
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(5),
"foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(5, "foo")); //$NON-NLS-1$
workContext.setVdb(vdb);
workContext.getVDB().addAttchment(QueryMetadataInterface.class, metadata);
DQPWorkContext.setWorkContext(workContext);
Modified:
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
===================================================================
---
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -27,7 +27,6 @@
import com.metamatrix.cache.Cache;
import com.metamatrix.cache.FakeCache.FakeCacheFactory;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
@@ -46,7 +45,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setVdbName("MyVDB"); //$NON-NLS-1$
workContext.setVdbVersion(1); //$NON-NLS-1$
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1),
"foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(1, "foo")); //$NON-NLS-1$
return workContext;
}
@@ -56,17 +55,17 @@
Cache cache =
this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString());
cache.put("key", "request-value"); //$NON-NLS-1$ //$NON-NLS-2$
- cache =
this.cacheContext.getSessionScopedCache(context.getSessionToken().getSessionIDValue());
+ cache =
this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID()));
cache.put("key", "session-value"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("request-value",
this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key"));
//$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("session-value",
this.cacheContext.getSessionScopedCache(context.getSessionToken().getSessionIDValue()).get("key"));
//$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("session-value",
this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID())).get("key"));
//$NON-NLS-1$ //$NON-NLS-2$
// close the request
this.cacheContext.removeRequestScopedCache(context.getRequestID(12L).toString());
assertNull(this.cacheContext.getRequestScopedCache(context.getRequestID(12L).toString()).get("key"));
//$NON-NLS-1$
- assertEquals("session-value",
this.cacheContext.getSessionScopedCache(context.getSessionToken().getSessionIDValue()).get("key"));
//$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("session-value",
this.cacheContext.getSessionScopedCache(String.valueOf(context.getSessionToken().getSessionID())).get("key"));
//$NON-NLS-1$ //$NON-NLS-2$
}
Modified:
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
---
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -31,12 +31,9 @@
import java.util.Arrays;
import java.util.List;
-import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-import javax.resource.spi.work.WorkEvent;
import javax.resource.spi.work.WorkManager;
import javax.transaction.xa.Xid;
@@ -59,7 +56,6 @@
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.service.TransactionContext;
import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
@@ -98,7 +94,7 @@
RequestMessage rm = new RequestMessage();
DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(EXAMPLE_BQT,
FakeMetadataFactory.exampleBQTVDB());
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(1),
"foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(1, "foo")); //$NON-NLS-1$
AtomicRequestMessage request = new AtomicRequestMessage(rm, workContext, nodeid);
request.setCommand(helpGetCommand("SELECT BQT1.SmallA.INTKEY FROM
BQT1.SmallA", EXAMPLE_BQT)); //$NON-NLS-1$
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 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -48,7 +48,6 @@
import com.metamatrix.dqp.service.AutoGenDataService;
import com.metamatrix.dqp.service.FakeBufferService;
import com.metamatrix.jdbc.api.ExecutionProperties;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.unittest.FakeMetadataFactory;
@@ -221,7 +220,7 @@
private ResultsMessage helpExecute(String sql, String userName, int sessionid,
boolean txnAutoWrap) throws Exception {
RequestMessage reqMsg = exampleRequestMessage(sql);
- DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(new
MetaMatrixSessionID(sessionid), userName));
+ DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(sessionid,
userName));
if (txnAutoWrap) {
reqMsg.setTxnAutoWrapMode(ExecutionProperties.AUTO_WRAP_ON);
}
Modified:
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
---
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -36,7 +36,6 @@
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.RequestID;
import com.metamatrix.dqp.message.RequestMessage;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.server.serverapi.RequestInfo;
@@ -45,7 +44,7 @@
*/
public class TestDQPCoreRequestHandling extends TestCase {
- private static final String SESSION_STRING = new MetaMatrixSessionID(2).toString();
+ private static final String SESSION_STRING = "2";
public TestDQPCoreRequestHandling(String name) {
super(name);
@@ -143,7 +142,7 @@
if (workContext == null) {
workContext = new DQPWorkContext();
- workContext.setSessionToken(new SessionToken(new
MetaMatrixSessionID(Long.valueOf(id.getConnectionID())), "foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(Long.valueOf(id.getConnectionID()),
"foo")); //$NON-NLS-1$
}
RequestWorkItem workItem = new RequestWorkItem(rm, requestMsg, null, null, id,
workContext);
workItem.setOriginalCommand(originalCommand);
Modified:
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
===================================================================
---
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -22,12 +22,9 @@
package org.teiid.dqp.internal.process;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
import junit.framework.TestCase;
import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
public class TestDQPWorkContext extends TestCase {
@@ -46,7 +43,7 @@
message.setVdbName("vdbName"); //$NON-NLS-1$
message.setVdbVersion(1); //$NON-NLS-1$
message.setAppName("querybuilder"); //$NON-NLS-1$
- message.setSessionToken(new SessionToken(new MetaMatrixSessionID(5),
"userName")); //$NON-NLS-1$
+ message.setSessionToken(new SessionToken(5, "userName")); //$NON-NLS-1$
return message;
}
Modified:
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
---
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -43,7 +43,6 @@
import com.metamatrix.common.buffer.BufferManagerFactory;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.optimizer.TestOptimizer;
@@ -251,7 +250,7 @@
}
DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata,
vdb);
- workContext.setSessionToken(new SessionToken(new MetaMatrixSessionID(conn),
"foo")); //$NON-NLS-1$
+ workContext.setSessionToken(new SessionToken(conn, "foo"));
//$NON-NLS-1$
PreparedStatementRequest serverRequest = new
PreparedStatementRequest(prepPlanCache) {
@Override
Modified:
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
---
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -40,8 +40,6 @@
import com.metamatrix.common.buffer.BufferManager;
import com.metamatrix.dqp.message.RequestMessage;
import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.parser.QueryParser;
Modified:
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
===================================================================
---
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -295,7 +295,7 @@
assertEquals(1, server.getTransactions().size());
Transaction t = server.getTransactions().iterator().next();
- assertEquals(THREAD1, t.getAssociatedSession());
+ assertEquals(Long.parseLong(THREAD1), t.getAssociatedSession());
assertNotNull(t.getXid());
}
Property changes on: branches/JCA/jboss-embedded
___________________________________________________________________
Name: svn:ignore
- .settings
.project
.classpath
+ .settings
.project
.classpath
target
Modified: branches/JCA/jboss-integration/pom.xml
===================================================================
--- branches/JCA/jboss-integration/pom.xml 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/jboss-integration/pom.xml 2009-12-23 22:55:47 UTC (rev 1703)
@@ -14,7 +14,7 @@
<build>
<testResources>
<testResource>
- <directory>target/jboss-embedded</directory>
+ <directory>target/test-classes/jboss-embedded</directory>
</testResource>
</testResources>
<plugins>
@@ -35,7 +35,7 @@
<artifactId>teiid-jboss-embedded</artifactId>
<type>jar</type>
<overWrite>true</overWrite>
- <outputDirectory>target/jboss-embedded</outputDirectory>
+
<outputDirectory>target/test-classes/jboss-embedded</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
Modified:
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
---
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -41,10 +41,13 @@
import org.jboss.managed.api.DeploymentTemplateInfo;
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedOperation;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.values.CollectionValueSupport;
import org.jboss.metatype.api.values.MapCompositeValueSupport;
import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.jboss.profileservice.spi.NoSuchDeploymentException;
import org.jboss.profileservice.spi.ProfileService;
@@ -54,15 +57,18 @@
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.adminapi.ConnectorBinding;
import org.teiid.adminapi.Model;
+import org.teiid.adminapi.Session;
import org.teiid.adminapi.TeiidAdminMBean;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.Visibility;
import org.teiid.adminapi.impl.BaseAdmin;
import org.teiid.adminapi.impl.ConnectorBindingMetaData;
import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import com.metamatrix.core.CoreConstants;
+import com.metamatrix.platform.security.session.service.SessionServiceImpl;
@JMX(name="jboss.teiid:service=teiid-admin",
exposedInterface=TeiidAdminMBean.class, registerDirectly=true)
public class Admin extends BaseAdmin implements TeiidAdminMBean{
@@ -72,6 +78,7 @@
private static ComponentType MODELTYPE = new ComponentType("teiid",
"model");
private static ComponentType NOTXTYPE = new ComponentType("ConnectionFactory",
"NoTx");
private static ComponentType TXTYPE = new ComponentType("ConnectionFactory",
"Tx");
+ private static ComponentType SESSIONSTYPE = new ComponentType("teiid",
"sessions");
private ManagementView getView() throws AdminComponentException {
try {
@@ -427,4 +434,35 @@
return model;
}
+
+ @Override
+ public Collection<Session> getSessions() throws AdminException {
+ try {
+ Collection<Session> sessionList = new ArrayList<Session>();
+ ManagedComponent mc = getView().getComponent(SessionServiceImpl.class.getName(),
SESSIONSTYPE);
+ ManagedProperty mp = mc.getProperty("activeSessions");
+ MetaValue[] sessions = ((CollectionValueSupport)mp.getValue()).getElements();
+ for (MetaValue mv:sessions) {
+ sessionList.add((SessionMetadata)MetaValueFactory.getInstance().unwrap(mv));
+ }
+ return sessionList;
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void terminateSession(long sessionId) throws AdminException {
+ try {
+ ManagedComponent mc = getView().getComponent(SessionServiceImpl.class.getName(),
SESSIONSTYPE);
+ Set<ManagedOperation> operations = mc.getOperations();
+ for (ManagedOperation mo:operations) {
+ mo.getName().equals("terminate");
+ // TODO: Finish this. rareddy
+ }
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+
+ }
}
Modified:
branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
---
branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -76,5 +76,4 @@
//
// assertNull(admin.getVDB("TransactionsRevisited", 1));
}
-
}
Modified: branches/JCA/runtime/pom.xml
===================================================================
--- branches/JCA/runtime/pom.xml 2009-12-23 17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/pom.xml 2009-12-23 22:55:47 UTC (rev 1703)
@@ -41,14 +41,8 @@
<artifactId>teiid-engine</artifactId>
<type>test-jar</type>
</dependency>
- <!-- Will open this later on once runtime is fixed
<dependency>
<groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-jboss-integration</artifactId>
- </dependency>
- -->
- <dependency>
- <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-metadata</artifactId>
</dependency>
<dependency>
Modified:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
===================================================================
---
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -38,7 +37,6 @@
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.adminapi.Cache;
import org.teiid.adminapi.ExtensionModule;
-import org.teiid.adminapi.Session;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.internal.process.Util;
@@ -47,8 +45,6 @@
import com.metamatrix.admin.objects.MMLogConfiguration;
import com.metamatrix.admin.objects.MMPropertyDefinition;
import com.metamatrix.admin.objects.MMRequest;
-import com.metamatrix.admin.objects.MMSession;
-import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.config.api.ComponentTypeDefn;
import com.metamatrix.common.config.api.ConnectorBinding;
@@ -59,7 +55,6 @@
import com.metamatrix.common.vdb.api.VDBArchive;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.server.serverapi.RequestInfo;
@@ -206,10 +201,10 @@
com.metamatrix.common.queue.WorkerPoolStats stats =
(com.metamatrix.common.queue.WorkerPoolStats)src;
return Util.convertStats(stats, stats.getQueueName());
}
- else if (src != null && src instanceof MetaMatrixSessionInfo) {
- MetaMatrixSessionInfo conn = (MetaMatrixSessionInfo)src;
- return convertConnection(conn);
- }
+// else if (src != null && src instanceof MetaMatrixSessionInfo) {
+// MetaMatrixSessionInfo conn = (MetaMatrixSessionInfo)src;
+// return convertConnection(conn);
+// }
else if (src != null && src instanceof
com.metamatrix.common.config.api.ExtensionModule) {
com.metamatrix.common.config.api.ExtensionModule extModule =
(com.metamatrix.common.config.api.ExtensionModule)src;
return convertExtensionModule(extModule);
@@ -239,18 +234,18 @@
return module;
}
- private Session convertConnection(MetaMatrixSessionInfo src) {
- MMSession session = new MMSession(new String[] {src.getSessionID().toString()});
- session.setVDBName(src.getProductInfo(MMURL.JDBC.VDB_NAME));
- session.setVDBVersion(src.getProductInfo(MMURL.JDBC.VDB_VERSION));
- session.setApplicationName(src.getApplicationName());
- session.setIPAddress(src.getClientIp());
- session.setHostName(src.getClientHostname());
- session.setUserName(src.getUserName());
- session.setLastPingTime(src.getLastPingTime());
- session.setCreated(new Date(src.getTimeCreated()));
- return session;
- }
+// private Session convertConnection(MetaMatrixSessionInfo src) {
+// MMSession session = new MMSession(new String[]
{src.getSessionID().toString()});
+// session.setVDBName(src.getProductInfo(MMURL.JDBC.VDB_NAME));
+// session.setVDBVersion(src.getProductInfo(MMURL.JDBC.VDB_VERSION));
+// session.setApplicationName(src.getApplicationName());
+// session.setIPAddress(src.getClientIp());
+// session.setHostName(src.getClientHostname());
+// session.setUserName(src.getUserName());
+// session.setLastPingTime(src.getLastPingTime());
+// session.setCreated(new Date(src.getTimeCreated()));
+// return session;
+// }
/**
* Convert LogConfiguration to Admin Object
@@ -427,30 +422,30 @@
* @return
* @since 4.3
*/
- MetaMatrixSessionInfo getClientConnection(String identifier) throws AdminException {
- Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
- for (MetaMatrixSessionInfo info:sessions) {
- if (info.getSessionID().toString().equals(identifier)) {
- return info;
- }
- }
- return null;
- }
+// MetaMatrixSessionInfo getClientConnection(String identifier) throws AdminException
{
+// Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
+// for (MetaMatrixSessionInfo info:sessions) {
+// if (info.getSessionID().toString().equals(identifier)) {
+// return info;
+// }
+// }
+// return null;
+// }
/**
* Get all the available connections
* @return
* @throws AdminException
*/
- Collection<MetaMatrixSessionInfo> getClientConnections() throws AdminException
{
+// Collection<MetaMatrixSessionInfo> getClientConnections() throws
AdminException {
// try {
// return getSessionService().getActiveSessions();
// } catch (SessionServiceException e) {
// // SessionServiceException not in the client known exception (in common-internal)
// throw new AdminComponentException(e.getMessage(), e.getCause());
// }
- return null;
- }
+// return null;
+// }
boolean matches(String regEx, String value) {
regEx = regEx.replaceAll(AdminObject.ESCAPED_WILDCARD, ".*");
//$NON-NLS-1$
Modified:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
===================================================================
---
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -219,11 +219,12 @@
*/
public Collection<Session> getSessions(String identifier)
throws AdminException {
-
- if (identifier == null || !identifier.matches(NUMBER_REGEX)) {
- throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
- }
- return matchedCollection(identifier,
(List)convertToAdminObjects(getClientConnections()));
+//
+// if (identifier == null || !identifier.matches(NUMBER_REGEX)) {
+// throw new
AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier"));
//$NON-NLS-1$
+// }
+// return matchedCollection(identifier,
(List)convertToAdminObjects(getClientConnections()));
+ return null;
}
/**
Modified:
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
===================================================================
---
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -22,30 +22,21 @@
package com.metamatrix.dqp.embedded.admin;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
import javax.transaction.xa.Xid;
import org.teiid.adminapi.AdminComponentException;
import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminObject;
import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.Cache;
-import org.teiid.adminapi.ConnectorBinding;
import org.teiid.adminapi.Request;
import org.teiid.adminapi.RuntimeStateAdmin;
-import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.admin.objects.MMRequest;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.service.TransactionService;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
/**
Modified:
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java
===================================================================
---
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/runtime/src/main/java/com/metamatrix/platform/security/session/service/SessionServiceImpl.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -39,6 +39,12 @@
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
+import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.deployers.VDBRepository;
@@ -53,14 +59,14 @@
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseException;
import com.metamatrix.platform.security.api.Credentials;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.security.api.service.SessionService;
import com.metamatrix.platform.security.membership.service.MembershipServiceImpl;
/**
* This class serves as the primary implementation of the Session Service.
*/
+@ManagementObject(isRuntime=true,
componentType=@ManagementComponent(type="teiid",subtype="sessions"),
properties=ManagementProperties.EXPLICIT)
public class SessionServiceImpl implements SessionService, Serializable {
private static final long serialVersionUID = 3366022966048148299L;
@@ -73,7 +79,7 @@
private long sessionExpirationTimeLimit = DEFAULT_SESSION_EXPIRATION;
private VDBRepository vdbRepository;
- private Map<MetaMatrixSessionID, MetaMatrixSessionInfo> sessionCache = new
ConcurrentHashMap<MetaMatrixSessionID, MetaMatrixSessionInfo>();
+ private Map<Long, SessionMetadata> sessionCache = new
ConcurrentHashMap<Long, SessionMetadata>();
private transient Timer sessionMonitor = new Timer("SessionMonitor",
true);
private AtomicLong idSequence = new AtomicLong();
private boolean isSecurityEnabled = false;
@@ -86,33 +92,34 @@
private void monitorSessions() {
long currentTime = System.currentTimeMillis();
- for (MetaMatrixSessionInfo info : sessionCache.values()) {
+ for (SessionMetadata info : sessionCache.values()) {
try {
if (currentTime - info.getLastPingTime() > ServerConnection.PING_INTERVAL * 5)
{
- LogManager.logInfo(LogConstants.CTX_SESSION, DQPEmbeddedPlugin.Util.getString(
"SessionServiceImpl.keepaliveFailed", info.getSessionID())); //$NON-NLS-1$
- closeSession(info.getSessionID());
- } else if (sessionExpirationTimeLimit > 0 && currentTime -
info.getTimeCreated() > sessionExpirationTimeLimit) {
- LogManager.logInfo(LogConstants.CTX_SESSION, DQPEmbeddedPlugin.Util.getString(
"SessionServiceImpl.expireSession", info.getSessionID())); //$NON-NLS-1$
- closeSession(info.getSessionID());
+ LogManager.logInfo(LogConstants.CTX_SESSION, DQPEmbeddedPlugin.Util.getString(
"SessionServiceImpl.keepaliveFailed", info.getSessionId())); //$NON-NLS-1$
+ closeSession(info.getSessionId());
+ } else if (sessionExpirationTimeLimit > 0 && currentTime -
info.getCreatedTime() > sessionExpirationTimeLimit) {
+ LogManager.logInfo(LogConstants.CTX_SESSION, DQPEmbeddedPlugin.Util.getString(
"SessionServiceImpl.expireSession", info.getSessionId())); //$NON-NLS-1$
+ closeSession(info.getSessionId());
}
} catch (Exception e) {
- LogManager.logDetail(LogConstants.CTX_SESSION, e, "error running session
monitor, unable to monitor: " + info.getSessionID()); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_SESSION, e, "error running session
monitor, unable to monitor: " + info.getSessionId()); //$NON-NLS-1$
}
}
}
@Override
- public void closeSession(MetaMatrixSessionID sessionID) throws InvalidSessionException
{
+ public void closeSession(long sessionID) throws InvalidSessionException {
LogManager.logDetail(LogConstants.CTX_SESSION, new Object[] {"closeSession",
sessionID}); //$NON-NLS-1$
- MetaMatrixSessionInfo info = this.sessionCache.remove(sessionID);
+ SessionMetadata info = this.sessionCache.remove(sessionID);
if (info == null) {
throw new
InvalidSessionException(DQPEmbeddedPlugin.Util.getString("SessionServiceImpl.invalid_session",
sessionID)); //$NON-NLS-1$
}
// try to log out of the context.
try {
- if (info.getLoginContext() != null) {
- info.getLoginContext().logout();
+ LoginContext context = info.getAttachment(LoginContext.class);
+ if (context != null) {
+ context.logout();
}
} catch (LoginException e) {
LogManager.logWarning(LogConstants.CTX_SESSION,e,"Exception terminitating
session"); //$NON-NLS-1$
@@ -120,7 +127,7 @@
}
@Override
- public MetaMatrixSessionInfo createSession(String userName, Credentials credentials,
String applicationName, Properties properties)
+ public SessionMetadata createSession(String userName, Credentials credentials, String
applicationName, Properties properties)
throws LoginException, SessionServiceException {
ArgCheck.isNotNull(applicationName);
ArgCheck.isNotNull(properties);
@@ -151,14 +158,14 @@
}
else {
vdb = this.vdbRepository.getVDB(vdbName, Integer.parseInt(vdbVersion));
- }
+ }
+
+ // Reset product info with validated constants
+ productInfo.put(MMURL.JDBC.VDB_NAME, vdb.getName());
+ productInfo.put(MMURL.JDBC.VDB_VERSION, vdb.getVersion());
} catch (VirtualDatabaseException e) {
throw new
SessionServiceException(DQPEmbeddedPlugin.Util.getString("VDBService.VDB_does_not_exist._2",
vdbName, vdbVersion==null?"latest":vdbVersion)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Reset product info with validated constants
- productInfo.put(MMURL.JDBC.VDB_NAME, vdb.getName());
- productInfo.put(MMURL.JDBC.VDB_VERSION, vdb.getVersion());
+ }
}
if (sessionMaxLimit > 0 && getActiveSessionsCount() >=
sessionMaxLimit) {
@@ -167,22 +174,28 @@
long creationTime = System.currentTimeMillis();
- // Get a new ID for this new session record
- MetaMatrixSessionID id = new MetaMatrixSessionID(idSequence.getAndIncrement());
-
// Return a new session info object
- MetaMatrixSessionInfo newSession = new MetaMatrixSessionInfo(id,
- userName,
- loginContext,
- securityDomain,
- securityContext,
- creationTime,
- applicationName,
- productInfo,
-
properties.getProperty(MMURL.CONNECTION.CLIENT_IP_ADDRESS),
-
properties.getProperty(MMURL.CONNECTION.CLIENT_HOSTNAME),
- vdb);
- this.sessionCache.put(newSession.getSessionID(), newSession);
+ long id = idSequence.getAndIncrement();
+ SessionMetadata newSession = new SessionMetadata();
+ newSession.setSessionId(id);
+ newSession.setUserName(userName);
+ newSession.setCreatedTime(creationTime);
+ newSession.setApplicationName(applicationName);
+
newSession.setClientHostName(properties.getProperty(MMURL.CONNECTION.CLIENT_HOSTNAME));
+
newSession.setIPAddress(properties.getProperty(MMURL.CONNECTION.CLIENT_IP_ADDRESS));
+ newSession.setSecurityDomain(securityDomain);
+ if (vdb != null) {
+ newSession.setVDBName(vdb.getName());
+ newSession.setVDBVersion(vdb.getVersion());
+ }
+
+ // these are local no need for monitoring.
+ newSession.addAttchment(LoginContext.class, loginContext);
+ newSession.addAttchment("SecurityContext", securityContext);
+ newSession.addAttchment(VDBMetaData.class, vdb);
+ newSession.addAttchment(SessionToken.class, new SessionToken(id, userName));
+
+ this.sessionCache.put(newSession.getSessionId(), newSession);
return newSession;
}
@@ -194,29 +207,31 @@
}
@Override
- public Collection<MetaMatrixSessionInfo> getActiveSessions() throws
SessionServiceException {
- return new ArrayList<MetaMatrixSessionInfo>(this.sessionCache.values());
+ @ManagementProperty(description="Active sessions", use={ViewUse.STATISTIC},
readOnly=true)
+ public Collection<SessionMetadata> getActiveSessions() throws
SessionServiceException {
+ return new ArrayList<SessionMetadata>(this.sessionCache.values());
}
@Override
- public MetaMatrixSessionInfo getActiveSession(MetaMatrixSessionID sessionID) {
+ public SessionMetadata getActiveSession(long sessionID) {
return this.sessionCache.get(sessionID);
}
@Override
+ @ManagementProperty(description="Active session count",
use={ViewUse.STATISTIC}, readOnly=true)
public int getActiveSessionsCount() throws SessionServiceException{
return this.sessionCache.size();
}
@Override
- public Collection<MetaMatrixSessionInfo> getSessionsLoggedInToVDB(String VDBName,
String VDBVersion)
+ public Collection<SessionMetadata> getSessionsLoggedInToVDB(String VDBName, int
vdbVersion)
throws SessionServiceException {
- if (VDBName == null || VDBVersion == null) {
+ if (VDBName == null || vdbVersion <= 0) {
return Collections.emptyList();
}
- ArrayList<MetaMatrixSessionInfo> results = new
ArrayList<MetaMatrixSessionInfo>();
- for (MetaMatrixSessionInfo info : this.sessionCache.values()) {
- if (VDBName.equalsIgnoreCase(info.getProductInfo(MMURL.JDBC.VDB_NAME)) &&
VDBVersion.equalsIgnoreCase(info.getProductInfo(MMURL.JDBC.VDB_VERSION))) {
+ ArrayList<SessionMetadata> results = new ArrayList<SessionMetadata>();
+ for (SessionMetadata info : this.sessionCache.values()) {
+ if (VDBName.equalsIgnoreCase(info.getVDBName()) && vdbVersion ==
info.getVDBVersion()) {
results.add(info);
}
}
@@ -224,15 +239,14 @@
}
@Override
- public void pingServer(MetaMatrixSessionID sessionID)
- throws InvalidSessionException {
- MetaMatrixSessionInfo info = getSessionInfo(sessionID);
+ public void pingServer(long sessionID) throws InvalidSessionException {
+ SessionMetadata info = getSessionInfo(sessionID);
info.setLastPingTime(System.currentTimeMillis());
this.sessionCache.put(sessionID, info);
}
@Override
- public boolean terminateSession(MetaMatrixSessionID
terminatedSessionID,MetaMatrixSessionID adminSessionID) {
+ public boolean terminateSession(long terminatedSessionID, long adminSessionID) {
Object[] params = {adminSessionID, terminatedSessionID};
LogManager.logInfo(LogConstants.CTX_SESSION, DQPEmbeddedPlugin.Util.getString(
"SessionServiceImpl.terminateSession", params)); //$NON-NLS-1$
try {
@@ -245,15 +259,14 @@
}
@Override
- public MetaMatrixSessionInfo validateSession(MetaMatrixSessionID sessionID)
- throws InvalidSessionException, SessionServiceException {
- MetaMatrixSessionInfo info = getSessionInfo(sessionID);
+ public SessionMetadata validateSession(long sessionID) throws InvalidSessionException,
SessionServiceException {
+ SessionMetadata info = getSessionInfo(sessionID);
return info;
}
- private MetaMatrixSessionInfo getSessionInfo(MetaMatrixSessionID sessionID)
+ private SessionMetadata getSessionInfo(long sessionID)
throws InvalidSessionException {
- MetaMatrixSessionInfo info = this.sessionCache.get(sessionID);
+ SessionMetadata info = this.sessionCache.get(sessionID);
if (info == null) {
throw new
InvalidSessionException(DQPEmbeddedPlugin.Util.getString("SessionServiceImpl.invalid_session",
sessionID)); //$NON-NLS-1$
}
@@ -299,8 +312,8 @@
}
@Override
- public void setLocalSession(MetaMatrixSessionID sessionID) {
- MetaMatrixSessionInfo info = this.sessionCache.get(sessionID);
+ public void setLocalSession(long sessionID) {
+ SessionMetadata info = this.sessionCache.get(sessionID);
if (info != null) {
info.setLastPingTime(Long.MAX_VALUE);
}
Modified:
branches/JCA/runtime/src/main/java/org/teiid/transport/AdminAuthorizationInterceptor.java
===================================================================
---
branches/JCA/runtime/src/main/java/org/teiid/transport/AdminAuthorizationInterceptor.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/runtime/src/main/java/org/teiid/transport/AdminAuthorizationInterceptor.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -136,7 +136,7 @@
* @since 5.0
*/
private Object[] buildAuditMessage(SessionToken adminToken, String requiredRoleName,
Method invocation) {
- return new Object[] {adminToken.getUsername(),
adminToken.getSessionID().toString(), requiredRoleName, invocation.getName()};
+ return new Object[] {adminToken.getUsername(), adminToken.getSessionID(),
requiredRoleName, invocation.getName()};
}
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2009-12-23
17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -24,8 +24,11 @@
import java.util.Properties;
+import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
@@ -42,8 +45,6 @@
import com.metamatrix.platform.security.api.Credentials;
import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.LogonResult;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.security.api.service.SessionService;
@@ -73,10 +74,10 @@
}
try {
- MetaMatrixSessionInfo sessionInfo = service.createSession(user,credential,
applicationName, connProps);
- MetaMatrixSessionID sessionID = updateDQPContext(sessionInfo);
+ 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$
- return new LogonResult(sessionInfo.getSessionToken(), sessionInfo.getProductInfo(),
clusterName);
+ return new LogonResult(sessionInfo.getAttachment(SessionToken.class),
sessionInfo.getVDBName(), sessionInfo.getVDBVersion(), clusterName);
} catch (LoginException e) {
throw new LogonException(e.getMessage());
} catch (SessionServiceException e) {
@@ -84,19 +85,26 @@
}
}
- private MetaMatrixSessionID updateDQPContext(MetaMatrixSessionInfo sessionInfo) {
- MetaMatrixSessionID sessionID = sessionInfo.getSessionID();
+ private long updateDQPContext(SessionMetadata s) {
+ long sessionID = s.getSessionId();
+
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- workContext.setSessionToken(sessionInfo.getSessionToken());
- workContext.setAppName(sessionInfo.getApplicationName());
- workContext.setVdbName(sessionInfo.getVDB().getName());
- workContext.setVdbVersion(sessionInfo.getVDB().getVersion());
- if (sessionInfo.getLoginContext() != null) {
- workContext.setSubject(sessionInfo.getLoginContext().getSubject());
- workContext.setSecurityDomain(sessionInfo.getSecurityDomain());
- workContext.setSecurityContext(sessionInfo.getSecurityContext());
+ workContext.setSessionToken(s.getAttachment(SessionToken.class));
+ workContext.setAppName(s.getApplicationName());
+
+ LoginContext loginContext = s.getAttachment(LoginContext.class);
+ if (loginContext != null) {
+ workContext.setSubject(loginContext.getSubject());
+ workContext.setSecurityDomain(s.getSecurityDomain());
+ workContext.setSecurityContext(s.getAttachment("SecurityContext"));
}
- workContext.setVdb(sessionInfo.getVDB());
+
+ VDBMetaData vdb = s.getAttachment(VDBMetaData.class);
+ if (vdb != null) {
+ workContext.setVdbName(vdb.getName());
+ workContext.setVdbVersion(vdb.getVersion());
+ workContext.setVdb(vdb);
+ }
return sessionID;
}
@@ -109,36 +117,41 @@
public ResultsFuture<?> ping() throws
InvalidSessionException,MetaMatrixComponentException {
// ping is double used to alert the aliveness of the client, as well as check the
server instance is
// alive by socket server instance, so that they can be cached.
- MetaMatrixSessionID id = DQPWorkContext.getWorkContext().getSessionId();
- if (id != null) {
+ long id = DQPWorkContext.getWorkContext().getSessionId();
+ if (id != -1) {
this.service.pingServer(id);
}
return null;
}
@Override
- public void assertIdentity(SessionToken sessionId) throws InvalidSessionException,
MetaMatrixComponentException {
- MetaMatrixSessionInfo sessionInfo;
+ public void assertIdentity(SessionToken checkSession) throws InvalidSessionException,
MetaMatrixComponentException {
+ SessionMetadata sessionInfo = null;
try {
- sessionInfo = this.service.validateSession(sessionId.getSessionID());
+ sessionInfo = this.service.validateSession(checkSession.getSessionID());
} catch (SessionServiceException e) {
throw new MetaMatrixComponentException(e);
}
- if (!sessionInfo.getSessionToken().equals(sessionInfo.getSessionToken())) {
+ if (sessionInfo == null) {
throw new InvalidSessionException();
}
+
+ SessionToken st = sessionInfo.getAttachment(SessionToken.class);
+ if (!st.equals(checkSession)) {
+ throw new InvalidSessionException();
+ }
this.updateDQPContext(sessionInfo);
}
@Override
public void terminate(SessionToken terminatee) {
- MetaMatrixSessionID terminator = DQPWorkContext.getWorkContext().getSessionId();
+ long terminator = DQPWorkContext.getWorkContext().getSessionId();
- MetaMatrixSessionInfo info = this.service.getActiveSession(terminatee.getSessionID());
+ SessionMetadata info = this.service.getActiveSession(terminatee.getSessionID());
if (info != null) {
try {
- if (info.getProductInfo(MMURL.JDBC.VDB_NAME) != null) {
+ if (info.getVDBName() != null) {
this.dqpService.terminateConnection(terminatee.getSessionID());
}
} catch (MetaMatrixComponentException e) {
Modified:
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/TestAdminAuthInterceptor.java
===================================================================
---
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/TestAdminAuthInterceptor.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/TestAdminAuthInterceptor.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -42,7 +42,6 @@
import com.metamatrix.api.exception.security.AuthorizationMgmtException;
import com.metamatrix.core.util.SimpleMock;
import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
@@ -53,7 +52,7 @@
@Before public void setUp() throws Exception {
DQPWorkContext.setWorkContext(new DQPWorkContext());
- DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(new
MetaMatrixSessionID(1), "gojo")); //$NON-NLS-1$
+ DQPWorkContext.getWorkContext().setSessionToken(new SessionToken(1,
"gojo")); //$NON-NLS-1$
}
@After public void tearDown() throws Exception {
@@ -108,7 +107,7 @@
@Test(expected=AdminProcessingException.class) public void testReadOnlyFails() throws
Exception {
Set<String> userRoles = new HashSet<String>();
Admin serverAdmin = getTestServerAdmin(userRoles, Admin.class);
- serverAdmin.getSessions("*"); //$NON-NLS-1$
+ serverAdmin.getSessions(); //$NON-NLS-1$
}
@Test public void testBounce_succeed() throws Exception {
Modified:
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java
===================================================================
---
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java 2009-12-23
17:10:18 UTC (rev 1702)
+++
branches/JCA/runtime/src/test/java/com/metamatrix/platform/security/session/service/TestSessionServiceImpl.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -11,11 +11,10 @@
import org.junit.Test;
import org.mockito.Mockito;
+import org.teiid.adminapi.impl.SessionMetadata;
import com.metamatrix.admin.api.exception.security.InvalidSessionException;
import com.metamatrix.platform.security.api.Credentials;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
import com.metamatrix.platform.security.membership.service.MembershipServiceImpl;
public class TestSessionServiceImpl {
@@ -37,24 +36,23 @@
ssi.setSecurityDomains("somedomain");
- MetaMatrixSessionID id1 = new MetaMatrixSessionID(1);
try {
- ssi.validateSession(id1);
+ ssi.validateSession(1);
fail("exception expected"); //$NON-NLS-1$
} catch (InvalidSessionException e) {
}
- MetaMatrixSessionInfo info = ssi.createSession("steve", null,
"foo", new Properties()); //$NON-NLS-1$ //$NON-NLS-2$
+ SessionMetadata info = ssi.createSession("steve", null, "foo", new
Properties()); //$NON-NLS-1$ //$NON-NLS-2$
if (securityEnabled) {
Mockito.verify(impl).authenticateUser("steve", null, "foo",
domains);
}
- id1 = info.getSessionID();
+ long id1 = info.getSessionId();
ssi.validateSession(id1);
assertEquals(1, ssi.getActiveSessionsCount());
- assertEquals(0, ssi.getSessionsLoggedInToVDB("a", "1").size());
//$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals(0, ssi.getSessionsLoggedInToVDB("a", 1).size()); //$NON-NLS-1$
//$NON-NLS-2$
ssi.closeSession(id1);
Modified: branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2009-12-23
17:10:18 UTC (rev 1702)
+++ branches/JCA/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2009-12-23
22:55:47 UTC (rev 1703)
@@ -28,13 +28,12 @@
import junit.framework.TestCase;
import org.mockito.Mockito;
-import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.common.api.MMURL;
import com.metamatrix.platform.security.api.LogonResult;
-import com.metamatrix.platform.security.api.MetaMatrixSessionID;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
+import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.security.api.service.SessionService;
public class TestLogonImpl extends TestCase {
@@ -48,18 +47,19 @@
p.setProperty(MMURL.CONNECTION.USER_NAME, userName);
p.setProperty(MMURL.CONNECTION.APP_NAME, applicationName);
- MetaMatrixSessionInfo resultInfo = new MetaMatrixSessionInfo(
- new MetaMatrixSessionID(1), userName, null, "securitydomain", null, 0,
applicationName, new Properties(),
- null, null, Mockito.mock(VDBMetaData.class));
+ SessionMetadata session = new SessionMetadata();
+ session.setUserName(userName);
+ session.setApplicationName(applicationName);
+ session.setSessionId(1);
+ session.addAttchment(SessionToken.class, new SessionToken(1, userName));
- Mockito.stub(ssi.createSession(userName, null, applicationName,
- p)).toReturn(resultInfo);
+ Mockito.stub(ssi.createSession(userName, null, applicationName,p)).toReturn(session);
LogonImpl impl = new LogonImpl(ssi, null, "fakeCluster"); //$NON-NLS-1$
LogonResult result = impl.logon(p);
assertEquals(userName, result.getUserName());
- assertEquals(new MetaMatrixSessionID(1), result.getSessionID());
+ assertEquals(1, result.getSessionID());
}