Package org.snmp4j.agent.mo
Class DefaultMOFactory
java.lang.Object
org.snmp4j.agent.mo.DefaultMOFactory
- All Implemented Interfaces:
LinkedMOFactory,MOFactory,MOTableRowFactory
- Direct Known Subclasses:
SimMOFactory
The
DefaultMOFactory is the default factory for creating
ManagedObjects. The default factory creates columnar and scalar objects
based on SNMPv2-TC textual conventions with appropriate constraints.
Other textual conventions can be added too.- Version:
- 2.3.0
- Author:
- Frank Fock
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddSNMPv2TCs(MOFactory factory) Adds support for SNMPv2TC textual conventions to the supplied ManagedObject factory.voidAdds a textual convention to this factory which can then be used by the factory to create appropriate value constraints for columnar and scalar managed objects.createAccess(int moAccess) Creates an MOAccess instance from an access specification constant that is the result of a bitwise OR of any of the constants defined byMOAccess.<V extends org.snmp4j.smi.Variable>
MOColumn<V>createColumn(int columnID, int syntax, MOAccess access) Creates a columnar object by supplying column ID, syntax, and maximum access.<V extends org.snmp4j.smi.Variable>
MOColumn<V>createColumn(int columnID, int syntax, MOAccess access, String tcModuleName, String textualConvention) Creates a columnar object by supplying column ID, syntax, and maximum access.<V extends org.snmp4j.smi.Variable>
MOColumn<V>createColumn(int columnID, int syntax, MOAccess access, V defaultValue, boolean mutableInService) Creates a columnar object by supplying column ID, syntax, and maximum access.<V extends org.snmp4j.smi.Variable>
MOColumn<V>createColumn(int columnID, int syntax, MOAccess access, V defaultValue, boolean mutableInService, String tcModuleName, String textualConvention) Creates a columnar object by supplying column ID, syntax, and maximum access.createIndex(MOTableSubIndex[] subIndexes, boolean impliedLength) Creates an index definition from the supplied sub-index definitions without index validation.createIndex(MOTableSubIndex[] subIndexes, boolean impliedLength, MOTableIndexValidator validator) Creates an index definition from the supplied sub-index definitions with index validation according to the supplied validator.createRow(org.snmp4j.smi.OID index, org.snmp4j.smi.Variable[] values) Creates a newMOTableRowrow instance and returns it.<V extends org.snmp4j.smi.Variable>
MOScalar<V>createScalar(org.snmp4j.smi.OID id, MOAccess access, V value) Creates a scalar object from a OID, maximum access, and value.<V extends org.snmp4j.smi.Variable>
MOScalar<V>createScalar(org.snmp4j.smi.OID id, MOAccess access, V value, String tcModuleName, String textualConvention) Creates a scalar object from a OID, maximum access, and value.createSubIndex(int smiSyntax) createSubIndex(int smiSyntax, int minLength, int maxLength) createSubIndex(org.snmp4j.smi.OID oid, int smiSyntax) Creates a sub-index definition.createSubIndex(org.snmp4j.smi.OID oid, int smiSyntax, int minLength, int maxLength) Creates a sub-index definition.<R extends MOTableRow,M extends MOTableModel<R>>
MOTable<R,MOColumn, M> createTable(org.snmp4j.smi.OID oid, MOTableIndex indexDef, MOColumn[] columns) Creates a MOTable instance for the supplied OID, index definition, and columns with theDefaultMOMutableTableModelas table model.<R extends MOTableRow,M extends MOTableModel<R>>
MOTable<R,MOColumn, M> createTable(org.snmp4j.smi.OID oid, MOTableIndex indexDef, MOColumn[] columns, M model) Creates a MOTable instance for the supplied OID, index definition, columns, and table model.<R extends MOTableRow,M extends MOTableModel<? extends R>>
McreateTableModel(org.snmp4j.smi.OID tableOID, MOTableIndex indexDef, MOColumn[] columns) Creates a table model (by default aDefaultMOMutableTableModel).<BaseRow extends MOTableRow,DependentRow extends MOTableRow>
MOTableRelation<BaseRow,DependentRow> createTableRelation(MOTable<BaseRow, ? extends MOColumn, ? extends MOTableModel<BaseRow>> baseTable, MOTable<DependentRow, ? extends MOColumn, ? extends MOTableModel<DependentRow>> dependentTable) Creates a relation between two tables.voidfreeRow(MOTableRow row) Frees resources associated with the supplied row which is to be deleted.static MOFactoryReturns the factory singleton with default support for SNMPv2-TC textual conventions.getLink(org.snmp4j.smi.OID oid) Gets the link for the given object ID or any sub-OID prefix thereof.getSysUpTime(org.snmp4j.smi.OctetString context) Gets a reference to the systems up-time object for the specified context.<V extends org.snmp4j.smi.Variable>
TextualConvention<V>getTextualConvention(String moduleName, String name) Gets the textual convention described by the TC's name and the MIB module name of the MIB module specifying the TC.protected Map<? extends String,? extends Map<String, TextualConvention>> protected voidvoidRemoves the supplied textual convention from the supported TCs by this ManagedObject factory.static voidsetInstance(MOFactory factory) Sets the singleton factory.voidSet a link between the supplied object ID of a managed object class (or a set of managed object classes if the OID refers to a MIB sub-tree) to the given helper object.
-
Constructor Details
-
DefaultMOFactory
protected DefaultMOFactory()
-
-
Method Details
-
getInstance
Returns the factory singleton with default support for SNMPv2-TC textual conventions.- Returns:
- a MOFactory instance.
-
setInstance
Sets the singleton factory.- Parameters:
factory- a MOFactory instance.
-
addSNMPv2TCs
Adds support for SNMPv2TC textual conventions to the supplied ManagedObject factory.- Parameters:
factory- a MOFactory instance.
-
getTextualConventions
-
addTextualConvention
Adds a textual convention to this factory which can then be used by the factory to create appropriate value constraints for columnar and scalar managed objects.- Specified by:
addTextualConventionin interfaceMOFactory- Parameters:
tc- a TextualConvention instance.
-
removeTextualConvention
Description copied from interface:MOFactoryRemoves the supplied textual convention from the supported TCs by this ManagedObject factory.- Specified by:
removeTextualConventionin interfaceMOFactory- Parameters:
tc- a TextualConvention instance.
-
getTextualConvention
public <V extends org.snmp4j.smi.Variable> TextualConvention<V> getTextualConvention(String moduleName, String name) Description copied from interface:MOFactoryGets the textual convention described by the TC's name and the MIB module name of the MIB module specifying the TC.- Specified by:
getTextualConventionin interfaceMOFactory- Type Parameters:
V- theVariabletype that is the base type of the returned textual convention.- Parameters:
moduleName- the name of the MIB module that defines the TC.name- the object name of the TC.- Returns:
- the
TextualConventionthat matches the given values, ornullif such a TC is not registered with this factory.
-
createColumn
public <V extends org.snmp4j.smi.Variable> MOColumn<V> createColumn(int columnID, int syntax, MOAccess access) Description copied from interface:MOFactoryCreates a columnar object by supplying column ID, syntax, and maximum access. Use this method for columns not based on a textual convention.- Specified by:
createColumnin interfaceMOFactory- Type Parameters:
V- theVariabletype of the column to return.- Parameters:
columnID- the column ID of the column. The column ID is the last sub-identifier of a column definition. It is NOT the index of the column.syntax- the SMI syntax of the column as defined bySMIConstants.access- the maximum access supported by this column.- Returns:
- a
MOColumninstance.
-
createColumn
public <V extends org.snmp4j.smi.Variable> MOColumn<V> createColumn(int columnID, int syntax, MOAccess access, V defaultValue, boolean mutableInService) Description copied from interface:MOFactoryCreates a columnar object by supplying column ID, syntax, and maximum access. Use this method for columns based on the textual convention.- Specified by:
createColumnin interfaceMOFactory- Type Parameters:
V- theVariabletype of the column to return.- Parameters:
columnID- the column ID of the column. The column ID is the last sub-identifier of a column definition. It is NOT the index of the column.syntax- the (effective) SMI syntax of the column as defined bySMIConstants.access- the maximum access supported by this column.defaultValue- the default value defined by the DEFVAL clause for this column.mutableInService- iftruethis object may be changed while it is active (inService), otherwise such an attempt will be rejected with a inconsistentValue error.- Returns:
- a
MOColumninstance.
-
createTableRelation
public <BaseRow extends MOTableRow,DependentRow extends MOTableRow> MOTableRelation<BaseRow,DependentRow> createTableRelation(MOTable<BaseRow, ? extends MOColumn, ? extends MOTableModel<BaseRow>> baseTable, MOTable<DependentRow, ? extends MOColumn, ? extends MOTableModel<DependentRow>> dependentTable) Description copied from interface:MOFactoryCreates a relation between two tables. Related tables share one or more sub-indexes beginning with the first sub-index.- Specified by:
createTableRelationin interfaceMOFactory- Type Parameters:
BaseRow- the base row type of the table relation.DependentRow- the dependent row type of the table relation.- Parameters:
baseTable- the base table.dependentTable- the dependent or augmenting table.- Returns:
- a
MOTableRelationinstance relating the supplied tables.
-
getSysUpTime
Description copied from interface:MOFactoryGets a reference to the systems up-time object for the specified context.- Specified by:
getSysUpTimein interfaceMOFactory- Parameters:
context- the SNMPv3 context for which the up-time object should be returned. If the context is null, the up-time of the default context is returned.- Returns:
- a reference to a
SysUpTimeimplementation.
-
createRow
public MOTableRow createRow(org.snmp4j.smi.OID index, org.snmp4j.smi.Variable[] values) throws UnsupportedOperationException Description copied from interface:MOTableRowFactoryCreates a newMOTableRowrow instance and returns it.- Specified by:
createRowin interfaceMOTableRowFactory- Parameters:
index- the index OID for the new row.values- the values to be contained in the new row.- Returns:
- the created
MOTableRow. - Throws:
UnsupportedOperationException- if the specified row cannot be created.
-
createScalar
public <V extends org.snmp4j.smi.Variable> MOScalar<V> createScalar(org.snmp4j.smi.OID id, MOAccess access, V value) Description copied from interface:MOFactoryCreates a scalar object from a OID, maximum access, and value.- Specified by:
createScalarin interfaceMOFactory- Type Parameters:
V- theVariabletype of the scalar to return.- Parameters:
id- the OID of the scalar (including the .0 suffix).access- the maximum access supported by this scalar.value- the (initial) value of the scalar.- Returns:
- a
MOScalarinstance.
-
createTable
public <R extends MOTableRow,M extends MOTableModel<R>> MOTable<R,MOColumn, createTableM> (org.snmp4j.smi.OID oid, MOTableIndex indexDef, MOColumn[] columns) Description copied from interface:MOFactoryCreates a MOTable instance for the supplied OID, index definition, and columns with theDefaultMOMutableTableModelas table model.- Specified by:
createTablein interfaceMOFactory- Type Parameters:
R- theMOTableRowtype of the table to return.M- theMOTableModeltype of the table to return.- Parameters:
oid- the OID of the table entry (thus table OID + ".1").indexDef- the index defintion of the table.columns- the columns for the new table as an array ofMOColumninstances.- Returns:
- a MOTable instance.
-
createTable
public <R extends MOTableRow,M extends MOTableModel<R>> MOTable<R,MOColumn, createTableM> (org.snmp4j.smi.OID oid, MOTableIndex indexDef, MOColumn[] columns, M model) Description copied from interface:MOFactoryCreates a MOTable instance for the supplied OID, index definition, columns, and table model.- Specified by:
createTablein interfaceMOFactory- Type Parameters:
R- theMOTableRowtype of the table to return.M- theMOTableModeltype of the table to return.- Parameters:
oid- the OID of the table entry (thus table OID + ".1").indexDef- the index defintion of the table.columns- the columns for the new table as an array ofMOColumninstances.model- the table model to use for the table.- Returns:
- a MOTable instance.
-
createTableModel
public <R extends MOTableRow,M extends MOTableModel<? extends R>> M createTableModel(org.snmp4j.smi.OID tableOID, MOTableIndex indexDef, MOColumn[] columns) Description copied from interface:MOFactoryCreates a table model (by default aDefaultMOMutableTableModel).- Specified by:
createTableModelin interfaceMOFactory- Type Parameters:
R- theMOTableRowtype of the table model to return.M- theMOTableModeltype of the table model to return.- Parameters:
tableOID- the table's OID for which this model is created.indexDef- the index definition for the table.columns- the columns defined for the table.- Returns:
- a
MOTableModelinstance.
-
freeRow
Description copied from interface:MOTableRowFactoryFrees resources associated with the supplied row which is to be deleted.- Specified by:
freeRowin interfaceMOTableRowFactory- Parameters:
row- a MOTableRow that has been created using this factory and is now to be deleted (removed from the associated table).
-
createIndex
Description copied from interface:MOFactoryCreates an index definition from the supplied sub-index definitions without index validation.- Specified by:
createIndexin interfaceMOFactory- Parameters:
subIndexes- an array ofMOTableSubIndexinstances defining the sub- index values of this index.impliedLength- indicates whether the last variable length sub-index value has an implied length or not (default is false).- Returns:
- MOTableIndex
a
MOTableIndexinstance.
-
createSubIndex
-
createSubIndex
Description copied from interface:MOFactoryCreates a sub-index definition.- Specified by:
createSubIndexin interfaceMOFactory- Parameters:
oid- the object identifier of the OBJECT-TYPE that defines this sub-index ornullif that information is not available. An nonnullis required for AgentX shared tables.smiSyntax- the SMI syntax as defined bySMIConstants.- Returns:
- a
MOTableSubIndexinstance.
-
createSubIndex
-
createSubIndex
public MOTableSubIndex createSubIndex(org.snmp4j.smi.OID oid, int smiSyntax, int minLength, int maxLength) Description copied from interface:MOFactoryCreates a sub-index definition.- Specified by:
createSubIndexin interfaceMOFactory- Parameters:
oid- the object identifier of the OBJECT-TYPE that defines this sub-index ornullif that information is not available. An nonnullis required for AgentX shared tables.smiSyntax- the SMI syntax as defined bySMIConstants.minLength- the minimum length in sub-identifiers (without length sub-id) of the sub-index.maxLength- the maximum length in sub-identifiers (without length sub-id) of the sub-index.- Returns:
- a
MOTableSubIndexinstance.
-
createIndex
public MOTableIndex createIndex(MOTableSubIndex[] subIndexes, boolean impliedLength, MOTableIndexValidator validator) Description copied from interface:MOFactoryCreates an index definition from the supplied sub-index definitions with index validation according to the supplied validator.- Specified by:
createIndexin interfaceMOFactory- Parameters:
subIndexes- an array ofMOTableSubIndexinstances defining the sub- index values of this index.impliedLength- indicates whether the last variable length sub-index value has an implied length or not (default is false).validator- an index validator to check index values.- Returns:
- MOTableIndex
a
MOTableIndexinstance.
-
createColumn
public <V extends org.snmp4j.smi.Variable> MOColumn<V> createColumn(int columnID, int syntax, MOAccess access, String tcModuleName, String textualConvention) Description copied from interface:MOFactoryCreates a columnar object by supplying column ID, syntax, and maximum access. Use this method for columns based on the textual convention.- Specified by:
createColumnin interfaceMOFactory- Type Parameters:
V- theVariabletype of the column to return.- Parameters:
columnID- the column ID of the column. The column ID is the last sub-identifier of a column definition. It is NOT the index of the column.syntax- the (effective) SMI syntax of the column as defined bySMIConstants.access- the maximum access supported by this column.tcModuleName- the MIB module name that defines the textual conventions.textualConvention- the object name of the textual convention on which this column is based.- Returns:
- a
MOColumninstance.
-
createColumn
public <V extends org.snmp4j.smi.Variable> MOColumn<V> createColumn(int columnID, int syntax, MOAccess access, V defaultValue, boolean mutableInService, String tcModuleName, String textualConvention) Description copied from interface:MOFactoryCreates a columnar object by supplying column ID, syntax, and maximum access. Use this method for columns based on the textual convention.- Specified by:
createColumnin interfaceMOFactory- Type Parameters:
V- theVariabletype of the column to return.- Parameters:
columnID- the column ID of the column. The column ID is the last sub-identifier of a column definition. It is NOT the index of the column.syntax- the (effective) SMI syntax of the column as defined bySMIConstants.access- the maximum access supported by this column.defaultValue- the default value defined by the DEFVAL clause for this column.mutableInService- iftruethis object may be changed while it is active (inService), otherwise such an attempt will be rejected with a inconsistentValue error.tcModuleName- the MIB module name that defines the textual conventions.textualConvention- the object name of the textual convention on which this column is based.- Returns:
- a
MOColumninstance.
-
createScalar
public <V extends org.snmp4j.smi.Variable> MOScalar<V> createScalar(org.snmp4j.smi.OID id, MOAccess access, V value, String tcModuleName, String textualConvention) Description copied from interface:MOFactoryCreates a scalar object from a OID, maximum access, and value.- Specified by:
createScalarin interfaceMOFactory- Type Parameters:
V- theVariabletype of the scalar to return.- Parameters:
id- the OID of the scalar (including the .0 suffix).access- the maximum access supported by this scalar.value- the (initial) value of the scalar.tcModuleName- the MIB module name that defines the textual conventions.textualConvention- the object name of the textual convention on which this scalar is based.- Returns:
- a
MOScalarinstance.
-
createAccess
Description copied from interface:MOFactoryCreates an MOAccess instance from an access specification constant that is the result of a bitwise OR of any of the constants defined byMOAccess.- Specified by:
createAccessin interfaceMOFactory- Parameters:
moAccess- any bitwise OR combined constant fromMOAccess.- Returns:
- a MOAccess instance.
-
setLink
Description copied from interface:LinkedMOFactorySet a link between the supplied object ID of a managed object class (or a set of managed object classes if the OID refers to a MIB sub-tree) to the given helper object.- Specified by:
setLinkin interfaceLinkedMOFactory- Parameters:
oid- an OID of a managed object class or sub-tree.instrumentationHelperObject- an object that helps the factory or the objects created on its behalf to instrument the those objects.- See Also:
-
getLink
Description copied from interface:LinkedMOFactoryGets the link for the given object ID or any sub-OID prefix thereof.- Specified by:
getLinkin interfaceLinkedMOFactory- Parameters:
oid- the oid of the managed object class (prefix) for which to returned the linked instrumentation helper class.- Returns:
- an instrumentation helper object (for example an URI) or
nullif no such link exists.
-
initLinkMap
protected void initLinkMap()
-