org.rhq.enterprise.server.plugin.pc
Class ServerPluginContext

java.lang.Object
  extended by org.rhq.enterprise.server.plugin.pc.ServerPluginContext

public class ServerPluginContext
extends Object

A global context containing information about a server-side plugin. This is an immutable object, plugins are not allowed to alter these values.

Author:
John Mazzitelli

Constructor Summary
ServerPluginContext(ServerPluginEnvironment env, File dataDirectory, File tmpDirectory, org.rhq.core.domain.configuration.Configuration pluginConfiguration, List<ScheduledJobDefinition> schedules)
          Creates a new ServerPluginContext object.
 
Method Summary
 File getDataDirectory()
          Directory where plugins can store persisted data that survives agent restarts.
 org.rhq.core.domain.configuration.Configuration getPluginConfiguration()
          Returns the configuration for the plugin itself.
 ServerPluginEnvironment getPluginEnvironment()
          The environment of the plugin, including its name and other information.
 List<ScheduledJobDefinition> getSchedules()
          The schedules in which the plugin component should be periodically invoked.
 File getTemporaryDirectory()
          A temporary directory for plugin use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerPluginContext

public ServerPluginContext(ServerPluginEnvironment env,
                           File dataDirectory,
                           File tmpDirectory,
                           org.rhq.core.domain.configuration.Configuration pluginConfiguration,
                           List<ScheduledJobDefinition> schedules)
Creates a new ServerPluginContext object. The plugin container is responsible for instantiating these objects; plugin writers should never have to actually create context objects.

Parameters:
env - the environment of the plugin - includes the plugin name and other info
dataDirectory - a directory where plugins can store persisted data that survives server restarts
tmpDirectory - a temporary directory for plugin use
pluginConfiguration - the configuration for the plugin itself
schedules - if not null, the plugin will be invoked periodically via these schedules
Method Detail

getPluginEnvironment

public ServerPluginEnvironment getPluginEnvironment()
The environment of the plugin, including its name and other information.

Returns:
plugin environment

getTemporaryDirectory

public File getTemporaryDirectory()
A temporary directory for plugin use. Plugins should use this if they need to write temporary files that they do not expect to remain after the server 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

getPluginConfiguration

public org.rhq.core.domain.configuration.Configuration getPluginConfiguration()
Returns the configuration for the plugin itself. This may return null if the plugin did not define configuration metadata in its plugin descriptor.

Returns:
the configuration for the entire plugin (may be null)

getSchedules

public List<ScheduledJobDefinition> getSchedules()
The schedules in which the plugin component should be periodically invoked. When this is non-null, the plugin's component must be prepared to be periodically invoked by the plugin container's scheduler.

Returns:
the schedule, or null if the plugin should not be scheduled


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