com.adventnet.adaptors.clients
Class AbstractClient

java.lang.Object
  |
  +--com.adventnet.adaptors.clients.AbstractClient
Direct Known Subclasses:
AbstractJMXConnector, CorbaClient, HttpClient, RMIClient

public abstract class AbstractClient
extends java.lang.Object
implements Client, AsyncClient

This Abstract class must be extended by All Adaptor Clients This class abstracts the common behaviour of Adaptor Clients such as RMI,IIOP and HTTP

Since:
Adaptor Framework 2.8
See Also:
Client

Inner Class Summary
(package private)  class AbstractClient.HeartBeatDiagnoser
          This Active class checks to see if an event needs to be send and then invokes the heartBeat generator
 
Field Summary
protected  java.lang.Object adaptorInfo
           
protected  java.util.Properties clientProp
           
(package private)  AbstractClient.HeartBeatDiagnoser heartBeatDiagnoser
           
(package private)  boolean heartBeatEnabled
           
protected  int heartBeatRate
           
protected  java.lang.String host
           
protected  boolean isSubAgentAlive
           
protected  java.util.ArrayList listeners
           
protected  int port
           
 
Constructor Summary
AbstractClient()
           
 
Method Summary
 void addHeartBeatListener(HeartBeatListener heartBeatListener)
          This method is used to add a heart beat listener
 java.lang.Object asyncGetAttribute(ObjectName name, java.lang.String attribute)
          Gets the value of a specific attribute of a named MBean.
 java.lang.Object asyncGetAttributes(ObjectName name, java.lang.String[] attributes)
          Gets the values of several attributes of a named MBean.
 java.lang.Object asyncInvoke(ObjectName name, java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)
          Dummy implementation of AsyncClient interface, subclasses can override to provide their own implementations
 java.lang.Object asyncSetAttributes(ObjectName name, AttributeList attributes)
          Sets the values of several attributes of a named MBean.
 void authenticate(com.adventnet.agent.security.UserContext userContext)
          Dummy implementation for Authentication will do nothing, subclasses can override to provide their own implementations
abstract  void connect(java.lang.String host, int port, java.lang.Object adaptorInfo)
          This method is used to connect to the adaptor
abstract  void disconnect()
          This method disconnects the client from the adaptor
 void enableHeartBeat(boolean enable)
          This method is used to enableHeartBeat mechanism
 int getHeartBeatRate()
          This method returns the heart beat rate
 boolean isAuthenticationEnabled()
          Dummy implementation to check if Authentication is enabled will return false, subclasses can override to provide their own implementations
abstract  java.lang.Boolean isConnectedWithAdaptor()
          This method returns true if the client is connected with the adaptor
 boolean isHeartBeatEnabled()
          This method returns true if the heartBeat is already enabled
 void removeHeartBeatListener(HeartBeatListener heartBeatListener)
          This method is used to remove a heart beat listener
protected abstract  void sendHeartBeatEvent()
          This abstract method is the Heart Beat Event Generator
 void setHeartBeatRate(int heartBeatRate)
          This method sets the heart beat rate
 void setProperty(java.lang.String key, java.lang.String value)
          Method to set additional properties required by client
 void startHeartBeat()
          This method starts the heartbeat mechanism
 void stopHeartBeat()
          This method stops the heartbeat mechanism
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

heartBeatEnabled

boolean heartBeatEnabled

heartBeatRate

protected int heartBeatRate

listeners

protected java.util.ArrayList listeners

heartBeatDiagnoser

AbstractClient.HeartBeatDiagnoser heartBeatDiagnoser

isSubAgentAlive

protected boolean isSubAgentAlive

host

protected java.lang.String host

port

protected int port

adaptorInfo

protected java.lang.Object adaptorInfo

clientProp

protected java.util.Properties clientProp
Constructor Detail

AbstractClient

public AbstractClient()
Method Detail

connect

public abstract void connect(java.lang.String host,
                             int port,
                             java.lang.Object adaptorInfo)
                      throws java.net.ConnectException
This method is used to connect to the adaptor
Specified by:
connect in interface Client
Throws:
java.net.ConnectException - if the client could not connect to the adaptor

disconnect

public abstract void disconnect()
This method disconnects the client from the adaptor
Specified by:
disconnect in interface Client

isConnectedWithAdaptor

public abstract java.lang.Boolean isConnectedWithAdaptor()
                                                  throws java.net.NoRouteToHostException
This method returns true if the client is connected with the adaptor
Specified by:
isConnectedWithAdaptor in interface Client

startHeartBeat

public void startHeartBeat()
This method starts the heartbeat mechanism

stopHeartBeat

public void stopHeartBeat()
This method stops the heartbeat mechanism
Specified by:
stopHeartBeat in interface Client

enableHeartBeat

public void enableHeartBeat(boolean enable)
This method is used to enableHeartBeat mechanism
Specified by:
enableHeartBeat in interface Client
Tags copied from interface: Client
Parameters:
flag - true to enable the heartbeat

isHeartBeatEnabled

public boolean isHeartBeatEnabled()
This method returns true if the heartBeat is already enabled
Specified by:
isHeartBeatEnabled in interface Client

getHeartBeatRate

public int getHeartBeatRate()
This method returns the heart beat rate
Specified by:
getHeartBeatRate in interface Client

setHeartBeatRate

public void setHeartBeatRate(int heartBeatRate)
This method sets the heart beat rate
Specified by:
setHeartBeatRate in interface Client
Tags copied from interface: Client
Parameters:
rate - the heart beat rate time interval at the connector client Default is 2000 msec i.e 2 seconds

addHeartBeatListener

public void addHeartBeatListener(HeartBeatListener heartBeatListener)
This method is used to add a heart beat listener
Specified by:
addHeartBeatListener in interface Client
Tags copied from interface: Client
Parameters:
listener - the heartbeat listener

removeHeartBeatListener

public void removeHeartBeatListener(HeartBeatListener heartBeatListener)
This method is used to remove a heart beat listener
Specified by:
removeHeartBeatListener in interface Client
Tags copied from interface: Client
Parameters:
listener - the heartbeat listener

sendHeartBeatEvent

protected abstract void sendHeartBeatEvent()
This abstract method is the Heart Beat Event Generator

isAuthenticationEnabled

public boolean isAuthenticationEnabled()
Dummy implementation to check if Authentication is enabled will return false, subclasses can override to provide their own implementations
Specified by:
isAuthenticationEnabled in interface Client

authenticate

public void authenticate(com.adventnet.agent.security.UserContext userContext)
                  throws com.adventnet.agent.security.AuthenticationException
Dummy implementation for Authentication will do nothing, subclasses can override to provide their own implementations
Specified by:
authenticate in interface Client

asyncInvoke

public java.lang.Object asyncInvoke(ObjectName name,
                                    java.lang.String actionName,
                                    java.lang.Object[] params,
                                    java.lang.String[] signature)
                             throws java.lang.Exception
Dummy implementation of AsyncClient interface, subclasses can override to provide their own implementations
Specified by:
asyncInvoke in interface AsyncClient
Tags copied from interface: AsyncClient
Parameters:
name - - The object name of the MBean on which the method is to be invoked.
actionName - - The name of the operation to be invoked.
params - - An array containing the parameters to be set when the operation is invoked
signature - - An array containing the signature of the operation. The class objects will be loaded using the same class loader as the one used for loading the MBean on which the operation was invoked.
Returns:
- returns an Object that contains information to correlate this request with the response sent by the agent and received elsewhere

asyncGetAttribute

public java.lang.Object asyncGetAttribute(ObjectName name,
                                          java.lang.String attribute)
                                   throws java.lang.Exception
Description copied from interface: AsyncClient
Gets the value of a specific attribute of a named MBean. The MBean is identified by its object name.
Specified by:
asyncGetAttribute in interface AsyncClient
Tags copied from interface: AsyncClient
Parameters:
name - - The object name of the MBean from which the attribute is to be retrieved.
attribute - - A String specifying the name of the attribute to be retrieved.
Returns:
- returns an Object that contains information to correlate this request with the response sent by the agent and received elsewhere

asyncGetAttributes

public java.lang.Object asyncGetAttributes(ObjectName name,
                                           java.lang.String[] attributes)
                                    throws java.lang.Exception
Description copied from interface: AsyncClient
Gets the values of several attributes of a named MBean. The MBean is identified by its object name.
Specified by:
asyncGetAttributes in interface AsyncClient
Tags copied from interface: AsyncClient
Parameters:
name - - The object name of the MBean from which the attributes are retrieved.
attributes - - A list of the attributes to be retrieved.
Returns:
- returns an Object that contains information to correlate this request with the response sent by the agent and received elsewhere

asyncSetAttributes

public java.lang.Object asyncSetAttributes(ObjectName name,
                                           AttributeList attributes)
                                    throws java.lang.Exception
Description copied from interface: AsyncClient
Sets the values of several attributes of a named MBean. The MBean is identified by its object name.
Specified by:
asyncSetAttributes in interface AsyncClient
Tags copied from interface: AsyncClient
Parameters:
name - - The object name of the MBean within which the attributes are to be set.
attributes - - A list of attributes: The identification of the attributes to be set and the values they are to be set to.
Returns:
- returns an Object that contains information to correlate this request with the response sent by the agent and received elsewhere

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
Description copied from interface: Client
Method to set additional properties required by client
Specified by:
setProperty in interface Client
Tags copied from interface: Client
Parameters:
propName - key for the property
propValue - value of the property