com.adventnet.adaptors
Class AbstractAdaptor

java.lang.Object
  |
  +--com.adventnet.adaptors.AbstractAdaptor
Direct Known Subclasses:
CorbaAdaptor, HtmlAdaptor, HttpConnector, RMIAdaptor, SnmpAdaptor, TL1Adaptor

public abstract class AbstractAdaptor
extends java.lang.Object
implements Adaptor, MBeanRegistration, NotificationBroadcaster, java.io.Serializable

This abstract class abstracts the common behaviour of all Adaptors. All Protocol Adaptors must extend this class .

Since:
Adaptor Framework Version 2.0
See Also:
com.adventnet.adaptor.Adaptor, com.adventnet.adaptor.Protocol, Serialized Form

Inner Class Summary
 class AbstractAdaptor.ProcessNotification
           
 
Field Summary
(package private) static boolean handleNotificationinNewThread
           
protected  java.util.Hashtable notifications
           
protected  int port
           
protected  AbstractAdaptor.ProcessNotification processnotification
           
protected  int state
           
 
Constructor Summary
AbstractAdaptor()
           
 
Method Summary
 void addNotificationListener(NotificationListener listener, NotificationFilter filter, java.lang.Object handback)
          This method can be used to Add a Notification Listener for this Adaptor
protected abstract  void bind()
          Must be used to bind to a naming service or to bind to a ServerSocket
 void changeState(int i)
          This method changes the state of the adaptor
protected abstract  void destroyAdaptor()
          Kills the adaptor and releases all its resources
abstract  void enableAuthentication(boolean flag)
          This abstract method needs to be implemented by the Adaptor for providing Authentication
abstract  void enableAuthorisation(boolean flag)
          This abstract method needs to be implemented by the Adaptor for providing Authorisation
abstract  ObjectName getAdaptorObjectName()
          Returns the adaptor object name
 java.lang.String getAdaptorVersion()
          Returns the adaptor version implemented by this Adaptor
 java.lang.String getHost()
          This method returns the host on which the adaptor resides
 MBeanNotificationInfo[] getNotificationInfo()
          This method returns the NotificationInfo
 int getPort()
          This method returns the port on which the adaptor listens
abstract  java.lang.String getProtocol()
          This abstract method returns the Protocol on which the adaptor is listening
 int getState()
          This method returns the state of the adaptor
 java.lang.String getStateInString()
          This method returns the state of the adaptor in string format
 void handleNotification(Notification notification, java.lang.Object handback)
          This method redirects notification to the processNotification method if handleNotificationinNewThread is set to true.
protected abstract  void instantiateAdaptor()
          Must be implemented by the adaptor and should be used to instantiate itsefl
 boolean isActive()
          This method returns true if the Adaptor is in STARTING or STARTED state
 boolean isSecure()
          Default returns false .
 void postDeregister()
          This method must be implemented by the Adaptor if it wants to perform any Post Deregistration tasks
 void postRegister(java.lang.Boolean registrationDone)
          This method must be overridden by the Adaptor if the Adaptor wants to perform any Post Registration tasks
 void preDeregister()
          This method must be overridden by the Adaptor if it wants to perform any Pre Deregistration tasks
 ObjectName preRegister(MBeanServer mbeanServer, ObjectName objectName)
          This method must be overriden by the Adaptor if the Adaptor wants to perform any Pre registration tasks
protected  void processNotification(Notification notification, java.lang.Object handback)
          Needs to overriden by the Adaptor implementation.
 void removeNotificationListener(NotificationListener listener)
          This method removes the Notification Listeners
 void setPort(int port)
          This method sets the port on which this adaptor is listening
 void startService()
          This method starts the Adaptor service
 void stopService()
          This method stops the Adaptor
protected abstract  void unbind()
          Must be used to unbind from a naming service or to relese a ServerSocket
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

port

protected int port

state

protected int state

processnotification

protected AbstractAdaptor.ProcessNotification processnotification

notifications

protected java.util.Hashtable notifications

handleNotificationinNewThread

static boolean handleNotificationinNewThread
Constructor Detail

AbstractAdaptor

public AbstractAdaptor()
Method Detail

getHost

public java.lang.String getHost()
This method returns the host on which the adaptor resides
Specified by:
getHost in interface Adaptor

getPort

public int getPort()
This method returns the port on which the adaptor listens
Specified by:
getPort in interface Adaptor

getProtocol

public abstract java.lang.String getProtocol()
This abstract method returns the Protocol on which the adaptor is listening
Specified by:
getProtocol in interface Adaptor

getState

public int getState()
This method returns the state of the adaptor
Specified by:
getState in interface Adaptor

getStateInString

public java.lang.String getStateInString()
This method returns the state of the adaptor in string format
Specified by:
getStateInString in interface Adaptor

setPort

public void setPort(int port)
             throws java.lang.IllegalStateException
This method sets the port on which this adaptor is listening
Specified by:
setPort in interface Adaptor
Throws:
java.lang.IllegalStateException - if the adaptor is STARTING or STARTED

isActive

public boolean isActive()
This method returns true if the Adaptor is in STARTING or STARTED state
Specified by:
isActive in interface Adaptor

isSecure

public boolean isSecure()
Default returns false . Needs to overriden by the Adaptor implementation
Specified by:
isSecure in interface Adaptor

enableAuthorisation

public abstract void enableAuthorisation(boolean flag)
                                  throws java.lang.UnsupportedOperationException
This abstract method needs to be implemented by the Adaptor for providing Authorisation
Specified by:
enableAuthorisation in interface Adaptor
Throws:
java.lang.UnsupportedOperationException - when authorisation is not suppported

enableAuthentication

public abstract void enableAuthentication(boolean flag)
                                   throws java.lang.UnsupportedOperationException
This abstract method needs to be implemented by the Adaptor for providing Authentication
Specified by:
enableAuthentication in interface Adaptor
Throws:
java.lang.UnsupportedOperationException - when authentication is not supported

startService

public void startService()
                  throws java.lang.IllegalStateException,
                         java.lang.Exception
This method starts the Adaptor service
Specified by:
startService in interface Adaptor
Throws:
java.lang.IllegalStateException - when the adaptor is in STARTED or STARTING state

stopService

public void stopService()
                 throws java.lang.IllegalStateException
This method stops the Adaptor
Specified by:
stopService in interface Adaptor
Throws:
java.lang.IllegalStateException - when the adaptor is in STOPPED or STOPPING state

instantiateAdaptor

protected abstract void instantiateAdaptor()
                                    throws java.lang.InstantiationException
Must be implemented by the adaptor and should be used to instantiate itsefl

bind

protected abstract void bind()
Must be used to bind to a naming service or to bind to a ServerSocket

unbind

protected abstract void unbind()
Must be used to unbind from a naming service or to relese a ServerSocket

destroyAdaptor

protected abstract void destroyAdaptor()
Kills the adaptor and releases all its resources

getAdaptorVersion

public java.lang.String getAdaptorVersion()
Returns the adaptor version implemented by this Adaptor
Specified by:
getAdaptorVersion in interface Adaptor

getAdaptorObjectName

public abstract ObjectName getAdaptorObjectName()
Returns the adaptor object name
Specified by:
getAdaptorObjectName in interface Adaptor

addNotificationListener

public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    java.lang.Object handback)
                             throws java.lang.IllegalArgumentException
This method can be used to Add a Notification Listener for this Adaptor
Specified by:
addNotificationListener in interface NotificationBroadcaster
Tags copied from interface: NotificationBroadcaster
Parameters:
listener - The listener object which will handle the notifications emitted by the broadcaster.
filter - The filter object. If filter is null, no filtering will be performed before handling notifications.
handback - An opaque object to be sent back to the listener when a notification is emitted. This object cannot be used by the Notification broadcaster object. It should be resent unchanged with the notification to the listener.
Throws:
java.lang.IllegalArgumentException - Listener parameter is null.
See Also:
NotificationBroadcaster.removeNotificationListener(javax.management.NotificationListener)

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()
This method returns the NotificationInfo
Specified by:
getNotificationInfo in interface NotificationBroadcaster
Tags copied from interface: NotificationBroadcaster
Returns:
the array of possible notifications.

removeNotificationListener

public void removeNotificationListener(NotificationListener listener)
                                throws ListenerNotFoundException
This method removes the Notification Listeners
Specified by:
removeNotificationListener in interface NotificationBroadcaster
Tags copied from interface: NotificationBroadcaster
Parameters:
listener - A listener that was previously added to this MBean
Throws:
ListenerNotFoundException - The listener is not registered with the MBean.
See Also:
NotificationBroadcaster.addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object), NotificationEmitter.removeNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)

changeState

public void changeState(int i)
This method changes the state of the adaptor

processNotification

protected void processNotification(Notification notification,
                                   java.lang.Object handback)
Needs to overriden by the Adaptor implementation. This should be implemented by the adaptor classes to process the notifications.
This method should process the notification received by the adaptor

handleNotification

public final void handleNotification(Notification notification,
                                     java.lang.Object handback)
This method redirects notification to the processNotification method if handleNotificationinNewThread is set to true.
If it is set to false then it is processed in the same thread

preRegister

public ObjectName preRegister(MBeanServer mbeanServer,
                              ObjectName objectName)
                       throws java.lang.Exception
This method must be overriden by the Adaptor if the Adaptor wants to perform any Pre registration tasks
Specified by:
preRegister in interface MBeanRegistration
Tags copied from interface: MBeanRegistration
Parameters:
server - The MBean server in which the MBean will be registered.
name - The object name of the MBean. This name is null if the name parameter to one of the createMBean or registerMBean methods in the MBeanServer interface is null. In that case, this method must return a non-null ObjectName for the new MBean.
Returns:
The name under which the MBean is to be registered. This value must not be null. If the name parameter is not null, it will usually but not necessarily be the returned value.
Throws:
java.lang.Exception - This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException or a RuntimeMBeanException.

postRegister

public void postRegister(java.lang.Boolean registrationDone)
This method must be overridden by the Adaptor if the Adaptor wants to perform any Post Registration tasks
Specified by:
postRegister in interface MBeanRegistration
Tags copied from interface: MBeanRegistration
Parameters:
registrationDone - Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration phase has failed.

preDeregister

public void preDeregister()
                   throws java.lang.Exception
This method must be overridden by the Adaptor if it wants to perform any Pre Deregistration tasks
Specified by:
preDeregister in interface MBeanRegistration
Tags copied from interface: MBeanRegistration
Throws:
java.lang.Exception - This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException or a RuntimeMBeanException.

postDeregister

public void postDeregister()
This method must be implemented by the Adaptor if it wants to perform any Post Deregistration tasks
Specified by:
postDeregister in interface MBeanRegistration