- java.lang.Object
-
- org.snmp4j.util.DefaultPDUFactory
-
- All Implemented Interfaces:
PDUFactory
public class DefaultPDUFactory extends java.lang.Object implements PDUFactory
TheDefaultPDUFactoryis a default implementation of thePDUFactoryinterface. It creates PDUs depending on the target's message processing model. That is, aPDUv1instance is created for a SNMPv1 target whereas aScopedPDUis created for a SNMPv3 target. In all other cases aPDUinstance is created.- Since:
- 1.0.4
- Version:
- 2.5.1
- Author:
- Frank Fock
-
-
Field Summary
Fields Modifier and Type Field Description static intGETBULK_DEFAULT_MAX_REPETITIONSstatic intGETBULK_DEFAULT_NON_REPEATERS
-
Constructor Summary
Constructors Constructor Description DefaultPDUFactory()Creates a PDU factory for thePDU.GETPDU type.DefaultPDUFactory(int pduType)Creates a PDU factory for the specified PDU type.DefaultPDUFactory(int pduType, OctetString contextEngineID, OctetString contextName)Creates aPDUFactorywith type and context information.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyContextInfoToScopedPDU(PDU pdu)Sets context engine ID and context name members on the given PDU if that PDU is aScopedPDU.static PDUcreatePDU(int targetVersion)Creates aPDUinstance for the specified SNMP version.PDUcreatePDU(MessageProcessingModel messageProcessingModel)Creates aPDUinstance for the specifiedMessageProcessingModel.static PDUcreatePDU(MessageProcessingModel messageProcessingModel, int pduType)Creates aPDUinstance for the specifiedMessageProcessingModeland PDU type.PDUcreatePDU(Target<?> target)Create aPDUinstance for the supplied target.static PDUcreatePDU(Target<?> target, int pduType)Create aPDUinstance for the supplied target.static PDUcreatePDU(Target<?> target, int pduType, int maxRepetitions, int nonRepeaters)Create aPDUinstance for the supplied target.OctetStringgetContextEngineID()Gets the context engine ID forScopedPDUinstances created by this factory.OctetStringgetContextName()Gets the context name forScopedPDUinstances created by this factory.intgetMaxRepetitions()Gets the maximum number of repetitions for the repetitions variable bindings forPDU.GETBULKPDUs.intgetNonRepeaters()Gets the number of non repeater variable bindings forPDU.GETBULKPDUs.intgetPduType()voidsetContextEngineID(OctetString contextEngineID)Sets the context engine ID forScopedPDUinstances created by this factory.voidsetContextName(OctetString contextName)Sets the context name forScopedPDUinstances created by this factory.voidsetMaxRepetitions(int maxRepetitions)Sets the max repetitions parameter value for GETBULK PDUs created by this factory.voidsetNonRepeaters(int nonRepeaters)Sets the non repeaters parameter value for GETBULK PDUs created by this factory.voidsetPduType(int pduType)
-
-
-
Field Detail
-
GETBULK_DEFAULT_MAX_REPETITIONS
public static final int GETBULK_DEFAULT_MAX_REPETITIONS
- See Also:
- Constant Field Values
-
GETBULK_DEFAULT_NON_REPEATERS
public static final int GETBULK_DEFAULT_NON_REPEATERS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultPDUFactory
public DefaultPDUFactory()
Creates a PDU factory for thePDU.GETPDU type.
-
DefaultPDUFactory
public DefaultPDUFactory(int pduType)
Creates a PDU factory for the specified PDU type. Context engine ID and name will be set to emptyOctetStringinstances.- Parameters:
pduType- a PDU type as specified byPDU.
-
DefaultPDUFactory
public DefaultPDUFactory(int pduType, OctetString contextEngineID, OctetString contextName)Creates aPDUFactorywith type and context information.
-
-
Method Detail
-
setPduType
public void setPduType(int pduType)
-
getPduType
public int getPduType()
-
createPDU
public PDU createPDU(Target<?> target)
Create aPDUinstance for the supplied target.- Specified by:
createPDUin interfacePDUFactory- Parameters:
target- theTargetwhere the PDU to be created will be sent.- Returns:
- PDU a PDU instance that is compatible with the supplied target.
-
applyContextInfoToScopedPDU
protected void applyContextInfoToScopedPDU(PDU pdu)
Sets context engine ID and context name members on the given PDU if that PDU is aScopedPDU.
-
createPDU
public static PDU createPDU(Target<?> target, int pduType)
Create aPDUinstance for the supplied target. For GETBULK PDUs, the default max repetitions and non repeaters are used. SeeGETBULK_DEFAULT_MAX_REPETITIONSandGETBULK_DEFAULT_NON_REPEATERS.- Parameters:
target- theTargetwhere the PDU to be created will be sent.pduType- a PDU type as specified byPDU.- Returns:
- PDU a PDU instance that is compatible with the supplied target.
-
createPDU
public static PDU createPDU(Target<?> target, int pduType, int maxRepetitions, int nonRepeaters)
Create aPDUinstance for the supplied target.- Parameters:
target- theTargetwhere the PDU to be created will be sent.pduType- a PDU type as specified byPDU.maxRepetitions- the maximum number of repetitions for GETBULK PDUs created by this factory.nonRepeaters- the number of non-repeater variable bindings (processed like GETNEXT) for GETBULK PDUs created by this factory.- Returns:
- PDU a PDU instance that is compatible with the supplied target.
- Since:
- 2.2
-
createPDU
public static PDU createPDU(int targetVersion)
Creates aPDUinstance for the specified SNMP version.- Parameters:
targetVersion- a SNMP version as defined bySnmpConstants.- Returns:
- a PDU instance that is compatible with the supplied target SNMP version.
- Since:
- 1.7.3
-
createPDU
public PDU createPDU(MessageProcessingModel messageProcessingModel)
Creates aPDUinstance for the specifiedMessageProcessingModel.- Specified by:
createPDUin interfacePDUFactory- Parameters:
messageProcessingModel- a message processing model instance.- Returns:
- a PDU that is compatible with the specified message processing model.
- Since:
- 2.2
-
createPDU
public static PDU createPDU(MessageProcessingModel messageProcessingModel, int pduType)
Creates aPDUinstance for the specifiedMessageProcessingModeland PDU type.- Parameters:
messageProcessingModel- a message processing model instance.pduType- the type for the new PDU.- Returns:
- a PDU that is compatible with the specified message processing model.
- Since:
- 2.2
-
getMaxRepetitions
public int getMaxRepetitions()
Gets the maximum number of repetitions for the repetitions variable bindings forPDU.GETBULKPDUs. Default isGETBULK_DEFAULT_MAX_REPETITIONS- Returns:
- the maximum number of repetitions for GETBULK PDUs created by this factory.
- Since:
- 2.2
-
setMaxRepetitions
public void setMaxRepetitions(int maxRepetitions)
Sets the max repetitions parameter value for GETBULK PDUs created by this factory.- Parameters:
maxRepetitions- the maximum number of repetitions for GETBULK PDUs created by this factory.- Since:
- 2.2
-
getNonRepeaters
public int getNonRepeaters()
Gets the number of non repeater variable bindings forPDU.GETBULKPDUs. Default isGETBULK_DEFAULT_NON_REPEATERS.- Returns:
- the number of non-repeater variable bindings (processed like GETNEXT) for GETBULK PDUs created by this factory.
- Since:
- 2.2
-
setNonRepeaters
public void setNonRepeaters(int nonRepeaters)
Sets the non repeaters parameter value for GETBULK PDUs created by this factory.- Parameters:
nonRepeaters- the number of non-repeater variable bindings (processed like GETNEXT) for GETBULK PDUs created by this factory.- Since:
- 2.2
-
getContextEngineID
public OctetString getContextEngineID()
Gets the context engine ID forScopedPDUinstances created by this factory.- Returns:
- the context engine ID or
nullif context engine ID is the same as authoritative engine ID. - Since:
- 2.2
-
setContextEngineID
public void setContextEngineID(OctetString contextEngineID)
Sets the context engine ID forScopedPDUinstances created by this factory.- Parameters:
contextEngineID- the context engine ID ornullif context engine ID is the same as authoritative engine ID.- Since:
- 2.2
-
getContextName
public OctetString getContextName()
Gets the context name forScopedPDUinstances created by this factory.- Returns:
- the context name or
nullfor the default context. - Since:
- 2.2
-
setContextName
public void setContextName(OctetString contextName)
Sets the context name forScopedPDUinstances created by this factory.- Parameters:
contextName- the context name ornullfor the default context.- Since:
- 2.2
-
-