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

java.lang.Object
  extended by org.rhq.enterprise.server.plugin.pc.ScheduledJobInvocationContext
Direct Known Subclasses:
StatefulScheduledJobInvocationContext

public class ScheduledJobInvocationContext
extends Object

A scheduled job's invocation method can take a single argument of this type. If this is the case, the scheduled job's method will be passed an object of this type enabling the job being invoked to be given information about the invocation.

When a job is not marked for concurrent execution, it can store data in the context in the form of key/value properties. These properties will be persisted across invocations of the job. If the job is marked to as clustered, the job data will persist across server restarts as well. Lastly, if the job is marked to run concurrently, the methods for accessing/updating properties will throw an exception.

Author:
John Mazzitelli

Constructor Summary
ScheduledJobInvocationContext(ScheduledJobDefinition jobDefinition, ServerPluginContext pluginContext, ServerPluginComponent serverPluginComponent)
           
 
Method Summary
 boolean containsKey(String key)
          Checks to see whether or not the property key is stored in the context.
 String get(String key)
          Retrieves a property value from the context.
 Map<String,String> getJobData()
          Returns a read-only view of the properties stored in the context.
 ScheduledJobDefinition getJobDefinition()
          The definition of the triggered job that owns this context object.
 ServerPluginComponent getServerPluginComponent()
          If the job's plugin has a plugin component defined, this will return the instance of that component.
 ServerPluginContext getServerPluginContext()
          General information for the job's plugin.
 void put(String key, String value)
          Adds a property to the context that is persisted across invocations of the job.
 String remove(String key)
          Removes the property value associated with the specified key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScheduledJobInvocationContext

public ScheduledJobInvocationContext(ScheduledJobDefinition jobDefinition,
                                     ServerPluginContext pluginContext,
                                     ServerPluginComponent serverPluginComponent)
Method Detail

getJobDefinition

public ScheduledJobDefinition getJobDefinition()
The definition of the triggered job that owns this context object.

Returns:
the triggered job's definition

getServerPluginContext

public ServerPluginContext getServerPluginContext()
General information for the job's plugin.

Returns:
the triggered job's plugin context

getServerPluginComponent

public ServerPluginComponent getServerPluginComponent()
If the job's plugin has a plugin component defined, this will return the instance of that component. This is helpful for stateless jobs to obtain information from the plugin component, which is stateful.

Returns:
the plugin component instance from the triggered job's plugin, or null if there is no plugin component for the plugin

put

public void put(String key,
                String value)
Adds a property to the context that is persisted across invocations of the job. The property is persisted across server restarts only if the scheduled job is declared to run as clustered. Note that method will throw an exception if the job is declared for concurrent execution.

Parameters:
key - The property name
value - The property value
Throws:
UnsupportedOperationException - if the job is marked for concurrent execution

get

public String get(String key)
Retrieves a property value from the context.

Parameters:
key - The property key
Returns:
The property value or null if the key is not found
Throws:
UnsupportedOperationException - if the job is marked for concurrent execution

remove

public String remove(String key)
Removes the property value associated with the specified key

Parameters:
key - The property key
Returns:
The value previously associated with the key or null if the key is present in the context
Throws:
UnsupportedOperationException - if the job is marked for concurrent execution

containsKey

public boolean containsKey(String key)
Checks to see whether or not the property key is stored in the context.

Parameters:
key - The property key
Returns:
true if the key is found, false otherwise.
Throws:
UnsupportedOperationException - if the job is marked for concurrent execution

getJobData

public Map<String,String> getJobData()
Returns a read-only view of the properties stored in the context.

Returns:
A read-only view of the properties stored in the context.
Throws:
UnsupportedOperationException - if the job is marked for concurrent execution


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