org.rhq.core.pluginapi.inventory
Class ResourceDiscoveryContext<T extends ResourceComponent>

java.lang.Object
  extended by org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext<T>
Type Parameters:
T - the parent resource component type for those resources discovered by the discovery component that is assigned this context. In other words, for all the resources created by the discovery component, T is the resource component type of the parent of those new resources.

public class ResourceDiscoveryContext<T extends ResourceComponent>
extends Object

The context object that ResourceDiscoveryComponent objects will have access to when needing to perform its work. This context will have all the information that the discovery components will need to build new resources that it discovers.

A plugin writer will use this context to build details of resources that were either auto-discovered or are to be manually discovered.

This context class is currently designed to be an immutable object. Instances of this context object are to be created by the plugin container only.


Constructor Summary
ResourceDiscoveryContext(ResourceType resourceType, T parentComponent, ResourceContext parentResourceContext, SystemInfo systemInfo, List<ProcessScanResult> processScanResults, List<Configuration> pluginConfigurations, String pluginContainerName, PluginContainerDeployment pluginContainerDeployment)
          Creates a new ResourceDiscoveryContext object.
 
Method Summary
 List<ProcessScanResult> getAutoDiscoveredProcesses()
          After having scanned all running processes, if the plugin container auto-discovered some resources for the discovery component, those processes will be returned.
 Configuration getDefaultPluginConfiguration()
          Returns the default plugin configuration as defined in the resource type's default template.
 T getParentResourceComponent()
          The resource components for all newly discovered resources will become children of this parent resource component.
 ResourceContext getParentResourceContext()
          Provides access to the parent's resource context.
 List<Configuration> getPluginConfigurations()
          Returns plugin configurations for other known resources.
 PluginContainerDeployment getPluginContainerDeployment()
          Indicates where the plugin container (and therefore where the plugins) are deployed and running.
 String getPluginContainerName()
          The name of the plugin container in which the discovery component is running.
 ResourceType getResourceType()
          The ResourceDiscoveryComponent that is assigned this context will have the responsibility to discover resources of the resource type returned by this method.
 SystemInfo getSystemInformation()
          Returns a SystemInfo object that contains information about the platform/operating system that the plugin is running on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceDiscoveryContext

public ResourceDiscoveryContext(ResourceType resourceType,
                                T parentComponent,
                                ResourceContext parentResourceContext,
                                SystemInfo systemInfo,
                                List<ProcessScanResult> processScanResults,
                                List<Configuration> pluginConfigurations,
                                String pluginContainerName,
                                PluginContainerDeployment pluginContainerDeployment)
Creates a new ResourceDiscoveryContext object. The plugin container is responsible for instantiating these objects; plugin writers should never have to actually create context objects.

This creates a context object that contains information on both auto-discovered resources (i.e. those found via process scans) and manually discovered resources (i.e. resources whose plugin configurations were directly supplied by a user).

Parameters:
resourceType - the resource type of resources to be discovered which includes the default plugin configuration
parentComponent - the parent component of the components that this discovery component will discover
parentResourceContext - the parent component's resource context
systemInfo - information about the system on which the plugin and its plugin container are running
processScanResults - processes that were auto-discovered by the plugin container on behalf of the plugin via process scans (may be null or empty if nothing was auto-discovered)
pluginConfigurations - for resources that are already known to exist (more specifically, resources that a user told us exists), this contains plugin configurations that provide connection information to those existing managed resources. (may be null or empty if there are no other known resources)
pluginContainerName - the name of the plugin container in which the discovery component is running. Components can be assured this name is unique across all plugin containers/agents running
pluginContainerDeployment - indicates where the plugin container is running
Method Detail

getResourceType

public ResourceType getResourceType()
The ResourceDiscoveryComponent that is assigned this context will have the responsibility to discover resources of the resource type returned by this method.

Returns:
type of resources to be discovered

getParentResourceComponent

public T getParentResourceComponent()
The resource components for all newly discovered resources will become children of this parent resource component.

Returns:
parent component of all new resources discovered
See Also:
ResourceContext.getParentResourceComponent()

getParentResourceContext

public ResourceContext getParentResourceContext()
Provides access to the parent's resource context. This can be useful to access the parent's current plugin configuration values for use in discovery of the children.

Returns:
the resource context for the parent
Since:
1.0.1

getSystemInformation

public SystemInfo getSystemInformation()
Returns a SystemInfo object that contains information about the platform/operating system that the plugin is running on. With this object, you can natively obtain things such as the process table (containing process information) about all running processes), the operating system name, and other things. Please refer to the javadoc on SystemInfo for more details on the types of information you can access.

Returns:
system information object

getAutoDiscoveredProcesses

@NotNull
public List<ProcessScanResult> getAutoDiscoveredProcesses()
After having scanned all running processes, if the plugin container auto-discovered some resources for the discovery component, those processes will be returned. The returned list of processes and their associated scans should be used to build new discovered resources to be included in the discovery component's set of discovered resources unless for some reason the discovery component does not wish to include them.

Returns:
the processes the plugin container has auto-discovered on behalf of the discovery component

getPluginConfigurations

@NotNull
public List<Configuration> getPluginConfigurations()
Returns plugin configurations for other known resources. This will contain one or more plugin configurations if, for example, a user told us about resources that should exist and wants to manually discover them (whether or not that resource can be auto-discovered or has a process associated with it). This may be empty if there are no resources that were "manually discovered".

Returns:
list of plugin configurations, may be empty

getDefaultPluginConfiguration

public Configuration getDefaultPluginConfiguration()
Returns the default plugin configuration as defined in the resource type's default template. This returns a new copy of the default configuration; it will not return the same configuration instance to any future call to this method.

Returns:
a new copy of the default plugin configuration

getPluginContainerName

public String getPluginContainerName()
The name of the plugin container in which the discovery component is running. Components can be assured this name is unique across all plugin containers/agents running in the RHQ environment.

Returns:
the name of the plugin container

getPluginContainerDeployment

public PluginContainerDeployment getPluginContainerDeployment()
Indicates where the plugin container (and therefore where the plugins) are deployed and running. See PluginContainerDeployment for more information on what the return value means.

Returns:
indicator of where the plugin container is deployed and running


Copyright © 2008-2009 RHQ Project Advisory Board (Red Hat, Inc.). All Rights Reserved.