[teiid-commits] teiid SVN: r1744 - trunk/console/src/main/java/org/teiid/rhq/plugin/util.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Thu Jan 14 11:15:49 EST 2010


Author: tejones
Date: 2010-01-14 11:15:49 -0500 (Thu, 14 Jan 2010)
New Revision: 1744

Added:
   trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
Modified:
   trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
Log:
TEIID-807: Adding Profile Service util

Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java	2010-01-13 21:42:42 UTC (rev 1743)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java	2010-01-14 16:15:49 UTC (rev 1744)
@@ -21,215 +21,188 @@
  */
 package org.teiid.rhq.plugin.util;
 
-
-/** 
- * These are the Constants that used in conjunction with using the 
+/**
+ * These are the Constants that used in conjunction with using the
+ * 
  * @since 5.5.3
  */
 public interface PluginConstants {
-	
+
 	/**
-     * These are properties required for connecting to the profile service and getting a handle
-     * to a specific component related to Teiid.
-     */
-	
-	// The system key is the value used to obtain a connection.   
+	 * These are properties required for connecting to the profile service and
+	 * getting a handle to a specific component related to Teiid.
+	 */
+
+	// 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 PROFILE_SERVICE = "ProfileService"; //$NON-NLS-1$
-        public final static String CONNECTION_FACTORY_TYPE = "ConnectionFactory"; //$NON-NLS-1$
-        public final static String NO_TX_SUBTYPE = "NoTx"; //$NON-NLS-1$
-        public final static String TEIID_RUNTIME_ENGINE = "teiid-runtime-engine"; //$NON-NLS-1$
-        public final static String TEIID_ENGINE_RESOURCE_NAME = "Data Service Runtime Engine"; //$NON-NLS-1$
-        public final static String TEIID_ENGINE_RESOURCE_DESCRIPTION = "JBoss Enterprise Data Service Runtime Engine"; //$NON-NLS-1$
-//        public final static String INSTALL_DIR = "install.dir"; //$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 are global properties used by all components
+	 */
+	public final static String PROFILE_SERVICE = "ProfileService"; //$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$
 
-    /**
-     * 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$
+	/**
+	 * Use these component type names when calling Connection related methods
+	 * that require the type.
+	 * 
+	 * @since 1.0
+	 */
+	public interface ComponentType {
+		
+		public interface Runtime {
 
-					public static interface Operations {
+			public final static String TYPE = "ConnectionFactory"; //$NON-NLS-1$
+			public final static String SUBTYPE = "NoTx"; //$NON-NLS-1$
+			public final static String TEIID_RUNTIME_ENGINE = "teiid/runtime-engine"; //$NON-NLS-1$
+			public final static String TEIID_ENGINE_RESOURCE_NAME = "Data Service Runtime Engine"; //$NON-NLS-1$
+			public final static String TEIID_ENGINE_RESOURCE_DESCRIPTION = "JBoss Enterprise Data Service Runtime Engine"; //$NON-NLS-1$
 
-						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 static interface Operations {
-					   	public final static String GET_HOSTS = "getHosts"; //$NON-NLS-1$            
-											
-					}        			
-        		}
-        		
-        		public interface Process {
+				public final static String BOUNCE_SYSTEM = "bounceSystem"; //$NON-NLS-1$					
+				public final static String GET_LONGRUNNINGQUERIES = "listLongRunningQueries"; //$NON-NLS-1$
 
-					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 static interface Metrics {
 
-						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 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 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 VDB {
 
-       			
-        		} 
-        		
-        		public interface Queries {
+			public final static String TYPE = "teiid"; //$NON-NLS-1$
+			public final static String SUBTYPE = "vdb"; //$NON-NLS-1$
+			public final static String NAME = "Enterprise Virtual Database"; //$NON-NLS-1$
+			public final static String DESCRIPTION = "JBoss Enterprise Virtual Database (VDB)"; //$NON-NLS-1$
 
-					public final static String TYPE = "Runtime.Queries"; //$NON-NLS-1$
-					public static interface Query {
+		}
+		
+		public interface Model {
 
-						public final static String GET_QUERIES = "listQueries"; //$NON-NLS-1$
-					}
-       			
+			public final static String TYPE = "teiid"; //$NON-NLS-1$
+			public final static String SUBTYPE = "model"; //$NON-NLS-1$
+			public final static String NAME = "Model"; //$NON-NLS-1$
+			public final static String DESCRIPTION = "Model used to map to a source"; //$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$
-                    
-                }
-                
-            }
-            
-        }  
-        
-   }
+		public interface Connector {
+
+			public final static String TYPE = "ConnectionFactory"; //$NON-NLS-1$
+			public final static String SUBTYPE = "NoTx"; //$NON-NLS-1$
+			public final static String NAME = "Enterprise Connector"; //$NON-NLS-1$
+			public final static String DESCRIPTION = "JBoss Enterprise Connector Binding"; //$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 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 Service {
+
+			public final static String TYPE = "Resource.Service"; //$NON-NLS-1$
+
+			public static interface Operations {
+
+			}
+
+			public static interface Query {
+
+			}
+
+		}
+
+	}
+
+	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$
+
+		}
+
+	}
+}

Added: trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java	                        (rev 0)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java	2010-01-14 16:15:49 UTC (rev 1744)
@@ -0,0 +1,71 @@
+package org.teiid.rhq.plugin.util;
+
+import java.util.Set;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.profileservice.spi.ProfileService;
+
+public class ProfileServiceUtil {
+
+	/**
+	 * Get the passed in {@link ManagedComponent}
+	 * 
+	 * @return {@link ManagedComponent}
+	 * @throws NamingException
+	 * @throws Exception
+	 */
+	public static ManagedComponent getManagedComponent(
+			ComponentType componentType, String componentName)
+			throws NamingException, Exception {
+		ProfileService ps = getProfileService();
+		ManagementView mv = getManagementView(ps);
+
+		ManagedComponent mc = mv.getComponent(componentName, componentType);
+		return mc;
+	}
+
+	/**
+	 * Get the {@link ManagedComponent} for the {@link ComponentType} and sub
+	 * type.
+	 * 
+	 * @return Set of {@link ManagedComponent}s
+	 * @throws NamingException
+	 * @throws Exception
+	 */
+	public static Set<ManagedComponent> getManagedComponents(
+			ComponentType componentType) throws NamingException, Exception {
+		ProfileService ps = getProfileService();
+		ManagementView mv = getManagementView(ps);
+
+		Set<ManagedComponent> mcSet = mv.getComponentsForType(componentType);
+
+		return mcSet;
+	}
+
+	/**
+	 * @param {@link ManagementView}
+	 * @return
+	 */
+	private static ManagementView getManagementView(ProfileService ps) {
+		ManagementView mv = ps.getViewManager();
+		mv.load();
+		return mv;
+	}
+
+	/**
+	 * @return {@link ProfileService}
+	 * @throws NamingException
+	 */
+	private static ProfileService getProfileService() throws NamingException {
+		InitialContext ic = new InitialContext();
+		ProfileService ps = (ProfileService) ic
+				.lookup(PluginConstants.PROFILE_SERVICE);
+		return ps;
+	}
+
+}



More information about the teiid-commits mailing list