SNMP Stack 5_1

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.12 $ $Date: 2006/01/26 12:38:30 $
Author:
Birgit Arkesteijn
See Also:
SNMPRunBean, IsHostReachableBean, OneInterfaceBean, InterfaceIndexesBean

Field Summary
protected  java.lang.String bindAddr
           
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
           
protected  java.lang.String socketType
           
 
Constructor Summary
SNMPBean()
          The default constructor.
SNMPBean(java.lang.String h, int p)
          The constructor that will set the host and the port no.
SNMPBean(java.lang.String h, int p, java.lang.String b, java.lang.String t)
          The constructor that will set the host, the port no and the local bind address.
 
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 getBindAddress()
          Returns the local bind address.
 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.
 java.lang.String getSocketType()
          Returns the socket type.
protected  boolean isHostPortReachable()
          Indicates whether the host is reachable.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a property change listener.
 void setBindAddress(java.lang.String b)
          Sets the local bind address.
 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.
 void setSocketType(java.lang.String t)
          Sets socket type.
 
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

bindAddr

protected java.lang.String bindAddr

port

protected int port

community

protected java.lang.String community

socketType

protected java.lang.String socketType

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)

SNMPBean

public SNMPBean(java.lang.String h,
                int p,
                java.lang.String b,
                java.lang.String t)
The constructor that will set the host, the port no and the local bind address.

Parameters:
h - the hostname
p - the port no
b - the local bind address
t - the socket type
Since:
4_14
See Also:
setHost(java.lang.String), setPort(int), setBindAddress(java.lang.String), setSocketType(java.lang.String)
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.

PduException
java.io.IOException

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()

getBindAddress

public java.lang.String getBindAddress()
Returns the local bind address.

Returns:
the name of the local bind address
Since:
4_14
See Also:
setBindAddress(java.lang.String)

setBindAddress

public void setBindAddress(java.lang.String b)
Sets the local bind address. The default is null. This bean will only start the request when action is called.

Since:
4_14
See Also:
getBindAddress()

getSocketType

public java.lang.String getSocketType()
Returns the socket type.

Returns:
the socket type.
Since:
4_14
See Also:
setSocketType(java.lang.String)

setSocketType

public void setSocketType(java.lang.String t)
Sets socket type. The default is null. This bean will only start the request when action is called.

Since:
4_14
See Also:
getSocketType(), SnmpContextBasisFace.STANDARD_SOCKET

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 (usually 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 5_1