Helper class for holding the address tuple for a model node
Implementation for complex model nodes.
A Scala wrapper around a org.jboss.dmr.ModelNode
providing methods to interact with model nodes in a more
natural way.
An operation for a model node containing optional parameters.
Helper class to read (nested) keys from a model node using a path like syntax
Provides methods to convert a model node to a simple value
Implementation for value model nodes.
Factory for org.jboss.dmr.scala.ModelNode
Holds a type alias for the parameters
An empty address
Provides classes for dealing with the management model of a WildFly, JBoss or EAP instance.
Getting started
Please make sure to import the following packages in order to bring the necessary implicit conversions into scope and to save you some keystrokes.
Creating model nodes
The main class to use is org.jboss.dmr.scala.ModelNode. Its companion object acts as a factory for creating new model node instances.
Addressing and operations
You can use a DSL like API to set the address and operation for a model node. To describe the "read-resource" operation on "/subsystem=datasources/data-source=ExampleDS" use the following code:
Addresses can be written down as
(String, String)
tuples separated by "/". Operations are specified using scala.Symbols and an optional list of parameters. Each parameter is made up of another scala.Symbol and a value. Using symbols makes the DSL both more readable and extentable.However there's one drawback in using symbols: they cannot contain characters like "-".
'read-resource
is therefore an illegal symbol. As most DMR operations and many parameters do contain "-", this library will replace all underscores in a symbol with dashes:Here are some more examples using addresses and operations:
Reading Nodes
Reading values from a model node follows the sementics of a
Map[String, ModelNode]
, but instead of a string you provide a org.jboss.dmr.scala.Path as key. Thanks to an implicit conversion expression like"a" / "b" / "c"
are automatically converted to a path.Since the result of
node.get("a" / "b" / "c")
isOption[ModelNode]
, reading nested model nodes is safe even if some children in the path do not exist. In this caseNone
wil be returned:Reading Values
You can use the folowing methods to read values from model nodes:
ModelNode.asBoolean
ModelNode.asInt
ModelNode.asLong
ModelNode.asBigInt
ModelNode.asDouble
ModelNode.asString
These methods return
Option
instances of the relevant type. This is because not all methods make sense on all kind of model nodes:Writing
Simple values can be set using
node("foo") = "bar"
. If "foo" doesn't exist it will be created and updated otherwise. As an alternative you can use the+=
operator, which comes in handy if you want to add multiple key / value pairs:Reading and writing can also be combined in one call:
Colection Operations
Since org.jboss.dmr.scala.ModelNode mixes in ModelNode)] you can use all those nifty collection methods like
foreach
,map
orfilter
Composites
A composite operation is setup using the
ModelNode.composite(n: ModelNode, xn: ModelNode*)
factory method: