[teiid-commits] teiid SVN: r2832 - in branches/7.1.x/console/src/main/java/org/teiid/rhq: plugin/objects and 1 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Jan 11 16:28:40 EST 2011


Author: tejones
Date: 2011-01-11 16:28:40 -0500 (Tue, 11 Jan 2011)
New Revision: 2832

Added:
   branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/RequestMetadata.java
   branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/SessionMetadata.java
   branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/TransactionMetadata.java
Modified:
   branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
   branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
Log:
TEIID-1427 - Fix for ClassDefNotFound exceptions

Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java	2011-01-11 21:18:44 UTC (rev 2831)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java	2011-01-11 21:28:40 UTC (rev 2832)
@@ -40,6 +40,7 @@
 import org.jboss.managed.plugins.ManagedObjectImpl;
 import org.jboss.metatype.api.types.MetaType;
 import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.CompositeValue;
 import org.jboss.metatype.api.values.CompositeValueSupport;
 import org.jboss.metatype.api.values.GenericValueSupport;
 import org.jboss.metatype.api.values.MetaValue;
@@ -47,15 +48,12 @@
 import org.jboss.metatype.api.values.SimpleValueSupport;
 import org.rhq.plugins.jbossas5.connection.ProfileServiceConnection;
 import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.Request;
-import org.teiid.adminapi.Session;
-import org.teiid.adminapi.Transaction;
+import org.teiid.adminapi.Request.ProcessingState;
 import org.teiid.adminapi.VDB.Status;
-import org.teiid.adminapi.impl.RequestMetadata;
-import org.teiid.adminapi.impl.RequestMetadataMapper;
-import org.teiid.adminapi.impl.SessionMetadataMapper;
-import org.teiid.adminapi.impl.TransactionMetadataMapper;
 import org.teiid.rhq.plugin.objects.ExecutedResult;
+import org.teiid.rhq.plugin.objects.RequestMetadata;
+import org.teiid.rhq.plugin.objects.SessionMetadata;
+import org.teiid.rhq.plugin.objects.TransactionMetadata;
 import org.teiid.rhq.plugin.util.DeploymentUtils;
 import org.teiid.rhq.plugin.util.PluginConstants;
 import org.teiid.rhq.plugin.util.ProfileServiceUtil;
@@ -68,7 +66,32 @@
 	private static final Log LOG = LogFactory.getLog(PluginConstants.DEFAULT_LOGGER_CATEGORY);
 
 	private static final String VDB_EXT = ".vdb"; //$NON-NLS-1$
+	
+	//Session metadata fields
+	private static final String SECURITY_DOMAIN = "securityDomain"; //$NON-NLS-1$
+	private static final String VDB_VERSION = "VDBVersion"; //$NON-NLS-1$
+	private static final String VDB_NAME = "VDBName"; //$NON-NLS-1$
+	private static final String USER_NAME = "userName"; //$NON-NLS-1$
+	private static final String SESSION_ID = "sessionId"; //$NON-NLS-1$
+	private static final String LAST_PING_TIME = "lastPingTime"; //$NON-NLS-1$
+	private static final String IP_ADDRESS = "IPAddress"; //$NON-NLS-1$
+	private static final String CLIENT_HOST_NAME = "clientHostName"; //$NON-NLS-1$
+	private static final String CREATED_TIME = "createdTime"; //$NON-NLS-1$
+	private static final String APPLICATION_NAME = "applicationName"; //$NON-NLS-1$
 
+	//Request metadata fields
+	private static final String TRANSACTION_ID = "transactionId"; //$NON-NLS-1$
+	private static final String NODE_ID = "nodeId"; //$NON-NLS-1$
+	private static final String SOURCE_REQUEST = "sourceRequest"; //$NON-NLS-1$
+	private static final String COMMAND = "command"; //$NON-NLS-1$
+	private static final String START_TIME = "startTime"; //$NON-NLS-1$
+	private static final String EXECUTION_ID = "executionId"; //$NON-NLS-1$
+	private static final String STATE = "processingState"; //$NON-NLS-1$
+	
+	//Transaction metadata fields
+	private static final String SCOPE = "scope"; //$NON-NLS-1$
+	private static final String ASSOCIATED_SESSION = "associatedSession"; //$NON-NLS-1$
+	
 	public DQPManagementView() {
 	}
 
@@ -77,7 +100,7 @@
 	 */
 	public Object getMetric(ProfileServiceConnection connection,
 			String componentType, String identifier, String metric,
-			Map<String, Object> valueMap) {
+			Map<String, Object> valueMap) throws Exception {
 		Object resultObject = new Object();
 
 		if (componentType.equals(PluginConstants.ComponentType.Platform.NAME)) {
@@ -89,7 +112,7 @@
 	}
 
 	private Object getPlatformMetric(ProfileServiceConnection connection,
-			String componentType, String metric, Map<String, Object> valueMap) {
+			String componentType, String metric, Map<String, Object> valueMap) throws Exception {
 
 		Object resultObject = new Object();
 
@@ -98,7 +121,7 @@
 		} else if (metric.equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
 			resultObject = new Double(getSessionCount(connection).doubleValue());
 		} else if (metric.equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
-			Collection<Request> longRunningQueries = new ArrayList<Request>();
+			Collection<RequestMetadata> longRunningQueries = new ArrayList<RequestMetadata>();
 			getRequestCollectionValue(getLongRunningQueries(connection),	longRunningQueries);
 			resultObject = new Double(longRunningQueries.size());
 		} else if (metric.equals(PluginConstants.ComponentType.Platform.Metrics.BUFFER_USAGE)) {
@@ -126,7 +149,7 @@
 
 	private Object getVdbMetric(ProfileServiceConnection connection,
 			String componentType, String identifier, String metric,
-			Map<String, Object> valueMap) {
+			Map<String, Object> valueMap) throws Exception {
 
 		Object resultObject = new Object();
 
@@ -141,7 +164,7 @@
 		} else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.SESSION_COUNT)) {
 			resultObject = new Double(getSessionCount(connection).doubleValue());
 		} else if (metric.equals(PluginConstants.ComponentType.VDB.Metrics.LONG_RUNNING_QUERIES)) {
-			Collection<Request> longRunningQueries = new ArrayList<Request>();
+			Collection<RequestMetadata> longRunningQueries = new ArrayList<RequestMetadata>();
 			getRequestCollectionValue(getLongRunningQueries(connection),	longRunningQueries);
 			resultObject = new Double(longRunningQueries.size());
 		}
@@ -164,10 +187,10 @@
 
 	private void executePlatformOperation(ProfileServiceConnection connection,
 			ExecutedResult operationResult, final String operationName,
-			final Map<String, Object> valueMap) {
-		Collection<Request> resultObject = new ArrayList<Request>();
-		Collection<Session> activeSessionsCollection = new ArrayList<Session>();
-		Collection<Transaction> transactionsCollection = new ArrayList<Transaction>();
+			final Map<String, Object> valueMap) throws Exception {
+		Collection<RequestMetadata> resultObject = new ArrayList<RequestMetadata>();
+		Collection<SessionMetadata> activeSessionsCollection = new ArrayList<SessionMetadata>();
+		Collection<TransactionMetadata> transactionsCollection = new ArrayList<TransactionMetadata>();
 
 		if (operationName.equals(Platform.Operations.GET_LONGRUNNINGQUERIES)) {
 			List<String> fieldNameList = operationResult.getFieldNameList();
@@ -249,8 +272,8 @@
 			ExecutedResult operationResult, final String operationName,
 			final Map<String, Object> valueMap) throws Exception {
 		Collection<ArrayList<String>> sqlResultsObject = new ArrayList<ArrayList<String>>();
-		Collection<Request> resultObject = new ArrayList<Request>();
-		Collection<Session> activeSessionsCollection = new ArrayList<Session>();
+		Collection<RequestMetadata> resultObject = new ArrayList<RequestMetadata>();
+		Collection<SessionMetadata> activeSessionsCollection = new ArrayList<SessionMetadata>();
 		String vdbName = (String) valueMap.get(PluginConstants.ComponentType.VDB.NAME);
 		vdbName = formatVdbName(vdbName);
 		String vdbVersion = (String) valueMap.get(PluginConstants.ComponentType.VDB.VERSION);
@@ -565,12 +588,12 @@
 		throw new Exception("No property found with given name =" + property); //$NON-NLS-1$
 	}
 
-	private Integer getQueryCount(ProfileServiceConnection connection) {
+	private Integer getQueryCount(ProfileServiceConnection connection) throws Exception {
 
 		Integer count = new Integer(0);
 
 		MetaValue requests = null;
-		Collection<Request> requestsCollection = new ArrayList<Request>();
+		Collection<RequestMetadata> requestsCollection = new ArrayList<RequestMetadata>();
 
 		requests = getRequests(connection);
 
@@ -583,9 +606,9 @@
 		return count;
 	}
 
-	private Integer getSessionCount(ProfileServiceConnection connection) {
+	private Integer getSessionCount(ProfileServiceConnection connection) throws Exception {
 
-		Collection<Session> activeSessionsCollection = new ArrayList<Session>();
+		Collection<SessionMetadata> activeSessionsCollection = new ArrayList<SessionMetadata>();
 		MetaValue sessionMetaValue = getSessions(connection);
 		getSessionCollectionValue(sessionMetaValue, activeSessionsCollection);
 		return activeSessionsCollection.size();
@@ -677,13 +700,12 @@
 		return usedBufferSpace;
 	}
 
-	private void getRequestCollectionValue(MetaValue pValue, Collection<Request> list) {
+	private void getRequestCollectionValue(MetaValue pValue, Collection<RequestMetadata> list) throws Exception {
 		MetaType metaType = pValue.getMetaType();
 		if (metaType.isCollection()) {
 			for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
 				if (value.getMetaType().isComposite()) {
-					RequestMetadataMapper rmm = new RequestMetadataMapper(); 
-					RequestMetadata request = rmm.unwrapMetaValue(value);
+					RequestMetadata request = unwrapRequestMetaValue(value);
 					list.add(request);
 				} else {
 					throw new IllegalStateException(pValue + " is not a Composite type"); //$NON-NLS-1$
@@ -722,13 +744,12 @@
 		}
 	}
 
-	public static <T> void getTransactionCollectionValue(MetaValue pValue, Collection<Transaction> list) {
+	public <T> void getTransactionCollectionValue(MetaValue pValue, Collection<TransactionMetadata> list) throws Exception {
 		MetaType metaType = pValue.getMetaType();
 		if (metaType.isCollection()) {
 			for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
 				if (value.getMetaType().isComposite()) {
-					TransactionMetadataMapper tmm = new TransactionMetadataMapper(); 
-					Transaction transaction = tmm.unwrapMetaValue(value);
+					TransactionMetadata transaction = unwrapTransactionMetaValue(value);
 					list.add(transaction);
 				} else {
 					throw new IllegalStateException(pValue
@@ -738,13 +759,12 @@
 		}
 	}
 
-	public static <T> void getSessionCollectionValue(MetaValue pValue,Collection<Session> list) {
+	public <T> void getSessionCollectionValue(MetaValue pValue,Collection<SessionMetadata> list) throws Exception {
 		MetaType metaType = pValue.getMetaType();
 		if (metaType.isCollection()) {
 			for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
 				if (value.getMetaType().isComposite()) {
-					SessionMetadataMapper rmm = new SessionMetadataMapper(); 
-					Session session = rmm.unwrapMetaValue(value);
+					SessionMetadata session = unwrapSessionMetaValue(value);
 					list.add(session);
 				} else {
 					throw new IllegalStateException(pValue
@@ -754,14 +774,13 @@
 		}
 	}
 
-	public static <T> void getSessionCollectionValueForVDB(MetaValue pValue,Collection<Session> list, String vdbName) throws Exception {
+	public <T> void getSessionCollectionValueForVDB(MetaValue pValue,Collection<SessionMetadata> list, String vdbName) throws Exception {
 		MetaType metaType = pValue.getMetaType();
 		if (metaType.isCollection()) {
 			for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
 				if (value.getMetaType().isComposite()) {
 					if (ProfileServiceUtil.stringValue(((CompositeValueSupport)value).get("VDBName")).equals(vdbName)) { //$NON-NLS-1$
-						SessionMetadataMapper rmm = new SessionMetadataMapper(); 
-						Session session = rmm.unwrapMetaValue(value);
+						SessionMetadata session = unwrapSessionMetaValue(value);
 						list.add(session);
 					}
 				} else {
@@ -819,5 +838,66 @@
 		}
 		return reportResultList;
 	}
+	
+	public SessionMetadata unwrapSessionMetaValue(MetaValue metaValue) throws Exception {
+		if (metaValue == null)
+			return null;
 
+		if (metaValue instanceof CompositeValue) {
+			CompositeValueSupport compositeValue = (CompositeValueSupport) metaValue;
+			
+			SessionMetadata session = new SessionMetadata();
+			session.setApplicationName((String) ProfileServiceUtil.stringValue(compositeValue.get(APPLICATION_NAME)));
+			session.setCreatedTime((Long) ProfileServiceUtil.longValue(compositeValue.get(CREATED_TIME)));
+			session.setClientHostName((String) ProfileServiceUtil.stringValue(compositeValue.get(CLIENT_HOST_NAME)));
+			session.setIPAddress((String) ProfileServiceUtil.stringValue(compositeValue.get(IP_ADDRESS)));
+			session.setLastPingTime((Long) ProfileServiceUtil.longValue(compositeValue.get(LAST_PING_TIME)));
+			session.setSessionId((String) ProfileServiceUtil.stringValue(compositeValue.get(SESSION_ID)));
+			session.setUserName((String) ProfileServiceUtil.stringValue(compositeValue.get(USER_NAME)));
+			session.setVDBName((String) ProfileServiceUtil.stringValue(compositeValue.get(VDB_NAME)));
+			session.setVDBVersion((Integer) ProfileServiceUtil.integerValue(compositeValue.get(VDB_VERSION)));
+			session.setSecurityDomain((String) ProfileServiceUtil.stringValue(compositeValue.get(SECURITY_DOMAIN)));
+			return session;
+		}
+		throw new IllegalStateException("Unable to unwrap session " + metaValue); //$NON-NLS-1$
+	}
+
+	public RequestMetadata unwrapRequestMetaValue(MetaValue metaValue) throws Exception {
+		if (metaValue == null)
+			return null;
+
+		if (metaValue instanceof CompositeValue) {
+			CompositeValue compositeValue = (CompositeValue) metaValue;
+			
+			RequestMetadata request = new RequestMetadata();
+			request.setExecutionId((Long) ProfileServiceUtil.longValue(compositeValue.get(EXECUTION_ID)));
+			request.setSessionId((String) ProfileServiceUtil.stringValue(compositeValue.get(SESSION_ID)));
+			request.setStartTime((Long) ProfileServiceUtil.longValue(compositeValue.get(START_TIME)));
+			request.setCommand((String) ProfileServiceUtil.stringValue(compositeValue.get(COMMAND)));
+			request.setSourceRequest((Boolean) ProfileServiceUtil.booleanValue(compositeValue.get(SOURCE_REQUEST)));
+			request.setNodeId((Integer) ProfileServiceUtil.integerValue(compositeValue.get(NODE_ID)));
+			request.setTransactionId((String) ProfileServiceUtil.stringValue(compositeValue.get(TRANSACTION_ID)));
+			request.setState((ProcessingState) ProfileServiceUtil.getSimpleValue(compositeValue.get(STATE), ProcessingState.class));
+			return request;
+		}
+		throw new IllegalStateException("Unable to unwrap RequestMetadata " + metaValue); //$NON-NLS-1$
+	}
+	
+	public TransactionMetadata unwrapTransactionMetaValue(MetaValue metaValue) throws Exception {
+		if (metaValue == null)
+			return null;
+
+		if (metaValue instanceof CompositeValue) {
+			CompositeValue compositeValue = (CompositeValue) metaValue;
+			
+			TransactionMetadata transaction = new TransactionMetadata();
+			transaction.setAssociatedSession((String) ProfileServiceUtil.stringValue(compositeValue.get(ASSOCIATED_SESSION)));
+			transaction.setCreatedTime((Long) ProfileServiceUtil.longValue(compositeValue.get(CREATED_TIME)));
+			transaction.setScope((String) (String) ProfileServiceUtil.stringValue(compositeValue.get(SCOPE)));
+			transaction.setId((String) (String) ProfileServiceUtil.stringValue(compositeValue.get("id"))); //$NON-NLS-1$
+			return transaction;
+		}
+		throw new IllegalStateException("Unable to unwrap TransactionMetadata " + metaValue); //$NON-NLS-1$
+	}
+	
 }

Added: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/RequestMetadata.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/RequestMetadata.java	                        (rev 0)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/RequestMetadata.java	2011-01-11 21:28:40 UTC (rev 2832)
@@ -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.rhq.plugin.objects;
+
+import java.util.Date;
+
+import org.teiid.adminapi.Request.ProcessingState;
+import org.teiid.adminapi.Request.ThreadState;
+import org.teiid.core.util.HashCodeUtil;
+
+
+
+public class RequestMetadata  {
+
+	private static final long serialVersionUID = -2779106368517784259L;
+	
+	private long executionId;
+	private String sessionId;
+    private String command;
+    private long startTime;
+    private boolean sourceRequest;
+	private Integer nodeID;
+    private String transactionId;
+    private ProcessingState processingState = ProcessingState.PROCESSING;
+    private ThreadState threadState = ThreadState.RUNNING;
+    
+    public long getExecutionId() {
+		return executionId;
+	}
+    
+    public void setExecutionId(long id) {
+		this.executionId = id;
+	}
+    
+    public ProcessingState getState() {
+		return processingState;
+	}
+    
+    public void setState(ProcessingState state) {
+		this.processingState = state;
+	}
+    
+	public ThreadState getThreadState() {
+		return threadState;
+	}
+	
+	public void setThreadState(ThreadState threadState) {
+		this.threadState = threadState;
+	}
+    
+    public String getSessionId() {
+        return this.sessionId;
+    }
+    
+    public void setSessionId(String session) {
+        this.sessionId = session;
+    }
+    
+    public long getStartTime() {
+        return this.startTime;
+    }
+    
+    public void setStartTime(long time) {
+        this.startTime = time;
+    }    
+
+    public String getCommand() {
+        return this.command;
+    }
+    
+    public void setCommand(String cmd) {
+        this.command = cmd;
+    }    
+    
+    public boolean sourceRequest() {
+		return sourceRequest;
+	}
+
+	public void setSourceRequest(boolean sourceRequest) {
+		this.sourceRequest = sourceRequest;
+	}    
+        
+	public Integer getNodeId() {
+        return this.nodeID;
+    }
+    
+    public void setNodeId(Integer nodeID) {
+        this.nodeID = nodeID;
+    }
+    
+	public String getTransactionId() {
+		return this.transactionId;
+	}
+
+	public void setTransactionId(String id) {
+		this.transactionId = id;
+	}
+	
+    public boolean equals(Object obj) {
+    	if (!(obj instanceof RequestMetadata)) {
+    		return false;
+    	}
+    	RequestMetadata value = (RequestMetadata)obj;
+    	if (!sourceRequest()) {
+    		return sessionId == value.sessionId && executionId == value.executionId;
+    	}
+		return sessionId == value.sessionId && executionId == value.executionId && nodeID.equals(value.nodeID);
+	}
+    
+    public int hashCode() {
+    	return HashCodeUtil.hashCode((int)executionId, sessionId);
+    }    
+    
+    @SuppressWarnings("nls")
+	public String toString() {
+    	StringBuilder str = new StringBuilder();
+    	str.append("Request: sessionid=").append(sessionId);
+    	str.append("; executionId=").append(executionId);
+    	if (nodeID != null) {
+    		str.append("; nodeId=").append(nodeID);
+    	}
+    	if (transactionId != null) {
+    		str.append("; transactionId=").append(transactionId);
+    	}
+    	str.append("; sourceRequest=").append(sourceRequest);
+    	str.append("; processingTime=").append(new Date(startTime));
+    	str.append("; command=").append(command); 
+    	
+    	return str.toString();
+    }
+}


Property changes on: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/RequestMetadata.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/SessionMetadata.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/SessionMetadata.java	                        (rev 0)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/SessionMetadata.java	2011-01-11 21:28:40 UTC (rev 2832)
@@ -0,0 +1,198 @@
+/*
+ * 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.rhq.plugin.objects;
+
+import java.util.Date;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginContext;
+
+import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.client.security.SessionToken;
+
+
+
+/**
+ * Add and delete properties also in the Mapper class for correct wrapping for profile service.
+ */
+public class SessionMetadata {
+
+	private static final long serialVersionUID = 918638989081830034L;
+	private String applicationName;
+	private long lastPingTime = System.currentTimeMillis();
+    private long createdTime;
+    private String ipAddress;
+    private String clientHostName;    
+    private String userName;
+    private String vdbName;
+    private int vdbVersion;
+    private String sessionId;
+    private String securityDomain;
+    
+    //server session state
+    private transient VDBMetaData vdb;
+    private transient SessionToken sessionToken;
+    private transient LoginContext loginContext;
+    private transient Object securityContext;
+    private transient boolean embedded;
+
+	public String getApplicationName() {
+		return this.applicationName;
+	}
+	
+    public void setApplicationName(String applicationName) {
+		this.applicationName = applicationName;
+	}	
+    
+	public long getCreatedTime() {
+		return this.createdTime;
+	}
+
+	public void setCreatedTime(long createdTime) {
+		this.createdTime = createdTime;
+	}
+
+	public String getClientHostName() {
+		return this.clientHostName;
+	}
+
+	public void setClientHostName(String clientHostname) {
+		this.clientHostName = clientHostname;
+	}
+
+	public String getIPAddress() {
+		return this.ipAddress;
+	}
+
+	public void setIPAddress(String ipAddress) {
+		this.ipAddress = ipAddress;
+	}
+
+	public long getLastPingTime() {
+		return this.lastPingTime;
+	}
+
+	public void setLastPingTime(long lastPingTime) {
+		this.lastPingTime = lastPingTime;
+	}
+
+	public String getSessionId() {
+		return this.sessionId;
+	}
+
+	public void setSessionId(String sessionId) {
+		this.sessionId = sessionId;
+	}
+
+	public String getUserName() {
+		return this.userName;
+	}
+
+	public void setUserName(String userName) {
+		this.userName = userName;
+	}
+
+	public String getVDBName() {
+		return this.vdbName;
+	}
+
+	public void setVDBName(String vdbName) {
+		this.vdbName = vdbName;
+	}
+
+	public int getVDBVersion() {
+		return this.vdbVersion;
+	}
+
+	public void setVDBVersion(int vdbVersion) {
+		this.vdbVersion = vdbVersion;
+	}
+
+	public String getSecurityDomain() {
+		return this.securityDomain;
+	}
+	
+	public void setSecurityDomain(String domain) {
+		this.securityDomain = domain;
+	}	
+	
+    @SuppressWarnings("nls")
+	public String toString() {
+    	StringBuilder str = new StringBuilder();
+    	str.append("session: sessionid=").append(sessionId);
+    	str.append("; userName=").append(userName);
+    	str.append("; vdbName=").append(vdbName);
+    	str.append("; vdbVersion=").append(vdbVersion);
+    	str.append("; createdTime=").append(new Date(createdTime));
+    	str.append("; applicationName=").append(applicationName);
+    	str.append("; clientHostName=").append(clientHostName);
+    	str.append("; IPAddress=").append(ipAddress);
+    	str.append("; securityDomain=").append(securityDomain); 
+    	str.append("; lastPingTime=").append(new Date(lastPingTime));
+    	return str.toString();
+    }
+
+	public VDBMetaData getVdb() {
+		return vdb;
+	}
+
+	public void setVdb(VDBMetaData vdb) {
+		this.vdb = vdb;
+	}
+
+	public SessionToken getSessionToken() {
+		return sessionToken;
+	}
+
+	public void setSessionToken(SessionToken sessionToken) {
+		this.sessionToken = sessionToken;
+	}
+
+	public LoginContext getLoginContext() {
+		return loginContext;
+	}
+
+	public void setLoginContext(LoginContext loginContext) {
+		this.loginContext = loginContext;
+	}
+
+	public Object getSecurityContext() {
+		return securityContext;
+	}
+
+	public void setSecurityContext(Object securityContext) {
+		this.securityContext = securityContext;
+	}	
+	
+	public Subject getSubject() {
+		return this.loginContext.getSubject();
+	}
+	
+	public void setEmbedded(boolean embedded) {
+		this.embedded = embedded;
+	}
+
+	public boolean isEmbedded() {
+		return embedded;
+	}
+	
+}


Property changes on: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/SessionMetadata.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/TransactionMetadata.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/TransactionMetadata.java	                        (rev 0)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/TransactionMetadata.java	2011-01-11 21:28:40 UTC (rev 2832)
@@ -0,0 +1,82 @@
+/*
+ * 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.rhq.plugin.objects;
+
+import java.util.Date;
+
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.metatype.api.annotations.MetaMapping;
+import org.teiid.adminapi.Transaction;
+
+
+public class TransactionMetadata {
+
+	private static final long serialVersionUID = -8588785315218789068L;
+	private String associatedSession;
+	private String scope;
+	private String id;
+	private long createdTime;
+
+	public String getAssociatedSession() {
+		return associatedSession;
+	}
+
+	public void setAssociatedSession(String associatedSession) {
+		this.associatedSession = associatedSession;
+	}
+
+	public String getScope() {
+		return scope;
+	}
+
+	public void setScope(String scope) {
+		this.scope = scope;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(String id) {
+		this.id = id;
+	}
+	
+	public long getCreatedTime() {
+		return createdTime;
+	}
+	
+	public void setCreatedTime(long time) {
+		this.createdTime = time;
+	}
+
+	@Override
+	public String toString() {
+        StringBuffer result = new StringBuffer();
+        result.append("Associated Session:").append(associatedSession); //$NON-NLS-1$
+        result.append("Scope:").append(scope); //$NON-NLS-1$
+        result.append("Id:").append(id); //$NON-NLS-1$
+        result.append("CreatedTime:").append(new Date(createdTime)); //$NON-NLS-1$
+        return result.toString();
+	}
+
+}


Property changes on: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/objects/TransactionMetadata.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
===================================================================
--- branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java	2011-01-11 21:18:44 UTC (rev 2831)
+++ branches/7.1.x/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java	2011-01-11 21:28:40 UTC (rev 2832)
@@ -286,11 +286,35 @@
 				SimpleValue simple = (SimpleValue) v1;
 				return Double.valueOf(simple.getValue().toString());
 			}
-			throw new Exception("Failed to convert value to boolean value"); //$NON-NLS-1$
+			throw new Exception("Failed to convert value to double value"); //$NON-NLS-1$
 		}
 		return null;
 	}
 	
+	public static Long longValue(MetaValue v1) throws Exception {
+		if (v1 != null) {
+			MetaType type = v1.getMetaType();
+			if (type instanceof SimpleMetaType) {
+				SimpleValue simple = (SimpleValue) v1;
+				return Long.valueOf(simple.getValue().toString());
+			}
+			throw new Exception("Failed to convert value to long value"); //$NON-NLS-1$
+		}
+		return null;
+	}
+	
+	public static Integer integerValue(MetaValue v1) throws Exception {
+		if (v1 != null) {
+			MetaType type = v1.getMetaType();
+			if (type instanceof SimpleMetaType) {
+				SimpleValue simple = (SimpleValue) v1;
+				return Integer.valueOf(simple.getValue().toString());
+			}
+			throw new Exception("Failed to convert value to integer value"); //$NON-NLS-1$
+		}
+		return null;
+	}
+	
 	public static <T> T getSimpleValue(ManagedComponent mc, String prop,
 			Class<T> expectedType) {
 		ManagedProperty mp = mc.getProperty(prop);
@@ -310,6 +334,24 @@
 		return null;
 	}
 
+	public static <T> T getSimpleValue(MetaValue prop,
+			Class<T> expectedType) {
+		if (prop != null) {
+			MetaType metaType = prop.getMetaType();
+			if (metaType.isSimple()) {
+				SimpleValue simpleValue = (SimpleValue) prop;
+				return expectedType.cast((simpleValue != null) ? simpleValue
+						.getValue() : null);
+			} else if (metaType.isEnum()) {
+				EnumValue enumValue = (EnumValue) prop;
+				return expectedType.cast((enumValue != null) ? enumValue
+						.getValue() : null);
+			}
+			throw new IllegalStateException(prop + " is not a simple type"); //$NON-NLS-1$
+		}
+		return null;
+	}
+	
 	public static <T> T getSimpleValue(ManagedCommon mc, String prop,
 			Class<T> expectedType) {
 		ManagedProperty mp = mc.getProperty(prop);



More information about the teiid-commits mailing list