|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.ifs.common.BaseMain | +--oracle.ifs.common.BaseApp | +--oracle.ifs.agents.common.IfsAgent
An IfsAgent is an abstract class that acts as a base class for all iFS agents.
IfsAgent implements the Agent interface, which is a required by ServerManager who manages the running of the agent. This class simplifies agent writing by reducing the number of methods that need to be implemented, and by hiding the threading considerations that are involved.
A class that extends IfsAgent will normally need to override the following methods that are declared by IfsAgent (using the same constructor/method signatures decalred in this class):
super
.
super
.
super
.
super
.
super
.
super
.
super
.
super
.
super
.
super
.
IfsAgent also implements convenience methods used by subclasses, for session management, timer management, etc.
Constructor Summary | |
IfsAgent(java.lang.String name,
java.lang.String[] args,
java.lang.String parameterTableSection,
oracle.ifs.agents.manager.ServerManager manager)
Constructs an IfsAgent. |
Method Summary | |
LibrarySession |
checkSession()
Gets the session used by this agent. |
LibrarySession |
connectSession()
Connects a session for use by the agent. |
void |
disconnectSession()
Disconnects the session used by this agent. |
AgentLogger |
getAgentLogger()
Gets the logger used by the Agent. |
java.util.Date |
getLastTimerActivation()
The time at which this Agent last received a Timer expired event. |
java.lang.String |
getName()
Gets the name of this Agent. |
java.util.Date |
getNextTimerActivation()
The time at which this Agent is expected to receive a Timer expired event. |
ParameterTable |
getParameterTable()
Gets the ParameterTable which defines the configuration options for this agent. |
int |
getPriority()
Gets the priority of this Agent. |
java.lang.Long |
getServerDetailId()
Gets the SERVERDETAIL Id that represents this agent. |
LibrarySession |
getSession()
Gets the session used by this agent. |
protected void |
handlePriorityChangeRequest()
handle priority change request. |
protected void |
handleRequests()
Handle any status requests. |
protected void |
handleResumeRequest()
handle the resume request. |
protected void |
handleStopRequest()
handle the stop request. |
protected void |
handleSuspendRequest()
handle the suspend request. |
protected void |
handleTimerExpired()
handle the timer expired request. |
boolean |
isAlive()
Gets whether this Agent is alive. |
boolean |
isSuspended()
Gets whether this Agent is suspended. |
protected boolean |
isTimerActive()
Return indication of timer being active. |
void |
postRun()
Performs post-run tasks for this Agent. |
void |
processEvent(IfsEvent event)
Process an event that has been queued. |
void |
processEvents()
Process all events that have been queued. |
void |
publishDetail(java.lang.String propertyName,
java.lang.Object value)
Publish new detailed status information or updated previously registered property in this agent's SERVERDETAIL object. |
void |
publishStatusDetail()
Publish the agent's status. |
protected void |
queueEvent(IfsEvent event)
Queues next IfsEvent for processing. |
void |
registerDetails()
Register detailed status information into our ServerDetail. |
void |
run()
Runs this Agent. |
void |
setAgentLogger(AgentLogger logger)
Sets the logger to be used by the Agent. |
void |
setPriority(int priority)
Sets the priority of this Agent. |
protected void |
startTimer()
Starts a timer, that will post "timer expired" events at a specified interval. |
protected void |
stopTimer()
Stops the timer, if it was started via startTimer(). |
protected void |
waitAgent()
Wait for the next request or event. |
Constructor Detail |
public IfsAgent(java.lang.String name, java.lang.String[] args, java.lang.String parameterTableSection, oracle.ifs.agents.manager.ServerManager manager) throws IfsException
Agent subclass constructors define a constructor with this signature, and must invoke super to invoke this constructor.
name
- the Agent nameargs
- a ParameterTable argument listparameterTableSection
- the section in the ParameterTable that
contains parameters for this Agentmanager
- the managing ServerManagerIfsException
- (IFS-46000) if the operation failsMethod Detail |
public java.lang.String getName()
getName
in interface Agent
public LibrarySession getSession()
public LibrarySession checkSession() throws IfsException
public java.lang.Long getServerDetailId()
public void registerDetails() throws IfsException
IfsException
- if the operation failspublic void publishStatusDetail()
If no session is active when this method is invoked, a session will be created temporarily in order to update the status information, and then disconnected when complete.
public void publishDetail(java.lang.String propertyName, java.lang.Object value) throws IfsException
propertyName
- The name of the property.value
- The value for the property.IfsException
- if the operation failspublic LibrarySession connectSession() throws IfsException
IfsException
- if the operation failspublic void disconnectSession()
public AgentLogger getAgentLogger()
getAgentLogger
in interface Agent
public void setAgentLogger(AgentLogger logger) throws IfsException
setAgentLogger
in interface Agent
logger
- the AgentLogger to be used for logging.IfsException
- if the operation failspublic ParameterTable getParameterTable()
getParameterTable
in interface Agent
getParameterTable
in class oracle.ifs.common.BaseMain
public int getPriority() throws IfsException
The priority must be between Thread.MIN_PRIORITY
and
Thread.MAX_PRIORITY
, inclusive.
getPriority
in interface Agent
IfsException
- (IFS-46013) if the operation failspublic void setPriority(int priority) throws IfsException
The priority must be between Thread.MIN_PRIORITY
and
Thread.MAX_PRIORITY
, inclusive.
setPriority
in interface Agent
priority
- the priorityIfsException
- (IFS-46014) if the operation failsprotected void waitAgent() throws IfsException
run()
.
This returns immediately if there are pending requests or events.
protected void handleRequests() throws IfsException
handleStopRequest()
,
handleSuspendRequest()
,
handleResumeRequest()
,
handleTimerExpired()
, or
handlePriorityChangeRequest()
for all pending status requests.protected void handleStopRequest() throws IfsException
IfsException
- if operation failsprotected void handleSuspendRequest() throws IfsException
IfsException
- if operation failsprotected void handleResumeRequest() throws IfsException
IfsException
- if operation failsprotected void handleTimerExpired() throws IfsException
IfsException
- if operation failsprotected void handlePriorityChangeRequest() throws IfsException
IfsException
- if operation failsprotected void queueEvent(IfsEvent event)
processEvents()
. *event
- the event.public void processEvents() throws IfsException
run()
.IfsException
- if operation fails.public void processEvent(IfsEvent event) throws IfsException
event
- the event.IfsException
- if operation fails.public boolean isAlive() throws IfsException
An Agent is alive if it has been started and has not stopped nor been requested to stop.
isAlive
in interface Agent
IfsException
- (IFS-46030) if the operation failspublic boolean isSuspended() throws IfsException
An Agent is suspended if it has been started and then suspended, and has not resumed or stopped.
isSuspended
in interface Agent
IfsException
- (IFS-46031) if the operation failspublic java.util.Date getLastTimerActivation()
public java.util.Date getNextTimerActivation()
public void run()
Override this method with the tasks to be performed by this Agent.
If this method returns (either explicitly or by throwing an Error),
postRun
is invoked and the Agent is stopped.
run
in interface Agent
public void postRun()
This method is invoked when an agent is stopped, and has returned
fomr the run()
method. Subclasses can override this
to perform custom tasks, such as disconnecting the session and stopping
the timer, but must invoke super first.
postRun
in interface Agent
protected void startTimer()
The timer options are specified in the agent section of the ServerManager configuration file. The options that are supported are:
The last and next timer events are published in the agent's SERVERDETAIL object once the timer is started.
protected void stopTimer()
protected boolean isTimerActive()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |