[teiid-commits] teiid SVN: r1210 - in trunk/console/src: main/java/org/teiid/rhq/admin and 15 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Fri Jul 31 09:15:36 EDT 2009


Author: vhalbert at redhat.com
Date: 2009-07-31 09:15:35 -0400 (Fri, 31 Jul 2009)
New Revision: 1210

Added:
   trunk/console/src/assembly/assemble-artifacts.xml
   trunk/console/src/assembly/binaries.xml
   trunk/console/src/main/java/org/teiid/rhq/admin/ConnectionMgr.java
   trunk/console/src/main/java/org/teiid/rhq/admin/utils/SingletonConnectionManager.java
   trunk/console/src/main/java/org/teiid/rhq/comm/Component.java
   trunk/console/src/main/java/org/teiid/rhq/comm/Connection.java
   trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionConstants.java
   trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionException.java
   trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionFactory.java
   trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionPool.java
   trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionPoolConstants.java
   trunk/console/src/main/java/org/teiid/rhq/comm/ExecutedResult.java
   trunk/console/src/main/java/org/teiid/rhq/comm/VMComponent.java
   trunk/console/src/main/java/org/teiid/rhq/comm/impl/ComponentImpl.java
   trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionImpl.java
   trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionUtil.java
   trunk/console/src/main/java/org/teiid/rhq/comm/impl/InvalidConnectionImpl.java
   trunk/console/src/main/java/org/teiid/rhq/comm/impl/NetUtils.java
   trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionConstants.java
   trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionFactory.java
   trunk/console/src/main/java/org/teiid/rhq/embedded/EmbeddedConnectionMgr.java
   trunk/console/src/main/java/org/teiid/rhq/embedded/pool/ConnectionPoolImpl.java
   trunk/console/src/main/java/org/teiid/rhq/embedded/pool/EmbeddedConnectionConstants.java
   trunk/console/src/main/java/org/teiid/rhq/enterprise/AdminUtil.java
   trunk/console/src/main/java/org/teiid/rhq/enterprise/EnterpriseConnectionMgr.java
   trunk/console/src/main/java/org/teiid/rhq/enterprise/pool/ConnectionPoolImpl.java
   trunk/console/src/main/java/org/teiid/rhq/enterprise/pool/EnterpriseConnectionConstants.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/ConnectorComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/ConnectorDiscoveryComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/HostComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/HostDiscoveryComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/NodeChildrenDiscoveryComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/NodeDiscoveryComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/ProcessComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/ProcessDiscoveryComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/QueriesComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/SessionComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/SystemComponent.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ConfigurationResultImpl.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginUtils.java
   trunk/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties
   trunk/console/src/resources/embedded/META-INF/rhq-plugin.xml
   trunk/console/src/resources/enterprise/META-INF/rhq-plugin.xml
   trunk/console/src/test/java/org/teiid/rhq/AllTests.java
   trunk/console/src/test/java/org/teiid/rhq/StartingEnvironmentConstants.java
   trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnection.java
   trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnectionFactory.java
   trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeInvalidConnectionFactory.java
   trunk/console/src/test/java/org/teiid/rhq/comm/impl/TestConnectionPool.java
Log:
moving jbedsp-monitor project into teiid as the starting point for teiid-console

Added: trunk/console/src/assembly/assemble-artifacts.xml
===================================================================
--- trunk/console/src/assembly/assemble-artifacts.xml	                        (rev 0)
+++ trunk/console/src/assembly/assemble-artifacts.xml	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,71 @@
+<project default="main" name="JON.Plugin.Build" basedir="../../">
+	
+	<property name="temp.dir" value="${basedir}/target/tmp"/>
+	<property name="embedded.temp.dir" value="${temp.dir}/embedded"/>
+	
+	<!--  this contains jars to be included in the embedded war -->
+	<property name="embedded.jar" value="${basedir}/target/distribution/jbedsp-embedded-plugin-${product.version}.jar"/>
+
+	<property name="enterprise.temp.dir" value="${temp.dir}/enterprise"/>
+	<!--  this is the plugin to be deployed to JON that get sent to the agent -->
+	<property name="enterprise.jar" value="${basedir}/target/distribution/jbedsp-enterprise-plugin-${product.version}.jar"/>
+
+	
+	<property name="bin.dir" value="${basedir}/target/distribution/${product.name}-${product.version}-binaries.jar"/>
+	
+	<target name="main" depends="build-embedded-jar, build-enterprise-jar" />
+	
+	<target name="build-embedded-jar" >
+		<!-- assemble the jars into the embeddedjars dir, to be zipped up -->
+		
+		<!-- assemble the plugin jar -->
+		<mkdir dir="${embedded.temp.dir}"/>
+		<copy todir="${embedded.temp.dir}">
+		   <fileset dir="${basedir}/src/resources/embedded"/>
+		</copy>
+		
+		<unzip src="${basedir}/target/${product.name}-${product.version}.jar" dest="${embedded.temp.dir}">
+		   <patternset>
+		        <exclude name="com/metamatrix/rhq/enterprise/**"/>
+		    </patternset>
+		</unzip>
+		<!--
+		<unjar dest="${embedded.temp.dir}/">
+			<fileset file="${basedir}/target/${product.name}-${product.version}.jar" />
+			<patternset>
+				<exclude name="com/metamatrix/rhq/enterprise/**"/>
+			</patternset>
+		</unjar>
+		
+		-->
+		<!-- jar up the plugin file -->
+		<jar destfile="${embedded.jar}" basedir="${embedded.temp.dir}"/>		
+
+		<!--
+		<delete dir="${embedded.temp.dir}"/>
+-->
+		
+	</target>
+	
+	<target name="build-enterprise-jar" >
+		<mkdir dir="${enterprise.temp.dir}"/>
+		
+		
+		<copy todir="${enterprise.temp.dir}">
+		   <fileset dir="${basedir}/src/resources/enterprise"/>
+		</copy>
+		
+		<unzip src="${basedir}/target/${product.name}-${product.version}.jar" dest="${enterprise.temp.dir}">
+		   <patternset>
+		        <exclude name="com/metamatrix/rhq/embedded/**"/>
+		    </patternset>
+		</unzip>		
+		
+		<jar destfile="${enterprise.jar}" basedir="${enterprise.temp.dir}"/>
+<!--
+		<delete dir="${enterprise.temp.dir}"/>
+		-->
+	</target>
+	
+	
+</project>
\ No newline at end of file


Property changes on: trunk/console/src/assembly/assemble-artifacts.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/assembly/binaries.xml
===================================================================
--- trunk/console/src/assembly/binaries.xml	                        (rev 0)
+++ trunk/console/src/assembly/binaries.xml	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,23 @@
+<!--This script builds a JAR for a Server Installation -->
+<assembly>
+  
+  <id>binaries</id>
+  
+  <formats>
+    <format>dir</format>
+  </formats>
+  
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <baseDirectory>server</baseDirectory>
+    
+  <dependencySets>
+    <dependencySet>
+      <useProjectArtifact>false</useProjectArtifact>      
+      <useTransitiveDependencies>true</useTransitiveDependencies>
+      <useTransitiveFiltering>false</useTransitiveFiltering>
+      <useDefaultExcludes>true</useDefaultExcludes>
+      <unpack>false</unpack>
+    </dependencySet>
+  </dependencySets>
+
+</assembly>
\ No newline at end of file


Property changes on: trunk/console/src/assembly/binaries.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/admin/ConnectionMgr.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/admin/ConnectionMgr.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/admin/ConnectionMgr.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,66 @@
+package org.teiid.rhq.admin;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionException;
+
+
+public interface ConnectionMgr {
+
+	/**
+	 * Called to indicate that this manager should be initialized.
+	 * @param props
+	 * @param cl is the ClassLoader to use to instantiate any classes downstream
+	 */
+	void initialize(Properties props, ClassLoader cl);
+	
+	/**
+	 * Called to reset the pool.   A subsequent call to @see #initialize(Properties, ClassLoader)
+	 * would establish a new set of installations based on the properties.
+	 */
+	void shutdown();
+	
+	/**
+	 * Returns <code>true</code> if server installations have been configured and will be returned
+	 * in the {@link #getServerInstallations()} call.
+	 * @return true if servers are defined.
+	 */
+	
+	 boolean hasServersDefined();
+	 
+	 
+	 /**
+	  * Returns the unique set of keys for each installation
+	  * @return Set of unique keys 
+	  */
+	 Set getInstallationSystemKeys();
+	 
+
+	
+	/**
+     * this is called only during discovery to obtain a connection for each 
+     * system (or server installation) on the local machine.
+     * 
+     *  In cases where a connection cannot be obtained, an entry in the
+     *  <code>Map</code> will be added with a null set for the value <code>Connection</code>
+     * @return Map <key=installdir value=Connection>
+     * @throws Exception
+     * @since 1.0
+     */
+	 Map<String, Connection> getServerInstallations();
+
+    /**
+     * Called to get a {@link Connection} that will be used to
+     * call the MetaMatrix Server.
+     * @param key is the unique identifier for the system in
+     * which to obtain the connection for.  
+     * @return Connection for the system to communicate with.
+     * @throws Exception
+     * @since 1.0
+     */	
+    Connection getConnection(String key) throws ConnectionException;
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/admin/ConnectionMgr.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/admin/utils/SingletonConnectionManager.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/admin/utils/SingletonConnectionManager.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/admin/utils/SingletonConnectionManager.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,145 @@
+/*
+ * 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.admin.utils;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.teiid.rhq.admin.ConnectionMgr;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionException;
+
+
+public class SingletonConnectionManager {
+
+	private static final Log log = LogFactory.getLog(SingletonConnectionManager.class);
+    
+    private static final String ENTERPRISE_CONNECTION_MGR="org.teiid.rhq.enterprise.EnterpriseConnectionMgr"; //$NON-NLS-1$
+    private static final String EMBEDDED_CONNECTION_MGR="org.teiid.rhq.embedded.EmbeddedConnectionMgr"; //$NON-NLS-1$
+
+	private static SingletonConnectionManager instance = null;
+	private ConnectionMgr connmgr;
+	private ClassLoader loader;
+	private boolean initialized = false;
+
+
+    private SingletonConnectionManager() {	
+         
+         
+	}
+
+	public synchronized static SingletonConnectionManager getInstance() {
+
+    		if (instance == null) {
+                   instance = new SingletonConnectionManager();
+                   instance.setupConnectionMgr();
+    		}
+            
+		return instance;
+	}	
+    
+	public Set getInstallationSystemKeys() {
+		return connmgr.getInstallationSystemKeys();
+	}
+
+	public Connection getConnection(String key) throws ConnectionException {
+    	return  connmgr.getConnection(key);
+    }
+	
+
+	public void initialize(Properties props) {
+		if (connmgr != null && initialized) {
+			// re-establish the connectionfactory and pool
+			shutdown();
+			setupConnectionMgr();
+		}
+		initializeConnectionMgr(props);
+		
+	}
+
+	public Map getServerInstallations() {
+		return connmgr.getServerInstallations();
+	}
+
+	public boolean hasServersDefined() {
+		return connmgr.hasServersDefined();
+	}
+
+	public void shutdown() {
+		connmgr.shutdown();
+		connmgr = null;
+	}
+
+	
+	
+	private void setupConnectionMgr() {
+		this.loader = this.getClass().getClassLoader();
+    	ConnectionMgr mgr = null;
+    	Class clzz = null;
+    	// first try enterprise version
+    	try { 
+    		clzz = Class.forName(ENTERPRISE_CONNECTION_MGR, true, this.loader); 
+    	} catch (ClassNotFoundException noent) {
+    		
+    		// no try the embedded connection pool version
+        	try { 
+        		clzz = Class.forName(EMBEDDED_CONNECTION_MGR, true, this.loader); 
+        	} catch (ClassNotFoundException noemb) {
+        		
+        	}
+    	}
+    	
+    	if (clzz == null) {
+    		throw new InvalidPluginConfigurationException("System Error: cannot load either enterprise or embedded connection mgr");
+    	}
+    	
+        try {
+			mgr = (ConnectionMgr) clzz.newInstance();
+		} catch (Exception e) {
+			throw new InvalidPluginConfigurationException(e);
+		}              
+
+    	this.connmgr = mgr;
+    	
+    }
+	
+	private void initializeConnectionMgr(Properties props) {
+            
+		connmgr.initialize(props, this.loader);
+		this.initialized = true;
+    	
+    }
+	
+	public boolean isEmbedded() {
+    	try { 
+    		Class.forName(EMBEDDED_CONNECTION_MGR);
+    		return true;
+    	} catch (ClassNotFoundException noent) {
+    		return false;    		
+    	}    	
+    }
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/admin/utils/SingletonConnectionManager.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/Component.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/Component.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/Component.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,85 @@
+/*
+ * 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.comm;
+
+import java.util.Map;
+
+
+/** 
+ * @since 4.3
+ */
+public interface Component extends Comparable<Object> {
+    
+    public static final String SYSTEM_KEY = "teiid.system.key"; //$NON-NLS-1$
+    public static final String NAME = "teiid.name"; //$NON-NLS-1$
+    public static final String IDENTIFIER = "teiid.identifier"; //$NON-NLS-1$
+    public static final String DESCRIPTION = "teiid.description"; //$NON-NLS-1$
+    public static final String VERSION = "teiid.version"; //$NON-NLS-1$
+    
+    /**
+     * Return the system key that this component identifies with.
+     * @return String system key
+     */
+    String getSystemKey();
+    
+    /**
+     * Return the name for this component
+     * @return String name
+     */
+    String getName();
+    
+    /**
+     * return the unique identifier for this component
+     * @return String unique identifier
+     */
+    String getIdentifier();
+    
+    /**
+     * Return the description
+     * @return String description
+     */
+    String getDescription();
+    
+    /**
+     * Return the version
+     * @return String version
+     */
+    String getVersion();
+    
+    /**
+     * Return a value for the request property key
+     * @param key is the identifier to look for
+     * @return String value
+     */
+    String getProperty(String key);
+    
+    
+    /**
+     * Return the map of properties.
+     * @return Map of properties
+     */
+    Map getProperties();
+
+    
+    
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/Component.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/Connection.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/Connection.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/Connection.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,140 @@
+/*
+ * 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.comm;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Properties;
+
+import org.teiid.rhq.admin.utils.SingletonConnectionManager;
+
+
+
+public interface Connection {
+    
+    /**
+     * Called to find out if the connection represents a valid connection to the
+     * JBEDSP system.   This call should be used only after obtaining a connection
+     * from the {@link SingletonConnectionManager#getConnection(String)}.
+     * The connection can become invalid if the JBEDSP system goes down.
+     */
+    boolean isValid();
+    
+    /**
+     * Called by the {@link ConnectionPool} to check if the connection is still open. 
+     * @return true is the connection is alive.
+
+     */
+    boolean isAlive();
+	
+    /**
+     * Call to indicate the connection is no longer needed and that
+     * resources can be released. 
+     */
+    public void close() ;
+     
+	
+	/**
+	 * This method is called by a component of the JBEDSP RHQ plugin. The
+	 * component identifier, type and metric operation are used to execute the correlating logic.
+	 * The valueMap is a map of values (0-n) that are required by
+	 * the logic to determine the metric.
+	 * @param componentType @see ConnectionConstants.ComponentType
+	 * @param identifier 
+	 * @param metric
+	 * @param valueMap
+	 * @return Object
+     * @throws ConnectionException
+	 */
+	public Object getMetric(final String componentType, String identifier, final String metric, final Map valueMap) throws ConnectionException;
+
+	/**
+	 * This method is called by a component of the JBEDSP RHQ plugin. The
+	 * component type and operation are used to execute the correlating logic.
+	 * The valueMap is a collection of values (0-n) that are required by
+	 * the operation.
+	 * {@link ConnectionConstants.ComponentType} for <code>componentType</code> values
+	 * @param result
+	 * @param componentType
+	 * @param operationName
+	 * @param valueMap
+     * @throws ConnectionException
+	 */
+	public void executeOperation(final ExecutedResult result, final Map valueMap) throws ConnectionException;
+	
+	/**
+	 * This method is called by a component to determine if that particular component is con. The
+	 * component type and identifier are used to execute the correlating logic.
+	 * 
+     * {@link ConnectionConstants.ComponentType} for <code>componentType</code> values
+     * 
+	 * The return value is true if UP else false if DOWN
+	 * 
+	 * @param componentType
+	 * @param identifier
+	 * @return Boolean 
+     * @throws ConnectionException
+	 */
+	public Boolean isAvailable(final String componentType, final String identifier) throws ConnectionException;
+	
+   
+    /**
+     *  Return the properties for component of a specified resource type {@link ConnectionConstants.ComponentType}  
+     * @param componentType {@link ConnectionConstants.ComponentType}
+     * @param identifier
+     * @return
+     * @throws ConnectionException
+     * @since 4.3
+     */
+    
+    public Properties getProperties(String componenType, String identifier) throws ConnectionException; 
+    
+	/**
+	 * Returns a property for a given identifier
+	 * 
+	 * @param identifier
+	 * @param property
+     * @throws ConnectionException
+	 */
+	public String getProperty(String identifier, String property) throws ConnectionException;
+	
+	/**
+	 * Returns the unique key that maps this connection to the system that is being connected to.
+	 * This key used during the enterprise monitoring to keep track of which connection belongs to
+	 * what's being monitored.
+	 * 
+	 * @return key JBEDSP represented by this connection
+     * @throws Exception
+	 */
+	public String getKey() throws Exception;
+    
+    /**
+     * Returns a <code>Collection</code> of {@link Component Component}s for the given identifier for the
+     * given name of the {@link ConnectionConstants.ComponentType}
+     * @param componentType
+     * @param identifier
+     * @return
+     * @throws ConnectionException
+     */
+    public Collection<Component> discoverComponents(String componentType, String identifier) throws ConnectionException;
+   
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/Connection.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionConstants.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionConstants.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionConstants.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,235 @@
+/*
+ * 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.comm;
+
+
+/** 
+ * These are the Constants that used in conjunction with using the 
+ * @since 5.5.3
+ */
+public interface ConnectionConstants {
+	
+	
+	public static final String VERSION = "6.0.0";
+    
+    /**
+     * These are Environment properties need to create a connection.  They will be exposed via the @see #getEnvironment call.
+     */
+	
+	// The system key is the value used to obtain a connection.   
+	// In embedded, its a predefined value
+	// In enterprise, its the installation directory
+	    public final static String SYSTEM_KEY = "system.key"; //$NON-NLS-1$
+        public final static String USERNAME = "username"; //$NON-NLS-1$
+        public final static String PASSWORD = "password"; //$NON-NLS-1$
+        public final static String URL = "url"; //$NON-NLS-1$
+//        public final static String INSTALL_DIR = "install.dir"; //$NON-NLS-1$
+
+    /**
+     * These are global properties used by all components
+     */
+        /*
+         * This is the key for the fully qualified identifier. 
+         * For Runtime components it should be the deployedcomponent full name
+         * For Resource components it should be the Service Defn full name
+         * for adding to the value maps for metrics and operations.
+         */
+        public final static String IDENTIFIER = "identifier"; //$NON-NLS-1$
+        
+
+    /**
+     * These properties are exposed via the #getProperty method call.
+     */
+        public static String SYSTEM_NAME = "cluster.name"; //$NON-NLS-1$
+        public static String SYSTEM_NAME_IDENTIFIER = "JGroups"; //$NON-NLS-1$
+        
+        /**
+         * Use these component type names when calling Connection related methods
+         * that require the type.
+         * @since 1.0
+         */
+        public  interface ComponentType {
+            public final static String PLATFORM = "Platform"; //$NON-NLS-1$            
+            
+        	public interface Runtime {
+        		
+        		public interface System {
+					public final static String TYPE = "Runtime.System"; //$NON-NLS-1$
+
+					public static interface Operations {
+
+						public final static String BOUNCE_SYSTEM = "bounceSystem"; //$NON-NLS-1$					
+						public final static String GET_LONGRUNNINGQUERIES = "listLongRunningQueries"; //$NON-NLS-1$
+						
+					}      
+					
+					public static interface Metrics {
+
+						public final static String QUERY_COUNT = "queryCount"; //$NON-NLS-1$            
+						public final static String SESSION_COUNT = "sessionCount"; //$NON-NLS-1$
+						public final static String LONG_RUNNING_QUERIES = "longRunningQueries"; //$NON-NLS-1$     
+						
+					}
+        		}
+        		       		
+        		public interface Host {
+					public final static String TYPE = "Runtime.Host"; //$NON-NLS-1$
+
+					public static interface Operations {
+					   	public final static String GET_HOSTS = "getHosts"; //$NON-NLS-1$            
+											
+					}        			
+        		}
+        		
+        		public interface Process {
+
+					public final static String TYPE = "Runtime.Process"; //$NON-NLS-1$
+					public static interface Operations {
+					
+					}
+       			
+        		}
+        		
+        		
+        		public interface Connector {
+
+					public final static String TYPE = "Runtime.Connector"; //$NON-NLS-1$
+					public static interface Operations {
+
+						public final static String RESTART_CONNECTOR = "restart"; //$NON-NLS-1$            
+						public final static String STOP_CONNECTOR = "stop"; //$NON-NLS-1$ 
+						
+					}
+       			
+        		}
+        		
+//        		public interface Service {
+//
+//					public final static String TYPE = "Runtime.Service"; //$NON-NLS-1$
+//					public static interface Operations {
+//
+//						public final static String RESTART_SERVICE = "restart"; //$NON-NLS-1$            
+//						public final static String STOP_SERVICE = "stop"; //$NON-NLS-1$ 
+//						
+//					}
+//       			
+//        		} 
+        		
+        		public interface Session {
+
+					public final static String TYPE = "Runtime.Sesssion"; //$NON-NLS-1$
+					public static interface Query {
+
+						public final static String GET_SESSIONS = "getSessions"; //$NON-NLS-1$
+					}
+       			
+
+       			
+        		} 
+        		
+        		public interface Queries {
+
+					public final static String TYPE = "Runtime.Queries"; //$NON-NLS-1$
+					public static interface Query {
+
+						public final static String GET_QUERIES = "listQueries"; //$NON-NLS-1$
+					}
+       			
+
+       			
+        		} 
+        	
+        	}
+        	public interface Resource {
+        		public interface Service {
+
+					public final static String TYPE = "Resource.Service"; //$NON-NLS-1$
+					public static interface Operations {
+						
+					}
+					
+					public static interface Query {
+						
+					}
+       			
+        		}   
+        		public interface Connector {
+
+					public final static String TYPE = "Resource.Connector"; //$NON-NLS-1$
+					public static interface Operations {
+						
+					}
+       			
+        		}
+        	}
+        	
+        	public interface Security {
+        		
+        	}
+            /**
+             * Use these metric names when calling getValues() on the connection
+             * interface.
+             * @since 1.0
+             */
+            public  interface Metric {
+            	public final static String HIGH_WATER_MARK = "highWatermark"; //$NON-NLS-1$
+                
+            }
+            
+            /**
+             * Use these operation names when calling executeOperation() on the connection
+             * interface.
+             * @since 1.0
+             */
+            public static interface Operation {
+            	public final static String KILL_REQUEST = "killRequest"; //$NON-NLS-1$
+                public final static String GET_VDBS = "listVDBs"; //$NON-NLS-1$
+                
+                public final static String GET_PROPERTIES = "getProperties"; //$NON-NLS-1$
+                 
+                /**
+                 * Use these value names when calling executeOperation() on the connection
+                 * interface. These will correlate with parameters used in operations.
+                 * @since 1.0
+                 */
+                public static interface Value {
+                	public final static String STOP_NOW = "stopNow"; //$NON-NLS-1$               
+                	public final static String WAIT_UNTIL_FINISHED = "waitUntilFinished"; //$NON-NLS-1$
+                	
+                	public final static String INCLUDE_SOURCE_QUERIES = "includeSourceQueries"; //$NON-NLS-1$
+                	
+                	public final static String LONG_RUNNING_QUERY_LIMIT = "longRunningQueryLimit"; //$NON-NLS-1$
+                	
+                	public final static String FIELD_LIST = "fieldList"; //$NON-NLS-1$
+                	
+                	public final static String REQUEST_ID = "requestID"; //$NON-NLS-1$
+                	
+                	public final static String NAME = "Name"; //$NON-NLS-1$
+                	public final static String VALUE = "Value"; //$NON-NLS-1$
+                    
+                }
+                
+            }
+            
+        }  
+        
+   }


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionConstants.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionException.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionException.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionException.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,50 @@
+/*
+ * 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.comm;
+
+
+/** 
+ * @since 4.3
+ */
+public class ConnectionException extends Exception {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -3342409142882071873L;
+
+
+	public ConnectionException() {
+        super();
+    }
+    
+    
+    public ConnectionException(final String msg) {
+        super(msg);
+    }
+    
+    
+    public ConnectionException(final Exception e) {
+    	super(e);
+    }
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionException.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionFactory.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionFactory.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionFactory.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,77 @@
+/*
+ * 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.comm;
+
+import java.util.Properties;
+
+
+/**
+ * The primary interface to be implemented by the pool user.  The ConnectionFactory
+ * is called by the {@link ConnectionPool} to create and close the connection. 
+ * 
+ * 
+ * This
+ */
+public interface ConnectionFactory {
+	
+    public static final String CONNECTION_FACTORY_DEFAULT="org.teiid.rhq.comm.impl.TeiidConnectionFactory";  //$NON-NLS-1$
+
+
+
+    /**
+     * Set the environment that this factory is being run in - typically used 
+     * to obtain properties when creating connections and to log messages as 
+     * necessary.
+     * @param env The environment properties needed to create a connection by the connector manager
+     *     {@link ConnectionConstants} 
+     * @param connectionPool is passed so the factory can set the pool on the connection.
+     */
+    void initialize(Properties env, ConnectionPool connectionPool) throws ConnectionException;
+    
+    /**
+     * Return the url used to connect to the server.
+     * @return String url
+     */
+    String getURL();
+
+    /**
+     * Create the connection. This connection is to an existing MetaMatrix server.
+     * @return The Connection form of source-specific connection
+     * @throws ConnectorException If an error occurs while creating the connection
+     */
+    Connection createConnection() throws ConnectionException;
+    
+    
+    /**
+     * Called by the {@link ConnectionPool} when a connection is being cleaned up from the pool.
+     * This will allow the creator of the connection to do any last cleanup steps necessary in order
+     * to release all resources.   
+     * 
+     * In cases where the {@link Connection}, when the {@link Connection#close()} method only returns
+     * the connection to the pool and does not actually close the connection, this close will be 
+     * responsible for actually closing the connection to the source.
+     * @param connection
+
+     */
+    void closeConnection(Connection connection) ;
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionFactory.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionPool.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionPool.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionPool.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,103 @@
+/*
+ * 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.comm;
+
+import java.util.Properties;
+
+
+
+
+/**
+ * The primary interface for the ConnectionPool used by the connection manager
+ * responsible for handing out connections to the discovery and resource JON objects.
+ *
+ * After the instantiation of the ConnectionPool, the @link #initialize(String, Properties) method
+ * will be called so the pool can be initialized.  
+ * @since 1.0
+ *  
+ */
+public interface ConnectionPool extends ConnectionPoolConstants {
+    
+
+    /**
+     * Set the connection factory responsible for creating a connection
+     * when the pool needs a new one.   @see ConnectionPoolConstants for the
+     * avalable settings to configure the pool.
+      * @param env are the environment variables needed to iniatilize the connection pool.
+     * @since 1.0
+     */
+    void initialize(Properties env, ClassLoader cl) throws ConnectionException ;
+    
+    /**
+     * Return a unique key that identifies this connection pool
+     * 
+     * @return
+     */
+    String getKey();
+    
+    
+    /**
+     * Returns a {@link Connection} from the pool.
+     * @return Connction
+     */
+    Connection getConnection() throws ConnectionException;
+    
+    
+    /**
+     * Return the connection to the pool.   It's up to the 
+     * implementation of the pool if the connection is reused or not
+     * @param connection returned to the pool
+     */
+    void close(Connection connection)  throws ConnectionException;
+    
+    
+    /** 
+     * Called to shutdown the pool. 
+     * 
+     */
+    void shutdown()  throws ConnectionException;
+    
+    
+    /**
+     * Return the <code>ClassLoader</code> used to instantiate the {@link ConnectionFactory} and
+     * will be used on all calls in the {@link Connection} 
+     * @return
+     */
+    ClassLoader getClassLoader();
+    
+    /**
+     * Return the number of connection that are currently in use.
+     * @return int is the number of connections in use
+     *
+     * @since
+     */
+    int getConnectionsInUseCount();
+    
+    /**
+     * Return the number of connections that are currently available in the pool.
+     * @return int is the number of connections currently available in the pool.
+     *
+     * @since 6.2
+     */
+    int getAvailableConnectionCount();
+    
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionPool.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionPoolConstants.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionPoolConstants.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionPoolConstants.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,73 @@
+/*
+ * 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.comm;
+
+
+
+/** 
+ * These are the properties are used by the {@link ConnectionPool) to create and manage
+ * connections.   These properties are passed into the pool when at initialization time.
+ * @since 1.0
+ */
+public interface ConnectionPoolConstants {
+     
+    /**
+     * Indicates the connection factory to use in the connection pool.
+     */
+    public static final String CONNECTION_FACTORY = "pool.connection.factory"; //$NON-NLS-1$
+        
+    /**
+     * Maximum connections for this pool. Default to 0, which means there is no limit.
+     */
+//    public static final String MAX_CONNECTIONS = "pool.max_connections"; //$NON-NLS-1$
+
+    /**
+     * Idle time of the connection before it should be closed in seconds. Default to 60 seconds.
+     */
+    public static final String LIVE_AND_UNUSED_TIME = "pool.live_and_unused_time"; //$NON-NLS-1$
+
+    /**
+     * Time to wait if the connection is not available in milliseconds.  Default to 2 seconds.
+     */
+    public static final String WAIT_FOR_SOURCE_TIME = "pool.wait_for_source_time"; //$NON-NLS-1$
+
+    /**
+     * Interval for running the cleaning thread in seconds. Default to 60 seconds.
+     */
+    public static final String CLEANING_INTERVAL = "pool.cleaning_interval"; //$NON-NLS-1$
+
+    /**
+     * Whether to enable pool shrinking.  Default to true.
+     */
+    public static final String ENABLE_SHRINKING = "pool.enable_shrinking"; //$NON-NLS-1$
+    
+    /**
+     * This property is used to specify the length of time between JDBC Source test connections
+     * How often (in seconds) to test that the data source is available by establishing a new connection.  Default to 600 seconds.
+     */
+//    public static final String CONNECTION_TEST_INTERVAL = "pool.connection.test.interval"; //$NON-NLS-1$
+
+    
+        
+
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/ConnectionPoolConstants.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/ExecutedResult.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/ExecutedResult.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/ExecutedResult.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,41 @@
+/*
+ * 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.comm;
+
+import java.util.List;
+
+public interface ExecutedResult {
+	
+	String getComponentType() ;
+	
+	String getOperationName();
+	
+	Object getResult();
+	
+	List<String> getFieldNameList();
+	
+	void setContent(List content);
+	
+	void setContent(String content);
+	
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/ExecutedResult.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/VMComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/VMComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/VMComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,32 @@
+/*
+ * 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.comm;
+
+
+/** 
+ * @since 4.3
+ */
+public interface VMComponent extends Component {
+    public static final String PORT = "mm.port"; //$NON-NLS-1$
+
+    String getPort();
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/VMComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/impl/ComponentImpl.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/impl/ComponentImpl.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/impl/ComponentImpl.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,244 @@
+/*
+ * 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.comm.impl;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.teiid.rhq.comm.Component;
+import org.teiid.rhq.comm.VMComponent;
+
+import com.metamatrix.core.util.HashCodeUtil;
+
+
+/** 
+ */
+public class ComponentImpl implements VMComponent {
+    private String systemKey;
+    private String description;
+    private String name;
+    private String identifier;
+    private String version="1.0"; //$NON-NLS-1$
+    private String port;
+    int hashCode;
+   
+    
+    private Properties compprops = new Properties();
+    
+    
+    public void addProperty(String key, String value) {
+    	compprops.put(key, value);
+    }
+    
+    public void setProperties(Properties props) {
+    	compprops.putAll(props);
+    }
+    
+    public String getProperty(String key) {
+    	return (String)compprops.get(key);
+    }
+    
+    public Map getProperties() {
+    	return compprops;
+    }
+    
+    /** 
+     * @return Returns the systemKey.
+     * @since 1.0
+     */
+    public String getSystemKey() {
+        return this.systemKey;
+    }
+
+    
+    /** 
+     * @param systemKey The systemKey to set.
+     * @since 1.0
+     */
+    public void setSystemKey(String systemKey) {
+        this.systemKey = systemKey;
+    }
+
+    /** 
+     * @see org.teiid.rhq.comm.Component#getDescription()
+     * @since 1.0
+     */
+    public String getDescription() {
+        return description;
+    }
+
+    /** 
+     * @see org.teiid.rhq.comm.Component#getIdentifier()
+     * @since 1.0
+     */
+    public String getIdentifier() {
+        return identifier;
+    }
+
+    /** 
+     * @see org.teiid.rhq.comm.Component#getName()
+     * @since 1.0
+     */
+    public String getName() {
+        return name;
+    }
+
+    /** 
+     * @see org.teiid.rhq.comm.Component#getVersion()
+     * @since 1.0
+     */
+    public String getVersion() {
+        return version;
+    }
+         
+    
+    /** 
+     * @return Returns the port.
+     */
+    public String getPort() {
+        return this.port;
+    }
+
+
+    
+    /** 
+     * @param port The port to set.
+     */
+    public void setPort(String port) {
+        this.port = port;
+    }
+
+
+    /** 
+     * @param description The description to set.
+     * @since 1.0
+     */
+    protected void setDescription(String description) {
+        this.description = description;
+    }
+
+    
+    /** 
+     * @param identifier The identifier to set.
+     * @since 1.0
+     */
+    protected void setIdentifier(String identifier) {
+        this.identifier = identifier;
+        this.hashCode = HashCodeUtil.hashCode(0, this.identifier);
+    }
+
+    
+    /** 
+     * @param name The name to set.
+     * @since 1.0
+     */
+    protected void setName(String name) {
+        this.name = name;
+    }
+
+    
+    /** 
+     * @param version The version to set.
+     * @since 1.0
+     */
+    protected void setVersion(String version) {
+        this.version = version;
+    }
+
+    /**
+     * Returns true if the specified object is semantically equal to this instance.
+     * Note:  this method is consistent with <code>compareTo()</code>.
+     * <p>
+     * @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 Component) {
+
+        	
+            // fail fast on different hash codes
+            if (this.hashCode() != obj.hashCode()) {
+                return false;
+            }
+
+            // slower comparison
+            Component that = (Component)obj;
+            return ( that.getSystemKey().equals(this.getSystemKey()) );
+        }
+
+        // Otherwise not comparable ...
+        return false;
+    }
+
+    /**
+     * Compares this object to another. If the specified object is an instance of
+     * the same class, then this method compares the name; otherwise, it throws a
+     * ClassCastException (as instances are comparable only to instances of the same
+     * class).  Note:  this method is consistent with <code>equals()</code>.
+     * <p>
+     * @param obj the object that this instance is to be compared to.
+     * @return a negative integer, zero, or a positive integer as this object
+     *      is less than, equal to, or greater than the specified object, respectively.
+     * @throws ClassCastException if the specified object's type prevents it
+     *      from being compared to this instance.
+     */
+    public int compareTo(Object obj) {
+        // Check if instances are identical ...
+        if (this == obj) {
+            return 0;
+        }
+        if (obj == null ) {
+            throw new IllegalArgumentException("Object is null, must be of type " + this.getClass().getName());
+        }
+
+        // Check if object cannot be compared to this one
+        // (this includes checking for null ) ...
+        if (!(obj instanceof Component)) {
+            throw new IllegalArgumentException(obj.getClass().getName() + " is not of type " + this.getClass().getName());
+        }
+
+        // Check if everything else is equal ...
+        Component that = (Component)obj;
+        int result = that.hashCode() - this.hashCode;
+        if ( result != 0 ) return result;
+        return this.getIdentifier().compareTo(that.getIdentifier());
+    }
+
+    /**
+     * Returns a string representing this instance.
+     * @return the string representation of this instance.
+     */
+    public String toString() {
+        return this.getIdentifier();
+    }
+
+    
+    
+ 
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/impl/ComponentImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionImpl.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionImpl.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionImpl.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,1340 @@
+/*
+ * 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.comm.impl;
+
+import java.lang.reflect.Method;
+import java.net.UnknownHostException;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.Host;
+import org.teiid.adminapi.ProcessObject;
+import org.teiid.adminapi.QueueWorkerPool;
+import org.teiid.adminapi.Request;
+import org.teiid.adminapi.Session;
+import org.teiid.adminapi.SystemObject;
+import org.teiid.rhq.comm.Component;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionPool;
+import org.teiid.rhq.comm.ExecutedResult;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Queries.Query;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.System.Metrics;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.System.Operations;
+import org.teiid.rhq.plugin.HostComponent;
+
+import com.metamatrix.jdbc.MMConnection;
+import com.metamatrix.platform.security.api.MetaMatrixSessionState;
+
+public class ConnectionImpl implements Connection, TeiidConnectionConstants {
+ 
+	// TODO:
+	// 1. Change from using LogManager. This writes to the MM Server, the
+	// messages should be
+	// written to the agent log
+	// 2. Need to support connecting via ssl
+	// 3. Need to understand the life cycle of a connection
+	// a. during discovery
+	// b. during monitoring, operations, etc.
+	// 4. add post processing for calculated fields in operation results
+	
+
+	private static final Log log = LogFactory.getLog(ConnectionImpl.class);
+
+	public String key = "";
+
+	private Properties environmentProps = null;
+
+	private Admin adminApi = null;
+	private MMConnection mmconn = null;
+    
+    private ConnectionPool connectionPool = null;
+    
+    // set when an exception is thrown by the admin api
+    // and indicates when close is called, to tell the pool
+    // to remove the connection;
+    private boolean invalidConnection = false;
+    
+    protected ConnectionImpl (final String key, 
+                                final Properties envProps,
+                                final ConnectionPool pool,
+                                final MMConnection connection) throws SQLException {
+        this.connectionPool = pool;
+        this.mmconn = connection;
+        this.adminApi = this.mmconn.getAdminAPI();
+        this.key = key;
+        this.environmentProps = envProps;        
+        
+    }
+
+    public boolean isValid() {
+        return (! this.invalidConnection);
+    }
+    /** 
+     * @see org.teiid.rhq.comm.Connection#isAlive()
+     */
+    public boolean isAlive() {
+        try {
+            if (adminApi != null) {
+                adminApi.getSystem();
+                this.invalidConnection=false;
+                return true;
+            }
+        } catch (Throwable e) {
+            invalidConnection = true;
+            log.error("Error: admin connection for " + key + " is not alive", e); //$NON-NLS-1$ //$NON-NLS-2$
+        } 
+        return false;
+    }    
+
+	/**
+	 * @see org.teiid.rhq.comm.Connection#close()
+	 */
+	public void close() {
+		try {
+			if (connectionPool != null) {
+                  connectionPool.close(this);
+            }
+                
+		} catch (Exception e) {
+			log.error("Error returning connection to the connection pool", e); //$NON-NLS-1$
+		} 
+		
+		invalidConnection = true;
+
+	}
+    
+
+    /**
+     * Called by the factory to close the source connection 
+     * 
+     */
+    
+    protected void closeSource() {
+        try {
+            if (mmconn != null) {
+            	mmconn.close();
+            }
+        } catch (Exception e) {
+            log.error("Error closing the admin connection", e); //$NON-NLS-1$
+        } finally {
+            adminApi = null;
+            mmconn = null;
+            connectionPool = null;
+            environmentProps.clear();
+            environmentProps = null; 
+            this.invalidConnection = true;
+            
+        }        
+    }
+
+//	public Properties getEnvironment() throws ConnectionException {
+//		Properties systemProperties = new Properties();
+//		try {
+//    		Collection processCollection = ConnectionUtil.getAllProcesses(
+//    				getConnection(), this.getHost().getIdentifier());
+//    
+//    		Iterator processIter = processCollection.iterator();
+//    		String portList = null;
+//    
+//    		boolean first = true;
+//    		while (processIter.hasNext()) {
+//    			ProcessObject process = (ProcessObject) processIter.next();
+//    			if (first) {
+//    				first = false;
+//    				portList = String.valueOf(process.getPort());
+//    			} else {
+//    				portList += PORT_DELIM + process.getPort(); //$NON-NLS-1$
+//    			}
+//    
+//    		}
+//    
+//    		systemProperties.setProperty(ConnectionConstants.USERNAME,
+//    				environmentProps.getProperty(ConnectionConstants.USERNAME));
+//    		systemProperties.setProperty(ConnectionConstants.PASSWORD,
+//    				environmentProps.getProperty(ConnectionConstants.PASSWORD));
+//    		systemProperties.setProperty(ConnectionConstants.PORTS, portList);
+//    		environmentProps = (Properties) systemProperties.clone();
+//    
+//    		return systemProperties;
+//        } catch (AdminException ae) {
+//            invalidConnection = true;
+//            throw new ConnectionException(ae.getMessage());            
+//        } finally {
+//            this.resetConnection();
+//        }
+//	}
+    
+    public Collection<Component> discoverComponents(String componentType,
+			String identifier) throws ConnectionException {
+		if (componentType
+				.equals(Runtime.Connector.TYPE)) {
+			return getConnectors(identifier);
+
+//		} else if (componentType
+//				.equals(Runtime.Service.TYPE)) {
+//			return getServices(identifier);
+
+		} else if (componentType
+				.equals(Runtime.Process.TYPE)) {
+			return getVMs(identifier);
+
+		} else if (componentType
+				.equals(Runtime.Host.TYPE)) {
+			return getAllHosts();
+
+//		} else if (componentType
+//				.equals(ComponentType.Resource.Service.TYPE)) {
+//			return getServicesForConfig(identifier);
+//
+//		} else if (componentType
+//				.equals(ComponentType.Resource.Connector.TYPE)) {
+//			return getConnectorsForConfig(identifier);
+
+		}
+//		else if (componentType
+//				.equals(ComponentType.Runtime.Session.TYPE)) {
+//			return getConnectorsForConfig(identifier);
+//
+//		}
+		return Collections.EMPTY_LIST;
+	}  
+    
+
+
+	public void executeOperation(ExecutedResult operationResult,
+            final Map valueMap) throws ConnectionException {
+
+        if (operationResult.getComponentType().equals(Runtime.Connector.TYPE)) {
+            executeConnectorOperation(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(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.TYPE)) {
+        	executeHostOperation(operationResult, operationResult.getOperationName(), valueMap);
+        }  else if (operationResult.getComponentType().equals(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session.TYPE)) {
+        	executeSessionOperation(operationResult, operationResult.getOperationName(), valueMap);
+        }  else if (operationResult.getComponentType().equals(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Queries.TYPE)) {
+        	executeQueriesOperation(operationResult, operationResult.getOperationName(), valueMap);
+        }         
+    }
+    
+
+
+	private void executeSystemOperation(ExecutedResult operationResult, final String operationName, final Map valueMap)
+    throws ConnectionException {
+        Object resultObject = new Object();
+        
+        if (operationName.equals(Operations.BOUNCE_SYSTEM)) {
+        	Boolean waitUntilFinished = (Boolean)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.WAIT_UNTIL_FINISHED);
+            bounceSystem(waitUntilFinished);
+        }else if (operationName.equals(Operations.GET_LONGRUNNINGQUERIES)) {
+        	Boolean includeSourceQueries = (Boolean)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.INCLUDE_SOURCE_QUERIES);
+        	Integer longRunningValue = (Integer)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.LONG_RUNNING_QUERY_LIMIT);
+			List fieldNameList = operationResult.getFieldNameList();
+        	resultObject = getLongRunningQueries(includeSourceQueries, longRunningValue, fieldNameList);
+        	operationResult.setContent((List)resultObject); 
+        }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); 
+        }
+
+    }    
+
+    private void executeProcessOperation(ExecutedResult operationResult, final String operationName, final Map valueMap)
+    throws ConnectionException {
+        Object resultObject = new Object();
+        
+        if (operationName.equals(ComponentType.Operation.GET_PROPERTIES)) {
+           	String identifier = (String)valueMap.get(ConnectionConstants.IDENTIFIER);
+           	Properties props = getProperties(Runtime.Process.TYPE, identifier); 
+           	resultObject = createReportResultList(props);
+           	operationResult.setContent((List)resultObject); 
+        }
+    }   
+    
+    private void executeHostOperation(ExecutedResult operationResult, final String operationName, final Map valueMap)
+    throws ConnectionException {
+        Object resultObject = new Object();
+        
+        if (operationName.equals(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.Operations.GET_HOSTS)) {
+           	String identifier = (String)valueMap.get(ConnectionConstants.IDENTIFIER);
+           	Properties props = getProperties(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.TYPE, identifier); 
+           	resultObject = createReportResultList(props);
+           	operationResult.setContent((List)resultObject); 
+        }
+    }    
+    
+    private void executeConnectorOperation(ExecutedResult operationResult, final String operationName, final Map valueMap)
+    throws ConnectionException {
+        Object resultObject = new Object();
+        String identifier = (String)valueMap.get(ConnectionConstants.IDENTIFIER);
+        
+        if (operationName.equals(Runtime.Connector.Operations.RESTART_CONNECTOR)) {
+            startConnector(identifier);
+        }else if (operationName.equals(Runtime.Connector.Operations.STOP_CONNECTOR)) { 
+            Boolean stopNow = (Boolean)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.STOP_NOW);
+            stopConnector(identifier, stopNow);
+        }else if (operationName.equals(ComponentType.Operation.GET_PROPERTIES)) {
+               	Properties props = getProperties(Runtime.Connector.TYPE, identifier); 
+               	resultObject = createReportResultList(props);
+               	operationResult.setContent((List)resultObject); 
+        }
+    }
+    
+    private void executeSessionOperation(ExecutedResult operationResult, final String operationName, final Map valueMap)
+    throws ConnectionException {
+    	if (operationName.equals(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session.Query.GET_SESSIONS)) {
+            Object resultObject = new Object();
+
+	    	List fieldNameList = operationResult.getFieldNameList();
+	        resultObject = getSessions(false, fieldNameList);
+	        operationResult.setContent((List)resultObject); 
+    	}
+
+    	
+    }
+    
+    private void executeQueriesOperation(ExecutedResult operationResult, final String operationName, final Map valueMap)
+    throws ConnectionException {
+   
+    	if (operationName.equals(Query.GET_QUERIES)) {
+    		Object resultObject = new Object();
+    		
+ //   		Boolean includeSourceQueries = (Boolean)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.INCLUDE_SOURCE_QUERIES);
+    		List fieldNameList = operationResult.getFieldNameList();
+    		resultObject = getRequests(false, fieldNameList);
+    		operationResult.setContent((List)resultObject); 
+    	}
+    }
+        
+
+    public Object getMetric(String componentType, String identifier, String metric, Map valueMap)
+    throws ConnectionException {
+        Object resultObject = new Object();
+        
+        if (componentType.equals(ComponentType.Runtime.System.TYPE)){
+            resultObject = getSystemMetric(componentType, metric, valueMap);
+        }else if (componentType.equals(Runtime.Process.TYPE)){
+            resultObject = getProcessMetric(componentType, identifier, metric, valueMap);
+        }
+        
+        
+        return resultObject;
+    }
+
+    private Object getSystemMetric(String componentType, String metric,
+                Map valueMap) throws ConnectionException {
+
+            Object resultObject = new Object();
+
+            if (metric.equals(Metrics.QUERY_COUNT)) {
+                resultObject = new Double(getQueryCount().doubleValue());
+            } else {
+                if (metric.equals(Metrics.SESSION_COUNT)) {
+                    resultObject = new Double(getSessionCount().doubleValue());
+                } else {
+                    if (metric.equals(Metrics.LONG_RUNNING_QUERIES)) {
+                    	Integer longRunningQueryLimit = (Integer)valueMap.get(ConnectionConstants.ComponentType.Operation.Value.LONG_RUNNING_QUERY_LIMIT);
+                        Collection<Request> longRunningQueries = getLongRunningQueries(false, longRunningQueryLimit, null);
+                        resultObject = new Double(longRunningQueries.size());
+                    }
+                }
+            }
+
+            return resultObject;
+        }
+            
+
+    private Object getProcessMetric(String componentType, String identifier, String metric,
+                Map valueMap) throws ConnectionException {
+
+            Object resultObject = new Object();
+
+            if (metric.equals(ComponentType.Metric.HIGH_WATER_MARK)) {
+                resultObject = new Double(getHighWatermark(identifier));
+            } 
+
+            return resultObject;
+        }
+
+	public Boolean isAvailable(String componentType, String identifier)
+			throws ConnectionException {
+
+		try {
+			
+			Admin conn = this.getConnection();
+			if (componentType
+					.equalsIgnoreCase(Runtime.Connector.TYPE)) {
+	                ConnectorBinding cb = ConnectionUtil.getConnector(conn, identifier);
+						if (cb.getState() == ConnectorBinding.STATE_OPEN) {
+							return true;
+						}	
+//			} else if (componentType
+//					.equalsIgnoreCase(Runtime.Service.TYPE)) {
+//                Service svc = ConnectionUtil.getService(conn, identifier);
+//				if (svc.getState() == Service.STATE_OPEN) {
+//					return true;
+//				}
+			
+			} else if (componentType
+					.equalsIgnoreCase(Runtime.Process.TYPE)) {
+	                ProcessObject vm = ConnectionUtil.getProcess(conn, identifier);
+					if (vm.isRunning()) {
+						return true;
+					}	
+			} else if (componentType
+					.equalsIgnoreCase(Runtime.Host.TYPE)) {
+	                Host host=ConnectionUtil.getHost(identifier, conn);
+					if (host.isRunning()) {
+						return true;
+					}	
+			} else if (componentType
+					.equalsIgnoreCase(Runtime.System.TYPE)) {
+					if (conn.getSystem() != null) {
+						return true;
+					}	
+			} 
+        } catch (AdminException ae) {
+            invalidConnection = true;
+                          
+            log.error(ae.getMessage());
+        } 
+		
+
+		return false;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see com.metamatrix.admin.api.rhq.connection.Connection#getProperty(java.lang.String,
+	 *      java.lang.String)
+	 */
+	public String getProperty(final String identifier, final String property)
+			throws ConnectionException {
+
+		String propertyValue = null;
+
+
+//		if (identifier.equals(ConnectionConstants.SYSTEM_NAME_IDENTIFIER)) {
+//			Resource mmResource = (Resource) getResource(identifier,
+//                                                             getConnection());
+//			propertyValue = mmResource.getPropertyValue(property);
+//		}
+
+		return propertyValue;
+
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see com.metamatrix.admin.api.rhq.connection.Connection#getInstallationDirectory()
+	 */
+	public String getKey() {
+		return key;
+	}
+
+	/**
+	 * @see org.teiid.rhq.comm.Connection#getHost()
+	 */
+	public Component getHost(String identifier) throws ConnectionException {
+        
+        try {
+        	
+			return  mapHost( ConnectionUtil.getHost(identifier, getConnection()) );
+		} catch (AdminException e) {
+	           invalidConnection = true;
+	            throw new ConnectionException(e.getMessage());            
+		} 
+
+	}
+	
+	public Collection getAllHosts() throws ConnectionException {
+		Collection<Component> hostObjs = null;
+//		try {
+//			Collection<Host> hosts = getConnection().getHosts("*"); 
+//			hostObjs = new ArrayList(hosts.size());
+//			
+//			for (Iterator<Host>it=hosts.iterator(); it.hasNext();) {
+//				Host h = it.next();
+//
+//				ComponentImpl chost = mapHost(h);
+//
+//				hostObjs.add(chost);
+//			}
+//		} catch (AdminException e) {
+//	           invalidConnection = true;
+//	            throw new ConnectionException(e.getMessage());            
+//		}  
+		
+		return hostObjs;
+	}
+	
+	private ComponentImpl mapHost(Host h) throws ConnectionException {
+		ComponentImpl chost = createComponent(h);
+		
+		chost.addProperty(HostComponent.INSTALL_DIR, h.getPropertyValue(Host.HOST_DIRECTORY));
+		return chost;
+	
+	}
+	
+	
+	/**
+	 * @see org.teiid.rhq.comm.Connection#getHost()
+	 */
+//	public Collection<Component> getServices(String vmIdentifier) throws ConnectionException {
+//        
+//        try {
+//        	
+//            Collection<Service> servicesCollection =  getConnection().getServices(vmIdentifier +"|*");
+//
+//       		Iterator<Service> iterSvc = servicesCollection.iterator();
+//
+//      		Collection<Component> svccomponents = new ArrayList<Component>(servicesCollection.size());
+//    		while (iterSvc.hasNext()) {
+//     			Service svc = iterSvc.next();   			
+//    			
+//    			Component comp = mapService(svc);
+//     
+//    			svccomponents.add(comp);
+//    		}
+//    		return svccomponents;
+//           	
+//		} catch (AdminException e) {
+//	           invalidConnection = true;
+//	            throw new ConnectionException(e.getMessage());            
+//		} 
+//
+//	}	
+//	
+	
+//	public Collection<Component> getServicesForConfig(String identifier)
+//			throws ConnectionException {
+//	       try {
+//	        	
+//	            Collection<Service> servicesCollection =  getConnection().getServicesToConfigure(identifier);
+//
+//	       		Iterator<Service> iterSvc = servicesCollection.iterator();
+//
+//	      		Collection<Component> svccomponents = new ArrayList<Component>(servicesCollection.size());
+//	    		while (iterSvc.hasNext()) {
+//	     			Service svc = iterSvc.next();   			
+//	    			
+//	    			Component comp = mapService(svc);
+//	     
+//	    			svccomponents.add(comp);
+//	    		}
+//	    		return svccomponents;
+//	           	
+//			} catch (AdminException e) {
+//		           invalidConnection = true;
+//		            throw new ConnectionException(e.getMessage());            
+//			} 
+//
+//	}
+
+	public Collection<Component> getVMs(String hostIdentifier) throws ConnectionException {
+        
+        try {
+             
+    		Collection processes = getConnection().getProcesses(hostIdentifier + "|*");   
+    
+    		Iterator<ProcessObject> iterVMs = processes.iterator();
+    		log.info("Processing processes..."); //$NON-NLS-1$
+    
+    		Collection vmcomponents = new ArrayList(processes.size());
+    		while (iterVMs.hasNext()) {
+    			// ProcessObject processObject = iterHostProcesses.next();
+    			ProcessObject vm = iterVMs.next();   			
+    			
+    			Component comp = mapProcess(vm);
+     
+    			vmcomponents.add(comp);
+    		}
+
+    		return vmcomponents;
+        } catch (AdminException ae) {
+            invalidConnection = true;
+            throw new ConnectionException(ae.getMessage());            
+            
+        } 
+	}	
+	
+	private Component mapProcess(ProcessObject vm) throws ConnectionException {
+		if (vm == null) return null;
+		
+			ComponentImpl comp = createComponent(vm);
+            comp.setPort(vm.getPropertyValue(ProcessObject.SERVER_PORT));
+ 		
+		return comp;
+
+	}
+
+	/**
+	 * @see com.metamatrix.rhq.comm.Connection#getVMs()
+	 */
+//	public Collection<Component> getVMs() throws ConnectionException {
+//        
+//		return getVMs(this.getHost().getIdentifier());
+// 
+//	}
+	
+	/**
+     * Returns a collection of all VDBs in the system.
+     * @param fieldNameList - operaration result fields if required. May be null. 
+     * 
+     * @return Collection   
+     */
+	public Collection getVDBs(List fieldNameList)
+			throws ConnectionException {
+
+		Collection vdbCollection = Collections.EMPTY_LIST;
+		
+		try {
+
+			vdbCollection = getConnection().getVDBs("*");
+		} catch (AdminException ae) {
+			invalidConnection = true;
+			throw new ConnectionException(ae.getMessage());
+
+		} 
+
+		if (fieldNameList != null) {
+			Collection reportResultCollection = createReportResultList(
+					fieldNameList, vdbCollection.iterator());
+			return reportResultCollection;
+		} else {
+			return vdbCollection;
+		}
+	}
+	
+	
+
+//	public Collection<Component> getConnectorsForConfig(String identifier)
+//			throws ConnectionException {
+//		
+//		Collection<Component> connectors = Collections.EMPTY_LIST;
+//		
+//	   try {
+//		Collection connectorsCollection =  getConnection().getConnectorBindingsToConfigure(identifier);
+//		
+//		Iterator<ConnectorBinding> iterConnectors = connectorsCollection.iterator();
+//		log.info("Getting connector bindings for configuration...");//$NON-NLS-1$
+//
+//		while (iterConnectors.hasNext()) {
+//			// ProcessObject processObject = iterHostProcesses.next();
+//			ConnectorBinding connectorBinding = iterConnectors.next();
+//
+//			log.debug("Found connector binding " + connectorBinding.getName());//$NON-NLS-1$
+//
+//			Component comp = mapConnector(connectorBinding);
+//
+//			connectors.add(comp);
+//		}		
+//		return connectors;
+//	} catch (AdminException e) {
+//        invalidConnection = true;
+//        throw new ConnectionException(e.getMessage());            
+//	}
+//
+//	}
+
+	public Collection<Component> getConnectors(String vmIdentifier) throws ConnectionException {
+
+		Collection<Component> connectors = Collections.EMPTY_LIST;
+		try {
+
+			Collection mmConnectors = getConnection().getConnectorBindings(vmIdentifier +"|*");
+
+			connectors = new ArrayList(mmConnectors != null ? mmConnectors
+					.size() : 0);
+
+			Iterator<ConnectorBinding> iterConnectors = mmConnectors.iterator();
+			log.info("Processing connector bindings...");//$NON-NLS-1$
+
+			while (iterConnectors.hasNext()) {
+				// ProcessObject processObject = iterHostProcesses.next();
+				ConnectorBinding connectorBinding = iterConnectors.next();
+
+				log
+						.info("Found connector binding " + connectorBinding.getName());//$NON-NLS-1$
+
+				Component comp = mapConnector(connectorBinding);
+
+				connectors.add(comp);
+			}
+        } catch (AdminException ae) {
+            invalidConnection = true;
+            throw new ConnectionException(ae.getMessage());            
+		} 
+		return connectors;
+	}
+	
+	private Component getConnector(String connectorIdentifier) throws ConnectionException {
+		
+			
+			try {
+				ConnectorBinding connectorBinding = ConnectionUtil.getConnector(getConnection(), connectorIdentifier);
+				return mapConnector(connectorBinding);
+				
+			} catch (AdminException ae) {
+	            invalidConnection = true;
+	            throw new ConnectionException(ae.getMessage());            
+			}
+	}
+	
+//	private Component getService(String svcIdentifier) throws ConnectionException {
+//		
+//		
+//		try {
+//			Service svc = ConnectionUtil.getService(getConnection(), svcIdentifier);
+//			return mapService(svc);
+//			
+//		} catch (AdminException ae) {
+//            invalidConnection = true;
+//            throw new ConnectionException(ae.getMessage());            
+//		}
+//}
+	
+	private Component mapConnector(ConnectorBinding connectorBinding) throws ConnectionException {
+		ComponentImpl comp = createComponent(connectorBinding);
+
+		comp.setDescription(connectorBinding.getDescription());
+		
+		return comp;
+
+	}	
+	
+//	private Component mapService(Service service) throws ConnectionException {
+//		ComponentImpl comp = createComponent(service);
+//
+//		comp.setDescription(service.getDescription());
+//		
+//		return comp;
+//
+//	}
+	
+	private Component mapSession(Session session) throws ConnectionException {
+		ComponentImpl comp = null;
+		
+			try {
+				Class clzz = Class.forName(ComponentImpl.class.getName(), true, this.connectionPool.getClassLoader());
+				comp = (ComponentImpl) clzz.newInstance();
+				
+						comp.setIdentifier(session.getIdentifier());
+					comp.setName(session.getSessionID());
+					comp.setSystemKey(getKey());
+					comp.setVersion("1.0"); //$NON-NLS-1$
+					
+					comp.setProperties(session.getProperties());
+
+
+			} catch (ClassNotFoundException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+				throw new ConnectionException(e.getMessage());
+			} catch (InstantiationException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+				throw new ConnectionException(e.getMessage());
+			} catch (IllegalAccessException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+				throw new ConnectionException(e.getMessage());
+			}
+	        return comp;
+
+
+	}	
+
+	// *******************
+	// Support Methods
+	// *******************
+
+	public Boolean isSystemAvailable() throws ConnectionException {
+
+        return this.isAlive();
+
+	}
+
+	private String getSystemName(final Admin adminApi) throws ConnectionException {
+		return "NoSystemName";
+//		Resource mmJGroups = (Resource) getResource("JGroups", adminApi); //$NON-NLS-1$
+//		return mmJGroups.getPropertyValue(SYSTEM_NAME_PROPERTY);
+	}
+
+
+	/**
+	 * @throws Exception
+	 */
+	// static
+//	private Integer getQueuedThreadCount(Admin adminApi) throws Exception {
+//		
+//		ProcessObject process = ConnectionUtil.getProcess(getConnection(), processIdentifier);
+//
+//		return process.getQueueWorkerPool().getQueued();
+//
+//	}
+
+    /**
+     * @throws Exception
+     */
+    private void startConnector(final String connectorBindingIdentifier) throws ConnectionException {
+        try {
+            (getConnection())
+                    .startConnectorBinding(connectorBindingIdentifier);
+        } catch (AdminException ae) {
+            invalidConnection = true;
+            throw new ConnectionException(ae.getMessage());            
+
+        } 
+    }
+
+    /**
+     * @throws Exception
+     */
+    private void bounceSystem(final boolean waitUntilFinished) throws ConnectionException {
+        try {
+            getConnection().restart();
+        } catch (AdminException err) {
+            throw new ConnectionException(err.getMessage());
+        } 
+    }
+    
+    /**
+     * @throws Exception
+     */
+    private void stopConnector(String connectorBindingIdentifier, boolean hardStop)
+            throws ConnectionException {
+        try {
+            getConnection().stopConnectorBinding(
+                    connectorBindingIdentifier, hardStop);
+        } catch (AdminException ae) {
+            invalidConnection = true;
+            throw new ConnectionException(ae.getMessage());            
+
+        } 
+    }
+
+	/**
+	 * @throws Exception
+	 */
+	private static boolean isReachable(final String host, int port)
+			throws UnknownHostException {
+		return NetUtils.getInstance().isPortAvailable(host, port);
+	}
+
+	/**
+	 * @throws Exception
+	 */
+	// static
+//	private Integer getThreadPoolThreadCount(final Admin adminApi)
+//			throws ConnectionException {
+//		Integer threadCount = new Integer(0);
+//		
+//		ProcessObject process = ConnectionUtil.getProcess(getConnection(), processIdentifier);
+//
+//		QueueWorkerPool pool = null;
+//			pool = process.getQueueWorkerPool();
+//			threadCount = pool.getThreads();
+//		return threadCount;
+//	}
+
+	private Integer getQueryCount() throws ConnectionException {
+
+		Integer count = new Integer(0);
+
+		Collection<Request> requestsCollection = null;
+		requestsCollection = getRequests(false, null);
+        
+		if (requestsCollection != null && !requestsCollection.isEmpty()) {
+			count = requestsCollection.size();
+		}
+
+		return count;
+	}
+	
+	protected Collection<Request> getRequests(boolean includeSourceQueries, List fieldNameList) throws ConnectionException {
+
+		Collection<Request> requestsCollection = null;;
+		
+		try {
+			Admin conn = getConnection();
+			requestsCollection = conn.getRequests(WILDCARD);
+			if (includeSourceQueries){
+				Collection<Request> sourceRequestsCollection = Collections.EMPTY_LIST;
+				sourceRequestsCollection = conn.getSourceRequests(WILDCARD);
+				requestsCollection.addAll(sourceRequestsCollection);
+			}
+        } catch (AdminException ae) {
+            invalidConnection = true;
+            throw new ConnectionException(ae.getMessage());            
+            
+		} catch (Exception e) {
+			final String msg = "Exception getting the AdminApi in getRequests: "; //$NON-NLS-1$
+            log.error(msg, e);
+            throw new ConnectionException(msg);
+		} 
+		
+		if (fieldNameList!=null){
+			Collection reportResultCollection = createReportResultList(fieldNameList, requestsCollection.iterator());
+			return reportResultCollection;
+		}else{
+			return requestsCollection;
+		}
+		
+	}
+	
+	protected void cancelRequest(String requestID) throws ConnectionException {
+		
+		try {
+			getConnection().cancelRequest(requestID);
+        } catch (AdminException ae) {
+            invalidConnection = true;
+            throw new ConnectionException(ae.getMessage());            
+            
+		} catch (Exception e) {
+			final String msg = "Exception getting the AdminApi in getRequests: "; //$NON-NLS-1$
+            log.error(msg, e);
+            throw new ConnectionException(msg);
+		} 
+		
+	}
+	
+//	public Collection<Request> postProcessing(String operationName, Collection reportResultCollection) throws ConnectionException {
+//
+//		if (operationName.equals(ConnectionConstants.ComponentType.Operation.GET_QUERIES)){
+//			Iterator resultIter = reportResultCollection.iterator();
+//			while (resultIter.hasNext()){
+//				Map row = (Map)resultIter.next();
+//				String createDateString = row.get("Createdate");
+//				Date createDate = new Date(createDateString);
+//				
+//				Date current = new Date(System.nanoTime());
+//				GregorianCalendar cal = new GregorianCalendar();
+//				cal.add()
+//				Date elapsedTime = Calendar.getInstance().add( createDate)
+//			}
+//			String createDateString = reportResultList.			
+//		}
+//		return reportResultList;
+//	}
+
+	protected Collection<Request> getLongRunningQueries(boolean includeSourceQueries, int longRunningValue, List fieldNameList) throws ConnectionException {
+
+		Collection<Request> requestsCollection = null;
+
+		double longRunningQueryTimeDouble = new Double(longRunningValue);
+
+		try {
+			requestsCollection = getRequests(includeSourceQueries, null);
+        } catch (Exception e) {
+			final String msg = "AdminException getting the AdminApi in getLongRunningQueries: "; //$NON-NLS-1$
+            log.error(msg, e);
+            throw new ConnectionException(msg);
+		} 
+
+		Iterator<Request> requestsIter = requestsCollection.iterator();
+		while (requestsIter.hasNext()) {
+			Request request = requestsIter.next();
+			Date startTime = request.getProcessingDate();
+			// Get msec from each, and subtract.
+			long runningTime = Calendar.getInstance().getTimeInMillis() - startTime.getTime();
+			
+			if (runningTime < longRunningQueryTimeDouble) {
+				requestsIter.remove();
+			}
+		}
+
+		if (fieldNameList!=null){
+			Collection reportResultCollection = createReportResultList(fieldNameList, requestsCollection.iterator());
+			return reportResultCollection;
+		}else{
+			return requestsCollection;
+		}
+	}
+	
+	private Integer getSessionCount() throws ConnectionException {
+
+		Collection<Session> activeSessionsCollection = Collections.EMPTY_LIST;
+		try {
+			activeSessionsCollection = getActiveSessions();
+        } catch (AdminException ae) {
+            invalidConnection = true;
+            throw new ConnectionException(ae.getMessage());            
+            
+		} catch (Exception e) {
+			final String msg = "AdminException getting the AdminApi in getSessionCount: "; //$NON-NLS-1$
+            log.error(msg, e);
+            throw new ConnectionException(e.getMessage());
+		} 
+
+		return activeSessionsCollection.size();
+	}
+	
+	private Collection<Session> getActiveSessions(String identifier) throws AdminException {
+		Collection allSessionsCollection = getConnection().getSessions(identifier);
+		Collection activeSessionsCollection = new ArrayList();
+
+		Iterator<Session> allSessionsIter = allSessionsCollection
+				.iterator();
+		while (allSessionsIter.hasNext()) {
+			Session session = allSessionsIter.next();
+			if (session.getState() == MetaMatrixSessionState.ACTIVE) {
+				activeSessionsCollection.add(session);
+			}
+		}
+		
+		return activeSessionsCollection;
+	}
+
+	private Collection<Session> getActiveSessions() throws AdminException {
+		Collection allSessionsCollection = getConnection().getSessions(WILDCARD);
+		Collection activeSessionsCollection = new ArrayList();
+
+		Iterator<Session> allSessionsIter = allSessionsCollection
+				.iterator();
+		while (allSessionsIter.hasNext()) {
+			Session session = allSessionsIter.next();
+			if (session.getState() == MetaMatrixSessionState.ACTIVE) {
+				activeSessionsCollection.add(session);
+			}
+		}
+		
+		return activeSessionsCollection;
+	}
+
+	public Collection getSessions(boolean activeOnly, List fieldNameList) throws ConnectionException {
+
+		Collection sessionsCollection  = Collections.EMPTY_LIST;
+		try {
+			if (activeOnly){
+				sessionsCollection = getActiveSessions();
+			}else{
+				sessionsCollection = getConnection().getSessions(WILDCARD);
+			}
+        } catch (AdminException ae) {
+            invalidConnection = true;
+            throw new ConnectionException(ae.getMessage());            
+            
+		} catch (Exception e) {
+			final String msg = "AdminException getting the AdminApi in getSessions: "; //$NON-NLS-1$
+            log.error(msg, e);
+            throw new ConnectionException(e.getMessage());
+		} 
+		
+		if (sessionsCollection != null && sessionsCollection.size() > 0) {
+			Iterator sessionsIter = sessionsCollection.iterator();
+		
+			return createReportResultList(fieldNameList, sessionsIter);
+		}
+
+		return Collections.EMPTY_LIST;
+	}
+
+	private Collection createReportResultList(Properties props) {
+		Collection reportResultList = new ArrayList();
+		
+		//Create list from properties and sort
+		Enumeration<Object> keys = props.keys();
+		List<String> elementList = new ArrayList();
+		while (keys.hasMoreElements()) {
+			elementList.add((String) keys.nextElement());
+		}
+
+		Collections.sort(elementList);
+		
+		Iterator propsKeySetIter = elementList.iterator();
+		
+		while (propsKeySetIter.hasNext()) {
+			Map reportValueMap = new HashMap();
+			String name = (String)propsKeySetIter.next();
+			Object value = props.get(name);
+			reportValueMap.put(ConnectionConstants.ComponentType.Operation.Value.NAME, name);
+			reportValueMap.put(ConnectionConstants.ComponentType.Operation.Value.VALUE, value);
+			reportResultList.add(reportValueMap);
+		}
+		return reportResultList;
+	}
+	
+	private Collection createReportResultList(List fieldNameList, Iterator sessionsIter) {
+		Collection reportResultList = new ArrayList();
+		
+		while (sessionsIter.hasNext()) {
+			Object object = sessionsIter.next();
+
+			Class cls = null;
+			try {
+				cls = object.getClass();
+				Iterator methodIter = fieldNameList.iterator();
+				Map reportValueMap = new HashMap();
+				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;
+	}
+	
+	private Integer getHighWatermark(String processIdentifier) throws ConnectionException {
+
+		try {
+			
+			ProcessObject process = ConnectionUtil.getProcess(getConnection(), processIdentifier);
+			QueueWorkerPool pool = null;
+				pool = process.getQueueWorkerPool();
+				return pool.getTotalHighwaterMark();
+				
+		} catch (AdminException e) {
+			// TODO Auto-generated catch block
+			throw new ConnectionException(e.getMessage());
+				
+		} 
+
+	}
+
+	/**
+	 * @param resourcePrefix
+	 * @return
+	 */
+//	private  Object getResource(final String resourceIdentifier,
+//			final Admin adminApi) throws ConnectionException {
+//
+//		Object resource = null;
+//		try {
+//
+//			Collection<Object> resourceCollection = getConnection()adminApi
+//					.getResources(resourceIdentifier);
+//			// Collection<Object> processCollection = ((ServerMonitoringAdmin)
+//			// adminApi)
+//			// .getProcesses(AdminObject.WILDCARD);
+//			Iterator<Object> resourceIter = resourceCollection.iterator();
+//
+//			while (resourceIter.hasNext()) {
+//				resource = resourceIter.next();
+//			}
+//        } catch (AdminException ae) {
+//            invalidConnection = true;
+//            throw new ConnectionException(ae.getMessage());            
+//           
+//
+//		} catch (Exception e) {
+//			final String msg = "LogonException getting the AdminApi in getResource: "; //$NON-NLS-1$
+//            log.error(msg, e);
+//		}
+//
+//		return resource;
+//	}
+
+
+	/**
+	 * @param resourcePrefix
+	 * @return
+	 */
+	private Component getProcess(final String processIdentifier) throws ConnectionException {
+
+		ProcessObject process = null;
+		try {
+
+			process = ConnectionUtil.getProcess(getConnection(), processIdentifier);
+			
+			return mapProcess(process);
+
+		} catch (Exception e) {
+			final String msg = "AdminException in getProcess: "; //$NON-NLS-1$
+            log.error(msg, e);
+            throw new ConnectionException(e.getMessage());
+		} 
+
+	}
+
+    /**
+     *  Return the properties for component of a specified resource type  
+     * @param resourceType
+     * @param identifier
+     * @return
+     * @throws ConnectionException
+     * @since 5.5.3
+     */
+    
+    public Properties getProperties(String resourceType, String identifier) 
+        throws ConnectionException { 
+    	String className = null;
+    	Component ao = null;
+        if (resourceType.equalsIgnoreCase(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.TYPE) ) {
+            className = Host.class.getName();
+            ao = this.getHost(identifier);
+          
+       } else if (resourceType.equalsIgnoreCase(ConnectionConstants.ComponentType.Runtime.System.TYPE) ) {
+           className = SystemObject.class.getName(); 
+           			
+                   
+       } else if (resourceType.equalsIgnoreCase(Runtime.Process.TYPE) ) {
+           className = ProcessObject.class.getName();   
+           
+           ao = this.getProcess(identifier);
+                   
+       } else if (resourceType.equalsIgnoreCase(Runtime.Connector.TYPE) ) {
+           className = ConnectorBinding.class.getName();                   
+                   
+           ao = this.getConnector(identifier);
+//       } else if (resourceType.equalsIgnoreCase(Runtime.Service.TYPE) ) {
+//           className = Service.class.getName();                   
+//                   
+//           ao = this.getService(identifier);
+       } 
+        
+       if (ao == null) {
+           throw new ConnectionException("Unable to get properties for invalid resource " + identifier + " of resource type " + resourceType);  //$NON-NLS-1$
+       }
+        
+        Properties props = null;
+        try {
+            Map defaults = ConnectionUtil.getPropertiesDefinitions(getConnection(), resourceType, className, identifier);
+            
+            props = new Properties();
+            props.putAll(defaults);
+            
+            // overlay the defined properties for the component object over the defaults
+            props.putAll(ao.getProperties());
+        } catch (AdminException ae) {
+            invalidConnection = true;
+            throw new ConnectionException(ae.getMessage());            
+
+        } 
+        
+        return props;
+        
+    }
+    /*    
+
+	/**
+	 * Returns the system name for the current connection
+	 * 
+	 * @param componentName
+	 * @param operationName
+	 * @param parameters
+	 * @return systemName
+	 */
+//	private String getProperty() throws Exception {
+//
+//		String systemName = "NoSystemName";
+
+
+//        Resource mmJGroups = (Resource) getResource("JGroups",  getConnection()); //$NON-NLS-1$
+//        systemName = mmJGroups.getPropertyValue("metamatrix.cluster.name"); //$NON-NLS-1$
+//
+//        return systemName;
+//
+//	}
+
+	private Admin getConnection()  {
+         return adminApi;
+        
+
+	}
+	
+   private ComponentImpl createComponent(AdminObject object) throws ConnectionException {
+	   if (object != null) {
+		   return createComponent(object.getIdentifier(), object.getName(), object.getProperties());
+	   }
+	   return createComponent("NOTSET", "NAMENOTSET", null);
+
+	   
+	   
+   }
+    
+    
+    private ComponentImpl createComponent(String identifier, String name, Properties props) throws ConnectionException {
+
+        ComponentImpl comp = null;
+		try {
+			Class clzz = Class.forName(ComponentImpl.class.getName(), true, this.connectionPool.getClassLoader());
+			comp = (ComponentImpl) clzz.newInstance();
+			
+			comp.setIdentifier(identifier);
+			comp.setName(name);
+			comp.setSystemKey(getKey());
+			comp.setVersion("1.0"); //$NON-NLS-1$
+			
+			if (props != null) {
+				comp.setProperties(props);
+			}
+			
+
+		} catch (ClassNotFoundException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			throw new ConnectionException(e.getMessage());
+		} catch (InstantiationException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			throw new ConnectionException(e.getMessage());
+		} catch (IllegalAccessException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			throw new ConnectionException(e.getMessage());
+		}
+        return comp;
+
+    }
+
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionUtil.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionUtil.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionUtil.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,341 @@
+/*
+ * 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.comm.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.Host;
+import org.teiid.adminapi.ProcessObject;
+import org.teiid.adminapi.PropertyDefinition;
+import org.teiid.adminapi.Service;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Process;
+
+
+/** 
+ * @since 4.3
+ */
+public class ConnectionUtil implements TeiidConnectionConstants {
+    
+	private static Map<String, Map<String, Object>> defCache = new HashMap<String, Map<String, Object>>();
+    
+    /**
+     * Call to find a host.  The hostName passed in can be any of the
+     * the following:
+     * <li>The fully qualified host name</li>
+     * <li>The short name of the fully qualified host name</li>
+     * <li>The IP address of box</li>
+     * <li>The bind address defined in the host properties</li>
+     * <li>The general reference of localhost</li>
+     * 
+     * The order of resolution will be as follows:
+     * 1.  Try to match the IPAddress resolved host names to what is configured.
+     * <li>hostName matches to configured host name</li>
+     * <li>resolve hostName to an InetAddress and use its' full host name to match configured host(s)</li>
+     * <li>resolve hostName to an InetAddress and use its' short host name to match configured host(s)</li>
+     * <li>In cases where the <code>hostName</code> represents the short name and will not resolve to a longer name, 
+     *     convert the <code>Host</code> full name to the short name to try to match.</li>
+     * <li>match hostname to the physical address for a configurated host</li>  
+     * <li>match hostname to the bindaddress for a configurated host</li>  
+     * 2.  Reverse the match, try matching what's configurated to host name passed
+     * <li>try using the short name of configured host to match</li>
+     * <li>try using the physical address of the configurated host match</li>
+     * <li>try using the bind address of the configured host to match</li>
+     * 
+     * NOTE:  This logic is duplicated from the CurrentConfiguration.findHost().  That method could not
+     * be used due to the different <code>Host</code> object types that are used.
+     * 
+     * @param hostName
+     * @return Host
+     * @throws Exception
+     * @since 5.5
+     */
+//    public static Host findHost(String hostName,  ServerAdmin adminapi)  throws AdminException  {
+//
+//        Host h = null;
+//        
+//        try {
+//            // first try to match the name pas host by what was passed before
+//            // substituting something else
+//            h = getHost(hostName, adminapi);
+//            if (h != null) {
+//                return h;
+//            }
+//            
+//            h = getHost(InetAddress.getLocalHost().getHostName(), adminapi);
+//            if (h != null) {
+//                return h;
+//            }
+//            
+//                            
+//            // the hostName could be an IP address that we'll use to try to 
+//            // resolve back to the actuall host name
+//            InetAddress inetAddress = InetAddress.getByName(hostName);           
+//
+//            // try using the fully qualified host name
+//            
+//            h = getHost(inetAddress.getCanonicalHostName(), adminapi);
+//            if (h != null) {
+//                return h;
+//            }
+//            
+//            h = getHost(inetAddress.getHostName(), adminapi);            
+//            if (h != null) {
+//                return h;
+//            }
+//                    
+//            // try the address
+//              h = getHost(inetAddress.getHostAddress(), adminapi);
+//              
+//              if (h != null) {
+//                  return h;
+//              }            
+//        } catch (AdminException ae) {
+//            throw ae;
+//        } catch (Exception e) {
+//            // do nothing
+//        }
+//        
+//        
+//        
+//        // 2nd try to match 
+//        try {
+//            Collection hosts = getAllHosts(adminapi);
+//            // if the host name passed in is the short name,
+//            // then try to match to the Host short name
+//            
+//            Iterator hi = hosts.iterator(); 
+//            
+//            while (hi.hasNext()) {
+//                   
+//                String hostAddress = h.getPropertyValue(Host.HOST_PHYSICAL_ADDRESS);
+//                
+//                if (hostAddress != null && hostAddress.equalsIgnoreCase(hostName)) {
+//                    return h;
+//                } 
+//                String hostBindAddress = h.getPropertyValue(Host.HOST_BIND_ADDRESS);
+//                
+//                if (hostBindAddress.equalsIgnoreCase(hostName)) {
+//                    return h;
+//                }
+//                         
+//    
+//            }                 
+//               
+//        } catch (AdminException ae) {
+//            throw ae;
+//        } catch (Exception e) {
+//            // do nothing
+//        }       
+//        
+//        
+//        return null;
+//
+//    }    
+    
+    /**
+     * Called to return only 1 host 
+     * @param hostName
+     * @param adminapi
+     * @return
+     * @throws AdminException
+     * @since 4.3
+     */
+    public static Host getHost(String hostIdentifier,  Admin adminapi) throws AdminException {
+        //  Configuring and monitoring will no longer be done thru a single connection.
+    	//  each host will be managed seperately
+     	
+    	
+//        Collection hosts = adminapi.getHosts(hostIdentifier);
+//        
+//        if (hosts != null && hosts.size() == 1) {
+//            // return the unique host by the hostName
+//            return (Host) hosts.iterator().next();
+//        }
+        // return null if no hosts were found or 
+        // multiple hosts were found by that name.          
+        return null;
+    }
+    
+    /**
+     * Called to return all the currently defined hosts 
+     * @param adminapi
+     * @return
+     * @throws AdminException
+     * @since 4.3
+     */
+//    public static Collection getAllHosts(Admin adminapi) throws AdminException {
+//        
+//    	return adminapi.getHosts("*"); //$NON-NLS-1$
+//    }   
+    
+    
+    /**
+     * @param adminApi is the connection to the MM Server
+     * @return Collection of MMProcesses
+     */
+//    public static Collection getAllProcesses(final Admin adminApi, String identifier) throws AdminException {
+//
+//        Collection processCollection = Collections.EMPTY_LIST;
+//
+//        processCollection =  adminApi.getProcesses(identifier + "|*");          //$NON-NLS-1$
+//
+//        return processCollection;
+//    }
+    
+    public static ProcessObject getProcess(final Admin adminApi, String processIdentifier) throws AdminException {
+        
+        Collection processCollection =  adminApi.getProcesses(processIdentifier);
+        
+        if (processCollection != null && processCollection.size() == 1) {
+            // return the unique connector binding
+            return (ProcessObject) processCollection.iterator().next();
+        }
+        
+        return null;
+    }     
+      
+    /**
+     * @param adminApi is the connection to the MM Server
+     * @return Collection of MMProcesses
+     */
+//    public static Collection getAllConnectors(final Admin adminApi, String vmIdentifier) throws AdminException {
+//
+//        Collection connectorCollection = Collections.EMPTY_LIST;
+//            
+//        connectorCollection =  adminApi.getConnectorBindings(vmIdentifier +"|*");
+//
+//
+//        return connectorCollection;
+//    }   
+    
+    public static ConnectorBinding getConnector(final Admin adminApi, String cbIdentifier) throws AdminException {
+            
+        Collection connectorCollection =  adminApi.getConnectorBindings(cbIdentifier);
+        
+        if (connectorCollection != null && connectorCollection.size() == 1) {
+            // return the unique connector binding
+            return (ConnectorBinding) connectorCollection.iterator().next();
+        }
+        
+        return null;
+    }
+    
+    public static Service getService(final Admin adminApi, String svcIdentifier) throws AdminException {
+        
+//        Collection svcCollection =  adminApi.getServices(svcIdentifier);
+//        
+//        if (svcCollection != null && svcCollection.size() == 1) {
+//            // return the unique connector binding
+//            return (Service) svcCollection.iterator().next();
+//        }
+        
+        return null;
+    }
+
+    
+    /**
+     * @param adminApi is the connection to the MM Server
+     * 
+     * @return Collection of VDBs
+     */
+//    public static Collection getAllVDBs(final Admin adminApi) throws AdminException {
+//
+//        Collection connectorCollection = Collections.EMPTY_LIST;
+//            
+//        connectorCollection =  adminApi.getVDBs("*"); //$NON-NLS-1$
+//
+//        return connectorCollection;
+//    }    
+    
+    /*
+     * Return the tokens in a string in a list. This is particularly
+     * helpful if the tokens need to be processed in reverse order. In that case,
+     * a list iterator can be acquired from the list for reverse order traversal.
+     *
+     * @param str String to be tokenized
+     * @param delimiter Characters which are delimit tokens
+     * @return List of string tokens contained in the tokenized string
+     */
+    public static List getTokens(String str, String delimiter) {
+        ArrayList l = new ArrayList();
+        StringTokenizer tokens = new StringTokenizer(str, delimiter);
+        while(tokens.hasMoreTokens()) {
+            l.add(tokens.nextToken());
+        }
+        return l;
+    }    
+    
+
+    public static synchronized Map getPropertiesDefinitions(final Admin adminApi, String resourceType, String className, String identifier) throws AdminException, ConnectionException {
+        Properties result = new Properties();
+        
+        boolean cache = false;
+        if ( resourceType.equalsIgnoreCase(org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.TYPE) ||
+        		resourceType.equalsIgnoreCase(Process.TYPE) ) {
+           	    cache = true;
+           	    
+                if (defCache.containsKey(className)) {
+                	return defCache.get(className);
+                }
+        }
+
+       
+         Collection pdefs = adminApi.getPropertyDefinitions(identifier, className);
+
+         Map<String, Object> defMap = new HashMap<String, Object>();
+         
+         for (Iterator it=pdefs.iterator(); it.hasNext();) {
+             PropertyDefinition pdef = (PropertyDefinition)it.next();
+             Object value = pdef.getValue() != null ? pdef.getValue() : pdef.getDefaultValue();
+             defMap.put(pdef.getName(), (value != null ? value : "")); //$NON-NLS-1$             
+             
+         } 
+         
+         if (cache) {
+        	 defCache.put(className, defMap);
+         }
+                  
+        
+        return defMap;
+    }
+    
+    static class InvalidAdminException extends Throwable {
+
+       public InvalidAdminException(String msg) {
+           super(msg);
+       }
+        
+    }
+        
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/impl/ConnectionUtil.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/impl/InvalidConnectionImpl.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/impl/InvalidConnectionImpl.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/impl/InvalidConnectionImpl.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,200 @@
+/*
+ * 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.comm.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.teiid.rhq.comm.Component;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionPool;
+import org.teiid.rhq.comm.ExecutedResult;
+
+
+
+/** 
+ */
+public class InvalidConnectionImpl implements
+                                    Connection,
+                                    TeiidConnectionConstants {
+
+
+	private static final Log LOG = LogFactory.getLog(InvalidConnectionImpl.class);
+
+    private static final Object METRIC=new Double(0);
+    private static final String EMPTY_STRING="";  //$NON-NLS-1$
+
+    
+    private String key = EMPTY_STRING;
+    private Properties environmentProps = null;
+    private ConnectionPool connectionPool = null;
+    
+    public InvalidConnectionImpl (final String key,
+                                final Properties envProps,
+                                final ConnectionPool pool) {
+        this.key = key;
+        this.environmentProps = envProps;       
+        this.connectionPool = pool;
+    }
+    
+    public boolean isValid() {
+        return false;
+    }
+    /** 
+     * @see org.teiid.rhq.comm.Connection#isAlive()
+     * @since 1.0
+     */
+    public boolean isAlive() {
+        return false;
+    }
+
+    /** 
+     * @see org.teiid.rhq.comm.Connection#close()
+     * @since 1.0
+     */
+    public void close() {
+        try {
+            if (connectionPool != null) {
+                 connectionPool.close(this);
+             }
+                
+        } catch (Exception e) {
+            LOG.error("Error returning connection to the connection pool", e); //$NON-NLS-1$
+        } 
+    }
+    
+    /** 
+     * @see org.teiid.rhq.comm.Connection#getMetric(java.lang.String, java.lang.String, java.util.Map)
+     * @since 1.0
+     */
+    public Object getMetric(String componentType,
+    						String identifier,
+                            String metric,
+                            Map valueMap) throws ConnectionException {
+        return METRIC;
+    }
+
+    /** 
+     * @see org.teiid.rhq.comm.Connection#executeOperation(java.lang.String, java.lang.String, java.util.Map)
+     * @since 1.0
+     */
+    public void executeOperation(ExecutedResult operationResult,
+    							 Map argumentMap) throws ConnectionException {       
+    }
+
+    /** 
+     * @see org.teiid.rhq.comm.Connection#isAvailable(java.lang.String, java.lang.String)
+     * @since 1.0
+     */
+    public Boolean isAvailable(String componentType,
+                               String identifier) throws ConnectionException {
+        return false;
+    }
+    
+    
+
+    /** 
+     * @see org.teiid.rhq.comm.Connection#getProperties(java.lang.String, java.lang.String)
+     * @since 1.0
+     */
+    public Properties getProperties(String resourceType,
+                                    String identifier) throws ConnectionException {
+        return new Properties();
+    }
+
+    /** 
+     * @see org.teiid.rhq.comm.Connection#getProperty(java.lang.String, java.lang.String)
+     * @since 1.0
+     */
+    public String getProperty(String identifier,
+                              String property) throws ConnectionException {
+        return EMPTY_STRING;
+    }
+
+    /** 
+     * @see org.teiid.rhq.comm.Connection#getKey()
+     * @since 1.0
+     */
+    public String getKey() throws Exception {
+        return key;
+    }
+
+    /** 
+     * @see org.teiid.rhq.comm.Connection#getConnectors(java.lang.String)
+     * @since 1.0
+     */
+    public Collection<Component> getConnectors(String vmname) throws ConnectionException {
+        return Collections.EMPTY_LIST;
+    }
+
+    
+    public Collection<Component> getVMs(String hostname) throws ConnectionException {
+        return Collections.EMPTY_LIST;
+    }    
+    
+    public Collection<Component> getVDBs(List fieldNameList) throws ConnectionException {
+		return Collections.EMPTY_LIST;
+	}
+
+    
+    public Collection getAllHosts() throws ConnectionException {
+        return Collections.EMPTY_LIST;
+    }
+
+	public Component getHost(String identifier) throws ConnectionException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+    
+    public Collection<Component> getConnectorsForConfig(String vmidentifier)
+	throws ConnectionException {
+// TODO Auto-generated method stub
+return Collections.EMPTY_LIST;
+}
+
+public Collection<Component> getServices(String vmIdentifier)
+	throws ConnectionException {
+// TODO Auto-generated method stub
+return Collections.EMPTY_LIST;
+}
+
+public Collection<Component> getServicesForConfig(String identifier)
+	throws ConnectionException {
+// TODO Auto-generated method stub
+return Collections.EMPTY_LIST;
+}
+
+public Collection<Component> discoverComponents(String componentType,
+		String identifier) throws ConnectionException {
+	// TODO Auto-generated method stub
+	return Collections.EMPTY_LIST;
+}  
+
+
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/impl/InvalidConnectionImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/impl/NetUtils.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/impl/NetUtils.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/impl/NetUtils.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,172 @@
+/*
+ * 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.comm.impl;
+
+import java.io.IOException;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.Socket;
+import java.net.SocketException;
+import java.net.UnknownHostException;
+import java.util.Enumeration;
+
+
+public class NetUtils {
+	private InetAddress inetAddress;
+	
+	private static NetUtils INSTANCE = new NetUtils();
+	
+	public static NetUtils getInstance() {
+		return INSTANCE;
+	}
+	    
+    public InetAddress getInetAddress() throws UnknownHostException {
+    	resolveHostName();
+    	return this.inetAddress; 
+    }
+    
+
+    /**
+     * Resolves the given host name into InetAddress; if host name can not be resolved then it will
+     * throw {@link UnknownHostException}
+     * @param hostName
+     * @return
+     * @throws UnknownHostException
+     */
+    public static InetAddress resolveHostByName(String hostName) throws UnknownHostException {
+        if( hostName.equalsIgnoreCase("localhost")) { //$NON-NLS-1$
+            try {
+				return getInstance().getInetAddress();
+			} catch (UnknownHostException e) {
+			}
+        } 
+       	return InetAddress.getByName(hostName);
+    }
+    
+    /*
+     * Dynamically resolving the host name should only be done when setupmm is being run
+     * or when the vm initially starts up and the configuration Host has to be found based on that resolution.  
+     * After that, the {@link VMNaming} class should be used to obtain the logical and physical host addresses. 
+     */
+    private synchronized void resolveHostName() throws UnknownHostException {
+    	UnknownHostException une = null;
+
+    	boolean preferIPv6=Boolean.getBoolean("java.net.preferIPv6Addresses");//$NON-NLS-1$
+
+    	// majority of the times we will find the address with this below call 
+    	if (this.inetAddress == null) {
+	    	try {
+	        	InetAddress addr = InetAddress.getLocalHost();
+	        	if(!addr.isLoopbackAddress()) {
+	        		this.inetAddress = addr;
+	        	}
+	        } catch(UnknownHostException e) {
+	        	une=e;
+	        }     
+    	}
+
+    	// see if you can find a non-loopback address, based on the preference
+    	if (this.inetAddress == null) {
+    		this.inetAddress = findAddress(preferIPv6, false);
+    	}
+    	
+    	// if no-addresses found so far then resort to IPv4 loopback address
+    	if (this.inetAddress == null) {
+    		this.inetAddress = findAddress(false, true);
+    	}
+    	
+    	if (this.inetAddress == null) {
+    		if (une != null) throw une;
+    		throw new UnknownHostException("failed to resolve the address for localhost"); //$NON-NLS-1$
+    	}
+    }
+
+    
+    
+    /**
+     * Finds a InetAddress of the current host where the JVM is running, by querying NetworkInterfaces installed
+     * and filters them by given preferences. It will return the first Address which UP and meets the criteria
+     * @param preferIPv6 
+     * @param perferLoopback
+     * @return null is returned if requested criteria is not met.
+     * @throws UnknownHostException
+     * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4665037 (Linux issue with resolving to loopback in the DHCP situations)
+     */
+    private InetAddress findAddress(boolean preferIPv6, boolean perferLoopback) throws UnknownHostException {
+    	try {
+			Enumeration<NetworkInterface> ne = NetworkInterface.getNetworkInterfaces();
+			while (ne.hasMoreElements()) {
+				NetworkInterface ni = ne.nextElement();
+				//## JDBC4.0-begin ##
+				if (ni.isUp()) {
+				//## JDBC4.0-end ##
+					Enumeration<InetAddress> addrs = ni.getInetAddresses();
+					while (addrs.hasMoreElements()) {
+						InetAddress addr = addrs.nextElement();
+						
+						boolean isIPv6 = (addr instanceof Inet6Address);
+						if (preferIPv6 == isIPv6 && perferLoopback == addr.isLoopbackAddress() ) {
+							return addr;
+						}
+					}
+				//## JDBC4.0-begin ##		
+				}
+				//## JDBC4.0-end ##
+			}
+		} catch (SocketException e) {
+			// treat this as address not found and return null;
+		}
+    	return null;
+    }
+    
+    /**
+     * Call to determine if a port is available to be opened.  
+     * This is used to determine if a port is already opened 
+     * by some other process. If the port is available, then
+     * it's not in use.   
+     * @param host
+     * @param port
+     * @return true if the port is not opened.
+     * @since 4.3
+     */
+    public boolean isPortAvailable(String host, int port) throws UnknownHostException {
+        
+        try {
+            //using Socket to try to connect to an existing opened socket
+            Socket ss = new Socket(host, port);
+            
+            try {
+                ss.close();
+            } catch (Exception ce) {
+                // it was open and considered available, then dont worry about the close error
+            }
+            return false;
+        } catch (UnknownHostException ce) {
+            throw ce;
+        } catch (IOException e) {
+        	//ignore
+        }
+        return true;
+    }
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/impl/NetUtils.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionConstants.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionConstants.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionConstants.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,49 @@
+/*
+ * 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.comm.impl;
+
+import org.teiid.adminapi.AdminObject;
+
+
+/** 
+ * @since 4.3
+ */
+public interface TeiidConnectionConstants {
+
+    public static final String MMPORT = "mmport"; //$NON-NLS-1$
+    public static final String PORT_DELIM = ","; //$NON-NLS-1$
+   
+    
+    public static String ID_DELIMITER = AdminObject.DELIMITER;
+    public static String MMPROCESS = AdminObject.DELIMITER + "MMProcess"; //$NON-NLS-1$
+    public static String WILDCARD = "*"; //$NON-NLS-1$
+    public static final String LONGRUNNINGQUERYTIME = "longRunningQueryTime"; //$NON-NLS-1$
+    public static final double MS_TO_MIN = 1.66666666666667E-05;
+    public static final String PROTOCOL = "mm://"; //$NON-NLS-1$
+    
+    public static final String SSL_PROTOCOL = "mms://"; //$NON-NLS-1$   
+    
+    public static String defaultPort = "31000"; //$NON-NLS-1$
+    
+    public static String SYSTEM_NAME_PROPERTY = "metamatrix.cluster.name"; //$NON-NLS-1$
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionConstants.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionFactory.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionFactory.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionFactory.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,248 @@
+/*
+ * 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.comm.impl;
+
+/*
+ * The connection factory implementation is located here so that a new version
+ * of MetaMatrix that has different connection requirements can be dealt
+ * with on a per MM Version.
+ */
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.teiid.adminapi.Admin;
+import org.teiid.jdbc.TeiidDriver;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionFactory;
+import org.teiid.rhq.comm.ConnectionPool;
+
+import com.metamatrix.common.comm.platform.client.ServerAdminFactory;
+import com.metamatrix.common.jdbc.JDBCUtil;
+import com.metamatrix.jdbc.MMConnection;
+
+
+
+public class TeiidConnectionFactory implements
+		ConnectionFactory {
+    private static final Log LOG = LogFactory.getLog(TeiidConnectionFactory.class);
+
+	private Properties connEnv;
+    private ConnectionPool pool;
+    private String username = null;
+    private String password = null;
+    private String url = null;
+    
+    public TeiidConnectionFactory() {
+        
+    }
+    
+    public String getURL() {
+    	return url;
+    }
+	
+	public Connection createConnection() throws ConnectionException {
+		
+		Thread currentThread = Thread.currentThread();
+		ClassLoader threadContextLoader = currentThread.getContextClassLoader();
+		try {
+	        currentThread.setContextClassLoader(pool.getClassLoader());
+	        
+	        MMConnection mmconn = getConnection();
+	
+	        if (mmconn != null) {
+	            ConnectionImpl conn  = new ConnectionImpl(url, connEnv, pool, mmconn);
+	            if (conn.isAlive()) {
+	                return conn;
+	            }
+	            
+	            conn.closeSource();                       
+	        } 
+	        
+	        return new InvalidConnectionImpl(url, connEnv, pool);
+		} catch (SQLException e) {
+			// TODO Auto-generated catch block
+			throw new ConnectionException(e);
+		} finally {
+			currentThread.setContextClassLoader(threadContextLoader);
+		}
+            
+		
+	}
+
+
+	public void initialize( final Properties env, final ConnectionPool connectionPool) throws ConnectionException {
+		this.connEnv = (Properties) env.clone();
+        this.pool = connectionPool;
+       
+        
+        if (pool == null || connEnv == null || connEnv.isEmpty()) {
+            throw new ConnectionException("ConnectionFactory has not been initialized properly"); //$NON-NLS-1$
+        }
+       
+        
+        url = connEnv.getProperty(ConnectionConstants.URL);
+        username = connEnv
+                .getProperty(ConnectionConstants.USERNAME);
+        password = connEnv
+                .getProperty(ConnectionConstants.PASSWORD);
+        
+        
+        if (url == null ) {
+            throw new ConnectionException("URL is not set"); //$NON-NLS-1$
+            
+        }
+        if (username == null ) {
+            throw new ConnectionException("USERNAME is not set"); //$NON-NLS-1$
+            
+        }
+        if (password == null ) {
+            throw new ConnectionException("PASSWORD is not set"); //$NON-NLS-1$
+            
+        }        
+	}
+
+
+    /** 
+     * @see org.teiid.rhq.comm.ConnectionFactory#closeConnection(org.teiid.rhq.comm.Connection)
+     */
+    public void closeConnection(Connection connection)  {
+        if (connection instanceof ConnectionImpl) {
+            ConnectionImpl conn = (ConnectionImpl) connection;
+            conn.closeSource();
+        } else {
+        
+        	connection.close();
+        }
+    }
+    
+    private MMConnection getConnection()  {
+    	MMConnection conn = null;
+        Throwable firstexception = null;
+
+            try {
+            	Properties props = new Properties();
+            	props.setProperty(JDBCUtil.DATABASE, url);
+            	props.setProperty(JDBCUtil.DRIVER, TeiidDriver.class.getName());
+            	props.setProperty(JDBCUtil.USERNAME, username);
+            	props.setProperty(JDBCUtil.PASSWORD, password);
+            	
+            	conn = (MMConnection) JDBCUtil.createJDBCConnection(props);
+            	
+
+                return conn;
+            } catch (Throwable ce) {
+                if (firstexception == null) {
+                    firstexception = ce;
+                }
+            }
+        
+        if (firstexception != null) {
+        	firstexception.printStackTrace();
+            LOG.error("Unable to connect to JBEDSP System: " + firstexception.getMessage()); //$NON-NLS-1$
+        }
+
+        return null;
+    }    
+       
+    /**
+     * @param userName
+     * @param password
+     * @param servers
+     * @return Admin
+     * @throws Exception,
+     *             AdminException
+     * @since 5.5.3
+     */
+//    private Admin getAdminAPI(String pusername, String ppassword, String purl)
+//            throws Exception {
+//      
+//        String servers = null;
+//                
+//        com.metamatrix.common.comm.platform.client.ServerAdminFactory factory = null;
+// 
+//        Admin serverAdmin = null;
+//        
+//        try {
+//            factory = ServerAdminFactory.getInstance();
+//
+//            serverAdmin = factory.createAdmin(pusername, ppassword.toCharArray(),                                                   
+//                purl, "RHQ"); //$NON-NLS-1$
+//             
+//        } catch (Throwable ae) {
+//                if (ae instanceof MetaMatrixRuntimeException) {
+//                    Throwable child = ((MetaMatrixRuntimeException) ae).getChild();
+//                    if (child.getMessage().indexOf("Read timed out") > 0) { //$NON-NLS-1$ 
+//                        try {
+//                            
+//                            System.setProperty("com.metamatrix.ssl.trustStore", key + "/client/metamatrix.truststore"); //$NON-NLS-1$  //$NON-NLS-2$ 
+//                            servers = MMConnectionConstants.SSL_PROTOCOL + iNetAddress.getHostName() + ":" + pport; //$NON-NLS-1$ 
+//                            serverAdmin = factory.createAdmin(pusername, ppassword.toCharArray(),                                                   
+//                                                          servers, "RHQ");//$NON-NLS-1$ 
+//                        } catch (Exception ae2) {
+//                            throw ae;
+//                        }
+//                    } else {
+//                        throw ae;
+//                    }
+//                } else {
+//                    throw new Exception(ae.getMessage());
+//                }
+
+//        }
+//        LOG.info("Connected to JBEDSP Server using " + servers);  //$NON-NLS-1$
+//
+//        this.url = purl;
+//
+//        return serverAdmin;
+//    }
+    
+    
+    
+    /*
+     * Return the tokens in a string in a list. This is particularly
+     * helpful if the tokens need to be processed in reverse order. In that case,
+     * a list iterator can be acquired from the list for reverse order traversal.
+     *
+     * @param str String to be tokenized
+     * @param delimiter Characters which are delimit tokens
+     * @return List of string tokens contained in the tokenized string
+     */
+    private static List getTokens(String str, String delimiter) {
+        ArrayList l = new ArrayList();
+        StringTokenizer tokens = new StringTokenizer(str, delimiter);
+        while(tokens.hasMoreTokens()) {
+            l.add(tokens.nextToken());
+        }
+        return l;
+    }      
+  
+   
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionFactory.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/embedded/EmbeddedConnectionMgr.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/embedded/EmbeddedConnectionMgr.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/embedded/EmbeddedConnectionMgr.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,97 @@
+package org.teiid.rhq.embedded;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.teiid.rhq.admin.ConnectionMgr;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionPool;
+import org.teiid.rhq.embedded.pool.ConnectionPoolImpl;
+import org.teiid.rhq.embedded.pool.EmbeddedConnectionConstants;
+
+
+
+public class EmbeddedConnectionMgr implements ConnectionMgr {
+	private static final Log log = LogFactory.getLog(EmbeddedConnectionMgr.class);
+		
+	private ConnectionPool pool;
+	private Properties props;
+	private ClassLoader loader;
+	
+	private Map<String, Connection> connectionList = new HashMap(1);
+	 
+
+	public Connection getConnection(String key) throws ConnectionException {
+		return pool.getConnection();
+	}
+	
+	
+
+	public Set<String> getInstallationSystemKeys() {
+		Set<String> keys = new HashSet<String>(1);
+		keys.add(EmbeddedConnectionConstants.SYSTEM_KEY);
+		return keys;
+	}
+
+
+
+	public Map getServerInstallations() {
+		connectionList = new HashMap(1);
+		try {
+			connectionList.put(pool.getKey(), pool.getConnection());
+		} catch (ConnectionException e) {
+			// TODO Auto-generated catch block
+			throw new InvalidPluginConfigurationException(e);
+		}
+		return connectionList;
+	}
+
+	public void shutdown() {
+
+			try {
+				pool.shutdown();
+			} catch (ConnectionException e) {
+				// TODO Auto-generated catch block
+				log.error("Error shutting down connection pool", e);
+
+			}
+			pool = null;
+			
+			connectionList.clear();
+		
+	}
+
+	   public boolean hasServersDefined() {
+		   return (pool !=null);
+	   }
+	   
+		  public void initialize(Properties props, ClassLoader cl) {
+				this.props = props;
+				this.loader = cl;
+		
+		            // allow override of the factory class
+		            // this was put in to allow testing to set the factory
+		            String factoryclass = System.getProperty(ConnectionPool.CONNECTION_FACTORY);
+		            if (factoryclass != null) {
+		                props.setProperty(ConnectionPool.CONNECTION_FACTORY, factoryclass);
+		            }
+		            
+		            try {	            
+		                 Class clzz = Class.forName(ConnectionPoolImpl.class.getName(), true, this.loader);
+		                 this.pool = (ConnectionPoolImpl) clzz.newInstance(); 
+		                	 //new ConnectionPoolImpl();
+		                this.pool.initialize(props, cl); 
+		           
+		                log.info("ConnectionPool created for key " + pool.getKey()); //$NON-NLS-1$ //$NON-NLS-2$
+		            } catch (Throwable t) {
+		                throw new InvalidPluginConfigurationException(t);
+		            }
+		      }
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/embedded/EmbeddedConnectionMgr.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/embedded/pool/ConnectionPoolImpl.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/embedded/pool/ConnectionPoolImpl.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/embedded/pool/ConnectionPoolImpl.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,266 @@
+package org.teiid.rhq.embedded.pool;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionFactory;
+import org.teiid.rhq.comm.ConnectionPool;
+
+
+/*
+ * 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.
+ */
+
+/**
+ * Simple pooling built on JDBCUtil.  Not compatible with DataSources, etc.
+ * Added due to poor 1.6 support among common connection pool implementations.
+ * 
+ * TODO: Should be switched to proxool or some implementation
+ */
+public class ConnectionPoolImpl implements ConnectionPool
+
+{
+
+    public static final String WAIT_TIME_FOR_RESOURCE= "jbedsp.pool.wait.time"; //$NON-NLS-1$
+    public static final String MAXIMUM_RESOURCE_POOL_SIZE = "jbedsp.pool.maximum.size"; //$NON-NLS-1$
+    public static final String RESOURCE_TEST_INTERVAL = "jbedsp.pool.test.interval"; //$NON-NLS-1$
+    
+	private final class ConnectionProxy implements InvocationHandler {
+		private Connection c;
+		private long lastTest = System.currentTimeMillis();
+		private Boolean valid = Boolean.TRUE;
+		
+		public ConnectionProxy(Connection c) {
+			this.c = c;
+		}
+
+		public Object invoke(Object proxy, Method method, Object[] args)
+				throws Throwable {
+			try {
+				if (method.getName().equals("close")) { //$NON-NLS-1$
+					boolean isShutdown = shutdown;
+					boolean success = false;
+					try {
+						if (!isShutdown) {
+							connections.add((Connection)proxy);
+							success = true;
+						}
+					} finally {
+						connectionLock.release();
+						if (!success) {
+							c.close();
+							return null;
+						}
+					}
+					if (success) {
+						return null;
+					}
+				} else if (method.getName().equals("isValid")) { //$NON-NLS-1$
+					long now = System.currentTimeMillis();
+					if (lastTest + testInterval > now) {
+						return c.isValid();
+					} 
+					lastTest = now;
+					try {
+						valid = c.isAlive();						
+					} catch (AbstractMethodError e) {
+						valid = c.isValid();
+					} 
+					return valid;
+				}
+				return method.invoke(c, args);
+			} catch (InvocationTargetException e) {
+				valid = false;
+				throw e.getCause();
+			}
+		}
+	}
+	
+   /**
+     * The default connection factory if one is not specified in the environment
+     */
+     static final String CONNECTION_FACTORY_DEFAULT=ConnectionFactory.CONNECTION_FACTORY_DEFAULT;  //$NON-NLS-1$
+	
+	
+	private Semaphore connectionLock;
+	private ConcurrentLinkedQueue<Connection> connections = new ConcurrentLinkedQueue<Connection>();
+	private Properties p;
+	private int timeout;
+	private int testInterval;
+	private volatile boolean shutdown;
+    private ConnectionFactory factory = null;
+    
+    private ClassLoader loader = null;
+			
+	public void close(Connection connection) {
+
+		
+	}
+
+	
+
+	@Override
+	public int getAvailableConnectionCount() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+
+
+	@Override
+	public int getConnectionsInUseCount() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+
+
+	public ClassLoader getClassLoader() {
+		return this.loader;
+	}
+
+
+	public String getKey() {
+		return EmbeddedConnectionConstants.SYSTEM_KEY;
+	}
+
+
+
+	public void initialize(Properties env, ClassLoader cl) throws ConnectionException {
+		this.p = env;
+		this.loader = cl;
+		this.timeout = getIntProperty(p, WAIT_TIME_FOR_RESOURCE, 30000);
+		this.testInterval = getIntProperty(p, RESOURCE_TEST_INTERVAL, 30000);
+		this.connectionLock = new Semaphore(getIntProperty(p, MAXIMUM_RESOURCE_POOL_SIZE, 15));
+		
+//        liveAndUnusedTime = getIntProperty(LIVE_AND_UNUSED_TIME, DEFAULT_LIVE_AND_UNUSED_TIME);
+//        cleaningInterval = getIntProperty(CLEANING_INTERVAL, DEFAULT_CLEANING_INTERVAL);
+
+		
+        createFactory();
+	}
+
+
+
+	public Connection getConnection() throws ConnectionException {
+		if (shutdown) {
+			throw new ConnectionException("pool shutdown"); //$NON-NLS-1$
+		}
+		try {
+			if (!connectionLock.tryAcquire(timeout, TimeUnit.MILLISECONDS)) {
+				throw new ConnectionException("Timeout waiting for connection"); //$NON-NLS-1$
+			}
+		} catch (InterruptedException e) {
+			throw new ConnectionException(e);
+		}
+		boolean releaseLock = true;
+		try {
+			boolean valid = false;
+			Connection c = connections.poll();
+			if (c != null) {
+
+				valid  = c.isValid();
+				if (!valid) {
+					try {
+						factory.closeConnection(c);
+					} catch (Exception e) {
+						
+					}
+					c = null;
+				}
+			}
+			if (c == null) {
+				if (shutdown) {
+					throw new ConnectionException("pool shutdown"); //$NON-NLS-1$
+				}
+				c = factory.createConnection();
+				c = (Connection) Proxy.newProxyInstance(this.loader, new Class[] {Connection.class}, new ConnectionProxy(c));
+				connections.add(c);
+			}
+
+			releaseLock = false;
+			return c;
+		} catch (ConnectionException ce) {
+			throw ce;
+		} finally {
+			if (releaseLock) {
+				connectionLock.release();
+			}
+		}
+	}
+	
+	public void shutdown() {
+		this.shutdown = true;
+		Connection c = connections.poll();
+		while (c != null) {
+			try {
+				c.close();
+			} catch (Exception e) {
+				
+			}
+			c = connections.poll();
+		}		
+		
+	}
+
+
+    private void createFactory() throws ConnectionException {
+        
+        String factoryclass = p.getProperty(ConnectionPool.CONNECTION_FACTORY, CONNECTION_FACTORY_DEFAULT);
+  
+            try {
+            	Class<?> c = Class.forName(factoryclass, true, this.loader);
+                factory = (ConnectionFactory)c.newInstance();
+            } catch (Exception err) {
+                throw new ConnectionException(err.getMessage());
+            }
+            
+             // Initialize connector instance...
+            factory.initialize(p, this);
+      
+   }
+    
+    public static int getIntProperty(Properties props, String propName, int defaultValue) throws ConnectionException {
+        int val = defaultValue;
+        String stringVal = props.getProperty(propName);
+        if(stringVal != null && stringVal.trim().length() > 0) {
+        	try {
+        		val = Integer.parseInt(stringVal);
+        	} catch (NumberFormatException nfe) {
+        		throw new ConnectionException(nfe.getMessage());
+        	}
+        }
+        return val;
+    }
+    
+
+    
+}
+
+


Property changes on: trunk/console/src/main/java/org/teiid/rhq/embedded/pool/ConnectionPoolImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/embedded/pool/EmbeddedConnectionConstants.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/embedded/pool/EmbeddedConnectionConstants.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/embedded/pool/EmbeddedConnectionConstants.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,40 @@
+/*
+ * 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.embedded.pool;
+
+
+/** 
+ * These are the Constants that used when the jbedsp-plugin is running in the enbedded environment
+ */
+public interface EmbeddedConnectionConstants {
+    
+    /**
+     * These are Environment properties need to create a connection.  They will be exposed via the @see #getEnvironment call.
+     */
+        public final static String USERNAME = "username"; //$NON-NLS-1$
+        public final static String PASSWORD = "password"; //$NON-NLS-1$
+        public final static String URL = "url"; //$NON-NLS-1$
+        
+
+        public final static String SYSTEM_KEY="jbedsp_system"; //$NON-NLS-1$
+         
+   }


Property changes on: trunk/console/src/main/java/org/teiid/rhq/embedded/pool/EmbeddedConnectionConstants.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/enterprise/AdminUtil.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/enterprise/AdminUtil.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/enterprise/AdminUtil.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,219 @@
+/*
+ * 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.enterprise;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+public class AdminUtil {
+	
+	private final static String[] CLASSLOADERPREFIXVALUES = new String[] {
+		"/jbedsp-teiid", "/teiid-client-", "/log4j-", "/commons-logging", "/teiid-common-core", "netty-" };  //$NON-NLS-1$,  //$NON-NLS-2$,  //$NON-NLS-3$,  //$NON-NLS-4$ 
+	
+	public static ClassLoader createClassloader(String installDir, ClassLoader parentClassLoader) {
+		if (true) {
+			return parentClassLoader;
+		}
+		        LinkedList p = new LinkedList();
+        String[] classLoaderValues = getJarsForPrefixes(installDir + "/lib");  //$NON-NLS-1$
+        String[] patches = getPatchJars(installDir + "/lib/patches");  //$NON-NLS-1$
+        int cnt = classLoaderValues.length;
+        if (patches != null) {        	
+            p.addAll(Arrays.asList(patches));
+            cnt += patches.length;
+        }  
+        
+        p.add(installDir + "/lib/"); //$NON-NLS-1$
+        cnt++;
+        
+        if (classLoaderValues != null){
+        	p.addAll(Arrays.asList(classLoaderValues));
+        }       
+
+		URL[] urls = new URL[cnt];
+		try {
+            
+          
+			for (int i = 0; i < cnt; i++) {
+                String f = (String) p.get(i);
+				urls[i] = new File(f).toURL();
+			}
+            ClassLoader classLoader = new URLClassLoader(urls, parentClassLoader);
+            return classLoader;
+          
+		} catch (Exception e) {
+            e.printStackTrace();
+			// TODO: handle exception 
+		}
+        
+        return null;
+	}
+	
+	private static String[] getJarsForPrefixes(String dir) {
+        ArrayList<String> jarArrayList = new ArrayList<String>();
+        File[] jarFiles = findAllFilesInDirectoryHavingExtension(dir, ".jar"); //$NON-NLS-1$
+        if (jarFiles != null && jarFiles.length > 0) {
+            for (int i = 0; i < jarFiles.length; i++) {
+                try {
+                	String fileName =  jarFiles[i].getCanonicalPath();
+                	for (int j = 0; j < CLASSLOADERPREFIXVALUES.length; j++){
+                		if (fileName.contains(CLASSLOADERPREFIXVALUES[j].toString())){
+                			jarArrayList.add(fileName);
+                			break;
+                		}
+                	}
+                } catch (Exception e) {
+                    //TODO
+                }
+            }
+                
+        }
+        String[] jars = new String[jarArrayList.size()];
+        int i = 0;
+        Iterator<String> jarIter = jarArrayList.iterator();
+        while(jarIter.hasNext()){
+        	jars[i++] = jarIter.next();
+        }
+        
+        return jars;
+    }
+    
+    private static String[] getPatchJars(String dir) {
+        String[] jars = null;
+        File[] jarFiles = findAllFilesInDirectoryHavingExtension(dir, ".jar"); //$NON-NLS-1$
+        if (jarFiles != null && jarFiles.length > 0) {
+            jars = new String[jarFiles.length];
+            for (int i = 0; i < jarFiles.length; i++) {
+                try {
+                	jars[i] =  jarFiles[i].getCanonicalPath();
+                } catch (Exception e) {
+                    //TODO
+                }
+            }
+                
+        }
+        return jars;
+    }
+    
+    /**
+     * Returns a <code>File</code> array that will contain all the files that
+     * exist in the directory that have the specified extension.
+     * @return File[] of files having a certain extension
+     */
+    private static File[] findAllFilesInDirectoryHavingExtension(String dir, final String extension) {
+
+      // Find all files in that directory that end in XML and attempt to
+      // load them into the runtime metadata database.
+      File modelsDirFile = new File(dir);
+      FileFilter fileFilter = new FileFilter() {
+          public boolean accept(File file) {
+              if(file.isDirectory()) {
+                  return false;
+              }
+
+
+              String fileName = file.getName();
+
+              if (fileName==null || fileName.length()==0) {
+                  return false;
+              }
+
+              // here we check to see if the file is an .xml file...
+              int index = fileName.lastIndexOf("."); //$NON-NLS-1$
+
+              if (index<0 || index==fileName.length()) {
+                  return false;
+              }
+
+              if (fileName.substring(index, fileName.length()).equalsIgnoreCase(extension)) {
+                  return true;
+              }
+              return false;
+          }
+      };
+
+      File[] modelFiles = modelsDirFile.listFiles(fileFilter);
+
+      return modelFiles;
+
+  }    
+	
+	/**
+	 * Return the tokens in a string in a list. This is particularly
+	 * helpful if the tokens need to be processed in reverse order. In that case,
+	 * a list iterator can be acquired from the list for reverse order traversal.
+	 *
+	 * @param str String to be tokenized
+	 * @param delimiter Characters which are delimit tokens
+	 * @return List of string tokens contained in the tokenized string
+	 */
+	public static List getTokens(String str, String delimiter) {
+		ArrayList l = new ArrayList();
+		StringTokenizer tokens = new StringTokenizer(str, delimiter);
+		while(tokens.hasMoreTokens()) {
+			l.add(tokens.nextToken());
+		}
+		return l;
+    }
+	
+    /*
+     * Replace all occurrences of the search string with the replace string
+     * in the source string. If any of the strings is null or the search string
+     * is zero length, the source string is returned.
+     * @param source the source string whose contents will be altered
+     * @param search the string to search for in source
+     * @param replace the string to substitute for search if present
+     * @return source string with *all* occurrences of the search string
+     * replaced with the replace string
+     */
+    public static String replaceAll(String source, String search, String replace) {
+        if (source != null && search != null && search.length() > 0 && replace != null) {
+            int start = source.indexOf(search);
+            if (start > -1) {
+                StringBuffer newString = new StringBuffer(source);
+                replaceAll(newString, search, replace);
+                return newString.toString();
+            }
+        }
+        return source;    
+    }
+    
+    public static void replaceAll(StringBuffer source, String search, String replace) {
+        if (source != null && search != null && search.length() > 0 && replace != null) {
+            int start = source.toString().indexOf(search);
+            while (start > -1) {
+                int end = start + search.length();
+                source.replace(start, end, replace);
+                start = source.toString().indexOf(search, start + replace.length());
+            }
+        }
+    }    
+	
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/enterprise/AdminUtil.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/enterprise/EnterpriseConnectionMgr.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/enterprise/EnterpriseConnectionMgr.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/enterprise/EnterpriseConnectionMgr.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,154 @@
+package org.teiid.rhq.enterprise;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.teiid.rhq.admin.ConnectionMgr;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionPool;
+import org.teiid.rhq.enterprise.pool.ConnectionPoolImpl;
+
+
+public class EnterpriseConnectionMgr implements ConnectionMgr {
+	private static final Log log = LogFactory.getLog(EnterpriseConnectionMgr.class);
+	
+	
+	public static final String INSTALL_SERVER_PROP="mmservers";  //$NON-NLS-1$
+
+	private static Map poolMap =  Collections.synchronizedMap( new HashMap(5) );
+	
+
+	private Properties props = null;
+
+
+	public Connection getConnection(String key) throws ConnectionException {
+        Connection connection = null;
+        
+        log.info("Get Connection for  " + key); //$NON-NLS-1$
+        
+        ConnectionPool pool = (ConnectionPool) poolMap.get(key);
+        connection = pool.getConnection();
+                
+        return connection;
+	}
+	
+
+	public Set getInstallationSystemKeys() {
+		// TODO Auto-generated method stub
+		return poolMap.keySet();
+	}
+
+
+	public boolean hasServersDefined() {
+        
+        if (poolMap != null && poolMap.size() > 0) {
+            return true;
+        }
+        return false;
+        
+    }	
+
+	public Map getServerInstallations() {
+        Map connectionList = new HashMap();
+        Iterator installationIter = poolMap.keySet().iterator();
+
+         while (installationIter.hasNext()) {
+            String installDir = (String) installationIter.next();
+            try {
+                if (poolMap.get(installDir) != null) {
+                    ConnectionPool pool = (ConnectionPool) poolMap.get(installDir);
+                
+                    Connection connection = pool.getConnection(); 
+                    connectionList.put(installDir, connection);
+                } else {
+                    // this shouldn't happen
+                    connectionList.put(installDir, null);
+                }
+            } catch (Exception e) {
+                connectionList.put(installDir, null);
+            }
+        }
+        
+
+		return connectionList;
+	}
+
+
+	public void shutdown() {
+        Iterator installationIter = poolMap.keySet().iterator();
+        
+        while (installationIter.hasNext()) {
+           String installDir = (String) installationIter.next();
+               ConnectionPool pool = (ConnectionPool) poolMap.get(installDir);
+       		try {
+    			pool.shutdown();
+    		} catch (ConnectionException e) {
+    			// TODO Auto-generated catch block
+    			log.error("Error shutting down connection pool " + pool.getKey(), e);
+    			e.printStackTrace();
+    		}
+        }
+         
+        poolMap.clear();
+    }
+	  public void initialize(Properties props, ClassLoader cl) {
+			this.props = props;
+
+	        String servers = this.props.getProperty(INSTALL_SERVER_PROP);
+
+	        /**
+	         * split the server installation properties by the delimiter
+	         * to determine the number of servers installed on the local machine
+	         */
+	         Collection installationList = AdminUtil.getTokens(servers, ";");  //$NON-NLS-1$
+	        Iterator installationIter = installationList.iterator();
+
+	        while (installationIter.hasNext()) {
+	            String serverInfoValues = (String) installationIter.next();
+	            Collection serverInfoValuesList = new LinkedList();
+	            serverInfoValuesList = AdminUtil.getTokens(serverInfoValues, ",");  //$NON-NLS-1$
+	            Object[] serverInfoArray = serverInfoValuesList.toArray();
+	            String installDir = (String) serverInfoArray[0];
+	            String url = (String) serverInfoArray[1];
+	            String username = (String) serverInfoArray[2];
+	            String password = (String) serverInfoArray[3];
+
+	            props.setProperty(ConnectionConstants.PASSWORD, password);
+	            props.setProperty(ConnectionConstants.USERNAME, username);
+	            props.setProperty(ConnectionConstants.URL, url);                             
+	                        
+	            // allow override of the factory class
+	            // this was put in to allow testing to set the factory
+	            String factoryclass = System.getProperty(ConnectionPool.CONNECTION_FACTORY);
+	            if (factoryclass != null) {
+	                props.setProperty(ConnectionPool.CONNECTION_FACTORY, factoryclass);
+	            }
+	            
+	            try {	            
+	                 
+	                 Class clzz = Class.forName(ConnectionPoolImpl.class.getName(), true, cl);
+	                ConnectionPool pool = (ConnectionPool) clzz.newInstance();
+	                pool.initialize(props, cl); 
+	                          
+	                poolMap.put(pool.getKey(), pool);
+	           
+	                log.info("ConnectionPool created for key " + pool.getKey() + " at url " + url); //$NON-NLS-1$ //$NON-NLS-2$
+	            } catch (Throwable t) {
+	                throw new InvalidPluginConfigurationException(t);
+	            }
+	        }
+	    }	
+	
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/enterprise/EnterpriseConnectionMgr.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/enterprise/pool/ConnectionPoolImpl.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/enterprise/pool/ConnectionPoolImpl.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/enterprise/pool/ConnectionPoolImpl.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,424 @@
+/*
+ * 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.enterprise.pool;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionFactory;
+import org.teiid.rhq.comm.ConnectionPool;
+
+
+
+
+/** 
+ *  This is the connection pool used to manage connections to the MetaMatrix server.
+ */
+public class ConnectionPoolImpl implements ConnectionPool {
+    private final Log LOG = LogFactory.getLog(ConnectionPoolImpl.class);
+    
+    /**
+     * The default connection factory if one is not specified in the environment
+     */
+    private static final String CONNECTION_FACTORY_DEFAULT=ConnectionFactory.CONNECTION_FACTORY_DEFAULT;  //$NON-NLS-1$
+    
+    public static final String WAIT_TIME_FOR_RESOURCE= "teiid.pool.wait.time"; //$NON-NLS-1$
+    public static final String MAXIMUM_RESOURCE_POOL_SIZE = "teiid.pool.maximum.size"; //$NON-NLS-1$
+    public static final String RESOURCE_TEST_INTERVAL = "teiid.pool.test.interval"; //$NON-NLS-1$
+
+
+     private static final int DEFAULT_LIVE_AND_UNUSED_TIME = 60;
+     private static final int DEFAULT_CLEANING_INTERVAL = 60;
+     private static final boolean DEFAULT_ENABLE_SHRINKING = true; 
+
+     
+     private int liveAndUnusedTime = DEFAULT_LIVE_AND_UNUSED_TIME;
+     private int cleaningInterval = DEFAULT_CLEANING_INTERVAL;
+     private boolean enableShrinking = DEFAULT_ENABLE_SHRINKING;
+     
+ 	 private int timeout;
+	 private int testInterval;
+
+     
+    
+	private Set<ConnectionWrapper>  availConnections          = Collections.synchronizedSet( new HashSet(10) );
+    private Set<Connection>  inuseConnections   = Collections.synchronizedSet( new HashSet(10) );
+    
+	private Semaphore connectionLock;
+    
+    private ConnectionFactory factory = null;
+//    private String installDir = null;
+    private Properties envProps = null;
+    
+    private volatile boolean shuttingDownPool;
+    
+    private CleanUpThread cleaningThread;   
+    
+    private ClassLoader clzzloader;
+    
+    
+ //   private Object lock = new Object();
+    
+    public ConnectionPoolImpl() {
+        
+        LOG.info("Creating Connection Pool");  //$NON-NLS-1$ 
+    }
+    
+
+    /** 
+     * @see org.teiid.rhq.comm.ConnectionPool#getClassLoader()
+     *  
+     */
+    public ClassLoader getClassLoader() {
+        return clzzloader;
+    }
+    
+    
+
+
+    @Override
+	public int getAvailableConnectionCount() {
+		return availConnections.size();
+	}
+    
+    
+
+
+	@Override
+	public int getConnectionsInUseCount() {
+		return inuseConnections.size();
+	}
+
+
+	public String getKey() {
+		// TODO Auto-generated method stub
+		return factory.getURL();
+	}
+
+
+	/** 
+     * @see com.metamatrix.rhq.admin.pool.ConnectionPool#close(org.teiid.rhq.comm.Connection)
+     *  
+     */
+    public void close(Connection connection) throws ConnectionException {
+        if (this.shuttingDownPool) {
+             return;
+        }        
+		try {
+			if (!connectionLock.tryAcquire(timeout, TimeUnit.MILLISECONDS)) {
+				throw new ConnectionException("Timeout waiting for lock"); //$NON-NLS-1$
+			}
+		} catch (InterruptedException e) {
+			throw new ConnectionException(e);
+		}
+		try {
+            inuseConnections.remove(connection);
+            if (connection.isValid()) {
+                ConnectionWrapper cw = new ConnectionWrapper(connection);
+                availConnections.add(cw);
+                LOG.debug("Connection checked in for system "); //$NON-NLS-1$
+            } else {
+               this.closeConnection(connection);  
+               LOG.debug("Connection returned and closed for system "); //$NON-NLS-1$                
+
+            }
+
+
+
+		} finally {
+			connectionLock.release();
+		}
+
+    }
+      
+
+    /** 
+     * @see com.metamatrix.rhq.admin.pool.ConnectionPool#getConnection()
+     *  
+     */
+    public Connection getConnection() throws ConnectionException {
+        
+        if (this.shuttingDownPool) {
+            return null;
+        }
+
+		try {
+			if (!connectionLock.tryAcquire(timeout, TimeUnit.MILLISECONDS)) {
+				throw new ConnectionException("Timeout waiting for lock trying to get connection"); //$NON-NLS-1$
+			}
+		} catch (InterruptedException e) {
+			throw new ConnectionException(e);
+		}
+		
+		try {
+            if (availConnections.isEmpty()) {
+                Connection conn = createConnection();                    
+                inuseConnections.add(conn);
+                return conn;
+            }                
+            
+        
+            for (Iterator it=availConnections.iterator(); it.hasNext();) {
+                ConnectionWrapper conn = (ConnectionWrapper) it.next();
+                it.remove();
+                if (conn.originalConnection.isValid()) {
+                    inuseConnections.add(conn.originalConnection);
+                    LOG.debug("Existing connection obtained for system "); //$NON-NLS-1$
+                    return conn.originalConnection;
+                } 
+                this.closeConnection(conn.originalConnection);                               
+                                       
+            }  
+            
+            Connection conn = createConnection();
+            inuseConnections.add(conn);
+            return conn;                
+
+		} finally {
+			connectionLock.release();
+		}
+       
+    }
+    
+    /** 
+     * @see com.metamatrix.rhq.admin.pool.ConnectionPool#initialize(java.lang.String, java.util.Properties)
+     *  
+     */
+    public void initialize(Properties env, ClassLoader cl) throws ConnectionException {
+        this.envProps = env;
+ //       this.installDir = env.getProperty(EnterpriseConnectionConstants.INSTALL_DIR);
+               
+        this.clzzloader = cl; 
+ 		this.connectionLock = new Semaphore(getIntProperty(MAXIMUM_RESOURCE_POOL_SIZE, 15));
+		
+		this.timeout = getIntProperty( WAIT_TIME_FOR_RESOURCE, 30000);
+		this.testInterval = getIntProperty( RESOURCE_TEST_INTERVAL, 30000);
+		this.connectionLock = new Semaphore(getIntProperty( MAXIMUM_RESOURCE_POOL_SIZE, 15));
+
+
+        initializeProps();        
+        createFactory();
+    }
+
+    /** 
+     * @see com.metamatrix.rhq.admin.pool.ConnectionPool#shutdown()
+     *  
+     */
+    public void shutdown()  throws ConnectionException {
+        shuttingDownPool = true;
+        
+		try {
+			if (!connectionLock.tryAcquire(timeout, TimeUnit.MILLISECONDS)) {
+				throw new ConnectionException("Timeout waiting for lock trying to get connection"); //$NON-NLS-1$
+			}
+		} catch (InterruptedException e) {
+			throw new ConnectionException(e);
+		}
+        
+		try {
+	        //close cleaning thread
+	        if (this.cleaningThread != null) {
+	            this.cleaningThread.stopCleanup();
+	            this.cleaningThread.interrupt();
+	        }        
+	        
+	        // cleanup, passing true, will close all available connections
+	        this.cleanUp(true);
+	        	
+	        
+	        for (Iterator i = inuseConnections.iterator(); i.hasNext();) {
+	            Connection conn = (Connection)i.next();
+	            this.closeConnection(conn);
+	        }
+	        inuseConnections.clear();
+	        
+	
+	        
+	        envProps.clear();
+	        factory = null;
+		} finally {
+			connectionLock.release();
+		}
+        
+        
+    }
+    
+    
+    private void createFactory() throws ConnectionException {
+        
+        String factoryclass = envProps.getProperty(ConnectionPool.CONNECTION_FACTORY, CONNECTION_FACTORY_DEFAULT);       
+        
+        Thread currentThread = Thread.currentThread();
+        ClassLoader threadContextLoader = currentThread.getContextClassLoader();
+        try {
+            currentThread.setContextClassLoader(this.clzzloader);
+            try {
+                Class c = Class.forName(factoryclass, true, this.clzzloader);
+                factory = (ConnectionFactory)c.newInstance();
+            } catch (Exception err) {
+                throw new ConnectionException(err.getMessage());
+            }
+            
+             // Initialize connector instance...
+            factory.initialize(this.envProps, this);
+
+ 
+        } finally {
+            currentThread.setContextClassLoader(threadContextLoader);
+        }
+        
+   }
+    
+    private void initializeProps() throws ConnectionException {
+            liveAndUnusedTime = getIntProperty(LIVE_AND_UNUSED_TIME, DEFAULT_LIVE_AND_UNUSED_TIME);
+            cleaningInterval = getIntProperty(CLEANING_INTERVAL, DEFAULT_CLEANING_INTERVAL);
+
+            
+            if (!this.shuttingDownPool) {
+                this.cleaningThread = new CleanUpThread(cleaningInterval * 1000);
+                this.cleaningThread.setDaemon(true);
+                this.cleaningThread.start();
+            }
+            
+            String value = envProps.getProperty(ENABLE_SHRINKING);
+            if ( value != null ) {
+                enableShrinking = Boolean.valueOf(value).booleanValue();
+            }            
+               
+    }    
+
+    private int getIntProperty(String propertyName, int defaultValue) throws ConnectionException {
+        String value = this.envProps.getProperty(propertyName );
+        if (value == null || value.trim().length() == 0) {
+            return defaultValue;
+        }
+        return Integer.parseInt(value); 
+        
+    }
+        
+    
+    private Connection createConnection() throws ConnectionException {
+        Thread currentThread = Thread.currentThread();
+        ClassLoader threadContextLoader = currentThread.getContextClassLoader();
+        try {
+            currentThread.setContextClassLoader(this.clzzloader);
+            
+            // Initialize connector instance...
+            return factory.createConnection();
+
+ 
+        } finally {
+            currentThread.setContextClassLoader(threadContextLoader);
+        }
+        
+        
+
+    }
+    
+    private void closeConnection(Connection conn) {
+        Thread currentThread = Thread.currentThread();
+        ClassLoader threadContextLoader = currentThread.getContextClassLoader();
+        try {
+            currentThread.setContextClassLoader(this.clzzloader);
+            // Initialize connector instance...
+            factory.closeConnection(conn);
+
+ 
+        } finally {
+            currentThread.setContextClassLoader(threadContextLoader);
+        }
+        
+    }
+    
+    protected void cleanUp(boolean forceClose) {        
+        Set values = new HashSet(this.availConnections);
+
+            for (Iterator i = values.iterator(); i.hasNext();) {
+                ConnectionWrapper conn = (ConnectionWrapper)i.next();
+                
+                    if (forceClose || (enableShrinking && conn.getIdelTime() >= this.liveAndUnusedTime)
+                                    || !conn.originalConnection.isAlive()) {
+                       availConnections.remove(conn);
+                       this.closeConnection(conn.originalConnection);   
+ 
+                    }
+            }
+
+    }    
+    
+    /**
+     * ConnectionWrapper is used to store the connection in the availableConnections and
+     * will provide the amount of idletime a connection has been unused so that
+     * it can be determined if the pool can be shrunk 
+     * 
+     */
+    class ConnectionWrapper {
+        Connection originalConnection;
+        private long timeReturnedToPool;
+
+        ConnectionWrapper(Connection originalConn) {
+            originalConnection = originalConn;
+            timeReturnedToPool = System.currentTimeMillis();
+        }
+
+        int getIdelTime() {
+            return (int) (System.currentTimeMillis() - timeReturnedToPool) / 1000;
+        }
+    }        
+    
+    class CleanUpThread extends Thread {
+        private long sleepTime;
+        private boolean continueChecks = true;
+
+        CleanUpThread(long sleepTime) {
+            super("MMConnectionPoolCleanUpThread");  //$NON-NLS-1$
+            this.sleepTime = sleepTime;
+        }
+
+        public void stopCleanup() {
+            this.continueChecks = false;
+        }
+
+        public void run() {
+            while ( this.continueChecks ) {
+                try {
+                    sleep(sleepTime);
+                } catch (InterruptedException e) {
+                    // ignore it
+                }
+                ConnectionPoolImpl.this.cleanUp(false);
+            }
+        }
+    }  
+        
+    
+
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/enterprise/pool/ConnectionPoolImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/enterprise/pool/EnterpriseConnectionConstants.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/enterprise/pool/EnterpriseConnectionConstants.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/enterprise/pool/EnterpriseConnectionConstants.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,39 @@
+/*
+ * 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.enterprise.pool;
+
+
+/** 
+ * These are the Constants that used when the jbedsp-plugin is running in the enteriprise environment
+ */
+public interface EnterpriseConnectionConstants {
+    
+    /**
+     * These are Environment properties need to create a connection.  They will be exposed via the @see #getEnvironment call.
+     */
+        public final static String USERNAME = "username"; //$NON-NLS-1$
+        public final static String PASSWORD = "password"; //$NON-NLS-1$
+
+        public final static String PORTS = "ports"; //$NON-NLS-1$
+        public final static String INSTALL_DIR = "install.dir"; //$NON-NLS-1$
+         
+   }


Property changes on: trunk/console/src/main/java/org/teiid/rhq/enterprise/pool/EnterpriseConnectionConstants.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/ConnectorComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/ConnectorComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/ConnectorComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,129 @@
+/*
+ * 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.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.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Connector;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Connector.Operations;
+
+
+/**
+ * MetaMatrix Connector component class
+ * 
+ */
+public class ConnectorComponent extends Facet {
+
+	private final Log LOG = LogFactory.getLog(ConnectorComponent.class);
+
+	/**
+	 * @see org.teiid.rhq.plugin.Facet#getComponentType()
+	 * @since 1.0
+	 */
+	@Override
+	String getComponentType() {
+		return Connector.TYPE;
+	}
+	
+	protected void setOperationArguments(String name, Configuration configuration,
+			Map argumentMap) {
+
+			if (name.equals(Operations.STOP_CONNECTOR)){
+				Boolean stopNow = configuration.getSimple(ConnectionConstants.ComponentType.Operation.Value.STOP_NOW).getBooleanValue();
+				argumentMap.put(ConnectionConstants.ComponentType.Operation.Value.STOP_NOW, stopNow);
+			}
+			//Need identifier for all Connector operations
+			String key = ConnectionConstants.IDENTIFIER;
+			argumentMap.put(key, getComponentIdentifier());				 
+		
+	}	
+
+	@Override
+	public void getValues(MeasurementReport arg0,
+			Set<MeasurementScheduleRequest> arg1) throws Exception {
+		// TODO Auto-generated method stub
+
+	}
+
+//	@Override
+//	public OperationResult invokeOperation(String name,
+//			Configuration configuration) {
+//		Map valueMap = new HashMap();
+//		Connection conn = null;
+//
+//		Set operationDefinitionSet = this.resourceContext.getResourceType()
+//				.getOperationDefinitions();
+//
+//		ExecutedOperationResult result = initResult(name, operationDefinitionSet);
+//			
+//		setValueMap(name, configuration, valueMap);
+//		
+//		execute(conn, result, getComponentType(), name, valueMap);
+//		
+//		return ((ExecutedOperationResultImpl) result).getOperationResult();
+//		
+		
+//		Connection conn = null;
+//		Map valueMap = new HashMap();
+//		MMOperationResult result = null;
+//
+//		// Add "stop now" value if we are attempting to stop a connector
+//		if (name.equals(ComponentType.Operation.STOP_CONNECTOR)) {
+//			Boolean stopNow = configuration.getSimple(
+//					ConnectionConstants.ComponentType.Operation.Value.STOP_NOW)
+//					.getBooleanValue();
+//			valueMap.put(
+//					ConnectionConstants.ComponentType.Operation.Value.STOP_NOW,
+//					stopNow);
+//		}
+//
+//		valueMap.put(ConnectionConstants.IDENTIFIER, getComponentIdentifier());
+//
+//		try {
+//			conn = getConnection();
+//
+//            if (!conn.isValid()) {
+//                return null;
+//            }
+//			// Object operationReturnObject = 
+//            conn.executeOperation(result,
+//					getComponentType(), name, valueMap);
+//            
+//            
+//		} catch (Exception e) {
+//			final String msg = "Failed to invoke operation [" + name + "]. Cause: " + e; //$NON-NLS-1$ //$NON-NLS-2$
+//			LOG.error(msg);
+//			throw new RuntimeException(msg); 
+//		} finally {
+//			conn.close();
+//		}
+//
+//		return (OperationResult)result;
+//	}
+}
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/ConnectorComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/ConnectorDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/ConnectorDiscoveryComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/ConnectorDiscoveryComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,43 @@
+/*
+ * 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.Collection;
+
+import org.teiid.rhq.comm.Component;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionException;
+
+
+/**
+ * Discovery component used to discover the monitored connector bindings
+ * 
+ */
+public class ConnectorDiscoveryComponent extends NodeChildrenDiscoveryComponent {
+	
+	 Collection<Component> getComponents(Connection conn, Facet parent) throws ConnectionException {
+		 return conn.discoverComponents(ConnectionConstants.ComponentType.Runtime.Connector.TYPE, parent.getComponentIdentifier());
+	 }
+	
+
+}
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/ConnectorDiscoveryComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,441 @@
+/*
+ * 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.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+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.ConfigurationUpdateStatus;
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.transfer.DeployPackageStep;
+import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
+import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+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.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.content.ContentFacet;
+import org.rhq.core.pluginapi.content.ContentServices;
+import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+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.utils.SingletonConnectionManager;
+import org.teiid.rhq.comm.Component;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ExecutedResult;
+import org.teiid.rhq.comm.VMComponent;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType;
+import org.teiid.rhq.plugin.objects.ExecutedOperationResultImpl;
+
+
+/**
+ * This class implements required RHQ interfaces and provides common logic used
+ * by all MetaMatrix components.
+ */
+public abstract class Facet implements ResourceComponent,
+		MeasurementFacet, OperationFacet, ConfigurationFacet, ContentFacet,
+		DeleteResourceFacet, CreateChildResourceFacet {
+
+	protected static SingletonConnectionManager connMgr = SingletonConnectionManager
+			.getInstance();
+
+	protected final Log LOG = LogFactory
+			.getLog(Facet.class);
+	
+	/**
+	 * Represents the resource configuration of the custom product being
+	 * managed.
+	 */
+	protected Configuration resourceConfiguration;
+
+
+	/**
+	 * All AMPS plugins are stateful - this context contains information that
+	 * your resource component can use when performing its processing.
+	 */
+	protected ResourceContext<?> resourceContext;
+
+	private String systemKey;
+
+	private String name;
+
+	private String identifier;
+
+	// may be null when the component is not a host or vm
+	private String port = null;
+
+	protected boolean isAvailable = false;
+
+	abstract String getComponentType();
+
+	/**
+	 * This is called when your component has been started with the given
+	 * context. You normally initialize some internal state of your component as
+	 * well as attempt to make a stateful connection to your managed resource.
+	 * 
+	 * @see ResourceComponent#start(ResourceContext)
+	 */
+	public void start(ResourceContext context) {
+		resourceContext = context;
+		
+		
+		systemKey = resourceContext.getPluginConfiguration()
+				.getSimpleProperties().get(Component.SYSTEM_KEY)
+				.getStringValue();
+		name = resourceContext.getPluginConfiguration().getSimpleProperties()
+				.get(Component.NAME).getStringValue();
+
+		// because the system may not be up, name and
+		// identifier may be null at initial creation
+		// and will be updated when the system becomes available.
+		if (name == null)
+			name = "NotSet"; //$NON-NLS-1$
+
+		identifier = resourceContext.getPluginConfiguration()
+				.getSimpleProperties().get(Component.IDENTIFIER)
+				.getStringValue();
+		if (identifier == null)
+			identifier = "";//$NON-NLS-1$
+		if (resourceContext.getPluginConfiguration().getSimpleProperties().get(
+				VMComponent.PORT) != null) {
+			port = resourceContext.getPluginConfiguration()
+					.getSimpleProperties().get(VMComponent.PORT)
+					.getStringValue();
+		}
+	}
+
+	/**
+	 * This is called when the component is being stopped, usually due to the
+	 * plugin container shutting down. You can perform some cleanup here; though
+	 * normally not much needs to be done here.
+	 * 
+	 * @see ResourceComponent#stop()
+	 */
+	public void stop() {
+		this.isAvailable = false;
+	}
+	
+	/**
+	 * @return the resourceConfiguration
+	 */
+	public Configuration getResourceConfiguration() {
+		return resourceConfiguration;
+	}
+
+	/**
+	 * @param resourceConfiguration the resourceConfiguration to set
+	 */
+	public void setResourceConfiguration(Configuration resourceConfiguration) {
+		this.resourceConfiguration = resourceConfiguration;
+	}
+
+	public String getSystemKey() {
+		return systemKey;
+	}
+
+	public String getComponentName() {
+		return name;
+	}
+
+	protected void setComponentName(String componentName) {
+		this.name = componentName;
+	}
+
+	public String getPort() {
+		return port;
+	}
+
+	public String getComponentIdentifier() {
+		return identifier;
+	}
+
+	protected void setComponentIdentifier(String identifier) {
+		this.identifier = identifier;
+	}
+
+	protected void setOperationArguments(String name, Configuration configuration,
+			Map argumentMap) {
+// moved this logic up to the associated implemented class
+		throw new InvalidPluginConfigurationException("Not implemented on component type " + this.getComponentType() + " named " + this.getComponentName());
+				 
+		
+	}
+
+	protected void execute(final ExecutedResult result,
+			final Map valueMap) {
+		Connection conn = null;
+		try {
+			conn = getConnection();
+
+			if (!conn.isValid()) {
+				return;
+			}
+			conn.executeOperation(result, valueMap);
+
+		} catch (Exception e) {
+			final String msg = "Error invoking operation [" + name + "]. Cause: " + e; //$NON-NLS-1$ //$NON-NLS-2$
+			LOG.error(msg);
+			throw new RuntimeException(msg);
+		} finally {
+			conn.close();
+		}
+	}
+
+	/**
+	 * The connection will be returned when it is available. If it is not, then
+	 * null will be returned. Resource methods will not throw exceptions as a
+	 * MetaMatrix System goes up and down. That state will be indicated by it's
+	 * availability state.
+	 * 
+	 * @return
+	 */
+
+	public Connection getConnection() throws ConnectionException {
+		Connection conn = connMgr.getConnection(getSystemKey());
+		if (conn.isValid()) {
+			this.isAvailable = true;
+		} else {
+			this.isAvailable = false;
+		}
+
+		return conn;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * This method is called by JON to check the availability of the inventoried component on a time scheduled basis
+	 * 
+	 * @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
+	 */
+	public AvailabilityType getAvailability() {
+
+		if (!connMgr.hasServersDefined()) {
+			this.isAvailable = false;
+			return AvailabilityType.DOWN;
+			
+		}
+		Connection connection = null;
+		try {
+
+			LOG.debug("Checking availability of  " + identifier); //$NON-NLS-1$
+			connection = getConnection();
+			if (connection.isAvailable(getComponentType(), identifier)) {
+				LOG.info("Availability of  " + identifier + " is up"); //$NON-NLS-1$  //$NON-NLS-2$
+				this.isAvailable = true;
+				return AvailabilityType.UP;
+			} 
+		} catch (InvalidPluginConfigurationException ipce) {
+			// dont log anything, already done when getconnection is called
+		} catch (Throwable err) {
+			LOG.error("Unknown exception occured when checking availability for resource " + identifier, err); //$NON-NLS-1$ 
+		} finally {
+			connection.close();
+		}
+		LOG.error("Availability of  " + identifier + " is down"); //$NON-NLS-1$ //$NON-NLS-2$
+		this.isAvailable = false;
+		return AvailabilityType.DOWN;
+	}
+
+	/**
+	 * Helper method that indicates the latest status based on the last
+	 * getAvailabilit() call.
+	 * 
+	 * @return true if the resource is available
+	 */
+	protected boolean isAvailable() {
+		return this.isAvailable;
+	}
+
+	/**
+	 * The plugin container will call this method when your resource component
+	 * has been scheduled to collect some measurements now. It is within this
+	 * method that you actually talk to the managed resource and collect the
+	 * measurement data that is has emitted.
+	 * 
+	 * @see MeasurementFacet#getValues(MeasurementReport, Set)
+	 */
+	public abstract void getValues(MeasurementReport arg0,
+			Set<MeasurementScheduleRequest> arg1) throws Exception;
+
+	/**
+	 * The plugin container will call this method when it wants to invoke an
+	 * operation on your managed resource. Your plugin will connect to the
+	 * managed resource and invoke the analogous operation in your own custom
+	 * way.
+	 * 
+	 * @see OperationFacet#invokeOperation(String, Configuration)
+	 */
+	public OperationResult invokeOperation(String name,
+			Configuration configuration) {
+		Map valueMap = new HashMap();
+		Connection conn = null;
+
+		Set operationDefinitionSet = this.resourceContext.getResourceType()
+				.getOperationDefinitions();
+
+
+		ExecutedResult result = new ExecutedOperationResultImpl(
+				this.getComponentType(),
+				name, 
+				operationDefinitionSet);
+			
+		setOperationArguments(name, configuration, valueMap);
+		
+		execute(result, valueMap);
+		
+		return ((ExecutedOperationResultImpl) result).getOperationResult();
+
+	}
+
+	/**
+	 * 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()
+	 */
+	public Configuration loadResourceConfiguration() {
+		// here we simulate the loading of the managed resource's configuration
+
+		if (resourceConfiguration == null) {
+			// for this example, we will create a simple dummy configuration to
+			// start with.
+			// note that it is empty, so we're assuming there are no required
+			// configs in the plugin descriptor.
+			resourceConfiguration = new Configuration();
+		}
+
+		Configuration config = resourceConfiguration;
+
+		return config;
+	}
+
+	/**
+	 * The plugin container will call this method when it has a new
+	 * configuration for your managed resource. Your plugin will re-configure
+	 * the managed resource in your own custom way, setting its configuration
+	 * based on the new values of the given configuration.
+	 * 
+	 * @see ConfigurationFacet#updateResourceConfiguration(ConfigurationUpdateReport)
+	 */
+	public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+		// this simulates the plugin taking the new configuration and
+		// reconfiguring the managed resource
+		resourceConfiguration = report.getConfiguration().deepCopy();
+
+		report.setStatus(ConfigurationUpdateStatus.SUCCESS);
+	}
+
+	/**
+	 * When this is called, the plugin is responsible for scanning its managed
+	 * resource and look for content that need to be managed for that resource.
+	 * This method should only discover packages of the given package type.
+	 * 
+	 * @see ContentFacet#discoverDeployedPackages(PackageType)
+	 */
+	public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
+		return null;
+	}
+
+	/**
+	 * The plugin container calls this method when new packages need to be
+	 * deployed/installed on resources.
+	 * 
+	 * @see ContentFacet#deployPackages(Set, ContentServices)
+	 */
+	public DeployPackagesResponse deployPackages(
+			Set<ResourcePackageDetails> packages,
+			ContentServices contentServices) {
+		return null;
+	}
+
+	/**
+	 * When a remote client wants to see the actual data content for an
+	 * installed package, this method will be called. This method must return a
+	 * stream of data containing the full content of the package.
+	 * 
+	 * @see ContentFacet#retrievePackageBits(ResourcePackageDetails)
+	 */
+	public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
+		return null;
+	}
+
+	/**
+	 * This is the method that is used when the component has to create the
+	 * installation steps and their results.
+	 * 
+	 * @see ContentFacet#generateInstallationSteps(ResourcePackageDetails)
+	 */
+	public List<DeployPackageStep> generateInstallationSteps(
+			ResourcePackageDetails packageDetails) {
+		return null;
+	}
+
+	/**
+	 * This is called when the actual content of packages should be deleted from
+	 * the managed resource.
+	 * 
+	 * @see ContentFacet#removePackages(Set)
+	 */
+	public RemovePackagesResponse removePackages(
+			Set<ResourcePackageDetails> packages) {
+		return null;
+	}
+
+	/**
+	 * When called, the plugin container is asking the plugin to create a new
+	 * managed resource. The new resource's details need to be added to the
+	 * given report.
+	 * 
+	 * @see CreateChildResourceFacet#createResource(CreateResourceReport)
+	 */
+	public CreateResourceReport createResource(CreateResourceReport report) {
+		return null;
+	}
+
+	/**
+	 * When called, the plugin container is asking the plugin to delete a
+	 * managed resource.
+	 * 
+	 * @see DeleteResourceFacet#deleteResource()
+	 */
+	public void deleteResource() {
+	}
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/HostComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/HostComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/HostComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,176 @@
+/*
+ * 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.Iterator;
+import java.util.Map;
+import java.util.Properties;
+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.PropertySimple;
+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.ConfigurationFacet;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host;
+
+
+/**
+ * Component class for the MetaMatrix Host Controller process.
+ * 
+ */
+public class HostComponent extends Facet {
+	private final Log LOG = LogFactory
+			.getLog(HostComponent.class);
+
+
+	public static final String CONNECTOR_ADDRESS_CONFIG_PROPERTY = "connectorAddress"; //$NON-NLS-1$
+
+	public static final String CONNECTION_TYPE = "type"; //$NON-NLS-1$
+
+	public static final String PARENT_TYPE = "PARENT"; //$NON-NLS-1$
+	
+	public static final String INSTALL_DIR = "install.dir"; //$NON-NLS-1$
+	
+    
+	private String install_dir;
+    /** 
+     * @see org.teiid.rhq.plugin.Facet#getComponentType()
+     * @since 1.0
+     */
+    @Override
+    String getComponentType() {
+        return Host.TYPE;
+    }
+    
+    
+    
+    String getInstallDirectory() {
+    	
+    	if (install_dir != null) {
+    		return install_dir;
+    	}
+    	install_dir = resourceContext.getPluginConfiguration()
+		.getSimpleProperties().get(INSTALL_DIR)
+		.getStringValue(); 
+ 
+    	return install_dir;
+    }
+
+
+	/**
+	 * The plugin container will call this method when your resource component
+	 * has been scheduled to collect some measurements now. It is within this
+	 * method that you actually talk to the managed resource and collect the
+	 * measurement data that is has emitted.
+	 * 
+	 * @see MeasurementFacet#getValues(MeasurementReport, Set)
+	 */
+	public void getValues(MeasurementReport report,
+			Set<MeasurementScheduleRequest> requests) {
+		for (MeasurementScheduleRequest request : requests) {
+			String name = request.getName();
+
+			// TODO: based on the request information, you must collect the
+			// requested measurement(s)
+			// you can use the name of the measurement to determine what you
+			// actually need to collect
+			try {
+				Number value = new Integer(1); // dummy measurement value -
+												// this should come from the
+												// managed resource
+				report.addData(new MeasurementDataNumeric(request, value
+						.doubleValue()));
+			} catch (Exception e) {
+				LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
+						+ "]. Cause: " + e); //$NON-NLS-1$
+			}
+		}
+
+		return;
+	}
+	
+	protected void setOperationArguments(String name, Configuration configuration,
+			Map argumentMap) {
+
+		if (name.equals(ConnectionConstants.ComponentType.Operation.GET_PROPERTIES)){
+			String key = ConnectionConstants.IDENTIFIER;
+			argumentMap.put(key, getComponentIdentifier());
+		}
+ 		
+	} 
+	
+	/**
+	 * 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() {
+		// here we simulate the loading of the managed resource's configuration
+		Configuration config = this.getResourceConfiguration() ;
+		if (config == null) {
+			// for this example, we will create a simple dummy configuration to
+			// start with.
+			// note that it is empty, so we're assuming there are no required
+			// configs in the plugin descriptor.
+			config = new Configuration();
+		}
+
+   		Properties props;
+		try {
+			props = getConnection().getProperties(this.getComponentType(), this.getComponentIdentifier());
+		} catch (ConnectionException e) {
+			LOG.error("Failed to obtain host properties for [" + this.getComponentIdentifier() //$NON-NLS-1$
+					+ "]. Cause: " + e); //$NON-NLS-1$
+			 throw new InvalidPluginConfigurationException(e); 
+		}
+        
+   		if (props != null && props.size() > 0) {
+   			Iterator it=props.keySet().iterator();
+   			while(it.hasNext())  {
+   				String k = (String)it.next();
+   				
+   				config.put(new PropertySimple(k, props.get(k)));
+
+   			}
+   			
+   		}
+
+				
+		this.setResourceConfiguration(config);
+		return this.getResourceConfiguration();
+	}
+
+}
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/HostComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/HostDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/HostDiscoveryComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/HostDiscoveryComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,55 @@
+/*
+ * 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.Collection;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.teiid.rhq.comm.Component;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionException;
+
+
+/**
+ * Discovery component for the MetaMatrix Host controller process
+ *
+ */
+public class HostDiscoveryComponent extends NodeChildrenDiscoveryComponent {
+
+
+	@Override
+	 Collection<Component> getComponents(Connection conn, Facet parent) throws ConnectionException {
+		 return conn.discoverComponents(ConnectionConstants.ComponentType.Runtime.Host.TYPE, "*");
+	 }
+	
+	@Override
+	protected void addAdditionalProperties(Configuration configuration, Component component) throws InvalidPluginConfigurationException {
+		 String installdir = component.getProperty(HostComponent.INSTALL_DIR);
+		 configuration.put(new PropertySimple(HostComponent.INSTALL_DIR,
+				 installdir));     
+	}
+	
+	
+}
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/HostDiscoveryComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/NodeChildrenDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/NodeChildrenDiscoveryComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/NodeChildrenDiscoveryComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,122 @@
+/*
+ * 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.Collection;
+import java.util.Iterator;
+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.PropertySimple;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.teiid.rhq.comm.Component;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionException;
+
+
+/**
+ * Discovery component used to discover the monitored connector bindings
+ * 
+ */
+public abstract class NodeChildrenDiscoveryComponent extends NodeDiscoveryComponent {
+
+
+	private final Log LOG = LogFactory.getLog(NodeChildrenDiscoveryComponent.class);
+
+	/**
+	 * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
+	 */
+
+	@Override
+	protected void addResources(Set<DiscoveredResourceDetails> found, ResourceType resourceType, Facet parent)
+		throws InvalidPluginConfigurationException {
+		Connection conn = null;
+		   try {
+		        conn = getConnection();
+		        if (!conn.isValid()) {
+		            return;
+		        }
+		        Collection<Component> components =  getComponents(conn, parent);
+		        
+		        if (components == null || components.size() == 0) {
+		            LOG.info("No components were found to be configured for parent "+ parent.getComponentIdentifier()); //$NON-NLS-1$
+		            return;
+		        }
+		         
+		        Iterator<Component> comIter = components.iterator();
+		        
+		        while (comIter.hasNext()) {
+		          Component comp =  comIter.next();           
+		          LOG.info("Processing component "+ comp.getName()); //$NON-NLS-1$
+		          
+		          DiscoveredResourceDetails resource = this.createResource(resourceType, comp);
+           
+		          found.add(resource);      
+		        }
+	       } catch (InvalidPluginConfigurationException ipe) {
+	            throw ipe;
+	        } catch (Throwable t) {
+	            throw new InvalidPluginConfigurationException(t);            
+	            
+	        } finally {
+	            if (conn != null) {
+	                conn.close();
+	            }
+	        } 
+
+		
+	}
+	
+	protected DiscoveredResourceDetails createResource(ResourceType resourceType, Component component)
+	throws InvalidPluginConfigurationException {
+		
+		DiscoveredResourceDetails resource = createResource(resourceType, 
+      		  systemkey + "|" + component.getIdentifier(), 
+      		component.getName(), 
+      		(component.getDescription()!=null?component.getDescription():""));
+
+  	                   
+	    Configuration configuration = resource.getPluginConfiguration();
+	    configuration.put(new PropertySimple(Component.NAME, component.getName()));
+	    configuration.put(new PropertySimple(Component.IDENTIFIER, component.getIdentifier()));
+	    configuration.put(new PropertySimple(Component.SYSTEM_KEY, systemkey));
+	    
+	    addAdditionalProperties(configuration, component);
+	    
+	    return resource;
+	
+	}
+	
+	protected void addAdditionalProperties(Configuration configuration, Component component) throws InvalidPluginConfigurationException {
+		
+	}
+	
+	abstract Collection<Component> getComponents(Connection conn, Facet parent) throws ConnectionException;
+	
+
+}
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/NodeChildrenDiscoveryComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/NodeDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/NodeDiscoveryComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/NodeDiscoveryComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,131 @@
+/*
+ * 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.Collections;
+import java.util.HashSet;
+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.PropertySimple;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.teiid.rhq.admin.utils.SingletonConnectionManager;
+import org.teiid.rhq.comm.Component;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionConstants;
+
+
+/**
+ * Discovery component used to discover the monitored services
+ *
+ */
+public class NodeDiscoveryComponent implements
+		ResourceDiscoveryComponent {
+	private static final Log LOG = LogFactory
+			.getLog(NodeDiscoveryComponent.class);
+    
+    private static SingletonConnectionManager connMgr  = SingletonConnectionManager.getInstance();
+
+    protected String systemkey = null;
+    
+
+	public Set<DiscoveredResourceDetails> discoverResources(
+			ResourceDiscoveryContext discoveryContext) throws InvalidPluginConfigurationException, Exception {
+		
+        
+        String name = discoveryContext.getResourceType().getName();
+  
+        LOG.info("Discovering " + name); //$NON-NLS-1$
+
+        // if no servers have been defined, do not discover resources
+        if (!connMgr.hasServersDefined()) {
+            LOG.info("Unable to discover " + name + ", no JBEDSP Platforms defined"); //$NON-NLS-1$
+            return Collections.EMPTY_SET;
+        }
+
+        Facet parent = (Facet) discoveryContext.getParentResourceComponent();
+         
+        String parentName = parent.getComponentName(); 
+        systemkey = parent.getSystemKey();
+        
+        LOG.info("Discovering JBEDSP " + name + " for " + (parentName!=null?parentName:"PARENTNAMENOTFOUND")); //$NON-NLS-1$ //$NON-NLS-2$
+        
+		Set<DiscoveredResourceDetails> found = new HashSet<DiscoveredResourceDetails>();           
+              
+        addResources(found, discoveryContext.getResourceType(), parent);
+        
+       return found;
+	}
+	
+	protected void addResources(Set<DiscoveredResourceDetails> found, ResourceType resourceType, Facet parent)
+		throws InvalidPluginConfigurationException {
+		 String identifier = parent.getComponentIdentifier()+ "|" + resourceType.getName();
+        DiscoveredResourceDetails resource = createResource(resourceType, identifier,  resourceType.getName(), resourceType.getDescription());
+           
+        found.add(resource);           	  
+		
+	}
+		
+	protected DiscoveredResourceDetails createResource(ResourceType resourceType, String identifier, String name, String description)
+		throws InvalidPluginConfigurationException {
+
+        DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType,
+      		  identifier, name,
+      		  ConnectionConstants.VERSION, 
+      		  (description!=null?description:""), 
+      		  null, 
+      		  null);
+      	                   
+        Configuration configuration = resource.getPluginConfiguration();
+        configuration.put(new PropertySimple(Component.NAME, name));
+        configuration.put(new PropertySimple(Component.IDENTIFIER, identifier));
+        configuration.put(new PropertySimple(Component.SYSTEM_KEY, systemkey));
+        
+        addAdditionalProperties(configuration);
+        
+        return resource;
+		
+	}
+	
+
+	
+	protected void addAdditionalProperties(Configuration configuration) throws InvalidPluginConfigurationException {
+		
+	}
+	
+	protected Connection getConnection() throws InvalidPluginConfigurationException{
+		try {
+			return connMgr.getConnection(this.systemkey);
+
+		} catch (Throwable t) {
+          throw new InvalidPluginConfigurationException(t);            
+          
+      } 
+	}
+	
+}
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/NodeDiscoveryComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,135 @@
+/*
+ * 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.Iterator;
+import java.util.Map;
+import java.util.Properties;
+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.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.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.teiid.rhq.admin.utils.SingletonConnectionManager;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType;
+
+
+/**
+ * 
+ */
+public class PlatformComponent extends Facet {
+	private final Log LOG = LogFactory.getLog(PlatformComponent.class);
+
+	/**
+	 * Property is used to identify an unreachable system
+	 */
+	protected static final String UNREACHABLE_NAME = "UNREACHABLE_PLATFORM"; //$NON-NLS-1$
+
+	/**
+	 * @see org.teiid.rhq.plugin.Facet#getComponentType()
+	 * @since 4.3
+	 */
+	@Override
+	String getComponentType() {
+		return ConnectionConstants.ComponentType.PLATFORM;
+	}
+	
+	@Override
+	public AvailabilityType getAvailability() {
+
+		if (!connMgr.hasServersDefined()) {
+			this.isAvailable = false;
+			return AvailabilityType.DOWN;
+			
+		}
+		Connection connection = null;
+		try {
+
+			LOG.debug("Checking availability of  " + this.getComponentIdentifier()); //$NON-NLS-1$
+			connection = getConnection();
+			if (connection.isAlive()) {
+				LOG.info("Availability of  " + this.getComponentIdentifier() + " is up"); //$NON-NLS-1$  //$NON-NLS-2$
+				this.isAvailable = true;
+				return AvailabilityType.UP;
+			} 
+		} catch (InvalidPluginConfigurationException ipce) {
+			// dont log anything, already done when getconnection is called
+		} catch (Throwable err) {
+			LOG.error("Unknown exception occured when checking availability for resource " + this.getComponentIdentifier(), err); //$NON-NLS-1$ 
+		} finally {
+			connection.close();
+		}
+		LOG.error("Availability of  " + this.getComponentIdentifier() + " is down"); //$NON-NLS-1$ //$NON-NLS-2$
+		this.isAvailable = false;
+		return AvailabilityType.DOWN;
+	}
+	
+	
+	
+	protected void setOperationArguments(String name, Configuration configuration,
+			Map valueMap) {
+ 		
+	}	
+
+
+	@Override
+	public void getValues(MeasurementReport report,
+			Set<MeasurementScheduleRequest> requests) throws Exception {
+	}
+	
+	
+	
+	@Override
+	public void stop() {
+		// TODO Auto-generated method stub
+		super.stop();
+		connMgr.shutdown();
+	}
+
+	@Override
+	public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+		
+		Properties props = System.getProperties();
+		
+		Iterator<PropertySimple> pluginPropIter = report.getConfiguration().getSimpleProperties().values().iterator();
+		
+		while (pluginPropIter.hasNext()){
+			PropertySimple pluginProp = pluginPropIter.next();
+			props.put(pluginProp.getName(), pluginProp.getStringValue());
+		}
+		
+		SingletonConnectionManager.getInstance().initialize(props);
+		super.updateResourceConfiguration(report);
+		
+	}	
+
+}
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,123 @@
+/*
+ * 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.HashSet;
+import java.util.Iterator;
+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.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.teiid.rhq.admin.utils.SingletonConnectionManager;
+import org.teiid.rhq.comm.Component;
+import org.teiid.rhq.comm.ConnectionConstants;
+
+
+/**
+ * This is the parent node for a MetaMatrix system
+ */
+public class PlatformDiscoveryComponent implements ResourceDiscoveryComponent {
+	private static SingletonConnectionManager connMgr  = SingletonConnectionManager.getInstance();
+	private static final Log LOG = LogFactory
+			.getLog(PlatformDiscoveryComponent.class);
+	   
+	
+	Map environmentMap = new HashMap();
+
+    /**
+	 * Review the javadoc for both {@link ResourceDiscoveryComponent} and
+	 * {@link ResourceDiscoveryContext} to learn what you need to do in this
+	 * method.
+	 * 
+	 * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
+	 */
+	public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws InvalidPluginConfigurationException,
+                                                                                                      Exception {
+        try {
+            
+            String name = discoveryContext.getResourceType().getName();
+            String desc = discoveryContext.getResourceType().getDescription();
+            String version = ConnectionConstants.VERSION;
+            
+            LOG.info("Discovering " + desc); //$NON-NLS-1$
+            
+            
+            // now perform your own discovery mechanism, if you have one. For each
+            // resource discovered, you need to
+            // create a details object that describe the resource that you
+            // discovered.
+            HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+
+            Set<String> systemkeys = null ;
+
+            try {
+            	systemkeys = connMgr.getInstallationSystemKeys();
+            } catch (Exception e) {
+            	systemkeys = new HashSet(1);
+            	systemkeys.add("NotDefined");
+
+            	// TODO
+                // - when the serverList cannot be obtained
+                
+                // DO NOT throw exception, still want to create the
+                // resource, but it will show not active / available
+            }
+
+
+
+            Iterator<String> serverIter = systemkeys.iterator();
+            int hostCount = -1;
+            while (serverIter.hasNext()) {
+                hostCount++;
+                String systemKey = serverIter.next();
+                    
+	                    DiscoveredResourceDetails resource = new DiscoveredResourceDetails(discoveryContext.getResourceType(),
+	                                                                                       systemKey, name,
+	                                                                                       version, desc, null, null);
+	
+	                    Configuration configuration = resource.getPluginConfiguration();
+	                    configuration.put(new PropertySimple(Component.NAME, name));
+	                    configuration.put(new PropertySimple(Component.IDENTIFIER, name));
+	                    configuration.put(new PropertySimple(Component.SYSTEM_KEY, systemKey));
+	                    
+	
+	                    set.add(resource); 
+
+            }
+
+            return set;
+        } catch (InvalidPluginConfigurationException ipe) {
+            throw ipe;
+        } catch (Throwable t) {
+            throw new InvalidPluginConfigurationException(t);
+        }
+
+    }
+}
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/ProcessComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/ProcessComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/ProcessComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,316 @@
+/*
+ * 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.io.File;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+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.PropertySimple;
+import org.rhq.core.domain.event.EventSeverity;
+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.ConfigurationFacet;
+import org.rhq.core.pluginapi.event.EventContext;
+import org.rhq.core.pluginapi.event.EventPoller;
+import org.rhq.core.pluginapi.event.log.LogFileEventPoller;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Process;
+import org.teiid.rhq.plugin.log.JBEDSPErrorLogEntryProcessor;
+
+
+/**
+ * 
+ * MetaMatrix server component class. This class represents the node for the
+ * MMProcess.
+ * 
+ */
+public class ProcessComponent extends Facet {
+	private final Log LOG = LogFactory.getLog(ProcessComponent.class);
+    
+    
+    public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_EVENTS_ENABLED = "enabled"; //$NON-NLS-1$
+    public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_MINIMUM_SEVERITY = "minimumSeverity"; //$NON-NLS-1$
+    public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_INCLUDES_PATTERN = "errorLogIncludesPattern"; //$NON-NLS-1$
+    public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_FILE_PATH = "errorLogFilePath"; //$NON-NLS-1$
+	public static final String INSTALL_DIR = "install.dir"; //$NON-NLS-1$
+   
+    private static final String ERROR_LOG_ENTRY_EVENT_TYPE = "errorLogEntry"; //$NON-NLS-1$
+   
+    
+    
+    private EventContext eventContext;   
+    private File errorLogFile;
+
+    
+    /** 
+     * @see org.teiid.rhq.plugin.Facet#start(org.rhq.core.pluginapi.inventory.ResourceContext)
+     */
+    @Override
+    public void start(ResourceContext context) {
+        super.start(context);
+        
+        this.eventContext = resourceContext.getEventContext();
+       
+ //       startEventPollers();
+    }
+    
+    /** 
+     * @see org.teiid.rhq.plugin.Facet#stop()
+     */
+    @Override
+    public void stop() {
+        stopEventPollers();
+        super.stop();
+            
+    }   
+    
+	public AvailabilityType getAvailability() {
+
+		return AvailabilityType.UP;
+		}
+    
+    /** 
+     * @see org.teiid.rhq.plugin.Facet#getComponentType()
+     * @since 1.0
+     */
+    @Override
+    String getComponentType() {
+        return Process.TYPE;
+    }
+    
+	protected void setOperationArguments(String name, Configuration configuration,
+			Map argumentMap) {
+
+		if (name.equals(ConnectionConstants.ComponentType.Operation.GET_PROPERTIES)){
+			String key = ConnectionConstants.IDENTIFIER;
+			argumentMap.put(key, getComponentIdentifier());
+		}
+ 		
+	}   
+    
+
+	@Override
+	public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) throws Exception {
+		 Connection conn = null;
+		    Map valueMap = new HashMap();
+		    
+		    try{ 
+		        conn = getConnection();
+                if (!conn.isValid()) {
+                    return;
+                }                
+		        for (MeasurementScheduleRequest request : requests) {
+		            String name = request.getName();
+		            LOG.info("Measurement name = " + name);  //$NON-NLS-1$
+		            
+		            Object metricReturnObject = conn.getMetric(getComponentType(), this.getComponentIdentifier(), name, valueMap);
+
+		            try {
+		                if (request.getName().equals(ComponentType.Metric.HIGH_WATER_MARK)) {
+		                    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);
+		            }
+		        }
+		    }finally{
+		        conn.close();
+		    }
+		
+	}
+	
+	
+	/**
+	 * 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() {
+		// here we simulate the loading of the managed resource's configuration
+		Configuration config = this.getResourceConfiguration() ;
+		if (config == null) {
+			// for this example, we will create a simple dummy configuration to
+			// start with.
+			// note that it is empty, so we're assuming there are no required
+			// configs in the plugin descriptor.
+			config = new Configuration();
+		}
+
+   		Properties props;
+		try {
+			props = getConnection().getProperties(this.getComponentType(), this.getComponentIdentifier());
+		} catch (ConnectionException e) {
+			LOG.error("Failed to obtain process properties for [" + this.getComponentIdentifier() //$NON-NLS-1$
+					+ "]. Cause: " + e); //$NON-NLS-1$
+			 throw new InvalidPluginConfigurationException(e); 
+		}
+        
+   		if (props != null && props.size() > 0) {
+   			Iterator it=props.keySet().iterator();
+   			while(it.hasNext())  {
+   				String k = (String)it.next();
+   				
+   				config.put(new PropertySimple(k, props.get(k)));
+
+   			}
+   			
+   		}
+
+				
+		this.setResourceConfiguration(config);
+		return this.getResourceConfiguration();
+	}	
+
+    
+	protected static String deriveFileName(final String identifier) {
+		
+		 String startFileName = identifier.substring(0, identifier.indexOf("|")); //$NON-NLS-1$
+         String endFileName = identifier.substring(identifier.indexOf("|")+1, identifier.length()); //$NON-NLS-1$
+         
+         startFileName = replaceAll(startFileName, ".", "_"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+         String logfilename = startFileName.toLowerCase() + "_" + endFileName + ".log"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+         
+         return logfilename;
+		
+	}
+    
+    private void startEventPollers() {
+		Configuration pluginConfig = resourceContext.getPluginConfiguration();
+		Boolean enabled = Boolean.valueOf(pluginConfig.getSimpleValue(
+				PLUGIN_CONFIG_PROP_ERROR_LOG_EVENTS_ENABLED, null)); //$NON-NLS-1$
+		if (enabled) {
+
+			String installdir = pluginConfig.getSimpleValue(
+					INSTALL_DIR, null); //$NON-NLS-1$
+			if (installdir == null) {
+				throw new InvalidPluginConfigurationException(
+						"Installation directory could not be determined in order for the process to monitor the log files"); //$NON-NLS-1$ //$NON-NLS-2$
+				
+			}
+
+			String logFileName = deriveFileName(this.getComponentIdentifier());
+
+			String relativelogname = pluginConfig.getSimpleValue(
+					PLUGIN_CONFIG_PROP_ERROR_LOG_FILE_PATH,
+					"/log/" + logFileName); //$NON-NLS-1$
+
+			errorLogFile = new File(installdir + "/" + relativelogname); //$NON-NLS-1$
+
+			LOG.info("Start event polling on logfile: " + errorLogFile.getAbsolutePath()); //$NON-NLS-1$
+
+			JBEDSPErrorLogEntryProcessor processor = new JBEDSPErrorLogEntryProcessor(
+					ERROR_LOG_ENTRY_EVENT_TYPE, errorLogFile);
+			String includesPatternString = pluginConfig.getSimpleValue(
+					PLUGIN_CONFIG_PROP_ERROR_LOG_INCLUDES_PATTERN, null);
+			if (includesPatternString != null) {
+				try {
+					Pattern includesPattern = Pattern
+							.compile(includesPatternString);
+					processor.setIncludesPattern(includesPattern);
+				} catch (PatternSyntaxException e) {
+					throw new InvalidPluginConfigurationException(
+							"Includes pattern [" + includesPatternString + "] is not a valid regular expression."); //$NON-NLS-1$ //$NON-NLS-2$
+				}
+			}
+			String minimumSeverityString = pluginConfig.getSimpleValue(
+					PLUGIN_CONFIG_PROP_ERROR_LOG_MINIMUM_SEVERITY, null);
+			if (minimumSeverityString != null) {
+				EventSeverity minimumSeverity = EventSeverity
+						.valueOf(minimumSeverityString.toUpperCase());
+				processor.setMinimumSeverity(minimumSeverity);
+			}
+			EventPoller poller = new LogFileEventPoller(this.eventContext,
+					ERROR_LOG_ENTRY_EVENT_TYPE, errorLogFile, processor);
+			this.eventContext.registerEventPoller(poller, 30, errorLogFile
+					.getPath());
+		}
+	}
+
+    private void stopEventPollers() {
+// Configuration pluginConfig = this.resourceContext.getPluginConfiguration();
+// File errorLogFile =
+// resolvePathRelativeToServerRoot(pluginConfig.getSimpleValue(PLUGIN_CONFIG_PROP_ERROR_LOG_FILE_PATH,
+// DEFAULT_ERROR_LOG_PATH));
+        this.eventContext.unregisterEventPoller(ERROR_LOG_ENTRY_EVENT_TYPE, errorLogFile.getPath());
+    }
+    
+    
+    /*
+     * Replace all occurrences of the search string with the replace string
+     * in the source string. If any of the strings is null or the search string
+     * is zero length, the source string is returned.
+     * @param source the source string whose contents will be altered
+     * @param search the string to search for in source
+     * @param replace the string to substitute for search if present
+     * @return source string with *all* occurrences of the search string
+     * replaced with the replace string
+     */
+    private static String replaceAll(String source, String search, String replace) {
+        if (source != null && search != null && search.length() > 0 && replace != null) {
+            int start = source.indexOf(search);
+            if (start > -1) {
+                StringBuffer newString = new StringBuffer(source);
+                replaceAll(newString, search, replace);
+                return newString.toString();
+            }
+        }
+        return source;    
+    }
+    
+    private static void replaceAll(StringBuffer source, String search, String replace) {
+        if (source != null && search != null && search.length() > 0 && replace != null) {
+            int start = source.toString().indexOf(search);
+            while (start > -1) {
+                int end = start + search.length();
+                source.replace(start, end, replace);
+                start = source.toString().indexOf(search, start + replace.length());
+            }
+        }
+    }
+    
+
+}
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/ProcessComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/ProcessDiscoveryComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/ProcessDiscoveryComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/ProcessDiscoveryComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,53 @@
+/*
+ * 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.Collection;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.teiid.rhq.comm.Component;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.VMComponent;
+
+
+
+/**
+ * 
+ * The discovery component class for the MetaMatrix server node
+ * 
+ */
+public class ProcessDiscoveryComponent extends NodeChildrenDiscoveryComponent {
+ 
+    
+	 Collection<Component> getComponents(Connection conn, Facet parent) throws ConnectionException {
+		 return conn.discoverComponents(ConnectionConstants.ComponentType.Runtime.Process.TYPE, parent.getComponentIdentifier());
+	 }
+	 
+		protected void addAdditionalProperties(Configuration configuration, Component component) throws InvalidPluginConfigurationException {
+            configuration.put(new PropertySimple(VMComponent.PORT, ((VMComponent)component).getPort()));   
+   
+		}
+}
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/ProcessDiscoveryComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/QueriesComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/QueriesComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/QueriesComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,130 @@
+/*
+ * 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.Queries;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Queries.Query;
+import org.teiid.rhq.plugin.objects.ExecutedResourceConfigurationResultImpl;
+
+
+/**
+ * MetaMatrix Connector component class
+ * 
+ */
+public class QueriesComponent extends Facet {
+
+	private final Log LOG = LogFactory.getLog(QueriesComponent.class);
+	
+	
+	private ExecutedResourceConfigurationResultImpl getQueries = null;
+
+	/**
+	 * @see org.teiid.rhq.plugin.Facet#getComponentType()
+	 * @since 1.0
+	 */
+	@Override
+	String getComponentType() {
+		return Queries.TYPE;
+	}
+	
+	public void start(ResourceContext context) {
+		super.start(context);
+		
+		Map defns = context.getResourceType().getResourceConfigurationDefinition().getPropertyDefinitions();
+		
+		getQueries = new ExecutedResourceConfigurationResultImpl(
+				this.getComponentType(),
+				Query.GET_QUERIES, 
+				defns);
+	}
+	
+	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() {
+  		// here we simulate the loading of the managed resource's configuration
+  		Configuration config = this.getResourceConfiguration() ;
+  		if (config == null) {
+  			// for this example, we will create a simple dummy configuration to
+  			// start with.
+  			// note that it is empty, so we're assuming there are no required
+  			// configs in the plugin descriptor.
+  			config = new Configuration();
+  			
+  			
+  		}
+  		
+  		getQueries.reset();
+		
+		execute(getQueries, new HashMap());
+
+
+  		config.put( (PropertyList) getQueries.getResult());
+         
+  				
+  		this.setResourceConfiguration(config);
+  		return this.getResourceConfiguration();
+  	}	
+
+
+}
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/QueriesComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,127 @@
+/*
+ * 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


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/SessionComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/SessionComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/SessionComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,154 @@
+/*
+ * 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 SessionComponent extends Facet {
+
+	private final Log LOG = LogFactory.getLog(SessionComponent.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);
+		
+		Map defns = context.getResourceType().getResourceConfigurationDefinition().getPropertyDefinitions();
+		
+		getSessions = new ExecutedResourceConfigurationResultImpl(
+				this.getComponentType(),
+				Query.GET_SESSIONS, 
+				defns);
+	}
+	
+	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() {
+  		// here we simulate the loading of the managed resource's configuration
+  		Configuration config = this.getResourceConfiguration() ;
+  		if (config == null) {
+  			// for this example, we will create a simple dummy configuration to
+  			// start with.
+  			// note that it is empty, so we're assuming there are no required
+  			// configs in the plugin descriptor.
+  			config = new Configuration();
+  			
+  			
+  		}
+  		
+  		getSessions.reset();
+		
+		execute(getSessions, new HashMap());
+
+
+  		config.put( (PropertyList) getSessions.getResult());
+         
+  				
+  		this.setResourceConfiguration(config);
+  		return this.getResourceConfiguration();
+  	}	
+
+
+//  	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


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/SessionComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/SystemComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/SystemComponent.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/SystemComponent.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,169 @@
+/*
+ * 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.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Queries.Query;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.System.Metrics;
+import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.System.Operations;
+
+
+/**
+ * 
+ */
+public class SystemComponent extends Facet {
+	private final Log LOG = LogFactory.getLog(SystemComponent.class);
+
+	/**
+	 * Property is used to identify an unreachable system
+	 */
+	protected static final String UNREACHABLE_NAME = "UNREACHABLE_SYSTEM"; //$NON-NLS-1$
+
+	/**
+	 * @see org.teiid.rhq.plugin.Facet#getComponentType()
+	 * @since 4.3
+	 */
+	@Override
+	String getComponentType() {
+		return ConnectionConstants.ComponentType.Runtime.System.TYPE;
+	}
+	
+	protected void setOperationArguments(String name, Configuration configuration,
+			Map valueMap) {
+
+		// Parameter logic for System Operations
+		if (name.equals(Query.GET_QUERIES) ||
+			name.equals(Operations.GET_LONGRUNNINGQUERIES)) {
+			Boolean includeSourceQueries = configuration.getSimple(ConnectionConstants.ComponentType.Operation.Value.INCLUDE_SOURCE_QUERIES).getBooleanValue();
+			Integer long_running_value = getResourceConfiguration().getSimple(ConnectionConstants.ComponentType.Operation.Value.LONG_RUNNING_QUERY_LIMIT).getIntegerValue();
+			valueMap.put(ConnectionConstants.ComponentType.Operation.Value.INCLUDE_SOURCE_QUERIES, includeSourceQueries);
+			valueMap.put(ConnectionConstants.ComponentType.Operation.Value.LONG_RUNNING_QUERY_LIMIT, long_running_value);				
+		}else if (name.equals(Operations.BOUNCE_SYSTEM)) {
+			Boolean waitUntilFinished = configuration.getSimple(ConnectionConstants.ComponentType.Operation.Value.WAIT_UNTIL_FINISHED).getBooleanValue();
+			valueMap.put(ConnectionConstants.ComponentType.Operation.Value.WAIT_UNTIL_FINISHED, waitUntilFinished);
+		}else if (name.equals(ConnectionConstants.ComponentType.Operation.KILL_REQUEST)) {
+			String key = ConnectionConstants.ComponentType.Operation.Value.REQUEST_ID;
+			valueMap.put(key, configuration.getSimple(key).getStringValue());
+		}else if (name.equals(ConnectionConstants.ComponentType.Operation.GET_PROPERTIES) ) {
+			String key = ConnectionConstants.IDENTIFIER;
+			valueMap.put(key, getComponentIdentifier());
+		}
+ 		
+	}	
+
+
+	@Override
+	public void getValues(MeasurementReport report,
+			Set<MeasurementScheduleRequest> requests) throws Exception {
+		
+		// because the sytsem object will be created before the use actually connects, checks have to be
+		// made not to perform actions that will require a connection before its available
+		if (!this.isAvailable()) {
+			return;
+		}
+
+		Connection conn = null;
+		Map valueMap = new HashMap();
+
+		try {
+			conn = getConnection();
+			if (!conn.isValid()) {
+				return;
+			}
+			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(Metrics.LONG_RUNNING_QUERIES)) {
+					Integer value = getResourceConfiguration().getSimple(ConnectionConstants.ComponentType.Operation.Value.LONG_RUNNING_QUERY_LIMIT).getIntegerValue();
+					valueMap.put(ComponentType.Operation.Value.LONG_RUNNING_QUERY_LIMIT, value);
+				}
+				
+				Object metricReturnObject = conn.getMetric(getComponentType(),
+						this.getComponentIdentifier(),
+						name, 
+						valueMap);
+
+				try {
+					if (request.getName().equals(
+							Metrics.QUERY_COUNT)) {
+						report.addData(new MeasurementDataNumeric(request,
+								(Double) metricReturnObject));
+					} else {
+						if (request.getName().equals(
+								Metrics.SESSION_COUNT)) {
+							report.addData(new MeasurementDataNumeric(request,
+									(Double) metricReturnObject));
+						} else {
+							if (request.getName().equals(
+									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);
+				}
+			}
+		} finally {
+			if (conn != null) {
+				conn.close();
+			}
+		}
+	}
+	
+//
+//	@Override
+//	public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+//		
+//		Properties props = System.getProperties();
+//		
+//		Iterator<PropertySimple> pluginPropIter = report.getConfiguration().getSimpleProperties().values().iterator();
+//		
+//		while (pluginPropIter.hasNext()){
+//			PropertySimple pluginProp = pluginPropIter.next();
+//			props.put(pluginProp.getName(), pluginProp.getStringValue());
+//		}
+//		
+//		SingletonConnectionManager.getInstance().initialize(props);
+//		super.updateResourceConfiguration(report);
+//		
+//	}	
+
+}
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/SystemComponent.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,96 @@
+/*
+ * 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.log;
+
+import java.io.File;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.pluginapi.event.log.MultiLineLogEntryProcessor;
+
+
+/** 
+ * @since 4.3
+ */
+public class JBEDSPErrorLogEntryProcessor extends MultiLineLogEntryProcessor {
+
+    
+    /**
+     * The regex for the primary log line: '['date']' '['severityLevel']' '['clientIP']' message
+     * e.g.: [Wed Oct 11 14:32:52 2008] [error] [client 127.0.0.1] client denied by server configuration
+     * NOTE: The message portion may contain multiple lines.
+     */
+    private static final String REGEX = "(.*) (.*) (INFO|WARNING|ERROR|DEBUG) (.*)"; //$NON-NLS-1$
+    private static final Pattern PATTERN = Pattern.compile(REGEX);
+
+    private static final String DATE_PATTERN = "MMM dd, yyyy kk:mm:ss.SSS"; // e.g.:  Aug 26, 2008 13:10:11.371  //$NON-NLS-1$
+    private static final DateFormat DATE_FORMAT = new SimpleDateFormat(DATE_PATTERN);
+
+    private static final Map<SeverityLevel, EventSeverity> LEVEL_TO_SEVERITY_MAP = new LinkedHashMap();
+    static {
+        LEVEL_TO_SEVERITY_MAP.put(SeverityLevel.DEBUG, EventSeverity.DEBUG);
+        LEVEL_TO_SEVERITY_MAP.put(SeverityLevel.INFO, EventSeverity.INFO);
+        LEVEL_TO_SEVERITY_MAP.put(SeverityLevel.WARNING, EventSeverity.WARN);
+        LEVEL_TO_SEVERITY_MAP.put(SeverityLevel.ERROR, EventSeverity.ERROR);        
+    }
+
+    public JBEDSPErrorLogEntryProcessor(String eventType, File logFile) {
+        super(eventType, logFile);
+    }
+
+    protected Pattern getPattern() {
+        return PATTERN;
+    }
+
+    protected DateFormat getDefaultDateFormat() {
+        return DATE_FORMAT;
+    }
+
+    protected LogEntry processPrimaryLine(Matcher matcher) throws ParseException {
+        String dateString = matcher.group(1);
+        Date  timestamp = parseDateString(dateString);
+        String severityLevelString = matcher.group(3);
+        SeverityLevel severityLevel;
+        try {
+            severityLevel = SeverityLevel.valueOf(severityLevelString.toUpperCase());
+        }
+        catch (IllegalArgumentException e) {
+            throw new ParseException("Unknown severity level: " + severityLevelString); //$NON-NLS-1$
+        }
+        EventSeverity severity = LEVEL_TO_SEVERITY_MAP.get(severityLevel);
+        String detail = matcher.group(4);
+        return new LogEntry(timestamp, severity, detail);
+    }
+
+    private enum SeverityLevel {
+        DEBUG,
+        INFO,
+        WARNING,
+        ERROR
+    }
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ConfigurationResultImpl.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ConfigurationResultImpl.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ConfigurationResultImpl.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,89 @@
+/*
+ * 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.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+
+public class ConfigurationResultImpl  {
+	
+		
+	public static Collection mapProperties(ResourceDiscoveryContext discoveryContext, Properties values ) {
+		Set<PropertySimple> properties = new HashSet();
+		if (discoveryContext.getResourceType().getPluginConfigurationDefinition() == null) {
+			return Collections.EMPTY_LIST;
+		}
+		Map<String , PropertyDefinition> propDefs = discoveryContext.getResourceType().getPluginConfigurationDefinition().getPropertyDefinitions();
+		
+		Iterator<String> propkeys = propDefs.keySet().iterator();
+		
+		while (propkeys.hasNext()) {
+			final String key = propkeys.next();
+			PropertyDefinition pdef = propDefs.get(key);
+			
+			if (pdef instanceof PropertyDefinitionSimple) {
+				String fieldName = ((PropertyDefinitionSimple) pdef).getName();
+				if (values.containsKey(fieldName)) {
+				
+					properties.add(new PropertySimple(key, values.get(fieldName)));
+				}
+			} else if (pdef instanceof PropertyDefinitionList) {
+				PropertyDefinition propertyDefinitionMap = ((PropertyDefinitionList) pdef)
+						.getMemberDefinition();
+				Map simpleProperties = ((PropertyDefinitionMap) propertyDefinitionMap)
+						.getPropertyDefinitions();
+				Iterator simplePropertiesIter = simpleProperties.values()
+						.iterator();
+		
+				while (simplePropertiesIter.hasNext()) {
+					PropertyDefinition simpleProp = (PropertyDefinition) simplePropertiesIter
+							.next();
+					String fieldName = ((PropertyDefinitionSimple) simpleProp)
+							.getName();
+					if (values.contains(fieldName)) {
+						
+						properties.add(new PropertySimple(key, values.get(fieldName)));
+					}
+				}
+		
+			}
+			
+		}
+				
+		return properties;
+	
+	}	
+	
+}


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

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,157 @@
+/*
+ * 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.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.teiid.rhq.comm.ExecutedResult;
+
+
+public class ExecutedOperationResultImpl implements ExecutedResult {
+
+	Set operationDefinitionSet;
+
+	String operationName;
+	
+	String componentType;
+
+	final static String LISTNAME = "list"; //$NON-NLS-1$
+	
+	final static String MAPNAME = "map"; //$NON-NLS-1$
+
+//	String mapName;
+
+	Object result;
+	
+	Object content;
+
+	List fieldNameList;
+	
+	OperationResult operationResult = new OperationResult();
+
+	public ExecutedOperationResultImpl() {
+	}
+
+	public ExecutedOperationResultImpl(String componentType, String operationName, Set operationDefinitionSet) {
+		this.componentType = componentType;
+		this.operationName = operationName;
+		this.operationDefinitionSet = operationDefinitionSet;
+		init();
+	}
+	
+	public String getComponentType() {
+		return this.componentType;
+	}
+	
+	public String getOperationName() {
+		return this.operationName;
+	}
+		
+	public OperationResult getOperationResult() {
+		return operationResult;
+	}
+	
+	public List getFieldNameList() {
+		return fieldNameList;
+	}
+
+	public Object getResult() {
+		return result;
+	}
+	
+	private void setComplexResult() {
+		PropertyList list = new PropertyList(LISTNAME); //$NON-NLS-1$
+		PropertyMap pm;
+		Iterator resultIter = ((List)content).iterator();
+		while (resultIter.hasNext()) {
+			Map reportRowMap = (Map) resultIter.next();
+			Iterator reportRowKeySetIter = reportRowMap.keySet().iterator();
+			pm = new PropertyMap("userMap"); //$NON-NLS-1$			
+
+			while (reportRowKeySetIter.hasNext()) {
+				String key = (String) reportRowKeySetIter.next();
+				pm.put(new PropertySimple(key, reportRowMap.get(key)==null?"":reportRowMap.get(key))); //$NON-NLS-1$
+			}
+			list.add(pm);
+		}
+		result = list;
+		operationResult.getComplexResults().put(list);
+	}
+
+	public void setContent(List content) {
+		this.content = content;
+		setComplexResult();
+	}
+
+	public void setContent(String content) {
+		this.content = content;
+		this.result = content;
+		operationResult.setSimpleResult(content);
+	}
+
+	private void init() {
+		fieldNameList = new LinkedList();
+
+		Iterator operationsIter = operationDefinitionSet.iterator();
+
+		while (operationsIter.hasNext()) {
+			OperationDefinition opDef = (OperationDefinition) operationsIter
+					.next();
+			if (opDef.getName().equals(operationName)) {
+				Map propDefs = opDef.getResultsConfigurationDefinition()
+						.getPropertyDefinitions();
+				PropertyDefinition listPropDefinition = (PropertyDefinition) propDefs
+						.get(LISTNAME);
+
+				PropertyDefinition propertyDefinitionMap = ((PropertyDefinitionList) listPropDefinition)
+						.getMemberDefinition();
+				Map simpleProperties = ((PropertyDefinitionMap) propertyDefinitionMap)
+						.getPropertyDefinitions();
+				Iterator simplePropertiesIter = simpleProperties.values()
+						.iterator();
+
+				while (simplePropertiesIter.hasNext()) {
+					PropertyDefinition simpleProp = (PropertyDefinition) simplePropertiesIter
+							.next();
+					String fieldName = ((PropertyDefinitionSimple) simpleProp)
+							.getName();
+					fieldNameList.add(fieldName);
+				}
+				
+				break;
+			}
+		}
+	}	
+}


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

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,143 @@
+/*
+ * 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.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.teiid.rhq.comm.ExecutedResult;
+
+
+public class ExecutedResourceConfigurationResultImpl implements ExecutedResult {
+
+	Map propertDefinitions;
+	
+	String operationName;
+	
+	String componentType;
+
+	final static String LISTNAME = "list"; //$NON-NLS-1$
+	
+	final static String MAPNAME = "map"; //$NON-NLS-1$
+
+	Object result;
+	
+	Object content;
+
+	List fieldNameList;
+	
+
+	public ExecutedResourceConfigurationResultImpl(String componentType, String operationName, Map propDefs) {
+		this.componentType = componentType;
+		this.operationName = operationName;
+		this.propertDefinitions = propDefs;
+		init();
+	}
+	
+	public void reset() {
+		result = null;
+		content = null;
+	}
+	
+	public String getComponentType() {
+		return this.componentType;
+	}
+	
+	public String getOperationName() {
+		return this.operationName;
+	}
+		
+
+	
+	public List getFieldNameList() {
+		return fieldNameList;
+	}
+
+	public Object getResult() {
+		return result;
+	}
+	
+	private void setComplexResult() {
+		PropertyList list = new PropertyList(LISTNAME); //$NON-NLS-1$
+		PropertyMap pm;
+		Iterator resultIter = ((List)content).iterator();
+		while (resultIter.hasNext()) {
+			Map reportRowMap = (Map) resultIter.next();
+			Iterator reportRowKeySetIter = reportRowMap.keySet().iterator();
+			pm = new PropertyMap("userMap"); //$NON-NLS-1$			
+
+			while (reportRowKeySetIter.hasNext()) {
+				String key = (String) reportRowKeySetIter.next();
+				pm.put(new PropertySimple(key, reportRowMap.get(key)==null?"":reportRowMap.get(key))); //$NON-NLS-1$
+			}
+			list.add(pm);
+		}
+		
+		result = list;
+	}
+	
+
+	public void setContent(List content) {
+		this.content = content;
+		setComplexResult();
+	}
+
+	public void setContent(String content) {
+		this.content = content;
+	}
+
+	private void init() {
+		fieldNameList = new LinkedList();
+
+		PropertyDefinition listPropDefinition = (PropertyDefinition) propertDefinitions
+				.get(LISTNAME);
+
+		PropertyDefinition propertyDefinitionMap = ((PropertyDefinitionList) listPropDefinition)
+				.getMemberDefinition();
+		Map simpleProperties = ((PropertyDefinitionMap) propertyDefinitionMap)
+				.getPropertyDefinitions();
+		Iterator simplePropertiesIter = simpleProperties.values()
+				.iterator();
+
+		while (simplePropertiesIter.hasNext()) {
+			PropertyDefinition simpleProp = (PropertyDefinition) simplePropertiesIter
+					.next();
+			String fieldName = ((PropertyDefinitionSimple) simpleProp)
+					.getName();
+			fieldNameList.add(fieldName);
+		}
+				
+
+	}	
+}


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

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginUtils.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginUtils.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginUtils.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,45 @@
+/*
+ * 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.util;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Properties;
+
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertySimple;
+
+public class PluginUtils {
+	
+	/*
+	 * Returns a Collection of PropertySimple instances from a Properties instance
+	 */
+	public static Collection<Property> getSimplePropertyCollection(Properties properties){
+		Collection<Property> collection  = Collections.emptyList();
+		
+		for (String key : properties.stringPropertyNames()) {
+			collection.add(new PropertySimple(key,properties.get(key)));
+		}
+		
+		return collection;
+	}
+}


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginUtils.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,3 @@
+url=mm://localhost:31000
+username=Admin
+password=mm
\ No newline at end of file


Property changes on: trunk/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/resources/embedded/META-INF/rhq-plugin.xml
===================================================================
--- trunk/console/src/resources/embedded/META-INF/rhq-plugin.xml	                        (rev 0)
+++ trunk/console/src/resources/embedded/META-INF/rhq-plugin.xml	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,635 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+ * 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.
+ */-->
+
+<plugin name="TeiidPlugin" displayName="Teiid Plugin"
+	package="org.teiid.rhq.plugin" version="2.0.0"	
+	description="Supports management and monitoring of JBoss Teiid DataServices version 6.2"
+
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns="urn:xmlns:rhq-plugin" 
+	xmlns:c="urn:xmlns:rhq-configuration">
+
+	<server name="Teiid Data Services"
+		discovery="PlatformDiscoveryComponent"
+		class="PlatformComponent" 
+		description="JBoss Teiid DataServices"
+		supportsManualAdd="true"
+		singleton="true">
+
+
+     <subcategories>
+         <subcategory name="Runtime"/>
+         <subcategory name="Resources"/>
+      </subcategories>
+
+		<resource-configuration>
+        	<c:group name="connection" displayName="Connection Info">
+        	<c:description>Connection</c:description>
+         	<c:simple-property name="url" displayName="Teiid URL"			
+                            description="The URL with which to connect to the Teiid Data Service instance (e.g. mm://localhost:31000)."
+                            default="mm://localhost:31000"/>
+         <c:simple-property name="username" required="true" description="The name of the administrative principal (i.e. user) to authenticate."/>
+         <c:simple-property name="password" type="password" required="true"
+                            description="The credentials (i.e. password) that should be used to authenticate the administrative principal."/>		            
+     	</c:group>
+       </resource-configuration> 
+
+
+		<server name="Sessions"
+			subCategory="Runtime"
+			discovery="NodeDiscoveryComponent"
+			description="Active / Inactive sessions connected to the Teidd Server"
+			class="SessionComponent"
+			singleton="true">
+
+<!--
+	group name = operation name or query name
+	
+	simple-property name = the method name on the object to get the value
+-->  
+			<resource-configuration>
+    			<c:group name="getSessions" displayName="Sessions">
+
+	                  <c:list-property name="list"
+	                                     displayName="Current Sessions"
+	                                     description="Sessions currently connected to the Teiid"
+	                                     required="false">
+	                        <c:map-property name="map">
+								<c:simple-property displayName="Session ID"
+									name="getSessionID" type="string" readOnly="true"
+									description="The id for this session" />
+								<c:simple-property displayName="User Name"
+									name="getUserName" type="string" readOnly="true"
+									description="The username for the user of this session" />
+								<c:simple-property
+									displayName="Application Name" name="getApplicationName"
+									type="string" readOnly="true"
+									description="The name of the application this user is accessing Teiid through" />
+								<c:simple-property displayName="VDB Name"
+									name="getVDBName" type="string" readOnly="true"
+									description="The name of the VDB the user is connected to" />
+								<c:simple-property displayName="VDB Version"
+									name="getVDBVersion" type="string" readOnly="true"
+									description="The version of the VDB the user is connected to" />
+		
+								<c:simple-property displayName="State"
+									name="getStateAsString" type="string" readOnly="true"
+									description="The current state of this session" />
+		
+								<c:simple-property displayName="IP Address"
+									name="getIPAddress" type="string" readOnly="true"
+									description="The IP Address for this user's connection" />
+								<c:simple-property displayName="Host Name"
+									name="getHostName" type="string" readOnly="true"
+									description="The host machine from which this user connected" />
+	                        </c:map-property>
+	                    </c:list-property>
+	
+	                </c:group>
+	            </resource-configuration>
+	            
+		</server>
+
+		<server name="Queries"
+			subCategory="Runtime"
+			discovery="NodeDiscoveryComponent"
+			description="Current queries executing against the Teiid Server"
+			class="QueriesComponent"
+			singleton="true">
+
+<!--
+	group name = operation name or query name
+	
+	simple-property name = the method name on the object to get the value
+-->  
+			<resource-configuration>
+    			<c:group name="listQueries" displayName="Executing Queries">
+
+	                  <c:list-property name="list"
+	                                     displayName="Executing Queries"
+	                                     description="Current queries executing in the Teiid system"
+	                                     required="false">
+	                        <c:map-property name="map">
+								<c:simple-property displayName="User Name"
+									name="getUserName" type="string"
+									description="The username for the user that submitted this query" />
+								<c:simple-property displayName="Session ID"
+									name="getSessionID" type="string"
+									description="The id for the session" />
+								<c:simple-property displayName="Request ID"
+									name="getRequestID" type="string"
+									description="The id for the request" />
+								<c:simple-property displayName="Start Time"
+									name="getCreated" type="string"
+									description="The time this query has been running" />
+								<c:simple-property displayName="Transaction ID"
+									name="getTransactionID" type="string"
+									description="The version of the VDB the user is connected to" />
+								<c:simple-property displayName="SQL String"
+									name="getSqlCommand" type="string"
+									description="The SQL string for this query" />
+								<c:simple-property
+									displayName="Connector Binding Name"
+									name="getConnectorBindingName" type="string"
+									description="The IP Address for this user's connection" />
+								<c:simple-property displayName="Node ID"
+									name="getNodeID" type="string"
+									description="The node ID of this query" />
+								<c:simple-property displayName="Source Request"
+									name="isSource" type="string"
+									description="If false this is the top level query. If true this a physical source query." />
+	                        </c:map-property>
+	                    </c:list-property>
+	
+	                </c:group>
+			</resource-configuration>
+	            
+		</server>
+
+
+
+
+
+	<server name="System"
+		subCategory="Runtime"
+		discovery="NodeDiscoveryComponent"
+		class="SystemComponent" 
+		description="Operational System"
+		supportsManualAdd="true"
+		singleton="true">
+
+ 
+		<operation name="bounceSystem"
+			displayName="Bounce System"
+			description="Stop and restart the system">
+			<parameters>
+				<c:simple-property name="waitUntilFinished"
+					type="boolean" default="false"
+					description="If true, this method waits until the operation is finished before returning. This may take a long time to complete.  If false, this method returns immediately, even though the operation may not be finished." />
+			</parameters>
+		</operation>
+<!--
+		<operation name="listUsers"
+			displayName="View current user sessions"
+			description="List current user sessions connected to this Teiid System">
+			<results>
+				<c:list-property name="list">
+					<c:map-property name="map">
+						<c:simple-property displayName="User Name"
+							name="getUserName" type="string"
+							description="The username for the user of this session" />
+						<c:simple-property
+							displayName="Application Name" name="getApplicationName"
+							type="string"
+							description="The name of the application this user is accessing Teiid through" />
+						<c:simple-property displayName="Session ID"
+							name="getSessionID" type="string"
+							description="The id for this session" />
+						<c:simple-property displayName="VDB Name"
+							name="getVDBName" type="string"
+							description="The name of the VDB the user is connected to" />
+						<c:simple-property displayName="VDB Version"
+							name="getVDBVersion" type="string"
+							description="The version of the VDB the user is connected to" />
+						<c:simple-property displayName="Product Name"
+							name="getProductName" type="string"
+							description="The product name" />
+						<c:simple-property displayName="IP Address"
+							name="getIPAddress" type="string"
+							description="The IP Address for this user's connection" />
+						<c:simple-property displayName="Host Name"
+							name="getHostName" type="string"
+							description="The host name for this user's connection" />
+						<c:simple-property displayName="Last Ping Time"
+							name="getLastPingTime" type="string"
+							description="The last time this client was ping'd" />
+						<c:simple-property displayName="State"
+							name="getStateAsString" type="string"
+							description="The current state of this session" />
+					</c:map-property>
+				</c:list-property>
+			</results>
+		</operation>
+-->
+
+<!--
+		<operation name="listQueries" displayName="View current queries"
+			description="List current queries executing against the Teiid System">
+			<parameters>
+				<c:simple-property name="includeSourceQueries"
+					type="boolean" default="true"
+					description="If true, source queries will be included in the results.  If false, only top-level queries will be included in the results." />
+			</parameters>
+			<results>
+				<c:list-property name="list">
+					<c:map-property name="map">
+						<c:simple-property displayName="User Name"
+							name="getUserName" type="string"
+							description="The username for the user that submitted this query" />
+						<c:simple-property displayName="Session ID"
+							name="getSessionID" type="string"
+							description="The id for the session" />
+						<c:simple-property displayName="Request ID"
+							name="getRequestID" type="string"
+							description="The id for the request" />
+						<c:simple-property displayName="Start Time"
+							name="getCreated" type="string"
+							description="The time this query has been running" />
+						<c:simple-property displayName="Transaction ID"
+							name="getTransactionID" type="string"
+							description="The version of the VDB the user is connected to" />
+						<c:simple-property displayName="SQL String"
+							name="getSqlCommand" type="string"
+							description="The SQL string for this query" />
+						<c:simple-property
+							displayName="Connector Binding Name"
+							name="getConnectorBindingName" type="string"
+							description="The IP Address for this user's connection" />
+						<c:simple-property displayName="Node ID"
+							name="getNodeID" type="string"
+							description="The node ID of this query" />
+						<c:simple-property displayName="Source Request"
+							name="isSource" type="string"
+							description="If false this is the top level query. If true this a physical source query." />
+					</c:map-property>
+				</c:list-property>
+			</results>
+		</operation>
+-->
+		<operation name="listLongRunningQueries"
+			displayName="View current long running queries"
+			description="List current queries executing against the Teiid System that have surpassed the long running query threshhold">
+			<parameters>
+				<c:simple-property name="includeSourceQueries"
+					type="boolean" default="true"
+					description="If true, source queries will be included in the results.  If false, only top-level queries will be included in the results." />
+			</parameters>
+			<results>
+				<c:list-property name="list">
+					<c:map-property name="map">
+						<c:simple-property displayName="User Name"
+							name="getUserName" type="string"
+							description="The username for the user that submitted this query" />
+						<c:simple-property displayName="Session ID"
+							name="getSessionID" type="string"
+							description="The name of the resource whose availability is being reported" />
+						<c:simple-property displayName="Request ID"
+							name="getRequestID" type="string"
+							description="The id for the request" />
+						<c:simple-property displayName="Start Time"
+							name="getCreated" type="string"
+							description="The time this query has been running" />
+						<c:simple-property displayName="Transaction ID"
+							name="getTransactionID" type="string"
+							description="The version of the VDB the user is connected to" />
+						<c:simple-property displayName="SQL String"
+							name="getSqlCommand" type="string"
+							description="The SQL string for this query" />
+						<c:simple-property
+							displayName="Connector Binding Name"
+							name="getConnectorBindingName" type="string"
+							description="The IP Address for this user's connection" />
+						<c:simple-property displayName="Node ID"
+							name="getNodeID" type="string"
+							description="The node ID of this query" />
+						<c:simple-property displayName="Source Request"
+							name="isSource" type="string"
+							description="If false this is the top level query. If true this a physical source query." />
+					</c:map-property>
+				</c:list-property>
+			</results>
+		</operation>
+
+		<operation name="killRequest" displayName="Terminate query"
+			description="Terminate the processing of a query and it's source queries">
+			<parameters>
+				<c:simple-property displayName="SessionID|RequestID"
+					name="requestID" type="string" required="true"
+					description="The IDs of the session|request to terminate (use format = sessionID|requestID)" />
+			</parameters>
+		</operation>
+
+
+		<metric displayName="Query Count" defaultOn="true"
+			displayType="summary" category="throughput" property="queryCount"
+			description="The number of queries for a given point in time" />
+
+		<metric displayName="Long Running Queries" defaultOn="true"
+			displayType="summary" category="performance"
+			property="longRunningQueries"
+			description="The number of queries that have been running longer than the limit set for queries. The default is 60 minutes, but this may be overridden by the 'longRunningQueryTime' system variable." />
+
+		<metric displayName="Session Count" defaultOn="true"
+			displayType="summary" category="throughput" property="sessionCount"
+			description="The number of user connections for a given point in time" />
+
+		<resource-configuration>
+         <c:group name="general" displayName="General" hiddenByDefault="false">
+            <c:description>Query Configuration</c:description>
+            <c:simple-property name="longRunningQueryLimit" type="integer" activationPolicy="immediate" units="seconds" default="600" displayName="Long Running Query limit" description="The value (in seconds) to use to determine if a query is to be considered 'long running'.">
+             <c:constraint>
+          		<c:integer-constraint minimum="0" maximum="999999" />
+      		 </c:constraint>
+            </c:simple-property>
+	     </c:group>                 
+      </resource-configuration> 
+             
+           
+		<server name="Host"
+			discovery="HostDiscoveryComponent"
+			class="HostComponent"
+			description="Teiid Host"
+			createDeletePolicy="delete-only">
+
+				<resource-configuration>
+		        	<c:group name="hostinfo" displayName="Host Info">
+		        		<c:description>Host configuration information</c:description>
+		
+       						<c:simple-property name="metamatrix.installationDir" readOnly="true" required="false" displayName="Installation Directory" 
+                                  			description="The physical location of the Teiid server installation"/>
+			               <c:simple-property name="metamatrix.log.dir" readOnly="true" required="false" displayName="Log Directory" 
+			                                  description="The physical location of the Host log files"/>
+			               <c:simple-property name="metamatrix.data.dir"  readOnly="true" required="false" displayName="Data Directory" 
+			                                  description="The physical location of the internal Teiid dynamic data"/>
+			              <c:simple-property name="metamatrix.host.dir" readOnly="true" required="false" displayName="Host Directory" 
+			                                  description="The Host directory is where host specific files are located."/>
+			               <c:simple-property name="metamatrix.host.bind.address" readOnly="true" required="false" displayName="Bind Address" 
+			                                  description="The bind address determines what interfaces the host machine will be bound to."/>
+			               <c:simple-property name="metamatrix.host.physical.address" readOnly="true" required="false" displayName="Physical Address" 
+			                                  description="The physical address indicates what address a client application will use to connect."/>
+		     		</c:group>
+		      </resource-configuration> 
+
+
+		<service name="Process"
+			discovery="ProcessDiscoveryComponent"
+			class="ProcessComponent"
+			description="Teiid Process instance"
+			createDeletePolicy="both">
+			
+	        <plugin-configuration>
+		         <c:group name="event" displayName="Process Log Tracking">
+                     <c:simple-property name="enabled" type="boolean" summary="true" default="true" required="true"
+                                        description="A flag indicating whether of not this log Event source is currently
+                                                     enabled (i.e. whether the associated log file should be tailed for
+                                                     new entries)."/>
+                     <c:simple-property name="minimumSeverity" required="true" default="ERROR" 
+                                        description="The minimum severity of Events that should be collected for this
+                                                     source. The default is ERROR.">
+                         <c:property-options>
+                            <c:option name="DEBUG" value="DEBUG"/>
+                            <c:option name="INFO"  value="INFO"/>
+                            <c:option name="WARNING"  value="WARNING"/>
+                            <c:option name="ERROR" value="ERROR" default="true"/>
+                         </c:property-options>
+                     </c:simple-property>
+		         </c:group>	        
+	        </plugin-configuration>			
+	        
+				<operation name="restartProcess"
+					displayName="Re-start Process"
+					description="Start/re-start this process" />
+				<operation name="stopProcess"
+					displayName="Stop Process"
+					description="Stop this process">
+					<parameters>
+						<c:simple-property name="stopNow" type="boolean"
+							default="true"
+							description="If true, stop the process forcefully. If false, wait until any pending work is completed." />
+					</parameters>
+				</operation>
+
+
+			<metric displayName="Query High Water Mark" defaultOn="true"
+				displayType="summary" category="utilization"
+				property="highWatermark"
+				description="High water mark for queries in the Socket Worker Queue" />
+
+ 			<event name="errorLogEntry" description="an entry in a log file"/>  
+			<!-- Ted Jones - 06/19/08
+				Commenting out current threads metric until http://jira.jboss.org/jira/browse/JBEDSP-426 is resolved. -->
+			<!--     <metric displayName="Current Threads"
+				defaultOn="true"
+				displayType="summary"
+				category="utilization"
+				property="threadCount"
+				description="The number of active threads in the Socket Worker Queue"/> -->
+
+				<resource-configuration>
+		        	<c:group name="processinfo" displayName="Process Info">
+		        		<c:description>Process configuration information</c:description>
+			               <c:simple-property name="vm.enabled" type="boolean" displayName="Start Enabled Flag" 
+			                                  description="The enabled flag allows for disabling the VM from starting without have to remove it from deployment."/>
+			              <c:simple-property name="vm.socketPort" type="integer" displayName="Socket Port" 
+			                                  description="The port number for the process when socket communications are being used"/>
+		
+       						<c:simple-property name="vm.starter.cmd.java_opts"  displayName="Java Options" 
+                                  			description="These are the java options passed in before the main class"/>
+    						<c:simple-property name="vm.starter.minHeapSize"  displayName="Minimum Heap Size (MB)"  required="false"
+                                  			description="The bind address, when specified determines what address the vm will be bound to."/>
+			              	<c:simple-property name="vm.starter.maxHeapSize" type="integer" displayName="Maximum Heap Size (MB)" required="false"
+			                                  description="The maximum heap size, in megabytes, to be used for this VM.  If no value is provided for this property, the default property value from the configuration is used; if no value is specified anywhere, no maximum heap size will be set."/>
+		              	 	<c:simple-property name="vm.bind.address" type="string" displayName="VM Bind Address" required="false"
+			                                  description="The bind address, when specified determines what address the vm will be bound to."/>
+			               <c:simple-property name="vm.unicast.port" type="integer" displayName="Cluster Port for Unicast" 
+			                                  description="The port number for the process when unicast based clustering is used."/>
+			               <c:simple-property name="vm.minPort" type="integer" displayName="Min Port Number" 
+			                                  description="Min port number"/>
+	
+		     		</c:group>
+		        	<c:group name="tuning" displayName="Tuning">
+
+			               <c:simple-property name="vm.timetolive"  type="integer" displayName="Socket Worker Thread Time-To-Live (ms)" 
+			                                  description="Time-to-live (in milliseconds) for threads used to do work on client requests."/>
+			               <c:simple-property name="vm.maxThreads" type="integer" displayName="Max Threads"  required="false"
+			                                  description="Maximum socket listener threads.">
+								<c:defaultValueDescription>If nothing is specified, the default of 64 will be used.
+                        		</c:defaultValueDescription>
+							</c:simple-property>
+ 			               <c:simple-property name="vm.inputBufferSize"  type="integer" displayName="Socket Input BufferSize" 
+			                                  description="The size of socket buffer used when reading."/>
+			              <c:simple-property name="vm.forced.shutdown.time" type="integer" displayName="VM Forced Shutdown Time (secs)" 
+			                                  description="The the number of seconds the VM will wait until it will perform a force shutdown."/>
+			               <c:simple-property name="vm.outputBufferSize" type="integer" displayName="Socket Output BufferSize" 
+			                                  description="The size of the socket buffer used when writing."/>
+
+		     		</c:group>
+		      </resource-configuration> 
+
+
+			<service name="Connectors"
+				discovery="ConnectorDiscoveryComponent"
+				class="ConnectorComponent">
+
+				<resource-configuration>
+    				<c:group name="advanced" displayName="Advanced">
+
+	                  	<c:list-property name="config-property"
+	                                     displayName="Config Property"
+	                                     description="Configuration Properties"
+	                                     required="false">
+	                        <c:map-property name="property-values">
+	                            <c:simple-property name="config-property-name"
+	                                               displayName="Name"
+	                                               description="Name of the Configuration Property"
+	                                               required="true"/>
+	                            <c:simple-property name="config-property-type"
+	                                               displayName="Type"
+	                                               description="Type of the Configuration Property"
+	                                               required="true"/>
+	                            <c:simple-property name="config-property-value"
+	                                               displayName="Value"
+	                                               description="Value of the Configuration Property"
+	                                               required="true"/>
+	                        </c:map-property>
+	                    </c:list-property>
+	
+	                </c:group>
+	            </resource-configuration>
+
+				<operation name="restartConnector"
+					displayName="Re-start Connector"
+					description="Start/re-start this connector binding" />
+				<operation name="stopConnector"
+					displayName="Stop Connector"
+					description="Stop this connector binding">
+					<parameters>
+						<c:simple-property name="stopNow" type="boolean"
+							default="true"
+							description="If true, stop the connector binding forcefully. If false, wait until any pending work is completed." />
+					</parameters>
+				</operation>
+			</service>
+
+			<service name="Services"
+				discovery="ServiceDiscoveryComponent"
+				class="ServiceComponent">
+
+				<resource-configuration>
+    				<c:group name="advanced" displayName="Advanced">
+
+	                  	<c:list-property name="config-property"
+	                                     displayName="Config Property"
+	                                     description="Configuration Properties"
+	                                     required="false">
+	                        <c:map-property name="property-values">
+	                            <c:simple-property name="config-property-name"
+	                                               displayName="Name"
+	                                               description="Name of the Configuration Property"
+	                                               required="true"/>
+	                            <c:simple-property name="config-property-type"
+	                                               displayName="Type"
+	                                               description="Type of the Configuration Property"
+	                                               required="true"/>
+	                            <c:simple-property name="config-property-value"
+	                                               displayName="Value"
+	                                               description="Value of the Configuration Property"
+	                                               required="true"/>
+	                        </c:map-property>
+	                    </c:list-property>
+	
+	                </c:group>
+	            </resource-configuration>
+
+				<operation name="restart"
+					displayName="Re-start Service"
+					description="Start/re-start this service" />
+				<operation name="stop"
+					displayName="Stop Service"
+					description="Stop this service">
+					<parameters>
+						<c:simple-property name="stopNow" type="boolean"
+							default="true"
+							description="If true, stop the servie forcefully. If false, wait until any pending work is completed." />
+					</parameters>
+				</operation>
+			</service>
+
+		</service>  <!-- end of VM -->
+
+		</server>  <!-- end of Host -->
+
+	</server> <!-- end of System -->
+
+		<server name="Security"
+			discovery="NodeDiscoveryComponent"
+			description="Security"
+			class="SecurityComponent"
+			singleton="true">
+					
+				 <resource-configuration>
+			         <c:group name="configuration" displayName="Configuration">
+	                     <c:simple-property name="enabled" type="boolean" summary="true" default="false" required="true"
+	                                        description="A flag indicating whether or not security is enabled for this system."/>
+	                      <c:simple-property name="username" required="false" description="The name of the administrative principal (i.e. user) to authenticate."/>
+         				  <c:simple-property name="password" type="password" required="false"
+                            description="The credentials (i.e. password) that should be used to authenticate the administrative principal."/>
+			        </c:group>	        
+	        	</resource-configuration>		
+		</server> <!-- End of security -->	
+
+  </server> <!-- end of Platform -->
+
+
+
+<!--
+
+
+		<service name="Connector Types"
+			subCategory="Resources"
+			discovery="ResourceDiscoveryComponent"
+			class="ResourceComponent"
+			description="Connector Types"
+			createDeletePolicy="both"
+               creationDataType="content">
+
+				<operation name="getProperties"
+					displayName="View properties"
+					description="List the properties">
+					<results>
+						<c:list-property name="list">
+							<c:map-property name="map">
+								<c:simple-property name="Name" type="string"
+									description="The name of this property" />
+								<c:simple-property name="Connector Type" type="string"
+									description="The type of connector that defines this data source" />
+								<c:simple-property name="Default" type="string"
+									description="The default value when not defined by the user" />
+								<c:simple-property name="Masked" type="boolean"
+									description="Indicates if the property value requires masking after being entered.  A password would be a good example of a value needing masking." />
+								<c:simple-property name="Descritpion" type="string"
+									description="The property description" />
+							</c:map-property>
+						</c:list-property>
+					</results>
+				</operation>
+
+         <content name="file" displayName="CDK File" category="deployable" isCreationType="true">
+            <configuration>
+            </configuration>
+         </content>
+		</service>
+-->
+
+</plugin>
\ No newline at end of file


Property changes on: trunk/console/src/resources/embedded/META-INF/rhq-plugin.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/resources/enterprise/META-INF/rhq-plugin.xml
===================================================================
--- trunk/console/src/resources/enterprise/META-INF/rhq-plugin.xml	                        (rev 0)
+++ trunk/console/src/resources/enterprise/META-INF/rhq-plugin.xml	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,348 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!--
+	* (c) 2008 Varsity Gateway LLC.
+	* All rights reserved.
+	*
+	* This descriptor is used for deploying JBEDSP to JON for enterprise use
+	* -->
+
+<plugin name="MetaMatrixPlugin" displayName="MetaMatrix Plugin"
+	package="com.metamatrix.rhq.plugin" version="2.0.0"	
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns="urn:xmlns:rhq-plugin" xmlns:c="urn:xmlns:rhq-configuration">
+
+	<server name="MetaMatrix System"
+		discovery="MetaMatrixSystemDiscoveryComponent"
+		class="MetaMatrixSystemComponent" description="MetaMatrix System"
+		singleton="true">
+
+		<operation name="bounceSystem"
+			displayName="Bounce MetaMatrix System"
+			description="Stop and restart the MetaMatrix system">
+			<parameters>
+				<c:simple-property name="waitUntilFinished"
+					type="boolean" default="false"
+					description="If true, this method waits until the operation is finished before returning. This may take a long time to complete.  If false, this method returns immediately, even though the operation may not be finished." />
+			</parameters>
+		</operation>
+
+		<operation name="listUsers"
+			displayName="View current user sessions"
+			description="List current user sessions connected to this MetaMatrix System">
+			<results>
+				<c:list-property name="list">
+					<c:map-property name="map">
+						<c:simple-property displayName="User Name"
+							name="getUserName" type="string"
+							description="The username for the user of this session" />
+						<c:simple-property
+							displayName="Application Name" name="getApplicationName"
+							type="string"
+							description="The name of the application this user is accessing MetaMatrix through" />
+						<c:simple-property displayName="Session ID"
+							name="getSessionID" type="string"
+							description="The id for this session" />
+						<c:simple-property displayName="VDB Name"
+							name="getVDBName" type="string"
+							description="The name of the VDB the user is connected to" />
+						<c:simple-property displayName="VDB Version"
+							name="getVDBVersion" type="string"
+							description="The version of the VDB the user is connected to" />
+						<c:simple-property displayName="Product Name"
+							name="getProductName" type="string"
+							description="The product name" />
+						<c:simple-property displayName="IP Address"
+							name="getIPAddress" type="string"
+							description="The IP Address for this user's connection" />
+						<c:simple-property displayName="Host Name"
+							name="getHostName" type="string"
+							description="The host name for this user's connection" />
+						<c:simple-property displayName="Last Ping Time"
+							name="getLastPingTime" type="string"
+							description="The last time this client was ping'd" />
+						<c:simple-property displayName="State"
+							name="getStateAsString" type="string"
+							description="The current state of this session" />
+					</c:map-property>
+				</c:list-property>
+			</results>
+		</operation>
+
+		<operation name="listQueries" displayName="View current queries"
+			description="List current queries executing against the MetaMatrix System">
+			<parameters>
+				<c:simple-property name="includeSourceQueries"
+					type="boolean" default="true"
+					description="If true, source queries will be included in the results.  If false, only top-level MetaMatrix queries will be included in the results." />
+			</parameters>
+			<results>
+				<c:list-property name="list">
+					<c:map-property name="map">
+						<c:simple-property displayName="User Name"
+							name="getUserName" type="string"
+							description="The username for the user that submitted this query" />
+						<c:simple-property displayName="Session ID"
+							name="getSessionID" type="string"
+							description="The id for the session" />
+						<c:simple-property displayName="Request ID"
+							name="getRequestID" type="string"
+							description="The id for the request" />
+						<c:simple-property displayName="Start Time"
+							name="getCreated" type="string"
+							description="The time this query has been running" />
+						<c:simple-property displayName="Transaction ID"
+							name="getTransactionID" type="string"
+							description="The version of the VDB the user is connected to" />
+						<c:simple-property displayName="SQL String"
+							name="getSqlCommand" type="string"
+							description="The SQL string for this query" />
+						<c:simple-property
+							displayName="Connector Binding Name"
+							name="getConnectorBindingName" type="string"
+							description="The IP Address for this user's connection" />
+						<c:simple-property displayName="Node ID"
+							name="getNodeID" type="string"
+							description="The node ID of this query" />
+						<c:simple-property displayName="Source Request"
+							name="isSource" type="string"
+							description="If false this is the top level query. If true this a physical source query." />
+					</c:map-property>
+				</c:list-property>
+			</results>
+		</operation>
+
+		<operation name="listLongRunningQueries"
+			displayName="View current long running queries"
+			description="List current queries executing against the MetaMatrix System that have surpassed the long running query threshhold">
+			<parameters>
+				<c:simple-property name="includeSourceQueries"
+					type="boolean" default="true"
+					description="If true, source queries will be included in the results.  If false, only top-level MetaMatrix queries will be included in the results." />
+			</parameters>
+			<results>
+				<c:list-property name="list">
+					<c:map-property name="map">
+						<c:simple-property displayName="User Name"
+							name="getUserName" type="string"
+							description="The username for the user that submitted this query" />
+						<c:simple-property displayName="Session ID"
+							name="getSessionID" type="string"
+							description="The name of the resource whose availability is being reported" />
+						<c:simple-property displayName="Request ID"
+							name="getRequestID" type="string"
+							description="The id for the request" />
+						<c:simple-property displayName="Start Time"
+							name="getCreated" type="string"
+							description="The time this query has been running" />
+						<c:simple-property displayName="Transaction ID"
+							name="getTransactionID" type="string"
+							description="The version of the VDB the user is connected to" />
+						<c:simple-property displayName="SQL String"
+							name="getSqlCommand" type="string"
+							description="The SQL string for this query" />
+						<c:simple-property
+							displayName="Connector Binding Name"
+							name="getConnectorBindingName" type="string"
+							description="The IP Address for this user's connection" />
+						<c:simple-property displayName="Node ID"
+							name="getNodeID" type="string"
+							description="The node ID of this query" />
+						<c:simple-property displayName="Source Request"
+							name="isSource" type="string"
+							description="If false this is the top level query. If true this a physical source query." />
+					</c:map-property>
+				</c:list-property>
+			</results>
+		</operation>
+
+		<operation name="killRequest" displayName="Terminate query"
+			description="Terminate the processing of a query and it's source queries">
+			<parameters>
+				<c:simple-property displayName="SessionID|RequestID"
+					name="requestID" type="string" required="true"
+					description="The IDs of the session|request to terminate (use format = sessionID|requestID)" />
+			</parameters>
+		</operation>
+
+		<operation name="listVDBs" displayName="View VDBs"
+			description="List VDBs in this MetaMatrix System">
+			<results>
+				<c:list-property name="list">
+					<c:map-property name="map">
+						<c:simple-property displayName="Name"
+							name="getName" type="string" description="The name of this VDB" />
+						<c:simple-property displayName="Version"
+							name="getVDBVersion" type="string"
+							description="The version of this VDB" />
+						<c:simple-property displayName="State"
+							name="getStateAsString" type="string"
+							description="The state of this VDB" />
+						<c:simple-property displayName="Has WSDL"
+							name="hasWSDL" type="string"
+							description="If true, this VDB contains a WSDL file" />
+						<c:simple-property
+							displayName="Has Materialized Views" name="hasMaterializedViews"
+							type="string"
+							description="If true, this VDB contains one or more materialized views" />
+						<c:simple-property displayName="Created Date"
+							name="getCreatedDate" type="string"
+							description="The creation date of this VDB" />
+						<c:simple-property displayName="Created By"
+							name="getCreatedBy" type="string"
+							description="The user that created this VDB" />
+						<c:simple-property displayName="Versioned Date"
+							name="getVersionedDate" type="string"
+							description="The version date of this VDB" />
+						<c:simple-property displayName="Versioned By"
+							name="getVersionedBy" type="string"
+							description="The user that versioned this VDB" />
+					</c:map-property>
+				</c:list-property>
+			</results>
+		</operation>
+
+		<operation name="getProperties"
+			displayName="View system properties"
+			description="List the system properties of this MetaMatrix System">
+			<results>
+				<c:list-property name="list">
+					<c:map-property name="map">
+						<c:simple-property name="Name" type="string"
+							description="The name of this property" />
+						<c:simple-property name="Value" type="string"
+							description="The value of this property" />
+					</c:map-property>
+				</c:list-property>
+			</results>
+		</operation>
+
+		<operation name="getHostProperties"
+			displayName="View host properties"
+			description="List the host properties of this MetaMatrix System">
+			<results>
+				<c:list-property name="list">
+					<c:map-property name="map">
+						<c:simple-property name="Name" type="string"
+							description="The name of this property" />
+						<c:simple-property name="Value" type="string"
+							description="The value of this property" />
+					</c:map-property>
+				</c:list-property>
+			</results>
+		</operation>
+
+		<metric displayName="Query Count" defaultOn="true"
+			displayType="summary" category="throughput" property="queryCount"
+			description="The number of queries for a given point in time" />
+
+		<metric displayName="Long Running Queries" defaultOn="true"
+			displayType="summary" category="performance"
+			property="longRunningQueries"
+			description="The number of queries that have been running longer than the limit set for queries. The default is 60 minutes, but this may be overridden by the 'longRunningQueryTime' system variable." />
+
+		<metric displayName="Session Count" defaultOn="true"
+			displayType="summary" category="throughput" property="sessionCount"
+			description="The number of user connections for a given point in time" />
+			
+			<resource-configuration>
+                 <c:group name="general" displayName="General" hiddenByDefault="false">
+                    <c:description>Query Configuration</c:description>
+                    <c:simple-property name="longrunning.query.limit" type="string" readOnly="true" required="true" displayName="Long Running Query limit" description="The value (in seconds) to use to determine if a query is to be considered 'long running'.">
+                    </c:simple-property>
+                 </c:group>
+             </resource-configuration>
+
+		<server name="MetaMatrix Process"
+			discovery="MetaMatrixServerDiscoveryComponent"
+			class="MetaMatrixServerComponent"
+			description="MetaMatrix Server instance">
+			
+	        <plugin-configuration>
+		         <c:group name="event" displayName="Process Log Tracking">
+                     <c:simple-property name="enabled" type="boolean" summary="true" default="true" required="true"
+                                        description="A flag indicating whether of not this log Event source is currently
+                                                     enabled (i.e. whether the associated log file should be tailed for
+                                                     new entries)."/>
+                     <c:simple-property name="minimumSeverity" required="true" default="ERROR" 
+                                        description="The minimum severity of Events that should be collected for this
+                                                     source. The default is ERROR.">
+                         <c:property-options>
+                            <c:option name="DEBUG" value="DEBUG"/>
+                            <c:option name="INFO"  value="INFO"/>
+                            <c:option name="WARNING"  value="WARNING"/>
+                            <c:option name="ERROR" value="ERROR" default="true"/>
+                         </c:property-options>
+                     </c:simple-property>
+		         </c:group>	        
+	        </plugin-configuration>			
+	        
+            <operation name="getProperties"
+				displayName="View process properties"
+				description="List the process properties of this vm instance">
+				<results>
+					<c:list-property name="list">
+						<c:map-property name="map">
+							<c:simple-property name="Name" type="string"
+								description="The name of this property" />
+							<c:simple-property name="Value"
+								type="string" description="The value of this property" />
+						</c:map-property>
+					</c:list-property>
+				</results>
+			</operation>
+
+			<metric displayName="Query High Water Mark" defaultOn="true"
+				displayType="summary" category="utilization"
+				property="highWatermark"
+				description="High water mark for queries in the Socket Worker Queue" />
+
+ 			<event name="errorLogEntry" description="an entry in a log file"/>  
+			<!-- Ted Jones - 06/19/08
+				Commenting out current threads metric until http://jira.jboss.org/jira/browse/JBEDSP-426 is resolved. -->
+			<!--     <metric displayName="Current Threads"
+				defaultOn="true"
+				displayType="summary"
+				category="utilization"
+				property="threadCount"
+				description="The number of active threads in the Socket Worker Queue"/> -->
+
+			<service name="Connectors"
+				discovery="MetaMatrixConnectorDiscoveryComponent"
+				class="MetaMatrixConnectorComponent">
+				<operation name="getProperties"
+					displayName="View connector properties"
+					description="List the properties of this connector">
+					<results>
+						<c:list-property name="list">
+							<c:map-property name="map">
+								<c:simple-property name="Name"
+									type="string" description="The name of this property" />
+								<c:simple-property name="Value"
+									type="string" description="The value of this property" />
+							</c:map-property>
+						</c:list-property>
+					</results>
+				</operation>
+				<operation name="restartConnector"
+					displayName="Re-start Connector"
+					description="Start/re-start this connector binding" />
+				<operation name="stopConnector"
+					displayName="Stop Connector"
+					description="Stop this connector binding">
+					<parameters>
+						<c:simple-property name="stopNow" type="boolean"
+							default="true"
+							description="If true, stop the process forcefully. If false, wait until any pending work is completed." />
+					</parameters>
+				</operation>
+			</service>
+
+		</server>
+		<server name="Host Controller"
+			discovery="MetaMatrixHostControllerDiscoveryComponent"
+			class="MetaMatrixHostControllerComponent"
+			description="MetaMatrix Host Controller">
+		</server>
+	</server>
+</plugin>
\ No newline at end of file


Property changes on: trunk/console/src/resources/enterprise/META-INF/rhq-plugin.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/test/java/org/teiid/rhq/AllTests.java
===================================================================
--- trunk/console/src/test/java/org/teiid/rhq/AllTests.java	                        (rev 0)
+++ trunk/console/src/test/java/org/teiid/rhq/AllTests.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2000-2008 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.rhq;
+
+import org.teiid.rhq.comm.impl.TestConnectionPool;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+
+/** 
+ * @since 1.0
+ */
+public class AllTests {
+    
+    public static void main(String[] args) {
+        junit.textui.TestRunner.runAndWait(AllTests.suite());
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("Test for com.metamatrix.rhq"); //$NON-NLS-1$
+        //$JUnit-BEGIN$
+        suite.addTest(TestConnectionPool.suite());
+        
+        //$JUnit-END$
+        return suite;
+    }
+
+
+
+}


Property changes on: trunk/console/src/test/java/org/teiid/rhq/AllTests.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/test/java/org/teiid/rhq/StartingEnvironmentConstants.java
===================================================================
--- trunk/console/src/test/java/org/teiid/rhq/StartingEnvironmentConstants.java	                        (rev 0)
+++ trunk/console/src/test/java/org/teiid/rhq/StartingEnvironmentConstants.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2000-2008 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.rhq;
+
+
+
+/** 
+ * @since 4.3
+ */
+public interface StartingEnvironmentConstants {
+
+    public static final String INSTALL_DIR = "D:/apps/MetaMatrix/enterpriseserver/5.5.3/073008"; //$NON-NLS-1$
+    public static final String PORT = "31000"; //$NON-NLS-1$
+    public static final String USERNAME = "metamatrixadmin"; //$NON-NLS-1$
+    public static final String PASSWORD = "mm"; //$NON-NLS-1$
+    
+    public static final String INSTALL_DIR2 = "D:/metamatrix/5.5.3/server_0721b"; //$NON-NLS-1$
+    public static final String PORT2 = "32000"; //$NON-NLS-1$
+    
+    
+    
+    
+    public static final String SINGLE_SYSTEM_PARM =  
+                INSTALL_DIR + "," + //$NON-NLS-1$
+                PORT + "," + //$NON-NLS-1$
+                USERNAME + "," + //$NON-NLS-1$
+                PASSWORD;
+                
+    public static final String TWO_SYSTEM_PARM = SINGLE_SYSTEM_PARM + ";" + //$NON-NLS-1$
+                INSTALL_DIR2 + "," + //$NON-NLS-1$
+                PORT2 + "," + //$NON-NLS-1$
+                USERNAME + "," + //$NON-NLS-1$
+                PASSWORD;
+            
+    
+
+}


Property changes on: trunk/console/src/test/java/org/teiid/rhq/StartingEnvironmentConstants.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnection.java
===================================================================
--- trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnection.java	                        (rev 0)
+++ trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnection.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,226 @@
+/*
+ * Copyright © 2000-2008 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.rhq.comm.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.teiid.rhq.comm.Component;
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionPool;
+import org.teiid.rhq.comm.ExecutedResult;
+
+
+/** 
+ * @since 6.2
+ */
+public class FakeConnection implements Connection{
+
+    public static int NUM_CONNECTORS = 3;
+    public static int NUM_VMS = 2;
+    public static int NUM_HOSTS = 1;
+    
+    private static final String HOST_ID = "Host_id_1"; //$NON-NLS-1$
+    
+    private String installDir = null;
+    private ConnectionPool pool;
+    private Properties envProps = null;
+    
+    public FakeConnection(ConnectionPool pool, Properties env) {
+        this.pool = pool;
+        this.envProps = env;
+        
+    }
+    
+    
+
+    @Override
+	public Collection<Component> discoverComponents(String componentType,
+			String identifier) throws ConnectionException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+
+
+	@Override
+	public void executeOperation(ExecutedResult result, Map valueMap)
+			throws ConnectionException {
+		// TODO Auto-generated method stub
+		
+	}
+
+
+
+	@Override
+	public String getKey() throws Exception {
+		// TODO Auto-generated method stub
+		return "fakekey";
+	}
+
+
+
+	@Override
+	public Object getMetric(String componentType, String identifier,
+			String metric, Map valueMap) throws ConnectionException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+
+
+	/** 
+     * @see com.metamatrix.rhq.comm.Connection#isValid()
+     * @since 6.2
+     */
+    public boolean isValid() {
+        return true;
+    }
+
+    /** 
+     * @throws Exception 
+     * @see com.metamatrix.rhq.comm.Connection#close()
+     * @since 6.2
+     */
+    public void close()  {
+        try {
+            pool.close(this);
+        } catch (Exception err) {
+            throw new RuntimeException(err);
+            
+        }
+    }
+
+
+    /** 
+     * @see com.metamatrix.rhq.comm.Connection#getConnectors(java.lang.String)
+     * @since 6.2
+     */
+    public Collection<Component> getConnectors(String vmname) throws ConnectionException {
+        Collection<Component> vms = getVMs();
+        Collection<Component> cs = new ArrayList(5);
+        for (Iterator vmIt=vms.iterator(); vmIt.hasNext();) {
+            Component vm = (Component) vmIt.next();
+            for (int i = 0; i < NUM_VMS; i++) {
+                ComponentImpl c = new ComponentImpl();
+                c.setSystemKey(this.installDir);
+                c.setIdentifier(vm.getIdentifier() + "|VM_id_" + i); //$NON-NLS-1$
+                c.setName("VM_id_" + i); //$NON-NLS-1$
+                cs.add(c);
+            }
+        }
+        
+        return cs;
+    }
+
+    /** 
+     * @see com.metamatrix.rhq.comm.Connection#getEnvironment()
+     * @since 6.2
+     */
+    public Properties getEnvironment() throws Exception {
+        return this.envProps;
+    }
+
+    /** 
+     * @see com.metamatrix.rhq.comm.Connection#getHost()
+     * @since 6.2
+     */
+    public Component getHost() throws ConnectionException {
+            ComponentImpl c = new ComponentImpl();
+            c.setSystemKey(this.installDir);
+            c.setIdentifier(HOST_ID);
+            c.setName(HOST_ID );
+            c.setPort("1"); //$NON-NLS-1$
+        return c;
+    }
+
+    /** 
+     * @see com.metamatrix.rhq.comm.Connection#getInstallationDirectory()
+     * @since 6.2
+     */
+    public String getInstallationDirectory() throws Exception {
+        return installDir;
+    }
+
+    /** 
+     * @see com.metamatrix.rhq.comm.Connection#getMetric(java.lang.String, java.lang.String, java.util.Map)
+     * @since 6.2
+     */
+    public Object getMetric(String componentType,
+                            String metric,
+                            Map valueMap) throws ConnectionException {
+        return null;
+    }
+    
+    
+
+    /** 
+     * @see com.metamatrix.rhq.comm.Connection#getProperties(java.lang.String, java.lang.String)
+     * @since 6.2
+     */
+    public Properties getProperties(String resourceType,
+                                    String identifier) throws ConnectionException {
+        return null;
+    }
+
+    /** 
+     * @see com.metamatrix.rhq.comm.Connection#getProperty(java.lang.String, java.lang.String)
+     * @since 6.2
+     */
+    public String getProperty(String identifier,
+                              String property) throws ConnectionException {
+        return this.envProps.getProperty(property);
+    }
+
+    /** 
+     * @see com.metamatrix.rhq.comm.Connection#getVMs()
+     * @since 6.2
+     */
+    public Collection<Component> getVMs() throws ConnectionException {
+  
+        
+        Component host = getHost();
+        Collection cs = new ArrayList(5);
+        for (int i = 0; i < NUM_VMS; i++) {
+            ComponentImpl c = new ComponentImpl();
+            c.setSystemKey(this.installDir);
+            c.setIdentifier(host.getIdentifier() + "|VM_id_" + i); //$NON-NLS-1$
+            c.setName("VM_id_" + i); //$NON-NLS-1$
+            c.setPort(String.valueOf(i));
+            cs.add(c);
+        }
+        
+        return cs;
+
+    }
+    
+    public Collection<Component> getVDBs(List fieldNameList) throws ConnectionException {
+		return Collections.EMPTY_LIST;
+	}
+
+	/** 
+     * @see com.metamatrix.rhq.comm.Connection#isAlive()
+     * @since 6.2
+     */
+    public boolean isAlive() {
+        return true;
+    }
+
+    /** 
+     * @see com.metamatrix.rhq.comm.Connection#isAvailable(java.lang.String, java.lang.String)
+     * @since 6.2
+     */
+    public Boolean isAvailable(String componentType,
+                               String identifier) throws ConnectionException {
+        return true;
+    }
+
+}


Property changes on: trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnection.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnectionFactory.java
===================================================================
--- trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnectionFactory.java	                        (rev 0)
+++ trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnectionFactory.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,59 @@
+package org.teiid.rhq.comm.impl;
+
+
+import java.util.Properties;
+
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionFactory;
+import org.teiid.rhq.comm.ConnectionPool;
+
+
+
+
+public class FakeConnectionFactory implements
+		ConnectionFactory {
+    
+    static boolean createdfactory = false;
+	private static Properties connEnv;
+    private ConnectionPool pool;
+	
+	public Connection createConnection(){
+
+        return new FakeConnection(pool, connEnv);
+           
+	}
+	
+	
+
+
+	@Override
+	public String getURL() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+
+
+
+	@Override
+	public void initialize(Properties env, ConnectionPool connectionPool)
+			throws ConnectionException {
+			connEnv = env;
+	        this.pool = connectionPool;
+	        createdfactory = true;
+		
+	}
+
+
+    public void closeConnection(Connection connection)  {
+
+    }
+    
+  
+    public String getProperty(String key) {
+        return connEnv.getProperty(key);
+    }
+   
+
+}


Property changes on: trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnectionFactory.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeInvalidConnectionFactory.java
===================================================================
--- trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeInvalidConnectionFactory.java	                        (rev 0)
+++ trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeInvalidConnectionFactory.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,60 @@
+package org.teiid.rhq.comm.impl;
+
+
+import java.util.Properties;
+
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionException;
+import org.teiid.rhq.comm.ConnectionFactory;
+import org.teiid.rhq.comm.ConnectionPool;
+
+
+
+public class FakeInvalidConnectionFactory implements
+		ConnectionFactory {
+    
+    static boolean createdfactory = false;
+	private static Properties connEnv;
+    private ConnectionPool pool;
+	
+	public Connection createConnection(){
+
+        Connection   result  = new InvalidConnectionImpl("INVALIDKEY", connEnv,  pool);
+           
+            
+		return result;
+	}
+
+	
+	
+
+	@Override
+	public String getURL() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+
+
+
+	@Override
+	public void initialize(Properties env, ConnectionPool connectionPool)
+			throws ConnectionException {
+		connEnv = env;
+        this.pool = connectionPool;
+        createdfactory = true;
+		
+	}
+
+
+     public void closeConnection(Connection connection)  {
+
+    }
+    
+  
+    public String getProperty(String key) {
+        return connEnv.getProperty(key);
+    }
+   
+
+}


Property changes on: trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeInvalidConnectionFactory.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/console/src/test/java/org/teiid/rhq/comm/impl/TestConnectionPool.java
===================================================================
--- trunk/console/src/test/java/org/teiid/rhq/comm/impl/TestConnectionPool.java	                        (rev 0)
+++ trunk/console/src/test/java/org/teiid/rhq/comm/impl/TestConnectionPool.java	2009-07-31 13:15:35 UTC (rev 1210)
@@ -0,0 +1,359 @@
+/*
+ * Copyright © 2000-2008 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.rhq.comm.impl;
+
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.teiid.rhq.comm.Connection;
+import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.comm.ConnectionPool;
+//import org.teiid.rhq.embedded.pool.ConnectionPoolImpl;
+
+import org.teiid.rhq.enterprise.pool.ConnectionPoolImpl;
+
+
+
+
+/** 
+ * @since 4.3
+ */
+public class TestConnectionPool extends TestCase  {
+    static {
+ //       System.setProperty(SingletonConnectionManager.INSTALL_SERVER_PROP,StartingEnvironmentConstants.SINGLE_SYSTEM_PARM);
+        
+        // reset the conn mager for the next test case class
+        
+    }    
+    
+    private boolean failure = false;
+    int count;
+    
+    /**
+     * This suite of all tests could be defined in another class but it seems easier to 
+     * maintain it here.
+     */
+    public static Test suite() {
+
+        TestSuite suite = new TestSuite("TestConnectionPool"); //$NON-NLS-1$
+        suite.addTestSuite(TestConnectionPool.class); 
+        return suite;
+    }
+
+
+    // ################################## MAIN ################################
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(suite());
+    }    
+
+    /**
+     * @since 1.0
+     */
+//    public static void main(final String[] arguments) {
+//        try {
+//            
+//            TestConnectionPool test = new TestConnectionPool();
+//            test.runTest();
+//
+//            
+//        }catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//    }
+    
+//    public void runTest() throws Exception {
+//        testSimple();
+//        testSecond();
+//        testThreading();
+//    }
+    
+    public void testSimple() throws Exception {
+        log("Start simpleTest...");
+        failure = false;
+        
+        Properties props = new Properties();
+        props.setProperty(ConnectionPool.CONNECTION_FACTORY, "org.teiid.rhq.comm.impl.FakeConnectionFactory");
+        
+        ConnectionPool pool = new ConnectionPoolImpl();
+        pool.initialize(props, this.getClass().getClassLoader());
+        
+        if (!FakeConnectionFactory.createdfactory) {
+            logError("Didn't use the fake factory");
+        }
+        
+        Connection conn = pool.getConnection();
+        
+        int cnt = pool.getAvailableConnectionCount();
+        if (cnt != 0) {
+            logError("Available count should have been 0, but was " + cnt);
+        }
+        
+        
+        cnt = pool.getConnectionsInUseCount();
+        if (cnt != 1) {
+            logError("Connections in use should have been 1, but was " + cnt);
+        }    
+
+          pool.close(conn);
+        
+        cnt = pool.getConnectionsInUseCount();
+        if (cnt != 0) {
+            logError("Connections in use should have been 0 after checkin, but was " + cnt);
+        } 
+        
+        cnt = pool.getAvailableConnectionCount();
+        if (cnt != 1) {
+            logError("Available count should have been 1 after checking, but was " + cnt);
+        }       
+        
+        pool.shutdown();
+        log("Was simpleTest a success " + !failure );
+    }
+    
+    public void testSecond() throws Exception {
+        log("Start secondTest...");
+        failure = false;
+       Properties props = new Properties();
+        props.setProperty(ConnectionPool.CONNECTION_FACTORY, "org.teiid.rhq.comm.impl.FakeConnectionFactory");
+        
+        ConnectionPool pool = new ConnectionPoolImpl();
+        pool.initialize( props, this.getClass().getClassLoader());
+        
+        if (!FakeConnectionFactory.createdfactory) {
+            logError("Didn't use the fake factory");
+        }        
+        
+        Connection conn = pool.getConnection();
+        Connection conn2 = pool.getConnection();
+        Connection conn3 = pool.getConnection();
+        
+        validateAvailCnt(pool, 0);
+
+        validateInUseCnt(pool, 3);
+        
+
+        pool.close(conn);
+
+        validateAvailCnt(pool, 1);
+
+        validateInUseCnt(pool, 2);
+        
+        
+        Connection conn4 = pool.getConnection();
+        Connection conn5 = pool.getConnection();
+        
+        validateAvailCnt(pool, 0);
+
+        validateInUseCnt(pool, 4);
+        
+        pool.close(conn5);
+        pool.close(conn3);
+        pool.close(conn2);
+        pool.close(conn4);
+        
+        validateAvailCnt(pool, 4);
+
+        validateInUseCnt(pool, 0);
+        
+        pool.shutdown();
+        log("Was secondTest a success " + !failure );
+    }  
+    
+    private void validateInUseCnt(ConnectionPool pool, int cnt) {
+        
+//        int incnt = pool.getConnectionsInUseCount();
+//        if (incnt != cnt) {
+//            logError("Connections in use should have been " + cnt + " , but was " + incnt);
+//        }   
+    }
+    
+    private void validateAvailCnt(ConnectionPool pool, int cnt) {
+        
+//        int incnt = pool.getAvailableConnectionCount();
+//        if (incnt != cnt) {
+//            logError("Available count should have been " + cnt + " , but was " + incnt);
+//        }   
+    }    
+    
+    public void testThreading() throws Exception {
+        failure = false;
+        log("Start threadingTest...");
+        
+        Properties props = new Properties();
+        props.setProperty(ConnectionPool.CONNECTION_FACTORY, "org.teiid.rhq.comm.impl.FakeConnectionFactory");
+        props.setProperty(ConnectionConstants.PASSWORD, "PW");
+        props.setProperty(ConnectionConstants.USERNAME, "USERNAME");
+                
+        ConnectionPool pool = new ConnectionPoolImpl();
+        pool.initialize( props, this.getClass().getClassLoader());
+        
+        
+        int threadCnt = 10;
+//        int max_size = 1;
+ //       int expectedNumErrors = threadCnt - max_size;
+
+        TimeOutThread[] ts = new TimeOutThread[threadCnt];
+
+        for (count = 0; count < threadCnt; count++) {
+            ts[count] = new TimeOutThread(pool, 10, count);
+        }
+    
+        for(int k = 0; k < threadCnt; k++){
+                    ts[k].start();
+        }
+    
+          try {
+                for(int k = 0; k < threadCnt; k++){
+                    ts[k].join();
+                }
+          } catch (InterruptedException e) {
+          }
+    
+          for(int k = 0; k < threadCnt; k++){
+            if (ts[k].hasException()) {
+                Exception e = ts[k].getException();
+
+                logError("Exception " + e.getMessage());
+
+    
+            }
+            // which thread
+            int pc = ts[k].getProcessCnt();
+            
+            // number of connections suppose to process per thread
+            int ptc = ts[k].getPerThreadCnt();
+
+            // the number of connection actually processed
+            int mx = ts[k].getMaxProcessedCnt();
+            
+            // the end count of the connection left after close is suppose to be called
+            int ct = ts[k].getConnectionCount();
+            if (ct != 0) {
+                logError("Thread " + pc + " did have the connections go back down to zero");
+            }
+            if (ptc != mx) {
+                logError("PerThreadCnt " + ptc + ", but only successfully processed " + mx);
+            } else {
+                log("Process " + pc + " for thread # " + k);
+            }
+            
+            
+          }
+    
+          log("Was threadingTest a success " + !failure );
+   
+
+    }
+
+
+    
+    private void logError(String msg) {
+        failure = true;
+        System.out.println(msg);
+    }
+
+    private void log(String msg) {
+        System.out.println(msg);
+    }    
+    
+    protected  class TimeOutThread extends BaseThread{
+      private ConnectionPool pool;
+      private int connCnt = 0;
+      private int processCnt = 0;
+      private int maxCnt = 0;
+
+
+      public TimeOutThread(ConnectionPool connpool, int connections, int processcnt) {
+          super(connections);
+          this.pool = connpool;
+          this.processCnt = processcnt;
+          
+
+      }
+      public int getProcessCnt() {
+          return processCnt;
+      }
+      
+      public int getMaxProcessedCnt() {
+          return maxCnt;
+      }
+      public int getConnectionCount() {
+          return this.connCnt;
+      }
+      
+        public void run(){
+      // DO NOT call resource.close(), all the resources should remain
+      // checkedout to cause the next resource request to timeout.
+      
+
+        for (int i=0; i < perThreadCnt; i++ ) {
+            Connection conn = null;
+            try {
+                conn = pool.getConnection();
+                ++connCnt;
+                ++maxCnt;
+                
+                 yield();
+//               Properties psrops =conn.
+//                if (psrops == null || psrops.isEmpty()) {
+//                    setException(new Exception("Null Environment"));
+//                }
+//                if (conn.getProperty(ConnectionConstants.USERNAME) == null) {
+//                    setException(new Exception("No UserName"));
+//                }
+//                if (psrops.size() < 3) {
+//                    setException(new Exception("NOt Enough Properties"));
+//                    System.out.println(psrops);
+//                }
+
+            } catch (Exception toe) {
+                setException(toe);
+
+            }
+
+            // yield to the other thread to checkout instance, which should timeout
+            try {
+                pool.close(conn);
+                --connCnt;
+            } catch (Exception err) {
+                setException(err);
+            }
+        }
+        }   
+    }
+
+    protected class BaseThread extends Thread{
+        protected String objName = "Thread " + count; //$NON-NLS-1$
+      protected int perThreadCnt = 1;
+      private Exception t = null;
+
+
+      public BaseThread(int iterationCnt) {
+          perThreadCnt = iterationCnt;
+      }
+      
+      public int getPerThreadCnt() {
+          return perThreadCnt;
+      }
+
+      public Exception getException() {
+          return t;
+      }
+
+      public void setException(Exception te) {
+          t = te;
+      }
+
+      public boolean hasException() {
+          return (t==null ? false : true);
+      }
+
+    }    
+
+}


Property changes on: trunk/console/src/test/java/org/teiid/rhq/comm/impl/TestConnectionPool.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the teiid-commits mailing list