MySnmpCrawler API

snmp.session
Class SnmpSession

java.lang.Object
  |
  +--snmp.session.SnmpSession
All Implemented Interfaces:
java.lang.Runnable

public class SnmpSession
extends java.lang.Object
implements java.lang.Runnable

The SnmpSession is the runnable object created by the SnmpAdaptor when the server receives the request. The SnmpSession encapsulates the information of the SNMP request. The SnmpSession will notify the listeners about the new session. The listeners will take appropriate actions to fulfill the different types of requests.

Version:
$Revision: 0.1 $ $Date: 2004/03/09 06:03:54 $
Author:
Scott Cheng

Field Summary
private  java.net.DatagramPacket packet
           
private static java.util.ArrayList sessionEventListeners
           
private  SnmpMessage snmpMessage
           
private  java.net.DatagramSocket socket
           
 
Constructor Summary
SnmpSession(java.net.DatagramSocket socket, java.net.DatagramPacket packet)
          Constructs the new SnmpSession object for the SNMP request.
 
Method Summary
private static void addSessionListener(SnmpSessionEventListener listener)
          Adds the listener to the listener list.
protected  void doRun()
          This method defines the routines to process the SNMP session.
 SnmpMessage getSnmpMessage()
          Gets the snmpMessage that encapsulates the SNMP request header and PDU.
private  void notifyListeners()
          Notify all listeners that a new session has been created.
protected  void processSession()
          This method contains the necessary routines to process the current SNMP session.
 void run()
          Invoked by the available thread to execute the doRun() method.
 void send()
          Sends the encapsulated snmpMessage back to the requesting manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sessionEventListeners

private static java.util.ArrayList sessionEventListeners

socket

private java.net.DatagramSocket socket

packet

private java.net.DatagramPacket packet

snmpMessage

private SnmpMessage snmpMessage
Constructor Detail

SnmpSession

public SnmpSession(java.net.DatagramSocket socket,
                   java.net.DatagramPacket packet)
            throws SnmpException
Constructs the new SnmpSession object for the SNMP request.

Parameters:
socket - The socket of the SNMP agent
packet - The received SNMP data packet
Throws:
SnmpException - thrown when any exception occurs during the object initialization
Method Detail

run

public void run()
Invoked by the available thread to execute the doRun() method.

Specified by:
run in interface java.lang.Runnable

getSnmpMessage

public SnmpMessage getSnmpMessage()
Gets the snmpMessage that encapsulates the SNMP request header and PDU.

Returns:
snmpMessage

send

public void send()
          throws SnmpException
Sends the encapsulated snmpMessage back to the requesting manager.

SnmpException

doRun

protected void doRun()
This method defines the routines to process the SNMP session.


processSession

protected void processSession()
                       throws SnmpException
This method contains the necessary routines to process the current SNMP session. It firstly creates the SnmpMessage and then notifiese listeners about the newly created session for further processing.

Throws:
SnmpException - thrown when any exception occurs

notifyListeners

private void notifyListeners()
Notify all listeners that a new session has been created.


addSessionListener

private static void addSessionListener(SnmpSessionEventListener listener)
Adds the listener to the listener list.


MySnmpCrawler API