[teiid-commits] teiid SVN: r1860 - in branches/JCA/console/src: main/java/org/teiid/rhq/plugin and 3 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Feb 19 16:47:43 EST 2010


Author: tejones
Date: 2010-02-19 16:47:42 -0500 (Fri, 19 Feb 2010)
New Revision: 1860

Added:
   branches/JCA/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
Removed:
   branches/JCA/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java
   branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties
   branches/JCA/console/src/test/java/org/teiid/rhq/comm/impl/
   branches/JCA/console/src/test/java/org/teiid/rhq/enterprise/pool/
Modified:
   branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java
   branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
   branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
   branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
Log:
Fixed VDB prop logic

Added: branches/JCA/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java	                        (rev 0)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java	2010-02-19 21:47:42 UTC (rev 1860)
@@ -0,0 +1,365 @@
+package org.teiid.rhq.admin;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.naming.NamingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.teiid.adminapi.impl.RequestMetadata;
+import org.teiid.adminapi.impl.RequestMetadataMapper;
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.adminapi.impl.SessionMetadataMapper;
+import org.teiid.rhq.comm.ExecutedResult;
+import org.teiid.rhq.plugin.util.PluginConstants;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
+import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
+import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform.Metrics;
+import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform.Operations;
+
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class DQPManagementView implements PluginConstants{
+
+	private static ManagedComponent mc = null;
+	private static final Log LOG = LogFactory.getLog(DQPManagementView.class);
+
+	public DQPManagementView() {
+
+	}
+
+	/*
+	 * Metric methods
+	 */
+	public Object getMetric(String componentType, String identifier,
+			String metric, Map<String, Object> valueMap) {
+		Object resultObject = new Object();
+
+		if (componentType.equals(PluginConstants.ComponentType.Platform.NAME)) {
+			resultObject = getPlatformMetric(componentType, metric, valueMap);
+		} else if (componentType.equals(PluginConstants.ComponentType.VDB.NAME)) {
+			resultObject = getVdbMetric(componentType, identifier, metric,
+					valueMap);
+		}
+
+		return resultObject;
+	}
+
+	private Object getPlatformMetric(String componentType, String metric,
+			Map valueMap) {
+
+		Object resultObject = new Object();
+
+		if (metric
+				.equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
+			resultObject = new Double(getQueryCount().doubleValue());
+		} else {
+			if (metric
+					.equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
+				resultObject = new Double(getSessionCount().doubleValue());
+			} else {
+				if (metric
+						.equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+					Integer longRunningQueryLimit = (Integer) valueMap
+							.get(PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT);
+					Collection<RequestMetadata> longRunningQueries = getLongRunningQueries(
+							longRunningQueryLimit);
+					resultObject = new Double(longRunningQueries.size());
+				}
+			}
+		}
+
+		return resultObject;
+	}
+
+	private Object getVdbMetric(String componentType, String identifier,
+			String metric, Map valueMap) {
+
+		Object resultObject = new Object();
+
+		// if (metric.equals(ComponentType.Metric.HIGH_WATER_MARK)) {
+		// resultObject = new Double(getHighWatermark(identifier));
+		// }
+
+		return resultObject;
+	}
+
+	/*
+	 * Operation methods
+	 */
+
+	public void executeOperation(ExecutedResult operationResult,
+			final Map valueMap) {
+
+		if (operationResult.getComponentType().equals(
+				PluginConstants.ComponentType.Platform.NAME)) {
+			executePlatformOperation(operationResult, operationResult
+					.getOperationName(), valueMap);
+		}
+
+		// else if
+		// (operationResult.getComponentType().equals(ConnectionConstants.ComponentType.Runtime.System.TYPE))
+		// {
+		// executeSystemOperation(operationResult,
+		// operationResult.getOperationName(), valueMap);
+		// } else if (operationResult.getComponentType().equals(
+		// Runtime.Process.TYPE)) {
+		// executeProcessOperation(operationResult,
+		// operationResult.getOperationName(), valueMap);
+		// } else if
+		// (operationResult.getComponentType().equals(com.metamatrix.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.TYPE))
+		// {
+		// executeHostOperation(operationResult,
+		// operationResult.getOperationName(), valueMap);
+		// } else if
+		// (operationResult.getComponentType().equals(com.metamatrix.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session.TYPE))
+		// {
+		// executeSessionOperation(operationResult,
+		// operationResult.getOperationName(), valueMap);
+		// } else if
+		// (operationResult.getComponentType().equals(com.metamatrix.rhq.comm.ConnectionConstants.ComponentType.Runtime.Queries.TYPE))
+		// {
+		// executeQueriesOperation(operationResult,
+		// operationResult.getOperationName(), valueMap);
+		// }
+	}
+
+	private void executePlatformOperation(ExecutedResult operationResult,
+			final String operationName, final Map<String, Object> valueMap) {
+		Collection<RequestMetadata> resultObject = new ArrayList<RequestMetadata>();
+
+		if (operationName.equals(Platform.Operations.GET_LONGRUNNINGQUERIES)) {
+			Integer longRunningValue = (Integer) valueMap
+					.get(Operation.Value.LONG_RUNNING_QUERY_LIMIT);
+			List<String> fieldNameList = operationResult.getFieldNameList();
+			resultObject = getLongRunningQueries(longRunningValue);
+			operationResult.setContent(createReportResultList(fieldNameList, resultObject.iterator()));
+		} 
+		
+//		else if (operationName.equals(ComponentType.Operation.KILL_REQUEST)) {
+//			String requestID = (String) valueMap
+//					.get(ConnectionConstants.ComponentType.Operation.Value.REQUEST_ID);
+//			cancelRequest(requestID);
+//		} else if (operationName.equals(ComponentType.Operation.GET_VDBS)) {
+//			List fieldNameList = operationResult.getFieldNameList();
+//			resultObject = getVDBs(fieldNameList);
+//			operationResult.setContent((List) resultObject);
+//		} else if (operationName.equals(ComponentType.Operation.GET_PROPERTIES)) {
+//			String identifier = (String) valueMap
+//					.get(ConnectionConstants.IDENTIFIER);
+//			Properties props = getProperties(
+//					ConnectionConstants.ComponentType.Runtime.System.TYPE,
+//					identifier);
+//			resultObject = createReportResultList(props);
+//			operationResult.setContent((List) resultObject);
+//		}
+
+	}
+
+	/*
+	 * Helper methods
+	 */
+
+	protected MetaValue getRequests(List<String> fieldNameList) {
+
+		MetaValue requestsCollection = null;
+		MetaValue args = null;
+
+		requestsCollection = executeManagedOperation(mc,
+				PluginConstants.Operation.GET_REQUESTS, args);
+
+		return requestsCollection;
+
+		// if (fieldNameList != null) {
+		// Collection reportResultCollection = createReportResultList(
+		// fieldNameList, requestsCollection.iterator());
+		// return reportResultCollection;
+		// } else {
+		// return requestsCollection;
+		// }
+	}
+
+	public MetaValue getSessions(List<String> fieldNameList) {
+
+		MetaValue sessionCollection = null;
+		MetaValue args = null;
+
+		sessionCollection = executeManagedOperation(mc,
+				PluginConstants.Operation.GET_SESSIONS, args);
+		return sessionCollection;
+
+		// if (fieldNameList != null) {
+		// Collection reportResultCollection = createReportResultList(
+		// fieldNameList, requestsCollection.iterator());
+		// return reportResultCollection;
+		// } else {
+		// return requestsCollection;
+		// }
+	}
+
+	public static MetaValue executeManagedOperation(ManagedComponent mc,
+			String operation, MetaValue... args) {
+
+		try {
+			mc = ProfileServiceUtil.getDQPManagementView();
+		} catch (NamingException e) {
+			LOG.error(e);
+		} catch (Exception e1) {
+			LOG.error(e1);
+		}
+
+		for (ManagedOperation mo : mc.getOperations()) {
+			String opName = mo.getName();
+			if (opName.equals(operation)) {
+				try {
+					if (args.length == 1 && args[0] == null) {
+						return mo.invoke();
+					} else {
+						return mo.invoke(args);
+					}
+				} catch (Exception e) {
+					final String msg = "Exception getting the AdminApi in " + operation; //$NON-NLS-1$
+					LOG.error(msg, e);
+				}
+			}
+		}
+		throw new MetaMatrixRuntimeException(
+				"No operation found with given name =" + operation);
+
+	}
+
+	private Integer getQueryCount() {
+
+		Integer count = new Integer(0);
+
+		MetaValue requests = null;
+		Collection<RequestMetadata> requestsCollection = new ArrayList();
+
+		requests = getRequests(null);
+
+		getRequestCollectionValue(requests, requestsCollection);
+
+		if (requestsCollection != null && !requestsCollection.isEmpty()) {
+			count = requestsCollection.size();
+		}
+
+		return count;
+	}
+
+	private Integer getSessionCount() {
+
+		Collection<SessionMetadata> activeSessionsCollection = new ArrayList<SessionMetadata>();
+		MetaValue sessionMetaValue = getSessions(null);
+		getSessionCollectionValue(sessionMetaValue, activeSessionsCollection);
+		return activeSessionsCollection.size();
+	}
+
+	protected Collection<RequestMetadata> getLongRunningQueries(
+			int longRunningValue) {
+
+		MetaValue requestsCollection = null;
+		Collection<RequestMetadata> list = new ArrayList<RequestMetadata>();
+
+		double longRunningQueryTimeDouble = new Double(longRunningValue);
+
+		requestsCollection = getRequests(null);
+
+		getRequestCollectionValue(requestsCollection, list);
+
+		Iterator<RequestMetadata> requestsIter = list.iterator();
+		while (requestsIter.hasNext()) {
+			RequestMetadata request = requestsIter.next();
+			long startTime = request.getProcessingTime();
+			// Get msec from each, and subtract.
+			long runningTime = Calendar.getInstance().getTimeInMillis()
+					- startTime;
+
+			if (runningTime < longRunningQueryTimeDouble) {
+				requestsIter.remove();
+			}
+		}
+		 
+		return list;
+	}
+	
+	public static <T> void getRequestCollectionValue(MetaValue pValue,
+			Collection<RequestMetadata> list) {
+		MetaType metaType = pValue.getMetaType();
+		if (metaType.isCollection()) {
+			for (MetaValue value : ((CollectionValueSupport) pValue)
+					.getElements()) {
+				if (value.getMetaType().isComposite()) {
+					RequestMetadataMapper requestMapper = new RequestMetadataMapper();
+					RequestMetadata requestMetaData = requestMapper
+							.unwrapMetaValue(value);
+					list.add(requestMetaData);
+				} else {
+					throw new IllegalStateException(pValue
+							+ " is not a Composite type");
+				}
+			}
+		}
+	}
+
+	public static <T> void getSessionCollectionValue(MetaValue pValue,
+			Collection<SessionMetadata> list) {
+		MetaType metaType = pValue.getMetaType();
+		if (metaType.isCollection()) {
+			for (MetaValue value : ((CollectionValueSupport) pValue)
+					.getElements()) {
+				if (value.getMetaType().isComposite()) {
+					SessionMetadataMapper sessionMapper = new SessionMetadataMapper();
+					SessionMetadata sessionMetaData = sessionMapper
+							.unwrapMetaValue(value);
+					list.add(sessionMetaData);
+				} else {
+					throw new IllegalStateException(pValue
+							+ " is not a Composite type");
+				}
+			}
+		}
+	}
+	
+	private Collection createReportResultList(List fieldNameList, Iterator objectIter) {
+		Collection reportResultList = new ArrayList();
+		
+		while (objectIter.hasNext()) {
+			Object object = objectIter.next();
+
+			Class cls = null;
+			try {
+				cls = object.getClass();
+				Iterator methodIter = fieldNameList.iterator();
+				Map reportValueMap = new HashMap<String, String>();
+				while (methodIter.hasNext()) {						
+					String fieldName = (String) methodIter.next();
+					String methodName = fieldName;
+					Method meth = cls.getMethod(methodName, (Class[]) null);  
+					Object retObj = meth.invoke(object, (Object[]) null);
+					reportValueMap.put(fieldName, retObj);
+				}
+				reportResultList.add(reportValueMap);
+			} catch (Throwable e) {
+				System.err.println(e);
+			}
+		}
+		return reportResultList;
+	}
+
+}

Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java	2010-02-19 20:41:28 UTC (rev 1859)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java	2010-02-19 21:47:42 UTC (rev 1860)
@@ -58,6 +58,7 @@
 import org.rhq.core.pluginapi.measurement.MeasurementFacet;
 import org.rhq.core.pluginapi.operation.OperationFacet;
 import org.rhq.core.pluginapi.operation.OperationResult;
+import org.teiid.rhq.admin.DQPManagementView;
 import org.teiid.rhq.comm.ExecutedResult;
 import org.teiid.rhq.plugin.objects.ExecutedOperationResultImpl;
 import org.teiid.rhq.plugin.util.DeploymentUtils;
@@ -180,9 +181,9 @@
 	}
 
 	protected void execute(final ExecutedResult result, final Map valueMap) {
-//		DQPManagementView dqp = new DQPManagementView();
-//			
-//		dqp.executeOperation(result, valueMap);
+		DQPManagementView dqp = new DQPManagementView();
+			
+		dqp.executeOperation(result, valueMap);
 		
 	}
 	
@@ -288,6 +289,7 @@
 		report.setStatus(ConfigurationUpdateStatus.SUCCESS);
 	}
 
+	@Override
 	public void deleteResource() throws Exception {
 		
 		DeploymentManager deploymentManager = ProfileServiceUtil.getDeploymentManager();
@@ -311,31 +313,36 @@
 
 	}
 
-	//@Override
+	@Override
 	public DeployPackagesResponse deployPackages(
 			Set<ResourcePackageDetails> packages,
 			ContentServices contentServices) {
 		return null;
 	}
 
+	@Override
 	public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType arg0) {
 		return null;
 	}
 
+	@Override
 	public List<DeployPackageStep> generateInstallationSteps(
 			ResourcePackageDetails arg0) {
 		return null;
 	}
 
+	@Override
 	public RemovePackagesResponse removePackages(
 			Set<ResourcePackageDetails> arg0) {
 		return null;
 	}
 
+	@Override
 	public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
 		return null;
 	}
 
+	@Override
 	public CreateResourceReport createResource(CreateResourceReport createResourceReport) {
 		ResourcePackageDetails details = createResourceReport
 				.getPackageDetails();

Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java	2010-02-19 20:41:28 UTC (rev 1859)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java	2010-02-19 21:47:42 UTC (rev 1860)
@@ -21,6 +21,7 @@
  */
 package org.teiid.rhq.plugin;
 
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
@@ -35,9 +36,11 @@
 import org.rhq.core.domain.configuration.Configuration;
 import org.rhq.core.domain.configuration.PropertySimple;
 import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
 import org.rhq.core.domain.measurement.MeasurementReport;
 import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
 import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.teiid.rhq.admin.DQPManagementView;
 import org.teiid.rhq.plugin.util.PluginConstants;
 import org.teiid.rhq.plugin.util.ProfileServiceUtil;
 import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
@@ -108,51 +111,51 @@
 	public void getValues(MeasurementReport report,
 			Set<MeasurementScheduleRequest> requests) throws Exception {
 		
-//		DQPManagementView view = new DQPManagementView();
-//
-//		Map<String, Object> valueMap = new HashMap<String, Object>();
-//
-//		for (MeasurementScheduleRequest request : requests) {
-//			String name = request.getName();
-//			LOG.debug("Measurement name = " + name); //$NON-NLS-1$
-//
-//			// Initialize any parameters to be used in the retrieval of metric
-//			// values
-//			if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
-//				Integer value = getResourceConfiguration()
-//						.getSimple(
-//								PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT)
-//						.getIntegerValue();
-//				valueMap.put(PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT, value);
-//			}
-//
-//			Object metricReturnObject = view.getMetric(getComponentType(), this
-//					.getComponentIdentifier(), name, valueMap);
-//
-//			try {
-//				if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
-//					report.addData(new MeasurementDataNumeric(request,
-//							(Double) metricReturnObject));
-//				} else {
-//					if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
-//						report.addData(new MeasurementDataNumeric(request,
-//								(Double) metricReturnObject));
-//					} else {
-//						if (request.getName().equals(
-//								PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
-//							report.addData(new MeasurementDataNumeric(request,
-//									(Double) metricReturnObject));
-//						}
-//					}
-//				}
-//
-//			} catch (Exception e) {
-//				LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
-//						+ "]. Cause: " + e); //$NON-NLS-1$
-//				// throw(e);
-//			}
-//		}
+		DQPManagementView view = new DQPManagementView();
 
+		Map<String, Object> valueMap = new HashMap<String, Object>();
+
+		for (MeasurementScheduleRequest request : requests) {
+			String name = request.getName();
+			LOG.debug("Measurement name = " + name); //$NON-NLS-1$
+
+			// Initialize any parameters to be used in the retrieval of metric
+			// values
+			if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+				Integer value = getResourceConfiguration()
+						.getSimple(
+								PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT)
+						.getIntegerValue();
+				valueMap.put(PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT, value);
+			}
+
+			Object metricReturnObject = view.getMetric(getComponentType(), this
+					.getComponentIdentifier(), name, valueMap);
+
+			try {
+				if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
+					report.addData(new MeasurementDataNumeric(request,
+							(Double) metricReturnObject));
+				} else {
+					if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
+						report.addData(new MeasurementDataNumeric(request,
+								(Double) metricReturnObject));
+					} else {
+						if (request.getName().equals(
+								PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+							report.addData(new MeasurementDataNumeric(request,
+									(Double) metricReturnObject));
+						}
+					}
+				}
+
+			} catch (Exception e) {
+				LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
+						+ "]. Cause: " + e); //$NON-NLS-1$
+				// throw(e);
+			}
+		}
+
 	}
 
 	@Override

Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java	2010-02-19 20:41:28 UTC (rev 1859)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java	2010-02-19 21:47:42 UTC (rev 1860)
@@ -1,127 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.  Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session.Query;
-import org.teiid.rhq.plugin.objects.ExecutedResourceConfigurationResultImpl;
-
-
-/**
- * MetaMatrix Connector component class
- * 
- */
-public class SecurityComponent extends Facet {
-
-	private final Log LOG = LogFactory.getLog(SecurityComponent.class);
-	
-	
-	private ExecutedResourceConfigurationResultImpl getSessions = null;
-
-	/**
-	 * @see org.teiid.rhq.plugin.Facet#getComponentType()
-	 * @since 1.0
-	 */
-	@Override
-	String getComponentType() {
-		return Session.TYPE;
-	}
-	
-	public void start(ResourceContext context) {
-		super.start(context);	
-	}
-	
-	protected void setOperationArguments(String name, Configuration configuration,
-			Map argumentMap) {
-
-		
-	}	
-	
-	@Override
-	public AvailabilityType getAvailability() {
-		return AvailabilityType.UP;
-
-	}
-
-	@Override
-	public void getValues(MeasurementReport arg0,
-			Set<MeasurementScheduleRequest> arg1) throws Exception {
-		// TODO Auto-generated method stub
-
-	}
-	
-  	  
-  	/**
-  	 * The plugin container will call this method and it needs to obtain the
-  	 * current configuration of the managed resource. Your plugin will obtain
-  	 * the managed resource's configuration in your own custom way and populate
-  	 * the returned Configuration object with the managed resource's
-  	 * configuration property values.
-  	 * 
-  	 * @see ConfigurationFacet#loadResourceConfiguration()
-  	 * 
-  	 */
-  	@Override
-  	public Configuration loadResourceConfiguration() {
-  		
-  		return super.loadResourceConfiguration();
-  	}	
-
-
-//  	class SessionComparable implements Comparator {
-//
-//		public int compare(Object arg0, Object arg1) {
-//			// TODO Auto-generated method stub
-//			Component a = (Component) arg0;
-//			Component b = (Component) arg1;
-//			
-//		        if ( a == null && b == null ) {
-//		            return 0;
-//		        }
-//		        if ( a != null && b == null ) {
-//		            return 1;
-//		        }
-//		        if ( a == null && b != null ) {
-//		            return -1;
-//		        }
-//		        int result = a.get.compareTo(b.getDisplayName());
-//		        return result;
-//		}
-
-
-  		
- // 	}
-
-}
\ No newline at end of file

Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java	2010-02-19 20:41:28 UTC (rev 1859)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java	2010-02-19 21:47:42 UTC (rev 1860)
@@ -26,10 +26,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.managed.api.ComponentType;
 import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment;
 import org.jboss.managed.api.ManagedProperty;
 import org.jboss.managed.plugins.ManagedObjectImpl;
 import org.jboss.metatype.api.values.CollectionValueSupport;
@@ -68,14 +66,11 @@
 		for (ManagedComponent mcVdb : vdbs) {
 
 			String vdbKey = mcVdb.getDeployment().getName();
-			String vdbName = ((SimpleValueSupport) mcVdb.getProperty("name")
-					.getValue()).getValue().toString();
-			String vdbVersion = ((SimpleValueSupport) mcVdb.getProperty(
-					"version").getValue()).getValue().toString();
-			// TODO: Correct this after deploying proper VDB/Metadata
-			String vdbDescription = "description"; // mcVdb.getProperty("description");
-			String vdbStatus = "active"; // mcVdb.getProperty("status");
-			String vdbURL = "url"; // mcVdb.getProperty("url");
+			String vdbName = ProfileServiceUtil.getSimpleValue(mcVdb, "name", String.class);
+			Integer vdbVersion = ProfileServiceUtil.getSimpleValue(mcVdb, "version", Integer.class);
+			String vdbDescription = ProfileServiceUtil.getSimpleValue(mcVdb, "description", String.class);
+			String vdbStatus = ProfileServiceUtil.getSimpleValue(mcVdb, "status", String.class);
+			String vdbURL = ProfileServiceUtil.getSimpleValue(mcVdb, "url", String.class); 
 
 			/**
 			 * 
@@ -86,7 +81,7 @@
 					discoveryContext.getResourceType(), // ResourceType
 					vdbKey, // Resource Key
 					vdbName, // Resource Name
-					vdbVersion, // Version
+					vdbVersion.toString(), // Version
 					PluginConstants.ComponentType.VDB.DESCRIPTION, // Description
 					discoveryContext.getDefaultPluginConfiguration(), // Plugin
 																		// Config

Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java	2010-02-19 20:41:28 UTC (rev 1859)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java	2010-02-19 21:47:42 UTC (rev 1860)
@@ -16,8 +16,16 @@
 import org.jboss.managed.api.ComponentType;
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
 import org.jboss.profileservice.spi.ProfileService;
 
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
 public class ProfileServiceUtil {
 
 	protected final Log LOG = LogFactory.getLog(ProfileServiceUtil.class);
@@ -139,5 +147,34 @@
 		
 		return getManagedComponent(DQPTYPE, DQPNAME);
 	}
+	
+	public static String stringValue(MetaValue v1) {
+		if (v1 != null) {
+			MetaType type = v1.getMetaType();
+			if (type instanceof SimpleMetaType) {
+				SimpleValue simple = (SimpleValue)v1;
+				return simple.getValue().toString();
+			}
+			throw new MetaMatrixRuntimeException("Failed to convert value to string value");
+		}
+		return null;
+	}	
+	
+	public static <T> T getSimpleValue(ManagedComponent mc, String prop, Class<T> expectedType) {
+		 ManagedProperty mp = mc.getProperty(prop);
+		 if (mp != null) {
+			 MetaType metaType = mp.getMetaType();
+			 if (metaType.isSimple()) {
+		            SimpleValue simpleValue = (SimpleValue)mp.getValue();
+		            return expectedType.cast((simpleValue != null) ? simpleValue.getValue() : null);
+			 }
+			 else if (metaType.isEnum()) {
+				 EnumValue enumValue = (EnumValue)mp.getValue();
+				 return expectedType.cast((enumValue != null) ? enumValue.getValue() : null);
+			 }
+			 throw new IllegalStateException(prop+ " is not a simple type");
+		 }
+		 return null;
+	}	
 
 }

Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties	2010-02-19 20:41:28 UTC (rev 1859)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties	2010-02-19 21:47:42 UTC (rev 1860)
@@ -1,3 +0,0 @@
-url=mm://localhost:31000
-username=Admin
-password=mm
\ No newline at end of file



More information about the teiid-commits mailing list