SNMP Stack 4_12

uk.co.westhawk.snmp.beans
Class SNMPBean

java.lang.Object
  |
  +--uk.co.westhawk.snmp.beans.SNMPBean
Direct Known Subclasses:
IsHostReachableBean, NcdPerfDataBean, SNMPRunBean

public abstract class SNMPBean
extends java.lang.Object

This bean forms the base of the SNMP beans.

The bean will only come into action when the method action() is called. This should be done after the properties have been set.

This bean also provide the methods for adding and removing property change listeners and firing property change events.

Version:
$Revision: 1.8 $ $Date: 2002/11/04 17:56:21 $
Author:
Birgit Arkesteijn
See Also:
SNMPRunBean, IsHostReachableBean, OneInterfaceBean, InterfaceIndexesBean

Field Summary
protected  java.lang.String community
           
protected  SnmpContext context
           
protected  java.lang.String host
           
protected  java.lang.String message
           
protected  int port
           
protected  java.util.Vector propertyChangeListener
           
 
Constructor Summary
SNMPBean()
          The default constructor.
SNMPBean(java.lang.String h, int p)
          The constructor that will set the host and the port no.
 
Method Summary
abstract  void action()
          This method should send the SNMP request.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a property change listener.
protected  void firePropertyChange(java.lang.String property, java.lang.Object old_v, java.lang.Object new_v)
          Fire the property event.
 java.lang.String getCommunityName()
          Returns the community name that is used to send the SNMP request.
 java.lang.String getHost()
          Returns the host (name or ipadress) which is addressed.
 java.lang.String getMessage()
          Returns the message (if any).
 int getPort()
          Returns the port no which is used.
protected  boolean isHostPortReachable()
          Indicates whether the host is reachable.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a property change listener.
 void setCommunityName(java.lang.String c)
          Sets the community name that is used to send the SNMP request.
 void setHost(java.lang.String h)
          Sets the host (name or ipadress) which will be asked for the SNMP request.
protected  void setMessage(java.lang.String st)
          Returns the message (if any).
 void setPort(int p)
          Sets the port no which is used.
 void setPort(java.lang.String p)
          Sets the port no which is used as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected SnmpContext context

host

protected java.lang.String host

port

protected int port

community

protected java.lang.String community

message

protected java.lang.String message

propertyChangeListener

protected java.util.Vector propertyChangeListener
Constructor Detail

SNMPBean

public SNMPBean()
The default constructor.

SNMPBean

public SNMPBean(java.lang.String h,
                int p)
The constructor that will set the host and the port no.
Parameters:
h - the hostname
p - the port no
See Also:
setHost(java.lang.String), setPort(int)
Method Detail

action

public abstract void action()
                     throws PduException,
                            java.io.IOException
This method should send the SNMP request. All properties should be set before this method is called.

getHost

public java.lang.String getHost()
Returns the host (name or ipadress) which is addressed. This is the host where the SNMP server is running.
Returns:
the name of the host
See Also:
setHost(java.lang.String)

setHost

public void setHost(java.lang.String h)
Sets the host (name or ipadress) which will be asked for the SNMP request. This is the host where the SNMP server is running. The default is localhost. This bean will only start the request when action is called.
See Also:
getHost()

getPort

public int getPort()
Returns the port no which is used. That is the no of the port on the host where the SNMP server is running.
See Also:
setPort(int), setPort(String)

setPort

public void setPort(int p)
Sets the port no which is used. That should be the no of the port on the host where the SNMP server is running. The default is 161. This bean will only start the request when action is called.
Parameters:
p - The number of the port
See Also:
getPort(), setPort(String)

setPort

public void setPort(java.lang.String p)
Sets the port no which is used as a String.
Parameters:
p - The number of the port as a String
See Also:
getPort(), setPort(int)

getCommunityName

public java.lang.String getCommunityName()
Returns the community name that is used to send the SNMP request.
See Also:
setCommunityName(java.lang.String)

setCommunityName

public void setCommunityName(java.lang.String c)
Sets the community name that is used to send the SNMP request. The default is public.
See Also:
getCommunityName()

isHostPortReachable

protected boolean isHostPortReachable()
Indicates whether the host is reachable. This method will try to make a new SnmpContext, if this works, it is reachable. If it does not work, the message will be set.
See Also:
SnmpContext

getMessage

public java.lang.String getMessage()
Returns the message (if any). The message is used to give the user feedback if anything is happened with the request or the connection.
Returns:
the message

setMessage

protected void setMessage(java.lang.String st)
Returns the message (if any). The message is used to give the user feedback if anything is happened (usualy when something went wrong) with the connection.
Parameters:
st - the message string
See Also:
getMessage()

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a property change listener.
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a property change listener.
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener)

firePropertyChange

protected void firePropertyChange(java.lang.String property,
                                  java.lang.Object old_v,
                                  java.lang.Object new_v)
Fire the property event.
See Also:
removePropertyChangeListener(java.beans.PropertyChangeListener), addPropertyChangeListener(java.beans.PropertyChangeListener), PropertyChangeEvent, PropertyChangeListener

SNMP Stack 4_12