org.rhq.core.clientapi.agent.metadata
Class PluginMetadataManager

java.lang.Object
  extended by org.rhq.core.clientapi.agent.metadata.PluginMetadataManager

public class PluginMetadataManager
extends Object

This is meant to provide an interface to the underlying metadata of a plugin. It will load, translate and cache the metadata for the rest of the services in the form of the domain object classes and the jaxb version of the descriptors. This object can also be used to separately store plugin descriptors without converting them into types (i.e. the descriptor staging area). The thinking here is the server has the ability to get all the plugin descriptors early on and in any order; only later does it load/register those plugins (because it needs to order them via the proper dependency graph. There may be times when we need a plugin's descriptor but before that plugin has been loaded/registered. This manager lets us stage those descriptors prior to converting them into types.

Author:
Greg Hinkle, John Mazzitelli

Field Summary
static org.rhq.core.domain.resource.ResourceType TEST_PLATFORM_TYPE
           
 
Constructor Summary
PluginMetadataManager()
           
 
Method Summary
 org.rhq.core.domain.resource.ResourceType addTestPlatformType()
          Adds a platform resource type to represent an "anonymous" platform.
 PluginDependencyGraph buildDependencyGraph()
          Builds the dependency graph using all known descriptors.
 Set<org.rhq.core.domain.resource.ResourceType> getAllTypes()
           
 String getComponentClass(org.rhq.core.domain.resource.ResourceType resourceType)
           
 String getDiscoveryClass(org.rhq.core.domain.resource.ResourceType resourceType)
           
 Map<String,PluginDescriptor> getEmbeddedExtensions(String parentPlugin)
          Returns a map of plugins and their descriptors where those plugins are child extensions of the given parent plugin.
 PluginDescriptor getPluginDescriptor(String pluginName)
          Get the plugin descriptor for the named plugin.
 String getPluginLifecycleListenerClass(String pluginName)
           
 Set<String> getPluginNames()
           
 Set<org.rhq.core.domain.resource.ResourceType> getRootTypes()
           
 org.rhq.core.domain.resource.ResourceType getType(org.rhq.core.domain.resource.ResourceType resourceType)
           
 org.rhq.core.domain.resource.ResourceType getType(String typeName, org.rhq.core.domain.resource.ResourceCategory category)
           
 org.rhq.core.domain.resource.ResourceType getType(String resourceTypeName, String pluginName)
          Returns the Resource type with the specified name and plugin, or null if no such Resource type exists.
 Set<org.rhq.core.domain.resource.ResourceType> getTypesForCategory(org.rhq.core.domain.resource.ResourceCategory category)
          Return the Resource types applicable for a category
 Set<org.rhq.core.domain.resource.ResourceType> loadPlugin(PluginDescriptor pluginDescriptor)
          Transforms the pluginDescriptor into domain object form and stores into this object's type system.
 void storePluginDescriptor(PluginDescriptor descriptor)
          This will simply squirrel away the given plugin descriptor for later retrieval via getPluginDescriptor(String).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEST_PLATFORM_TYPE

public static final org.rhq.core.domain.resource.ResourceType TEST_PLATFORM_TYPE
Constructor Detail

PluginMetadataManager

public PluginMetadataManager()
Method Detail

storePluginDescriptor

public void storePluginDescriptor(PluginDescriptor descriptor)
This will simply squirrel away the given plugin descriptor for later retrieval via getPluginDescriptor(String). Use this as a simple storage mechanism for descriptors. Nothing is done with descriptor other than store it in memory for later retrieval.

Parameters:
descriptor - the descriptor to store

getPluginDescriptor

public PluginDescriptor getPluginDescriptor(String pluginName)
Get the plugin descriptor for the named plugin. If the descriptor was previously staged via storePluginDescriptor(PluginDescriptor), it will be used. If a new descriptor hasn't been staged, but a previous descriptor was loaded and converted into types, via loadPlugin(PluginDescriptor), it will be used. If the descriptor cannot be found anywhere, returns null.

Parameters:
pluginName - name of the plugin whose descriptor is to be returned.
Returns:
the descriptor or null if not available

addTestPlatformType

public org.rhq.core.domain.resource.ResourceType addTestPlatformType()
Adds a platform resource type to represent an "anonymous" platform. This should really only ever be used in a test scenario when the platform plugin is unavailable.

Returns:
the very thin anonymous resource type object

getPluginLifecycleListenerClass

public String getPluginLifecycleListenerClass(String pluginName)

getDiscoveryClass

public String getDiscoveryClass(org.rhq.core.domain.resource.ResourceType resourceType)

getComponentClass

public String getComponentClass(org.rhq.core.domain.resource.ResourceType resourceType)

loadPlugin

public Set<org.rhq.core.domain.resource.ResourceType> loadPlugin(PluginDescriptor pluginDescriptor)
Transforms the pluginDescriptor into domain object form and stores into this object's type system.

Parameters:
pluginDescriptor - the descriptor to transform
Returns:
the root resource types represented by this descriptor, or null on failure

getType

public org.rhq.core.domain.resource.ResourceType getType(String typeName,
                                                         org.rhq.core.domain.resource.ResourceCategory category)

getType

@Nullable
public org.rhq.core.domain.resource.ResourceType getType(String resourceTypeName,
                                                                  String pluginName)
Returns the Resource type with the specified name and plugin, or null if no such Resource type exists.

Parameters:
resourceTypeName - the Resource type name
pluginName - the name of the plugin that defines the Resource type
Returns:
the Resource type with the specified name and plugin, or null if no such Resource type exists

getType

@Nullable
public org.rhq.core.domain.resource.ResourceType getType(org.rhq.core.domain.resource.ResourceType resourceType)

getTypesForCategory

public Set<org.rhq.core.domain.resource.ResourceType> getTypesForCategory(org.rhq.core.domain.resource.ResourceCategory category)
Return the Resource types applicable for a category

Parameters:
category - ResourceCategory to look up
Returns:
the types for this category or an empty Set

getAllTypes

public Set<org.rhq.core.domain.resource.ResourceType> getAllTypes()

getRootTypes

public Set<org.rhq.core.domain.resource.ResourceType> getRootTypes()

getPluginNames

public Set<String> getPluginNames()

buildDependencyGraph

public PluginDependencyGraph buildDependencyGraph()
Builds the dependency graph using all known descriptors.

Returns:
dependency graph

getEmbeddedExtensions

public Map<String,PluginDescriptor> getEmbeddedExtensions(String parentPlugin)
Returns a map of plugins and their descriptors where those plugins are child extensions of the given parent plugin. The child extensions are those that used the "embedded" plugin extension model (that is, those whose types used sourcePlugin attribute in their type metedata). Note that this will examine all known descriptors, those that were loaded and those that were merely stored.

Parameters:
parentPlugin - the parent plugin
Returns:
a map of child plugin info where the children are those that extended the given parent plugin. If the given parent plugin was not extended by any other plugin, the map will be empty.


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.