org.rhq.core.pluginapi.inventory
Interface ResourceComponent<T extends ResourceComponent>

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.
All Superinterfaces:
AvailabilityFacet

public interface ResourceComponent<T extends ResourceComponent>
extends AvailabilityFacet

The plugin component that wraps a Resource. This component allows you to work with the actual resource, such as determining its availability and setting its configuration, among other things. Resource components have a lifecycle controlled by the plugin container - see start(ResourceContext) and stop().

Implementations of this interface can also implement one or more of the different functionality facets which will allow the component to support different features such as measureability, configurability and others. These functionality facets are:

All implementations of this interface must also implement the base AvailabilityFacet.


Method Summary
 void start(ResourceContext<T> context)
          Initializes the resource component, possibly connecting to the managed resource itself.
 void stop()
          Stops the resource component, which usually indicates the plugin container itself is shutting down.
 
Methods inherited from interface org.rhq.core.pluginapi.availability.AvailabilityFacet
getAvailability
 

Method Detail

start

void start(ResourceContext<T> context)
           throws InvalidPluginConfigurationException,
                  Exception
Initializes the resource component, possibly connecting to the managed resource itself. The implementation can be custom to the plugin or resource, but the idea is that a resource component can create a single connection to their resource here, and maintain that connection throughout the life of the component (i.e. until the time when stop() is called).

This method typically examines the plugin configuration from ResourceContext.getPluginConfiguration() and uses that information to connect to the managed resource. If this method finds that the plugin configuration is invalid which causes the connection to the managed resource to fail, then this method should throw InvalidPluginConfigurationException. This exception typically should not be thrown if the connection failed for some reason other than an invalid plugin configuration (e.g. in the case the managed resource is simply not running now) because usually those conditions can be tracked as part of the resource's availability data.

Note that this method does not imply that the actual managed resource should be started; this only starts the plugin's resource component. To start the actual resource, plugins must utilize the OperationFacet facet to provide an operation to start it.

Parameters:
context - the context for this resource which includes information about the resource
Throws:
InvalidPluginConfigurationException - if the resource component failed to start because it could not connect to the resource due to a bad plugin configuration
Exception - any other exception that causes the component to fail to start

stop

void stop()
Stops the resource component, which usually indicates the plugin container itself is shutting down. This method is used to allow the component to disconnect from its managed resource and to clean up anything else as appropriate.

Note that this does not imply that the actual managed resource should be stopped; this only stops the plugin's resource component. To stop the actual resource, plugins must utilize the OperationFacet facet to provide an operation to stop it.



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