Writing attributes (write)
Writing an attribute is quite similar to reading one, except that the request takes an
additional value
element.
GET write request
Writing an attribute with a GET request, an URL with the following format has to be used:
<base url>/write/<mbean name>/<attribute name>/<value>/<inner path>
Part | Description | Example |
---|---|---|
|
MBean’s ObjectName |
|
|
Name of attribute to set |
|
|
The attribute name to value. The value must be serializable as described in Request parameter serialization. |
|
|
Inner path for accessing the parent object on which to set the value. (See also Paths). Note, that this is not the path to the attribute itself, but to the object carrying this attribute. With a given path it is possible to deeply set a value on a complex object. |
For example, you can set the garbage collector to verbose mode by using something like
http://localhost:8080/jolokia/write/java.lang:type=Memory/Verbose/true
POST write request
The keys which are evaluated for a POST write request are:
Key | Description | Example |
---|---|---|
|
|
|
|
MBean’s ObjectName |
|
|
Name of attribute to set |
|
|
The attribute name to value. The value must be serializable as described in Request parameter serialization. |
|
|
An optional inner path for specifying an inner object on which to set the value. See Paths for more on inner paths. |
Write response
As response for a write operation the old attribute’s value is returned. For a request
http://localhost:8080/jolokia/write/java.lang:type=ClassLoading/Verbose/true
you get the answer (supposed that verbose mode was switched off for class loading at the time this request was sent)
{
"request": {
"mbean": "java.lang:type=ClassLoading",
"attribute": "Verbose",
"type": "write",
"value": "true"
},
"value": false,
"status": 200,
"timestamp": 1702455595
}
- NOTE
-
Since Jolokia 2.1.0 we can use
includeRequest
parameter to tell Jolokia to excluderequest
field from the response.
The response is quite similar to the read operation except for
the additional value
element in the request
(and of course, the different type
).