org.rhq.core.pc.agent
Class AgentService

java.lang.Object
  extended by org.rhq.core.pc.agent.AgentService
Direct Known Subclasses:
BundleManager, ConfigurationManager, ContentManager, DriftManager, InventoryManager, MeasurementManager, OperationManager, ResourceFactoryManager, SupportManager

public abstract class AgentService
extends Object

Those plugin container managers that need to expose their interfaces remotely (to the JON Server for example) need to extend this class. This class will know what its remote client interface is (see the constructor) and will be able notify a set of listeners when it is started and stopped (to presumably tell the listeners that they should remote and "unremote" its client interface).


Nested Class Summary
static class AgentService.LifecycleState
          The different states agent services can be in.
 
Constructor Summary
protected AgentService(Class clientInterface)
          Creates a new AgentService object.
 
Method Summary
 void addLifecycleListener(AgentServiceLifecycleListener listener)
          Adds the given listener to the list of listeners that will be notified when this agent service changes its state (i.e.
 Class getClientInterface()
          Returns the interface that this agent service wants to be made remotely accessible to external clients.
 void notifyLifecycleListenersOfNewState(AgentService.LifecycleState newState)
          This is called when the agent service changes its state - it will notify all listeners of the changed state.
protected  InputStream remoteInputStream(InputStream inputStream)
          Given any input stream, this will attempt to remote it using the stream remoter, thus providing access to external clients.
protected  OutputStream remoteOutputStream(OutputStream outputStream)
          Given any output stream, this will attempt to remote it using the stream remoter, thus providing access to external clients.
 void removeLifecycleListener(AgentServiceLifecycleListener listener)
          Removes the given listener so it is no longer notified of changed states.
 void setAgentServiceStreamRemoter(AgentServiceStreamRemoter remoter)
          Sets the remoter object that is responsible for remoting streams.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgentService

protected AgentService(Class clientInterface)
Creates a new AgentService object.

Parameters:
clientInterface - the client interface that this agent service wants to make remotely accessible to external clients
Method Detail

notifyLifecycleListenersOfNewState

public void notifyLifecycleListenersOfNewState(AgentService.LifecycleState newState)
This is called when the agent service changes its state - it will notify all listeners of the changed state.

Parameters:
newState -

remoteInputStream

protected InputStream remoteInputStream(InputStream inputStream)
Given any input stream, this will attempt to remote it using the stream remoter, thus providing access to external clients. If there is no remoter available, the same input stream instance passed into this method is returned as-is.

If inputStream is null, null is returned.

Parameters:
inputStream - the input stream to remote
Returns:
the input stream possibly wrapped in a remote proxy to enable it for remote access.

remoteOutputStream

protected OutputStream remoteOutputStream(OutputStream outputStream)
Given any output stream, this will attempt to remote it using the stream remoter, thus providing access to external clients. If there is no remoter available, the same output stream instance passed into this method is returned as-is.

If outputStream is null, null is returned.

Parameters:
outputStream - the output stream to remote
Returns:
the output stream possibly wrapped in a remote proxy to enable it for remote access.

addLifecycleListener

public void addLifecycleListener(AgentServiceLifecycleListener listener)
Adds the given listener to the list of listeners that will be notified when this agent service changes its state (i.e. is started or stopped).

Parameters:
listener -

removeLifecycleListener

public void removeLifecycleListener(AgentServiceLifecycleListener listener)
Removes the given listener so it is no longer notified of changed states.

Parameters:
listener -

setAgentServiceStreamRemoter

public void setAgentServiceStreamRemoter(AgentServiceStreamRemoter remoter)
Sets the remoter object that is responsible for remoting streams. If null, the agent service will not be able to remote streams to external clients, as in the case when the plugin container is not running inside an agent (i.e. embedded mode).

Parameters:
remoter -

getClientInterface

public Class getClientInterface()
Returns the interface that this agent service wants to be made remotely accessible to external clients. In other words, this is the interface the agent will expose as the service's remote POJO interface.

Returns:
the interface that should be remoted so external clients can access it


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