Class PropertyMOTreeBuilder
MIBTree from a MOInput-formatted
properties configuration (see PropertyMOInput for the format description).
The builder reuses PropertyMOInput.createVariableFromString(String, Class) for the actual
value/OID parsing (including all {type}value format codes, embedded OID references and
randomly generated secrets), so it is fully faithful to how an agent would interpret the same
file. It enumerates the configured scalar and table objects per context and inserts them into an
OID tree.
Because no running agent is available to supply referenced instance values, all {$name}
value references (and ${name}/$#{name} index references) are resolved to
UnresolvedReference placeholders via a ReferenceVariableProvider, preserving the
configured reference for display.
The resulting tree can be rendered to a human readable overview using
org.snmp4j.agent.util.MarkdownMIBTreeFormatter.
- Since:
- 3.9.2
- Version:
- 3.9.2
- Author:
- SNMP4J.org
-
Constructor Summary
ConstructorsConstructorDescriptionPropertyMOTreeBuilder(Properties properties) Creates a builder for the given configuration properties. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the MIB tree from the configuration.static PropertyMOTreeBuilderCreates a builder by loading properties from the given file.static PropertyMOTreeBuilderfrom(InputStream in) Creates a builder by loading properties from the given input stream.static PropertyMOTreeBuilderCreates a builder by loading properties from the given reader.voidsetRandomValue(String name, org.snmp4j.smi.OctetString value) Predefines a named random value (secret) that is used instead of generating a new randomOctetStringwherever the configuration references it via a{r}name/{R}namevalue.
-
Constructor Details
-
PropertyMOTreeBuilder
Creates a builder for the given configuration properties.- Parameters:
properties- thePropertyMOInput-formatted properties. The properties are not modified; a private copy is used internally.
-
-
Method Details
-
from
Creates a builder by loading properties from the given input stream. The stream is closed by this method.- Parameters:
in- the input stream to read the properties from.- Returns:
- a new builder.
- Throws:
IOException- if the stream cannot be read.
-
from
Creates a builder by loading properties from the given reader. The reader is closed by this method.- Parameters:
reader- the reader to read the properties from.- Returns:
- a new builder.
- Throws:
IOException- if the reader cannot be read.
-
from
Creates a builder by loading properties from the given file.- Parameters:
file- the properties file to read.- Returns:
- a new builder.
- Throws:
IOException- if the file cannot be read.
-
setRandomValue
Predefines a named random value (secret) that is used instead of generating a new randomOctetStringwherever the configuration references it via a{r}name/{R}namevalue. This mirrorsPropertyMOInput.setRandomValue(String, OctetString)and must be called beforebuild()so that the generated overview reflects the supplied secrets (for example pass keys provided on an agent command line) rather than freshly generated random values.- Parameters:
name- the name of the random value as referenced by a{r}name/{R}namevalue.value- the value to use for that name; anullvalue removes any predefined value.
-
build
-