Debian Codegraph @

src/docbkx/protocol.xml

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 ~ Copyright 2009-2013 Roland Huss
4 ~
5 ~ Licensed under the Apache License, Version 2.0 (the "License");
6 ~ you may not use this file except in compliance with the License.
7 ~ You may obtain a copy of the License at
8 ~
9 ~ http://www.apache.org/licenses/LICENSE-2.0
10 ~
11 ~ Unless required by applicable law or agreed to in writing, software
12 ~ distributed under the License is distributed on an "AS IS" BASIS,
13 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ~ See the License for the specific language governing permissions and
15 ~ limitations under the License.
16 -->
17
18 <chapter id="protocol" xmlns:xi="http://www.w3.org/2001/XInclude">
19 <title>Jolokia Protocol</title>
20 <para>
21 Jolokia uses a JSON-over-HTTP protocol which is described in
22 this chapter. The communication is based on a request-response
23 paradigm, where each request results in a single response.
24 </para>
25 <sidebar>
26 <title>GET URLs are chatty</title>
27 Keep in mind
28 that many web servers log the requested path of every request, including
29 parameters passed to a GET request, so sending messages over GET
30 often bloats server logs.
31 </sidebar>
32 <para>
33 Jolokia requests can be sent in two ways: Either as a HTTP GET
34 request, in which case the request parameters are encoded
35 completely in the URL. Or as a POST request where the request is
36 put into a JSON payload in the HTTP request's body. GET based
37 requests are mostly suitable for simple use cases and for
38 testing the agent via a browser. The focus here is on
39 simplicity. POST based requests uses a JSON representation of
40 the request within the HTTP body. They are more appropriate for
41 complex requests and provide some additional features (e.g. bulk
42 requests are only possible with POST).
43 </para>
44 <para>
45 The response returned by the agent uses always JSON for its data
46 representation. It has the same format regardless whether GET or
47 POST requests are used.
48 </para>
49 <para>
50 The rest of this chapter is divided into two parts: First, the
51 general structure of requests and responses are explained after
52 which the representation of Jolokia supported operations defined.
53 </para>
54 <note>
55 Unfortunately the term <emphasis>operation</emphasis> is
56 used in different contexts which should be
57 distinguished from one another. <emphasis>Jolokia operations</emphasis> denote
58 the various kind of Jolokia requests, whereas <emphasis>JMX
59 operations</emphasis> are methods which can be invoked on an JMX
60 MBean. Whenever the context requires it, this documents uses
61 <emphasis>Jolokia</emphasis> or <emphasis>JMX</emphasis> as
62 prefix.
63 </note>
64 <section id="request-response">
65 <title>Requests and Responses</title>
66 <para>
67 Jolokia knows about two different styles of handling
68 requests, which are distinguished by the HTTP method used: GET
69 or POST. Regardless of what method is used, the agent doesn't
70 keep any state on the server side (except of course that
71 MBeans are obviously stateful most of the time). So in this aspect, the
72 communication can be considered
73 <ulink url="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</ulink>
74 like<footnote id="rest-comment">
75 <para>This document will avoid the term REST as much as
76 possible in order to avoid provoking any dogmatic
77 resentments.</para>
78 </footnote>.
79 </para>
80 <section id="get-request">
81 <title>GET requests</title>
82 <para>
83 The simplest way to access the Jolokia agent is by sending
84 HTTP GET requests. These requests encode all their
85 parameters within the access URL. Typically, Jolokia uses
86 the path-info part of an URL to extract the
87 parameters. Within the path-info, each part is separated by
88 a slash (<literal>/</literal>). In general, the request URL
89 looks like
90 <synopsis><![CDATA[<base-url>/<type>/<arg1>/<arg2>/..../]]></synopsis>
91 The <literal>&lt;base-url&gt;</literal> specifies the URL
92 under which the agent is accessible. It normally looks like
93 <uri>http://localhost:8080/jolokia</uri>, but depends on
94 your deployment setup. The last part of this URL is the
95 <emphasis>context root</emphasis> of the deployed agent,
96 which by default is based on the agent's filename
97 (e.g. <filename>jolokia.war</filename>).
98 <literal>&lt;type&gt;</literal> specifies one of the
99 supported Jolokia operations (described in the next
100 section), followed by one or more operation-specific
101 parameters separated by slashes.
102 </para>
103 <para>
104 For example, the following URL executes a
105 <constant>read</constant> Jolokia operation on the MBean
106 <literal>java.lang:type=Memory</literal> for reading the
107 attribute <literal>HeapMemoryUsage</literal> (see <xref
108 linkend="read"/>). It is assumed, that the agent is
109 reachable under the base URL
110 <uri>http://localhost:8080/jolokia</uri>:
111 <informalexample>
112 <literallayout class="monospaced">http://localhost:8080/jolokia/read/java.lang:type=Memory/HeapMemoryUsage</literallayout>
113 </informalexample>
114 </para>
115 <sidebar>
116 <title>
117 Why escaping ?
118 </title>
119 You might wonder why simple URI encoding isn't enough for
120 escaping slashes. The reason is that JBoss/Tomcat has a
121 strange behaviour when returning an HTTP response
122 <literal>HTTP/1.x 400 Invalid URI: noSlash</literal> for
123 any URL which contains an escaped slash in the path info
124 (i.e. <literal>%2F</literal>). The reason behind this
125 behaviour is security related, slashes get decoded on the
126 agent side before the agent-servlet gets the
127 request. Other appservers might exhibit a similar
128 behaviour, so Jolokia uses an own escaping mechanism.
129 </sidebar>
130 <para>
131 If one of the request parts contain a slash
132 (<literal>/</literal>) (e.g. as part of you bean's name) it
133 needs to be escaped. An exclamation mark
134 (<literal>!</literal>) is used as escape character<footnote
135 id="no-backslash">
136 <para>
137 A backslash (<literal>\</literal>) can not be used, since
138 most servlet container translate a backslash into a forward
139 slash on the fly when given in an URL.
140 </para>
141 </footnote>. An exclamation mark itself needs to be doubled
142 for escaping. Any other characted preceded by an exclamation
143 mark is taken literally. Table <xref
144 linkend="escape-rules"/> illustrates the escape rules as
145 used in GET requests. Also, if quotes are part of an GET
146 request the need to be escaped with
147 <constant>!"</constant>.
148 </para>
149 <table id="escape-rules">
150 <title>Escaping rules</title>
151 <thead>
152 <tr>
153 <td>Escaped</td>
154 <td>Unescaped</td>
155 </tr>
156 </thead>
157 <tr>
158 <td><constant>!/</constant></td>
159 <td><constant>/</constant></td>
160 </tr>
161 <tr>
162 <td><constant>!!</constant></td>
163 <td><constant>!</constant></td>
164 </tr>
165 <tr>
166 <td><constant>!"</constant></td>
167 <td><constant>"</constant></td>
168 </tr>
169 <tr>
170 <td><constant>!</constant><emphasis>(anything else)</emphasis></td>
171 <td><emphasis>(anything else)</emphasis></td>
172 </tr>
173 </table>
174 <para>
175 For example, to read the atrribute <literal>State</literal>
176 on the MBean named
177 <literal>jboss.jmx:alias=jmx/rmi/RMIAdaptor</literal>, an
178 access URL like this has to be constructed:
179 </para>
180 <informalexample>
181 <literallayout class="monospaced">.../read/jboss.jmx:alias=jmx!/rmi!/RMIAdaptor/State</literallayout>
182 </informalexample>
183 <para>
184 Client libraries like <ulink
185 url="http://search.cpan.org/~roland/jmx4perl">JMX::Jmx4Perl</ulink>
186 do this sort of escaping transparently.
187 </para>
188 <para>
189 Escaping can be avoided alltogether if a slightly different
190 variant for a request is used (which doesn't look that
191 REST-stylish, though). Instead of providing the information
192 as path-info, a query parameter <literal>p</literal> can be
193 used instead. This should be URL encoded, though. For the
194 example above, the alternative is
195 <informalexample>
196 <literallayout class="monospaced">http://localhost:8080/jolokia?p=/read/jboss.jmx:alias=jmx%2Frmi%2FRMIAdaptor/State</literallayout>
197 </informalexample>
198 This format <emphasis>must</emphasis> be used for GET
199 requests containing backslashes (<literal>\</literal>) since
200 backslashes can not be sent as part of an URL at all.
201 </para>
202 </section>
203
204 <section id="post-request">
205 <title>POST requests</title>
206 <para>
207 POST requests are the most powerful way to communicate
208 with the Jolokia agent. There are fewer escaping issues and it
209 allows for features which are not available with GET
210 requests. POST requests uses a fixed URL and put their payload
211 within the HTTP request's body. This payload is represented
212 in <ulink url="http://www.json.org">JSON</ulink>, a
213 data serialization format originating from the JavaScript
214 world.
215 </para>
216 <para>
217 The JSON format for a single request is a JSON object, which
218 is essentially a map with keys (or
219 <emphasis>attributes</emphasis>) and values. All requests
220 have a common mandatory attribute,
221 <constant>type</constant>, which specifies the kind of JMX
222 operation to perform. The other attributes are either
223 operation specific as described in <xref
224 linkend="jolokia-operations"/> or are <emphasis>processing
225 parameters</emphasis> which influence the overall behaviour
226 and can be mixed in to any request. See <xref
227 linkend="processing-parameters"/> for details. Operation specific attributes
228 can be either mandatory or optional and depend on the operation type.
229 In the following, if not mentioned otherwise, attributes are mandatory.
230 Processing parameters are always optional, though.
231 </para>
232 <para>
233 A sample read request in JSON format looks like the
234 following example. It has a <constant>type</constant>
235 "read"
236 (case doesn't matter) and the three attributes
237 <constant>mbean</constant>, <constant>attribute</constant>
238 and <constant>path</constant> which are specific to a read
239 request.
240 </para>
241 <example id="request-example">
242 <title>JSON Request</title>
243 <programlisting><![CDATA[
244 {
245 "type" : "read",
246 "mbean" : "java.lang:type=Memory",
247 "attribute" : "HeapMemoryUsage",
248 "path" : "used",
249 }]]></programlisting>
250 </example>
251 <para>
252 Each request JSON object results in a single JSON response
253 object contained in the HTTP answer's body. A <emphasis>bulk
254 request</emphasis> contains multiple Jolokia requests within
255 a single HTTP request. This is done by putting individual
256 Jolokia requests into a JSON array:
257 </para>
258 <programlisting><![CDATA[
259 [
260 {
261 "type" : "read",
262 "attribute" : "HeapMemoryUsage",
263 "mbean" : "java.lang:type=Memory",
264 "path" : "used",
265 },
266 {
267 "type" : "search"
268 "mbean" : "*:type=Memory,*",
269 }
270 ]]]></programlisting>
271 <para>
272 This request will result in a JSON array containing multiple
273 JSON responses within the HTTP response. They are returned
274 in same order as the requests in the initial bulk request.
275 </para>
276 </section>
277
278 <section id="responses">
279 <title>Responses</title>
280 <para>
281 Responses are always encoded in UTF-8 JSON, regardless whether the
282 requst was a GET or POST request. In general, two kinds of
283 responses can be classified: In the normal case, a HTTP
284 Response with response code 200 is returned, containing the
285 result of the operation as a JSON payload. In case of an
286 error, a 4xx or 5xx code will be returned and the JSON
287 payload contains details about the error
288 occured (e.g. 404 means "not found"). (See
289 <ulink url="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes">this page</ulink>
290 for more information about HTTP error codes..). If the processing option
291 <constant>ifModifiedSince</constant> is given and the requested
292 value as been not changed since then, a response code of 304 is returned.
293 This option is currently only supported by the <constant>LIST</constant> request, for
294 other request types the value is always fetched.
295 </para>
296 <para>
297 In the non-error case a JSON response looks mostly the same
298 for each request type except for the
299 <constant>value</constant> attribute which is request type
300 specific.
301 </para>
302 <para>
303 The format of a single Jolokia response is
304 </para>
305 <example id="response-example">
306 <title>JSON Response</title>
307 <programlisting><![CDATA[
308 {
309 "value": .... ,
310 "status" : 200,
311 "timestamp" : 1244839118,
312 "request": {
313 "type": ...,
314 ....
315 },
316 "history":[
317 {"value": ... ,
318 "timestamp" : 1244839045
319 }, ....
320 ]
321 }]]></programlisting>
322 </example>
323 <para>
324 For successful requests, the <constant>status</constant> is
325 always <literal>200</literal> (the HTTP success code). The
326 <constant>timestamp</constant> contains the epoch
327 time<footnote id="epoch-time">
328 <para>
329 Seconds since 1.1.1970
330 </para>
331 </footnote> when the
332 request has been handled. The request leading to this
333 response can be found under the attribute
334 <constant>request</constant>. Finally and optionally, if
335 history tracking is switched on (see <xref
336 linkend="history"/>), an entry with key
337 <constant>history</constant> contains a list of historical
338 values along with their timestamps. History tracking is only
339 available for certain type of requests
340 (<constant>read</constant>, <constant>write</constant> and
341 <constant>exec</constant>). The <constant>value</constant>
342 is specific for the type of request, it can be a single
343 scalar value or a monster JSON structure.
344 </para>
345 <para>
346 If an error occurs, the <constant>status</constant> will be
347 a number different from <literal>200</literal>. An error
348 response looks like
349 </para>
350 <programlisting><![CDATA[
351 {
352 "status":400,
353 "error_type":"java.lang.IllegalArgumentException",
354 "error":"java.lang.IllegalArgumentException: Invalid request type 'java.lang:type=Memory'",
355 "stacktrace":"java.lang.IllegalArgumentException: Invalid request type 'java.lang:type=Memory'\n
356 \tat org.cpan.jmx4perl.JmxRequest.extractType(Unknown Source)\n
357 \tat org.cpan.jmx4perl.JmxRequest.<init>(Unknown Source) ...."
358 }]]></programlisting>
359 <para>
360 For status codes it is important to distinguish status
361 codes as they appear in Jolokia JSON response objects
362 and the HTTP status code of the (outer) HTTP
363 response. There can be many Jolokia status codes, one for
364 each Jolokia request contained in the single HTTP request. The
365 HTTP status code merely reflect the status of agent itself
366 (i.e. whether it could perform the operation at all), whereas the
367 Jolokia response status reflects the result of the
368 operation (e.g. whether the performed operation throws an
369 exception). So it is not uncommon to have an HTTP status
370 code of 200, but the contained JSON response(s) indicate
371 some errors.
372 </para>
373 <para>
374 I.e. the <constant>status</constant> has a code in the range
375 <literal>400 .. 499</literal> or <literal>500 .. 599</literal>
376 <ulink url="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes">as it is specified for HTTP return codes</ulink>.
377 The <constant>error</constant> member contains an error
378 description. This is typically the message of an exception
379 occured on the agent side<footnote
380 id="mbeanexception-wrapping">
381 <para>
382 If the server exception
383 is a subtype of <classname>MBeanException</classname>, the wrapped
384 exception's message is used.
385 </para>
386 </footnote>. Finally, <constant>error_type</constant> contains the Java class name
387 of the exception occured.
388 The <constant>stacktrace</constant> contains a Java stacktrace
389 occured on the server side (if any stacktrace is available).
390 </para>
391
392 <para>
393 For each type of operation, the format of the
394 <constant>value</constant> entry is explained in
395 <xref linkend="jolokia-operations"/>
396 </para>
397 </section>
398
399 <section id="paths">
400 <title>Paths</title>
401 <para>
402 An <emphasis>inner path</emphasis> points to a certain
403 substructure (plain value, array, hash) within a a complex
404 JSON value. Think of it as something like "XPath lite". This
405 is best explained by an example:
406 </para>
407 <para>
408 The attribute <literal>HeapMemoryUsage</literal> of the MBean
409 <literal>java.lang:type=Memory</literal> can be
410 requested with the URL
411 <literal>http://localhost:8080/jolokia/read/java.lang:type=Memory/HeapMemoryUsage</literal>
412 which returns a complex JSON structure like
413 <programlisting language="json"><![CDATA[
414 {
415 "status" : 200,
416 "value" : {
417 "committed" : 18292736,
418 "used" : 15348352,
419 "max" : 532742144,
420 "init" : 0
421 },
422 "request" : { .... },
423 "timestamp" : ....
424 }]]></programlisting>
425 </para>
426 <para>
427 In order to get to the value for used heap memory you should
428 specify an inner path <literal>used</literal>, so that the
429 request
430 <literal>http://localhost:8080/jolokia/read/java.lang:type=Memory/HeapMemoryUsage/used</literal>
431 results in a response of <literal>15348352</literal>for the value:
432 </para>
433 <programlisting><![CDATA[
434 {
435 "status" : 200,
436 "value" : 15348352,
437 "request" : { .... },
438 "timestamp" : ....
439 }]]></programlisting>
440 <para> If the attribute contains arrays at some level, use a numeric
441 index (0 based) as part of the inner path if you want to
442 traverse into this array.
443 </para>
444 <para>
445 For both, GET and POST requests, paths must be escaped as
446 described in <xref linkend="escape-rules"/> when they
447 contain slashes (<literal>/</literal>) or exclamation marks
448 (<literal>!</literal>).
449 </para>
450 <para>
451 Paths support wildcards <literal>*</literal> in a simple form. If given as a path part exclusively, it
452 matches any entry and path matching continues on the next level. This feature is especially
453 useful when using pattern read request together with paths. See <xref linkend="read"/> for details. A
454 <constant>*</constant> mixed with other characters in a path part has no special meaning and is used literally.
455 </para>
456 </section>
457 </section>
458
459 <section id="jolokia-operations">
460 <title>Jolokia operations</title>
461
462 <xi:include href='protocol/read.xml'/>
463 <xi:include href='protocol/write.xml'/>
464 <xi:include href='protocol/exec.xml'/>
465 <xi:include href='protocol/search.xml'/>
466 <xi:include href='protocol/list.xml'/>
467 <xi:include href='protocol/version.xml'/>
468
469 </section>
470
471 <section id="processing-parameters">
472 <title>Processing parameters</title>
473 <para>
474 Jolokia operations can be influenced by so-called
475 <emphasis>processing parameters</emphasis>. These parameters
476 are provided differently for POST and GET requests.
477 </para>
478 <para>
479 For GET request, the processing parameter are given as normal
480 query parameters:
481 <synopsis><![CDATA[<GET request URL>?param1=value1&param2=value2&...]]></synopsis>
482 For example the request
483 <synopsis><![CDATA[http://localhost:8080/jolokia/list?maxObjects=100]]></synopsis>
484 will limit the response to at max 100 values.
485 </para>
486 <para>
487 POST request take the processing instructions within the
488 JSON request below the key <constant>config</constant>:
489 </para>
490 <programlisting><![CDATA[
491 {
492 "type" : "list"
493 "config" : {
494 "maxObjects" : 100
495 }
496 }]]></programlisting>
497 <para>
498 If a POST request carries also query parameters in the URL, these processing parameters
499 are merged with the ones given within the request. Configuration options given in the
500 request take precedence over the ones given as query parameters.
501 </para>
502 <para>
503 The list of known processing parameters is:
504 </para>
505 <variablelist>
506 <varlistentry>
507 <term><literal>maxDepth</literal></term>
508 <listitem>
509 <para>
510 Maximum depth of the tree traversal into a bean's
511 properties. The maximum value as configured in the
512 agent's configuration is a hard limit
513 and cannot be exceeded by a query parameter.
514 </para>
515 </listitem>
516 </varlistentry>
517 <varlistentry>
518 <term><literal>maxCollectionSize</literal></term>
519 <listitem>
520 <para>
521 For collections (lists, maps) this is the maximum
522 size.
523 </para>
524 </listitem>
525 </varlistentry>
526 <varlistentry>
527 <term><literal>maxObjects</literal></term>
528 <listitem>
529 <para>
530 Number of objects to visit in total. A hard limit
531 can be configured in the agent's configuration.
532 </para>
533 </listitem>
534 </varlistentry>
535 <varlistentry>
536 <term><literal>ignoreErrors</literal></term>
537 <listitem>
538 <para>
539 If set to "true", a Jolokia operation will not return an
540 error if an JMX operation fails, but includes the
541 exception message as value. This is useful for e.g. the
542 read operation when requesting multiple attributes'
543 values. Default: false
544 </para>
545 </listitem>
546 </varlistentry>
547 <varlistentry>
548 <term><literal>mimeType</literal></term>
549 <listitem>
550 <para>
551 The MIME type to return for the response. By default,
552 this is <constant>text/plain</constant>, but it can be
553 useful for some tools to change it to
554 <constant>application/json</constant>. Init parameters can
555 be used to change the default mime type.
556 Only <constant>text/plain</constant> and <constant>application/json</constant> are allowed.
557 For any other value Jolokia will fallback to <constant>text/plain</constant>.
558 </para>
559 </listitem>
560 </varlistentry>
561 <varlistentry>
562 <term><literal>canonicalNaming</literal></term>
563 <listitem>
564 <para>
565 Defaults to <constant>true</constant> to return the canonical format of property lists.
566 If set to <constant>false</constant> then the default unsorted property list is returned.
567 </para>
568 </listitem>
569 </varlistentry>
570 <varlistentry>
571 <term><literal>includeStackTrace</literal></term>
572 <listitem>
573 <para>
574 If set to <constant>true</constant>, then in case of an error the stack trace is included.
575 With <constant>false</constant> no stack trace will be returned, and when this parameter
576 is set to <constant>runtime</constant> only for RuntimeExceptions a stack trace is put into
577 the error response. Default is <constant>true</constant> if not set otherwise in the global
578 agent configuration.
579 </para>
580 </listitem>
581 </varlistentry>
582 <varlistentry>
583 <term><literal>serializeException</literal></term>
584 <listitem>
585 <para>
586 If this parameter is set to <constant>true</constant> then a serialized version of the
587 exception is included in an error response. This value
588 is put under the key <constant>error_value</constant> in
589 the response value. By default this is set to
590 <constant>false</constant> except when the agent global
591 configuration option is configured otherwise.
592 </para>
593 </listitem>
594 </varlistentry>
595 <varlistentry>
596 <term><literal>ifModifiedSince</literal></term>
597 <listitem>
598 <para>
599 If this parameter is given, its value is interpreted as epoch time (seconds since 1.1.1970) and
600 if the requested value did not change since this time, an empty response (with no <constant>value</constant>)
601 is returned and the response status code is set to 304 ("Not modified"). This
602 option is currently only supported for <literal>LIST</literal> requests. The time value can be
603 extracted from a previous' response <constant>timestamp</constant>.
604 </para>
605 </listitem>
606 </varlistentry>
607 </variablelist>
608 </section>
609
610 <section id="serialization">
611 <title>Object serialization</title>
612 <para>
613 Jolokia has some object serialization facilities in order to
614 convert complex Java data types to JSON and vice
615 versa. Serialization works in both ways in requests and
616 responses, but the capabilities differ.
617 </para>
618 <para>
619 Complex data types returned from the agent can be serialized
620 completely into a JSON value object. It can detect cycles in
621 the object graph and provides a way to limit the depth of
622 serialization. For certain types (like
623 <classname>File</classname> or
624 <classname>ObjectName</classname>) it uses simplifier to not
625 expose internal and redundant information.
626 </para>
627 <para>
628 Object values used for values in
629 <emphasis>write</emphasis> operations and arguments in
630 <emphasis>exec</emphasis>, type support is limited to a
631 handful of data types.
632 </para>
633 <section id="serialization-response">
634 <title>Response value serialization</title>
635 <para>
636 Jolokia can serialize any object into a JSON representation
637 when generating the response. It uses some specific
638 converters for certain well known data type with a generic
639 bean converter as fallback.
640 </para>
641 <para>
642 The following types are directly supported:
643 <itemizedlist>
644 <listitem>
645 Arrays and <classname>java.util.List</classname>
646 are converted to JSON arrays
647 </listitem>
648 <listitem>
649 <classname>java.util.Map</classname> gets
650 converted into a JSON object. Note, however, that JSON
651 Object keys are <emphasis>always strings</emphasis>.
652 </listitem>
653 <listitem>
654 Enums are converted to their canonical name.<footnote id="enum-serial-jboss">
655 <para>
656 For JBoss older than version 7, there might be use cases
657 when custom enums need to be serialized. In this case,
658 the type information must be available to the agent,
659 too. For the standard PlatformMBeanServer
660 serialization should work always, regardless whether
661 the customer enum type is accessible by the agent or
662 not.
663 </para>
664 </footnote>
665 </listitem>
666 <listitem>
667 <classname>javax.management.openmbean.CompositeData</classname>
668 is converted in a JSON object, with the keys taken from
669 the <classname>CompositeData</classname>'s key set and
670 the value are its values.
671 </listitem>
672 <listitem>
673 <classname>javax.management.openmbean.TabularData</classname>
674 is serialized differently depending on its internal
675 structure. See below for a detailed explanation of this
676 serialization mechanism including examples.
677 </listitem>
678 <listitem>
679 <classname>java.lang.Class</classname> is converted to
680 a JSON object with keys <literal>name</literal> (the class
681 name) and <literal>interfaces</literal> (the implemented
682 interfaces, if any)
683 </listitem>
684 <listitem>
685 <classname>java.io.File</classname> becomes a JSON
686 object with keys <literal>name</literal> (file name),
687 <literal>modified</literal> (date of last modification),
688 <literal>length</literal> (file size in bytes),
689 <literal>directory</literal> (whether the file is a directory),
690 <literal>canonicalPath</literal> (the canonical path)
691 and <literal>exists</literal>.
692 </listitem>
693 <listitem>
694 <classname>javax.management.ObjectName</classname> is
695 converted into a JSON object with the single key
696 <literal>objectName</literal>.
697 </listitem>
698 <listitem>
699 <classname>java.net.URL</classname> becomes a JSON
700 object with the key <literal>url</literal> containing
701 the URL as String.
702 </listitem>
703 <listitem>
704 <classname>java.util.Date</classname> is represented in
705 an ISO-8601 format. When used with a path
706 <literal>time</literal> the milliseconds since 1.1.1970
707 00:00 UTC are returned.
708 </listitem>
709 <listitem>
710 <classname>org.w3c.dom.Element</classname> is translated
711 into a JSON object with the properties
712 <literal>name</literal>, <literal>value</literal> and
713 <literal>hasChildNodes</literal>.
714 </listitem>
715 <listitem>
716 <classname>java.math.BigInteger</classname> becomes a JSON
717 object with the key <literal>bigint</literal> containing
718 the big integer value as String.
719 </listitem>
720 </itemizedlist>
721 </para>
722 <para>
723 Primitive and simple types (like String) are
724 directly converted into their string presentation. All
725 objects not covered by the list above are serialized in JSON
726 objects, where the keys are the public bean properties of
727 the object and the values are serialized (recursively) as
728 described.
729 </para>
730 <para>
731 <classname>TabularData</classname> serialization depends on
732 the type of the index. It is serialized into one or multiple
733 nested JSON objects where the keys are derived from its
734 <methodname>TabularType.indexNames()</methodname>. If there is
735 a single valued index with a simple type (i.e. an instance of
736 <classname>javax.management.openmbean.SimpleType</classname>),
737 the index's value is the key and a
738 <classname>TabularData</classname>'s row (which in turn is a
739 <classname>CompositeData</classname>) is a map. With multi
740 valued, simple typed, keys, the map is nested (first level:
741 first index's value, second level: second index's value and
742 so on). For the serialization of
743 <classname>TabularData</classname> resulting from a
744 <classname><ulink
745 url="http://download.oracle.com/javase/6/docs/api/javax/management/MXBean.html">MXBean</ulink></classname>
746 translation for maps, see <xref
747 linkend="serialization-mxbean"/>. If any of the declared
748 index keys of a <classname>TabularData</classname> is a
749 complex type (i.e. not a <classname>SimpleType</classname>),
750 then this simple serialization into maps of maps is not
751 possible anymore, since for JSON, map keys must be simple
752 types. In this case, a more generic serialization is used in
753 which case an JSON object with two keys is returned:
754 <constant>indexNames</constant> is an array with the
755 <classname>TabularData</classname>'s indexes as names and
756 <constant>values</constant> is the array containing the
757 values as JSON object with the corresponding rows as values
758 (including the indexes).
759 </para>
760 <para>
761 For example if there is a single valued key
762 <constant>key</constant>, then the returned JSON looks like
763 </para>
764 <programlisting><![CDATA[
765 {
766 "mykey1" : { "key" : "mkey1", "item" : "value1", .... }
767 "mykey2" : { "key" : "mkey2", "item" : "value2", .... }
768 ....
769 }]]></programlisting>
770 <para>
771 For multi valued keys of simple open types
772 (i.e. <methodname>TabularType.getIndexNames()</methodname>)
773 is a list with more than one element but all of them are
774 simple types), the returned JSON structure looks like (index
775 names here are <constant>key</constant> and
776 <constant>innerkey</constant>):
777 </para>
778 <programlisting><![CDATA[
779 {
780 "mykey1" : {
781 "myinner1" : { "key" : "mkey1", "innerkey" : "myinner1", "item" : "value1", .... }
782 "myinner2" : { "key" : "mkey1", "innerkey" : "myinner2", "item" : "value1", .... }
783 ....
784 },
785 "mykey2" : {
786 "second1" : { "key" : "mkey2", "innerkey" : "second1", "item" : "value1", .... }
787 "second2" : { "key" : "mkey2", "innerkey" : "second2", "item" : "value1", .... }
788 ....
789 }
790 ....
791 }]]></programlisting>
792 <para>
793 If keys are used, which themselves are complex objects (like
794 <classname>CompositeData</classname>), this hierarchical map structure can not be
795 used. In this case an object with two keys is returned:
796 "<constant>indexNames</constant>" holds the name of the key
797 index and "<constant>values</constant>" is an array of all
798 rows which are represented as JSON objects:
799 </para>
800 <programlisting><![CDATA[
801 {
802 "indexNames" : [ "key", "innerkey" ],
803 "values" : [
804 { "key" : "mykey1", "innerkey" : { "name" : "a", "number" : 4711 }, "item" : "value1", .... },
805 { "key" : "mykey2", "innerkey" : { "name" : "b", "number" : 815 }, "item" : "value2", .... },
806 ...
807 ]
808 }]]></programlisting>
809 <para>
810 Beside this special behaviour for
811 <classname>TabularData</classname>, serialization can be
812 influenced by certain processing parameters given with the
813 request (see <xref
814 linkend="processing-parameters"/>). I.e. the recursive
815 process of JSON serialization can be stopped when the data
816 set gets too large. Self and other circular references are
817 detected, too. If this happen, special values indicate the
818 truncation of the generated JSON object.
819 </para>
820 <variablelist>
821 <varlistentry>
822 <term><constant>[this]</constant></term>
823 <listitem>
824 <para>
825 This label is used when a property contains a self reference
826 </para>
827 </listitem>
828 </varlistentry>
829 <varlistentry>
830 <term><constant>[Depth limit .... ]</constant></term>
831 <listitem>
832 <para>
833 When a depth limit is used or the hard depth limit
834 is exceeded, this label contains a string
835 representation of the next object one level deeper.
836 (see <xref linkend="processing-parameters"/>,
837 parameter <literal>maxDepth</literal>)
838 </para>
839 </listitem>
840 </varlistentry>
841 <varlistentry>
842 <term><constant>[Reference .... ]</constant></term>
843 <listitem>
844 <para>
845 If during the traversal an object is visited a second time, this label is
846 used in order to break the cycle.
847 </para>
848 </listitem>
849 </varlistentry>
850 <varlistentry>
851 <term><constant>[Object limit exceeded]</constant></term>
852 <listitem>
853 <para>
854 The total limit of object has been exceeded and hence
855 the object are not deserialized further. (see <xref
856 linkend="processing-parameters"/>, parameters
857 <literal>maxCollectionSize</literal> and
858 <literal>maxObjects</literal>)
859 </para>
860 </listitem>
861 </varlistentry>
862 </variablelist>
863 </section>
864
865 <section id="serialization-request">
866 <title>Request parameter serialization</title>
867 <para>
868 Serialization in the upstream direction (i.e. when sending
869 values for <constant>write</constant> operations or arguments
870 for <constant>exec</constant> operations) differs from
871 from the object serializaton as used as response values
872 which is described in <xref
873 linkend="serialization-response"/>. Not all types are
874 supported for upstream serialization <footnote id="upstream-serialization-comment">
875 <para>
876 Conversion from a typed system to an untyped
877 representation is obviously much easier than vice
878 versa. Please note, that Jolokia does not replace a full
879 blown JSON object serialization framework like
880 Jackson. Nor does it use one in order to keep the agent small
881 and simple with a low dependency count.
882 </para>
883 </footnote>
884 and the capabilities differ also for POST and GET requests.
885 <literal>GET</literal> upstream serialization is limited to
886 basic types and simple arrays. POST requests on the other
887 support a much large set of types, including the
888 serialization of <constant>Map</constant>s,
889 <constant>List</constant>s and all <ulink
890 url="http://download.oracle.com/javase/6/docs/api/javax/management/openmbean/OpenType.html">Open
891 Types</ulink>.
892 </para>
893 <section>
894 <title>GET request values</title>
895 <para>
896 Since parameters get encoded in the URL for GET request,
897 only the following types can used for values and arguments
898 in <constant>write</constant> and
899 <constant>exec</constant> requests:
900 <itemizedlist>
901 <listitem>String</listitem>
902 <listitem>Integer / int</listitem>
903 <listitem>Long / long</listitem>
904 <listitem>Byte / byte</listitem>
905 <listitem>Short / short</listitem>
906 <listitem>Float / float</listitem>
907 <listitem>Double / double</listitem>
908 <listitem>BigDecimal / BigInteger</listitem>
909 <listitem>char</listitem>
910 <listitem>Boolean / boolean</listitem>
911 <listitem>Date</listitem>
912 <listitem>URL</listitem>
913 <listitem>Enums (whose type is accessible to the agent,
914 see below)</listitem>
915 <listitem>Any type, that is accessible to the agent, and
916 has a public constructor with one String parameter</listitem>
917 </itemizedlist>
918 </para>
919 <para>
920 The serialized value is simply the string representation
921 of those types. Dates can be set either by an long value
922 (epoch milliseconds) or with a string value (ISO-8601
923 format). Arrays of the given types are serialized as a
924 comma separated list.
925 </para>
926 <note>
927 The array support is somewhat limited since it makes a
928 native split on commas. It does not yet take into account
929 any quoting or escaping. For a much safer way to transport
930 arrays to the agent, please consider using POST requests.
931 </note>
932 <para>
933 Certain <emphasis>tag values</emphasis> are used to mark special
934 values. A <constant>null</constant> value has to be
935 serialized as <literal>[null]</literal>, an empty String
936 as <literal>""</literal>. Tag values are not required for
937 POST requests.
938 </para>
939 </section>
940 <section>
941 <title>POST request values</title>
942 <para>
943 POST request take advantage of the JSON type of the value
944 transfered. These are basic types for numbers
945 (<literal>42</literal> or <literal>23.5</literal>),
946 booleans (<literal>true</literal> or
947 <literal>false</literal>) and strings
948 (<literal>"habanero"</literal>). Also, JSON knows about
949 <constant>null</constant> values so no special 'tags' like
950 for GET requests are not required. Since JSON supports
951 intrinsically key-value maps and array types, these can be
952 used directly, too. I.e. if the JMX operation to execute
953 takes a <constant>Map</constant> argument, the argument
954 can be given as a JSON object. Be aware, however, that JSON
955 maps (objects) only support strings as keys.
956 </para>
957 <para>
958 The agent knows how to convert an JSON array to Java
959 Arrays (of a basic type) or Lists, depending on the
960 requirement as dictated by the MBeans operation or
961 attribute signature. Numbers in JSON are always transfered
962 as long or double values and are as well tried to fit
963 to the MBean's signature. In case of an overflow
964 (e.g. when trying to treat a long with a too large value
965 as int), an exception is raised.
966 </para>
967 <para>
968 Enums can be converted from their canonical name. The
969 prerequisite for this is, that the Jolokia agent has
970 access to the Enum's class. This is true for all Enums
971 shipped with the JDK (like
972 <classname>TimeUnit</classname>). Custom enums can not be
973 used for upstream serialization by default since the
974 Jolokia Agent is not able to contruct an instance of it
975 because of missing type information.
976 </para>
977 <para>
978 Upstream serialization also supports <ulink
979 url="http://download.oracle.com/javase/6/docs/api/javax/management/openmbean/OpenType.html">OpenType</ulink>s.
980 If the signature of JMX exec operation or the value type
981 of a JMX attribute is a <classname>OpenType</classname>,
982 they are serialized as follows:
983 </para>
984 <itemizedlist>
985 <listitem>
986 <classname>SimpleType</classname>s are extracted from
987 their corresponding JSON type.
988 </listitem>
989 <listitem>
990 <classname>ArrayType</classname> is extracted from a
991 <classname>JSONArray</classname> where the elements are
992 serialized recursively with this algorithms. Only
993 <classname>ArrayType</classname>s with element type
994 <classname>CompositeType</classname> or
995 <classname>SimpleType</classname> are supported.
996 </listitem>
997 <listitem>
998 <classname>CompositeType</classname> is extracted
999 recursively from a <classname>JSONObject</classname>
1000 where there the string keys must fit to the
1001 <classname>CompositeType</classname>'s item names and
1002 the values must be serializable as open types.
1003 </listitem>
1004 <listitem>
1005 <para>
1006 <classname>TabularType</classname> is converted from
1007 <classname>JSONObject</classname>. If it is single index
1008 (i.e. has only one single index name), the
1009 <classname>JSONObject</classname> must have the index
1010 values as string keys and the map values are other
1011 <classname>JSONObject</classname>s representing the row
1012 data. For <classname>TabularType</classname>s with more
1013 than one index name, the incoming
1014 <classname>JSONObjecct</classname> must be a nested
1015 object with each index as an additional
1016 layer. E.g. the following JSON object works for
1017 a <classname>TabularType</classname> with the two
1018 index names <literal>lastname</literal> and
1019 <literal>firstname</literal>, which are both of type <classname>SimpleType.STRING</classname>:
1020 </para>
1021 <programlisting language="perl"><![CDATA[{
1022 "Mann": {
1023 "Thomas": {
1024 "lastname": "Mann",
1025 "firstname": "Thomas",
1026 "birth": 1875
1027 },
1028 "Heinrich": {
1029 "lastname": "Mann",
1030 "firstname": "Heinrich",
1031 "birth": 1871
1032 }
1033 }
1034 }]]></programlisting>
1035 <para>
1036 <classname>TabularType</classname> used by the MXBean
1037 framework for serialization of Maps are translated
1038 directly from maps. More details are explained in the
1039 next section <xref linkend="serialization-mxbean"/>.
1040 </para>
1041 <para>
1042 <classname>TabularType</classname>s with index values
1043 which are <emphasis>not</emphasis> of type
1044 <classname>SimpleType</classname> can be used, too.
1045 However, in this case this simple nested map structure
1046 is not enough, since keys of complex types
1047 (e.g. <classname>CompositeData</classname> types) can
1048 not be represented as JSON map keys. Instead, a
1049 generic representation for
1050 <classname>TabularTypes</classname> must be used. A
1051 JSON object with two keys:
1052 <constant>indexNames</constant> with an array of the
1053 index names and <constant>values</constant> with an
1054 array of rows containing objects which include the
1055 index values plus any other values of the rows'
1056 <classname>CompositeType</classname>. E.g. if in the
1057 example above, the index would have been an
1058 <classname>User</classname> with first- and lastname,
1059 the JSON structure for setting the <classname>TabularData</classname> should
1060 look like
1061 </para>
1062 <programlisting language="perl"><![CDATA[{
1063 "indexNames": [ "user" ],
1064 "values" : [
1065 { "user" : { "lastname": "Mann", "firstname": "Thomas" }, "birth": 1875 },
1066 { "user" : { "lastname": "Mann", "firstname": "Heinrich" }, "birth": 1871 }
1067 ]
1068 }]]></programlisting>
1069 </listitem>
1070 </itemizedlist>
1071
1072 </section>
1073 </section>
1074
1075 <section id="serialization-mxbean">
1076 <title>Jolokia and MXBeans</title>
1077 <para>
1078 The <ulink url="http://download.oracle.com/javase/6/docs/api/javax/management/MXBean.html">MXBean Framework</ulink> is availale in
1079 the JRE since version 6 and allows for easy creation and
1080 registration of own MBeans. MXBeans are some what the
1081 successor for standard MBeans and support an annotation driven
1082 as well as a naming convention driven programming model. The
1083 most important difference to standard MBeans it the
1084 restriction of MXBean to reference only open types.
1085 </para>
1086 <para>
1087 Although to the outside only open types are exposed by the
1088 MXBean framework, MXBean themselves can use more complex
1089 data types. The framework will translate forth and back
1090 between the custom and open types according to certain rules
1091 as declared in the MXBean <ulink
1092 url="http://download.oracle.com/javase/6/docs/api/javax/management/MXBean.html">specification</ulink>.
1093 Most of the translations to open types fits naturally to
1094 Jolokia's serialization, except for the translation of Map.
1095 </para>
1096 <para>
1097 When an MXBean references a map, the MXBean framework
1098 translates this map into a
1099 <classname>TabularData</classname> with a fixed internal
1100 structure, i.e. with an index <literal>key</literal> and
1101 rows with keys <literal>key</literal> and
1102 <literal>value</literal>. This leads directly to a JSON
1103 representation which is quite artificial. E.g a map with
1104 two keys <literal>kind</literal> and
1105 <literal>hotness</literal> will be converted by the MXBean
1106 framework to a TabularData object which in turn would be
1107 translated by Jolokia to the following JSON struture
1108 </para>
1109 <programlisting><![CDATA[{
1110 "kind" : {
1111 "key": "kind",
1112 "value": "Habanero"
1113 },
1114 "hotness" : {
1115 "key": "hotness",
1116 "value": 10
1117 }
1118 }]]></programlisting>
1119 <para>
1120 Since this representation of a simple map is unnecessarily
1121 complicated, Jolokia treats <classname>TabularData</classname>
1122 of this kind (i.e. one index <literal>key</literal> and rows
1123 with properties <literal>key</literal> and
1124 <literal>value</literal>) specially in order to translate it
1125 back (and forth) to
1126 </para>
1127 <programlisting><![CDATA[{
1128 "kind" : "Habanero",
1129 "hotness" : 10
1130 }]]></programlisting>
1131 </section>
1132
1133 </section>
1134
1135 <section id="history">
1136 <title>Tracking historical values</title>
1137 <para>
1138 The Jolokia agents are able to keep requested values in memory
1139 along with a timestamp. If history tracking is switched on,
1140 then the agent will put the list of historical values specific
1141 for this request into the response. History tracking is
1142 toggled by an MBean operation on a Jolokia-owned MBean (see
1143 <xref linkend="mbeans"/>). This has to be done individually for each
1144 attribute or JMX operation to be tracked.
1145 </para>
1146 <para>
1147 A <constant>history</constant> entry is contained in every
1148 response for which history tracking was switched on. A certain
1149 JMX operation on an Jolokia specific MBean has to be executed
1150 to turn history tracking on for a specific attribute or
1151 operation. See <xref linkend="mbeans"/> for details.The
1152 <constant>history</constant> property of the JSON response
1153 contains an array of json objects which have two attributes:
1154 <constant>value</constant> containing the historical value
1155 (which can be as complex as any other value) and
1156 <constant>timestamp</constant> indicating the time when this
1157 value was current (as measured by the server). <xref
1158 linkend="response-example"/> has an example of a response
1159 containing historical values.
1160 </para>
1161 <para>
1162 For multi attribute read requests, the history entry in the
1163 response is a JSON object instead of an array, where this
1164 object's attributes are the request's attribute names and the
1165 values are the history arrays as described above.
1166 </para>
1167 </section>
1168
1169 <section id="protocol-proxy">
1170 <title>Proxy requests</title>
1171 <para>
1172 For proxy requests, POST must be used as HTTP method so that
1173 the given JSON request can contain an extra section for the
1174 target which should be finally reached via this proxy
1175 request. A typical proxy request looks like
1176 </para>
1177 <programlisting><![CDATA[
1178 {
1179 "type" : "read",
1180 "mbean" : "java.lang:type=Memory",
1181 "attribute" : "HeapMemoryUsage",
1182 "target" : {
1183 "url" : "service:jmx:rmi:///jndi/rmi://targethost:9999/jmxrmi",
1184 "user" : "jolokia",
1185 "password" : "s!cr!t"
1186 }
1187 }]]></programlisting>
1188 <para>
1189 <literal>url</literal> within the <literal>target</literal>
1190 section is a JSR-160 service URL for the target server
1191 reachable from within the proxy agent. <literal>user</literal>
1192 and <literal>password</literal> are optional credentials used
1193 for the JSR-160 communication.
1194 </para>
1195 </section>
1196
1197 <section id="discovery">
1198 <title>Agent Discovery</title>
1199 <para>
1200 Jolokia agents are able to respond to certain multicast
1201 requests in order to allow clients to detect automatically
1202 connection parameters. The agent URL to expose can be either
1203 manually configured for an agent or an agent can try to detect
1204 its URL automatically. This works fine for the JVM agent, for
1205 the WAR agent it only works after the first HTTP request has
1206 been processed by the agent. Due to limitations of the Servlet
1207 API the agent servlet has no clue about its own URL until this
1208 first request, which contains the request URL. Of course, the
1209 URL obtained that way can be bogus as well, since the agent
1210 might hide behind a proxy, too. So, if in doubt you should
1211 configure the agent URL from outside to allow external clients
1212 to be discovered. The configuration options for enabling
1213 multicast requests are described in the <xref
1214 linkend="agent-jvm-config">JVM</xref> and <xref
1215 linkend="agent-war-init-params">WAR</xref> agent configuration
1216 sections.
1217 </para>
1218 <para>
1219 A agent which is enabled for multicast discovery will only
1220 respond to a multicast request if the <xref
1221 linkend="security-policy">restrictor</xref> allows
1222 connections from the source IP. Otherwise a multicast request
1223 will be simply ignored. For example, if you have configured
1224 your agent to only allow request from a central monitoring
1225 host, only this host is able to detect these agents. Beside
1226 security aspects it wouldn't make sense to expose the URL as
1227 any other host is not able to connect anyways.
1228 </para>
1229 <para>
1230 Starting with version 1.2.0 the Jolokia JVM agent has this
1231 discovery feature enabled by default which can be switched off
1232 via <literal>--discoveryEnabled=true</literal> command line parameter or the
1233 corresponding configuration option. For the WAR agent and OSGi
1234 agents this feature is switched off by default since auto
1235 detection doesn't work always. It can be enabled with the init
1236 parameter <literal>discoveryEnabled</literal> (in which case the auto discovery
1237 described above is enabled) or better with <literal>discoveryAgentUrl</literal>
1238 with the URL. Alternatively, a system property can be used
1239 with a <literal>jolokia.</literal> prefix
1240 (e.g. <literal>jolokia.discoveryEnabled</literal>). More on the configuration
1241 options can be found in the agent's configuration sections.
1242 </para>
1243 <para>
1244 For sending a multicast request discovery message, an UDP
1245 message should be send to the address <literal>239.192.48.84</literal>, port
1246 <literal>24884</literal> which contains a JSON message encoded in UTF-8 with
1247 the following format
1248 </para>
1249 <programlisting><![CDATA[
1250 {
1251 "type": "query"
1252 }]]></programlisting>
1253 <para>
1254 Any agent enabled for discovery will respond to requester on the same socket with an answer which looks like
1255 </para>
1256 <programlisting><![CDATA[
1257 {
1258 "type": "response",
1259 "agent_description" : "Atlantis Tomcat",
1260 "agent_id" : "10.9.11.18-58613-81b087d-servlet",
1261 "url": "http://10.9.11.25:8778/jolokia",
1262 "server_vendor" : "Apache",
1263 "server_product" : "Tomcat",
1264 "server_version" : "7.0.35"
1265 }]]></programlisting>
1266 <para>
1267 The response itself is a JSON object and is restricted to 8192
1268 bytes maximum. The request type is either
1269 <constant>query</constant> or <constant>response</constant>. A
1270 <constant>query</constant> request is sent via multicast by any
1271 interested client and each agent responds with a response of
1272 type <constant>response</constant>. Query requests contain
1273 only the type as property. Responses are sent back to the
1274 address and port of the sender of the query request.
1275 </para>
1276 <para>
1277 Please note, that IPv6 is currently not supported yet but likely
1278 in the future.
1279 </para>
1280 <table id="discovery-response">
1281 <title>Response properties</title>
1282 <thead>
1283 <tr>
1284 <td>Property</td>
1285 <td>Description</td>
1286 <td>Example</td>
1287 </tr>
1288 </thead>
1289 <tr>
1290 <td><constant>type</constant></td>
1291 <td>
1292 Request type, either <constant>query</constant> or
1293 <constant>response</constant>.
1294 </td>
1295 <td>
1296 <constant>query</constant> or <constant>response</constant>
1297 </td>
1298 </tr>
1299 <tr>
1300 <td><constant>agent_id</constant></td>
1301 <td>
1302 Each agent has a unique id which can be either provided
1303 during startup of the agent in form of a configuration
1304 parameter or being autodetected. If autodected, the id has
1305 several parts: The IP, the process id, hashcode of the agent
1306 and its type. This field will be always provided.
1307 </td>
1308 <td>
1309 10.9.11.87-23455-9184ef-osgi
1310 </td>
1311 </tr>
1312 <tr>
1313 <td><constant>agent_description</constant></td>
1314 <td>
1315 An optional description which can be used as a UI label if
1316 given.
1317 </td>
1318 <td>
1319 ServiceMix ESB
1320 </td>
1321 </tr>
1322 <tr>
1323 <td><constant>url</constant></td>
1324 <td>
1325 The URL how this agent can be contacted. This URL is
1326 typically autodetected. For the JVM agent it should be
1327 highly accurate. For the servlet based agents, it
1328 depends. If configured via an initialisation parameter this
1329 URL is used. If autodetected it is taken from the first HTTP
1330 request processed by the servlet. Hence no URL is available
1331 until this first request was processed. This property might
1332 be empty.
1333 </td>
1334 <td>
1335 http://10.9.11.87:8080/jolokia
1336 </td>
1337 </tr>
1338 <tr>
1339 <td><constant>secured</constant></td>
1340 <td>
1341 Whether the agent was configured for authentication or not.
1342 </td>
1343 <td>
1344 false
1345 </td>
1346 </tr>
1347 <tr>
1348 <td><constant>server_vendor</constant></td>
1349 <td>
1350 The vendor of the container the agent is running in. This
1351 field is included if it could be automatically detected.
1352 </td>
1353 <td>
1354 Apache
1355 </td>
1356 </tr>
1357 <tr>
1358 <td><constant>server_product</constant></td>
1359 <td>
1360 The container product if detected
1361 </td>
1362 <td>
1363 tomcat
1364 </td>
1365 </tr>
1366 <tr>
1367 <td><constant>server_version</constant></td>
1368 <td>
1369 The container's version (if detected)
1370 </td>
1371 <td>
1372 7.0.50
1373 </td>
1374 </tr>
1375 </table>
1376
1377 </section>
1378
1379 <section id="versions">
1380 <title>Jolokia protocol versions</title>
1381 <para>
1382 The protocol definition is versioned. It contains of a major
1383 and minor version. Changes in the minor version are backward
1384 compatible to other protocol with the same major
1385 version. Major version changes incorporate possibly backwards
1386 incompatible changes. This document describes the Jolokia
1387 protocol version <emphasis role="bold">7.2</emphasis>.
1388 </para>
1389 <variablelist>
1390 <varlistentry>
1391 <term><emphasis role="bold">7.2</emphasis> (since 1.2.2)</term>
1392 <listitem>
1393 <para>
1394 Pathes can now be used with wildcards
1395 (<literal>*</literal>) which match everything in the
1396 selected level. They are especially useful with pattern
1397 read requests.
1398 </para>
1399 </listitem>
1400 </varlistentry>
1401 <varlistentry>
1402 <term><emphasis role="bold">7.1</emphasis> (since 1.2.0)</term>
1403 <listitem>
1404 <para>
1405 The <literal>version</literal> command returns now the configuration
1406 global information as well with the key <code>config</code> in the
1407 returned value.
1408 </para>
1409 </listitem>
1410 </varlistentry>
1411 <varlistentry>
1412 <term><emphasis role="bold">7.0</emphasis> (since 1.1.0)</term>
1413 <listitem>
1414 <para>
1415 The <emphasis
1416 role="bold"><constant>maxDepth</constant></emphasis>
1417 parameter (either as processing parameter or as
1418 configuration value) is now 1 based. I.e. 0 means always
1419 "no limit" (be careful with this, though), 1 implies
1420 truncating the value on the first level for READ
1421 request. This was already true for LIST requests and the
1422 other limit values (maxCollectionSize and maxObjects) so
1423 this change is used in order to harmonize the overall
1424 behaviour with regard to limits.
1425 </para>
1426 </listitem>
1427 <listitem>
1428 <para>
1429 Enums are now serialized downstream (full support)
1430 and upstream (for type accessible to the agent).
1431 </para>
1432 </listitem>
1433 <listitem>
1434 <para>
1435 New query parameter options
1436 <constant>serializeException</constant> (for setting an
1437 <constant>error_value</constant> in case of an
1438 exception), <constant>canonicalNaming</constant>
1439 (influences how object names are returned) and
1440 <constant>includeStackTrace</constant> (for adding or
1441 omitting stacktraces in error responses).
1442 </para>
1443 </listitem>
1444 </varlistentry>
1445 <varlistentry>
1446 <term><emphasis role="bold">6.1</emphasis> (since 1.0.2)</term>
1447 <listitem>
1448 <para>
1449 Error responses contain now the original request as
1450 well, for single and bulk requests.
1451 </para>
1452 </listitem>
1453 </varlistentry>
1454 <varlistentry>
1455 <term><emphasis role="bold">6.0</emphasis> (since 1.0.0)</term>
1456 <listitem>
1457 <para>
1458 Escaping has been changed from <literal>/-/</literal> to
1459 <literal>!/</literal>. This affects GET Urls and
1460 <emphasis> inner paths</emphasis>.
1461 </para>
1462 </listitem>
1463 </varlistentry>
1464 <varlistentry>
1465 <term><emphasis role="bold">5.0</emphasis> (since 0.95)</term>
1466 <listitem>
1467 <para>
1468 <classname>javax.management.openmbean.TabularData</classname>
1469 is serialized differently when generating the
1470 response. In fact, the serialization as an array in
1471 the former versions of this protocol is not correct,
1472 since <classname>TabularData</classname> in fact is a
1473 hash and not a list. It is now generated as map (or
1474 multiple maps), depending on the declared
1475 <emphasis>index</emphasis>. Also, access via path is now
1476 an access via key, not a list index. For the special
1477 case of MXBean map serialization, where the returned
1478 <classname>TabularData</classname> has a fixed format
1479 (i.e. with <literal>key</literal> and
1480 <literal>value</literal> columns), the
1481 <classname>TabularData</classname> is transformed to an
1482 appropriate map..
1483 </para>
1484 </listitem>
1485 <listitem>
1486 <para>
1487 Removed JSON property <literal>modified</literal> from
1488 the serialized JSON representation of a File return
1489 value since it duplicated the
1490 <literal>lastModified</literal> property on the same
1491 object.
1492 </para>
1493 </listitem>
1494 </varlistentry>
1495 <varlistentry>
1496 <term><emphasis role="bold">4.3</emphasis> (since 0.91)</term>
1497 <listitem>
1498 <para>
1499 The <literal>list</literal> operation supports a
1500 <literal>maxDepth</literal> option for truncating the
1501 answer.
1502 </para>
1503 </listitem>
1504 </varlistentry>
1505 <varlistentry>
1506 <term><emphasis role="bold">4.2</emphasis> (since 0.90)</term>
1507 <listitem>
1508 <para>
1509 Response values are returned in the native JSON
1510 datatype, not always as strings as in previous versions
1511 of this protocol. Parameter serialization for writing
1512 attribute values or for arguments in exec operations has
1513 been enhanced for POST requests, which are now
1514 represented as native JSON types and not in a string
1515 representation as before. GET requests still use a
1516 simplified string representation.
1517 </para>
1518 </listitem>
1519 </varlistentry>
1520 <varlistentry>
1521 <term><emphasis role="bold">4.0</emphasis> (17.10.2010)</term>
1522 <listitem>
1523 <para>This is the initial version for Jolokia. Versions below 4 are
1524 implemented by jmx4perl</para>
1525 </listitem>
1526 </varlistentry>
1527 </variablelist>
1528 </section>
1529 </chapter>