SNMP Stack 4_12

uk.co.westhawk.snmp.beans
Class IsHostReachableBean

java.lang.Object
  |
  +--uk.co.westhawk.snmp.beans.SNMPBean
        |
        +--uk.co.westhawk.snmp.beans.IsHostReachableBean
All Implemented Interfaces:
java.util.Observer

public class IsHostReachableBean
extends SNMPBean
implements java.util.Observer

This bean will determine whether the host+port is up, by sending an UpSincePdu.

The properties in the parent classes should be set, before calling the action() method. Via a PropertyChangeEvent the application/applet will be notified.

Version:
$Revision: 1.9 $ $Date: 2002/10/10 15:13:56 $
Author:
Birgit Arkesteijn
See Also:
SNMPBean.setHost(java.lang.String), SNMPBean.setPort(int), SNMPBean.setCommunityName(java.lang.String), SNMPBean.addPropertyChangeListener(java.beans.PropertyChangeListener), SNMPBean.action(), UpSincePdu

Fields inherited from class uk.co.westhawk.snmp.beans.SNMPBean
community, context, host, message, port, propertyChangeListener
 
Constructor Summary
IsHostReachableBean()
          The default constructor.
IsHostReachableBean(java.lang.String h, int p)
          The constructor that will set the host and the port no.
 
Method Summary
 void action()
          This method actually performs the request.
protected  void action(boolean wait)
           
 java.util.Date getUpSinceDate()
          Returns the date when the host went up.
 boolean isReachable()
          Indicates whether the host + port is reachable.
protected  void setReachable(boolean b)
          The reachable property is set according to the succes of making a connection and the response of the SNMP request.
protected  void setUpSinceDate(java.util.Date d)
          Answer is set according to the received SNMP response.
 void update(java.util.Observable obs, java.lang.Object ov)
          The update method according to the Observer interface, it will be called when the Pdu response is received.
 void waitForSelfAction()
          This method performs the request and wait for it.
 
Methods inherited from class uk.co.westhawk.snmp.beans.SNMPBean
addPropertyChangeListener, firePropertyChange, getCommunityName, getHost, getMessage, getPort, isHostPortReachable, removePropertyChangeListener, setCommunityName, setHost, setMessage, setPort, setPort
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IsHostReachableBean

public IsHostReachableBean()
The default constructor.

IsHostReachableBean

public IsHostReachableBean(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:
SNMPBean.setHost(java.lang.String), SNMPBean.setPort(int)
Method Detail

getUpSinceDate

public java.util.Date getUpSinceDate()
Returns the date when the host went up. This might be null is no answer is received yet.
Returns:
the date
See Also:
SNMPBean.getMessage(), isReachable()

setUpSinceDate

protected void setUpSinceDate(java.util.Date d)
Answer is set according to the received SNMP response.
See Also:
getUpSinceDate()

isReachable

public boolean isReachable()
Indicates whether the host + port is reachable. The host + port is reachable if a valid response is received from a UpSincePdu request.
Returns:
is the host + port + community name valid
See Also:
SNMPBean.getMessage(), getUpSinceDate()

setReachable

protected void setReachable(boolean b)
The reachable property is set according to the succes of making a connection and the response of the SNMP request. This method will fire a Property Change Event.
See Also:
isReachable(), SNMPBean.addPropertyChangeListener(java.beans.PropertyChangeListener)

waitForSelfAction

public void waitForSelfAction()
                       throws PduException,
                              java.io.IOException
This method performs the request and wait for it. It is not recommended to use the waitForSelf option, preferred is the action() method. Use it if it is really necessary to wait.
See Also:
SnmpContext, action(), Pdu.waitForSelf()

action

public void action()
            throws PduException,
                   java.io.IOException
This method actually performs the request. All properties should be set before this method is called. This will create a new SnmpContext and send a UpSincePdu SNMP request. If the connection fails, the reachable property will be set to false.
Overrides:
action in class SNMPBean
See Also:
SnmpContext

action

protected void action(boolean wait)
               throws PduException,
                      java.io.IOException

update

public void update(java.util.Observable obs,
                   java.lang.Object ov)
The update method according to the Observer interface, it will be called when the Pdu response is received. If there is no error it means that the host is reachable. If it is not reachable the message will contain the type of error, if it is reachable the message will say since when the host is up.
Specified by:
update in interface java.util.Observer

SNMP Stack 4_12