org.snmp4j.agent.request
Class SnmpRequest

java.lang.Object
  extended by org.snmp4j.agent.request.AbstractRequest
      extended by org.snmp4j.agent.request.SnmpRequest
All Implemented Interfaces:
Request

public class SnmpRequest
extends AbstractRequest

The SnmpRequest class implements requests from a SNMP source.

Version:
1.2
Author:
Frank Fock

Nested Class Summary
 class SnmpRequest.SnmpSubRequest
           
 class SnmpRequest.SnmpSubRequestIterator
           
 
Field Summary
static org.snmp4j.smi.OctetString DEFAULT_CONTEXT
           
protected  java.util.Map processingUserObjects
           
 
Fields inherited from class org.snmp4j.agent.request.AbstractRequest
errorStatus, phase, repeaterRowSize, repeaterStartIndex, reprocessCounter, subrequests, transactionID
 
Fields inherited from interface org.snmp4j.agent.request.Request
PHASE_1PC, PHASE_2PC_CLEANUP, PHASE_2PC_COMMIT, PHASE_2PC_PREPARE, PHASE_2PC_UNDO, PHASE_INIT
 
Constructor Summary
SnmpRequest(org.snmp4j.CommandResponderEvent request, CoexistenceInfo cinfo)
           
 
Method Summary
protected  void addRepeaterSubRequest()
           
protected  void assignErrorStatus2Response()
           
 CoexistenceInfo getCoexistenceInfo()
           
 int getCompleteRepetitions()
          Returns the number of repetitions that are complete.
 org.snmp4j.smi.OctetString getContext()
          Gets the context of the request.
 int getErrorIndex()
           
 org.snmp4j.CommandResponderEvent getInitiatingEvent()
           
protected  int getMaxPhase()
           
 int getMaxRepetitions()
           
 int getMessageProcessingModel()
           
 int getNonRepeaters()
           
 java.lang.Object getProcessingUserObject(java.lang.Object key)
          Gets the processing user object for the specified key.
 int getRepeaterCount()
           
 java.lang.Object getResponse()
          Returns the response object for this request.
 org.snmp4j.PDU getResponsePDU()
           
 int getSecurityLevel()
           
 int getSecurityModel()
           
 org.snmp4j.smi.OctetString getSecurityName()
           
 java.lang.Object getSource()
          Returns the initiating event object for the request.
 int getTransactionID()
           
 org.snmp4j.smi.OctetString getViewName()
           
 int getViewType()
           
static int getViewType(int pduType)
          Returns the VACM view type for the supplied PDU type.
protected  boolean is2PC()
           
 boolean isBulkRequest()
           
 boolean isPhaseComplete()
          Checks whether the current phase is complete.
 java.util.Iterator iterator()
          iterator
static int nextTransactionID()
           
 java.lang.Object setProcessingUserObject(java.lang.Object key, java.lang.Object value)
          Sets an user object association.
 void setRequestEvent(org.snmp4j.CommandResponderEvent requestEvent)
           
protected  void setupSubRequests()
           
 void setViewName(org.snmp4j.smi.OctetString viewName)
           
 int size()
          Gets the number of sub-requests in this request.
 
Methods inherited from class org.snmp4j.agent.request.AbstractRequest
equals, find, get, getErrorStatus, getPhase, getReprocessCounter, hashCode, incReprocessCounter, initSubRequests, isComplete, nextPhase, resetCompletionStatus, resetProcessedStatus, setErrorStatus, setPhase, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CONTEXT

public static final org.snmp4j.smi.OctetString DEFAULT_CONTEXT

processingUserObjects

protected java.util.Map processingUserObjects
Constructor Detail

SnmpRequest

public SnmpRequest(org.snmp4j.CommandResponderEvent request,
                   CoexistenceInfo cinfo)
Method Detail

nextTransactionID

public static int nextTransactionID()

setupSubRequests

protected void setupSubRequests()
Specified by:
setupSubRequests in class AbstractRequest

getCompleteRepetitions

public int getCompleteRepetitions()
Returns the number of repetitions that are complete.

Returns:
the minimum r for which all i<r*(pduSize-nonRepeaters) SubRequests returned by AbstractRequest.get(int i) return true on SubRequest.isComplete().

getMaxRepetitions

public int getMaxRepetitions()

getNonRepeaters

public int getNonRepeaters()

getMaxPhase

protected int getMaxPhase()
Specified by:
getMaxPhase in class AbstractRequest

size

public int size()
Description copied from interface: Request
Gets the number of sub-requests in this request. For GETBULK requests this number may increase over time.

Returns:
a positive integer (greater or equal to zero).

getSource

public java.lang.Object getSource()
Description copied from interface: Request
Returns the initiating event object for the request.

Returns:
an Object instance on whose behalf this request has been initiated.

getInitiatingEvent

public org.snmp4j.CommandResponderEvent getInitiatingEvent()

setRequestEvent

public void setRequestEvent(org.snmp4j.CommandResponderEvent requestEvent)

assignErrorStatus2Response

protected void assignErrorStatus2Response()

getResponsePDU

public org.snmp4j.PDU getResponsePDU()

getResponse

public java.lang.Object getResponse()
Description copied from interface: Request
Returns the response object for this request.

Returns:
an object containing the response for this request.

iterator

public java.util.Iterator iterator()
iterator

Returns:
Iterator

is2PC

protected boolean is2PC()

getContext

public org.snmp4j.smi.OctetString getContext()
Description copied from interface: Request
Gets the context of the request.

Returns:
an OctetString instance.

getViewName

public org.snmp4j.smi.OctetString getViewName()

setViewName

public void setViewName(org.snmp4j.smi.OctetString viewName)

getSecurityLevel

public int getSecurityLevel()

getSecurityModel

public int getSecurityModel()

getSecurityName

public org.snmp4j.smi.OctetString getSecurityName()

getViewType

public int getViewType()

getViewType

public static final int getViewType(int pduType)
Returns the VACM view type for the supplied PDU type.

Parameters:
pduType - a PDU type.
Returns:
the corresponding VACM view type.

addRepeaterSubRequest

protected void addRepeaterSubRequest()

getErrorIndex

public int getErrorIndex()
Specified by:
getErrorIndex in interface Request
Overrides:
getErrorIndex in class AbstractRequest

getTransactionID

public int getTransactionID()
Specified by:
getTransactionID in interface Request
Overrides:
getTransactionID in class AbstractRequest

getCoexistenceInfo

public CoexistenceInfo getCoexistenceInfo()

getMessageProcessingModel

public int getMessageProcessingModel()

getRepeaterCount

public int getRepeaterCount()

isPhaseComplete

public boolean isPhaseComplete()
Description copied from interface: Request
Checks whether the current phase is complete.

Returns:
true if all required processing has been finished for the current request phase. For single phase request types this method returns the same result as Request.isComplete().

isBulkRequest

public boolean isBulkRequest()
Specified by:
isBulkRequest in class AbstractRequest

getProcessingUserObject

public java.lang.Object getProcessingUserObject(java.lang.Object key)
Description copied from interface: Request
Gets the processing user object for the specified key. By default there is no such object associated with a request, but ManagedObjects may put their own objects into the request (for example to avoid unnecessary updates on behalf of the same request).

Parameters:
key - an Object.
Returns:
the associated Object or null if their exists no such association.

setProcessingUserObject

public java.lang.Object setProcessingUserObject(java.lang.Object key,
                                                java.lang.Object value)
Description copied from interface: Request
Sets an user object association.

Parameters:
key - a key Object.
value - a value Object associated with key.
Returns:
the previous value associated with key or null if no such association existed.

Copyright 2005-2008 Frank Fock (SNMP4J.org)