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

java.lang.Object
  extended by org.rhq.core.pluginapi.inventory.ResourceContext<T>
Type Parameters:
T - the parent resource component type for this component. This means you can nest a hierarchy of resource components that mimic the resource type hierarchy as defined in a plugin deployment descriptor.
Direct Known Subclasses:
ResourceUpgradeContext

public class ResourceContext<T extends ResourceComponent<?>>
extends Object

The context object that ResourceComponent objects will have access - it will have all the information that the resource components needs during their lifetime.

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
ResourceContext(Resource resource, T parentResourceComponent, ResourceContext<?> parentResourceContext, ResourceDiscoveryComponent<T> resourceDiscoveryComponent, SystemInfo systemInfo, File temporaryDirectory, File dataDirectory, String pluginContainerName, EventContext eventContext, OperationContext operationContext, ContentContext contentContext, AvailabilityContext availabilityContext, PluginContainerDeployment pluginContainerDeployment)
          Creates a new ResourceContext object.
 
Method Summary
 AvailabilityCollectorRunnable createAvailabilityCollectorRunnable(AvailabilityFacet availChecker, long interval)
          Deprecated. Use AvailabilityContext.createAvailabilityCollectorRunnable(AvailabilityFacet, long)
 AvailabilityContext getAvailabilityContext()
          Returns an AvailabilityContext that allows the plugin to access the availability functionality provided by the plugin container.
 ContentContext getContentContext()
          Returns a ContentContext that allows the plugin to access the content functionality provided by the plugin container.
 File getDataDirectory()
          Directory where plugins can store persisted data that survives plugin container restarts.
 EventContext getEventContext()
          Returns an EventContext, if the resource supports one or more types of Events, or null otherwise.
 File getFutureChildResourceDataDirectory(String childResourceKey)
          The data directory of a child to be created for the resource this context is associated with.
 ProcessInfo getNativeProcess()
          Returns the information on the native operating system process in which the managed resource is running.
 List<ProcessScanResult> getNativeProcessesForType()
          Scans the current list of running processes and returns information on all processes that may contain resources of the same type as this resource.
 OperationContext getOperationContext()
          Returns an OperationContext that allows the plugin to access the operation functionality provided by the plugin container.
 T getParentResourceComponent()
          The parent of the resource component that is associated with this context.
protected  ResourceContext<?> getParentResourceContext()
          Returns the resource context of the parent resource or null if there is no parent resource.
 Configuration getPluginConfiguration()
          Returns the resource's plugin configuration.
 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 resource component is running.
 File getResourceDataDirectory()
          The data directory of the resource this context is associated with.
 String getResourceKey()
          The resource key of the resource this context is associated with.
 ResourceType getResourceType()
          The resource type of the resource this context is associated with.
 SystemInfo getSystemInformation()
          Returns a SystemInfo object that contains information about the platform/operating system that the resource is running on.
 File getTemporaryDirectory()
          A temporary directory for plugin use that is destroyed at plugin container shutdown.
 String getVersion()
          The version of the resource this context is associated with.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceContext

public ResourceContext(Resource resource,
                       T parentResourceComponent,
                       ResourceContext<?> parentResourceContext,
                       ResourceDiscoveryComponent<T> resourceDiscoveryComponent,
                       SystemInfo systemInfo,
                       File temporaryDirectory,
                       File dataDirectory,
                       String pluginContainerName,
                       EventContext eventContext,
                       OperationContext operationContext,
                       ContentContext contentContext,
                       AvailabilityContext availabilityContext,
                       PluginContainerDeployment pluginContainerDeployment)
Creates a new ResourceContext object. NOTE: The plugin container is responsible for instantiating these objects; plugin writers should never have to actually create context objects.

Parameters:
resource - the resource whose ResourceComponent will be given this context object of the plugin
parentResourceComponent - the parent component of the context's associated resource component (or null if parent resource is null)
parentResourceContext - the resource context of the parent resource (or null if parent resource is null)
resourceDiscoveryComponent - the discovery component that can be used to detect other resources of the same type as this resource (may be null)
systemInfo - information about the system on which the plugin and its plugin container are running
temporaryDirectory - a temporary directory for plugin use that is destroyed at plugin container shutdown
dataDirectory - a directory where plugins can store persisted data that survives plugin container restarts
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 in the RHQ environment.
eventContext - an EventContext, if the resource supports one or more types of Events, or null otherwise
operationContext - an OperationContext the plugin can use to interoperate with the operation manager
contentContext - a ContentContext the plugin can use to interoperate with the content manager
availabilityContext - a AvailabilityContext the plugin can use to interoperate with the plugin container inventory manager
pluginContainerDeployment - indicates where the plugin container is running
Method Detail

getResourceKey

public String getResourceKey()
The resource key of the resource this context is associated with. This resource key is unique across all of the resource's siblings. That is to say, this resource key is unique among all children of the parent.

Returns:
resource key of the associated resource

getResourceType

public ResourceType getResourceType()
The resource type of the resource this context is associated with.

Returns:
type of the associated resource

getVersion

public String getVersion()
The version of the resource this context is associated with.

Returns:
the resource's version string
Since:
1.2

getResourceDataDirectory

public File getResourceDataDirectory()
The data directory of the resource this context is associated with.

Returns:
resource data directory

getFutureChildResourceDataDirectory

public File getFutureChildResourceDataDirectory(String childResourceKey)
The data directory of a child to be created for the resource this context is associated with.

Returns:
child resource data directory

getParentResourceComponent

public T getParentResourceComponent()
The parent of the resource component that is associated with this context.

Returns:
parent component of the associated resource component

getParentResourceContext

protected ResourceContext<?> getParentResourceContext()
Returns the resource context of the parent resource or null if there is no parent resource.

(This method is protected to be able to share that information with the ResourceUpgradeContext but at the same time to not pollute the ResourceContext public API with data that doesn't belong to it).

Returns:

getSystemInformation

public SystemInfo getSystemInformation()
Returns a SystemInfo object that contains information about the platform/operating system that the resource is running on. With this object, you can natively obtain things such as the operating system name, its hostname,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

getPluginConfiguration

public Configuration getPluginConfiguration()
Returns the resource's plugin configuration. This is used to configure the subsystem that is used to actually talk to the managed resource. Do not confuse this with the resource configuration, which is the actual configuration settings for the managed resource itself.

Returns:
plugin configuration

getNativeProcess

public ProcessInfo getNativeProcess()
Returns the information on the native operating system process in which the managed resource is running. If native support is not available or the process for some reason can no longer be found, this may return null.

Returns:
information on the resource's process

getNativeProcessesForType

public List<ProcessScanResult> getNativeProcessesForType()
Scans the current list of running processes and returns information on all processes that may contain resources of the same type as this resource. More specifically, this method will scan all the processes and try to match them up with the PIQL queries associated with this resource's type.

Returns:
information on the processes that may be running this resource or other resources of the same type
See Also:
ResourceType.getProcessScans()

getTemporaryDirectory

public File getTemporaryDirectory()
A temporary directory for plugin use that is destroyed at plugin container shutdown. Plugins should use this if they need to write temporary files that they do not expect to remain after the plugin container is restarted. This directory is shared among all plugins - plugins must ensure they write unique files here, as other plugins may be using this same directory. Typically, plugins will use the File.createTempFile(String, String, File) API when writing to this directory.

Returns:
location for plugin temporary files

getDataDirectory

public File getDataDirectory()
Directory where plugins can store persisted data that survives plugin container restarts. Each plugin will have their own data directory. The returned directory may not yet exist - it is up to each individual plugin to manage this directory as they see fit (this includes performing the initial creation when the directory is first needed).

Returns:
location for plugins to store persisted data

getPluginContainerName

public String getPluginContainerName()
The name of the plugin container in which the resource 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
Since:
1.3

getEventContext

public EventContext getEventContext()
Returns an EventContext, if the resource supports one or more types of Events, or null otherwise.

Returns:
an EventContext, if the resource supports one or more types of Events, or null otherwise

getOperationContext

public OperationContext getOperationContext()
Returns an OperationContext that allows the plugin to access the operation functionality provided by the plugin container.

Returns:
operation context object

getContentContext

public ContentContext getContentContext()
Returns a ContentContext that allows the plugin to access the content functionality provided by the plugin container.

Returns:
content context object

getAvailabilityContext

public AvailabilityContext getAvailabilityContext()
Returns an AvailabilityContext that allows the plugin to access the availability functionality provided by the plugin container.

Returns:
availability context object

createAvailabilityCollectorRunnable

public AvailabilityCollectorRunnable createAvailabilityCollectorRunnable(AvailabilityFacet availChecker,
                                                                         long interval)
Deprecated. Use AvailabilityContext.createAvailabilityCollectorRunnable(AvailabilityFacet, long)



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