Overview | Package | Class | Tree | Deprecated | Index | Help
| SNMP Stack 5_1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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.14 $ $Date: 2006/01/26 12:38:59 $
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`

Field Summary

Fields inherited from class uk.co.westhawk.snmp.beans.SNMPBean
`bindAddr, community, context, host, message, port, propertyChangeListener, socketType`

Constructor Summary
`IsHostReachableBean()` The default constructor.
`IsHostReachableBean(java.lang.String h, int p)` The constructor that will set the host and the port no.
`IsHostReachableBean(java.lang.String h, int p, java.lang.String b)` The constructor that will set the host, the port no and the local bind address.

Method Summary
`void` | `action()` This method actually performs the request.
`protected void` | `action(boolean wait)`
`void` | `freeResources()` Destroys the context.
`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, getBindAddress, getCommunityName, getHost, getMessage, getPort, getSocketType, isHostPortReachable, removePropertyChangeListener, setBindAddress, setCommunityName, setHost, setMessage, setPort, setPort, setSocketType`

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

### IsHostReachableBean

    public IsHostReachableBean(java.lang.String h,
                               int p,
                               java.lang.String b)

  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
Since:
  4_14
See Also:
  `SNMPBean.setHost(java.lang.String)`, `SNMPBean.setPort(int)`, `SNMPBean.setBindAddress(java.lang.String)`

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.

    `PduException`
    `java.io.IOException`
  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.

  Specified by:
    `action` in class `SNMPBean`
    `PduException`
    `java.io.IOException`
  See Also:
    `SnmpContext`

### action

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

    `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`

### freeResources

    public void freeResources()

  Destroys the context.

  Since:
    4_14

Overview | Package | Class | Tree | Deprecated | Index | Help
| SNMP Stack 5_1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD