org.rhq.core.pluginapi.plugin
Class PluginContext

java.lang.Object
  extended by org.rhq.core.pluginapi.plugin.PluginContext

public class PluginContext
extends Object

A global context containing information about a plugin.


Constructor Summary
PluginContext(String pluginName, SystemInfo systemInfo, File temporaryDirectory, File dataDirectory, String pluginContainerName)
          Creates a new PluginContext object.
 
Method Summary
 File getDataDirectory()
          Directory where plugins can store persisted data that survives agent restarts.
 String getPluginContainerName()
          The name of the plugin container in which the plugin is running.
 String getPluginName()
          The name of the plugin which corresponds to this context object.
 SystemInfo getSystemInformation()
          Returns a SystemInfo object that contains information about the platform/operating system that the plugin is running on.
 File getTemporaryDirectory()
          A temporary directory for plugin use that is destroyed at agent shutdown.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginContext

public PluginContext(String pluginName,
                     SystemInfo systemInfo,
                     File temporaryDirectory,
                     File dataDirectory,
                     String pluginContainerName)
Creates a new PluginContext object. The plugin container is responsible for instantiating these objects; plugin writers should never have to actually create context objects.

Parameters:
pluginName - the name of the plugin that corresponds to this context
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 agent shutdown
dataDirectory - a directory where plugins can store persisted data that survives agent restarts
pluginContainerName - the name of the plugin container in which the plugin is running. You can be assured this name is unique across all plugin containers/agents running in the RHQ environment.
Method Detail

getPluginName

public String getPluginName()
The name of the plugin which corresponds to this context object.

Returns:
plugin name as it is specified in the plugin descriptor

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 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

getTemporaryDirectory

public File getTemporaryDirectory()
A temporary directory for plugin use that is destroyed at agent shutdown. Plugins should use this if they need to write temporary files that they do not expect to remain after the agent 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 agent 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 plugin is running. You can be assured this name is unique across all plugin containers/agents running in the RHQ environment.

Returns:
the name of the plugin container


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