Debian Codegraph @

src/docbkx/protocol/exec.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 <section id="exec">
19 <title>Executing JMX operations (exec)</title>
20 <para>
21 Beside attribute provides a way for the execution of exposed JMX
22 operations with optional arguments. The same as for writing
23 attributes, Jolokia must be able to serialize the arguments. See
24 <xref linkend="serialization"/> for details. Execution of
25 overloaded methods is supported. The JMX specifications recommends
26 to avoid overloaded methods when exposing them via JMX, though.
27 </para>
28 <section id="get-exec">
29 <title>GET exec request</title>
30 <para>
31 The format of an GET exec request is
32 <synopsis><![CDATA[<base url>/exec/<mbean name>/<operation name>/<arg1>/<arg2>/....]]></synopsis>
33 </para>
34 <table>
35 <title>GET Exec Request</title>
36 <thead>
37 <tr>
38 <td>Part</td>
39 <td>Description</td>
40 <td>Example</td>
41 </tr>
42 </thead>
43 <tr>
44 <td><literal>&lt;mbean name&gt;</literal></td>
45 <td>MBean's ObjectName</td>
46 <td><literal>java.lang:type=Threading</literal></td>
47 </tr>
48 <tr>
49 <td><literal>&lt;operation name&gt;</literal></td>
50 <td>
51 Name of the operation to execute. If this is an overloaded method,
52 it is mandatory to provide a method signature as
53 well. A signature consist the fully qualified argument class
54 names or native types, separated by commas and enclosed with
55 parentheses. For calling a non-argument overloaded method use <literal>()</literal>
56 as signature.
57 </td>
58 <td>
59 <literal>loadUsers(java.lang.String,int)</literal>
60 </td>
61 </tr>
62 <tr>
63 <td><literal>&lt;arg1&gt;</literal>, <literal>&lt;arg2&gt;</literal>, ...</td>
64 <td>
65 String representation for the arguments required to execute this
66 operation. Only certain data types can be used here as
67 described in <xref linkend="serialization-request"/>.
68 </td>
69 <td><literal>"true","true"</literal></td>
70 </tr>
71 </table>
72
73 <para>
74 The following request will trigger a garbage collection:
75 <informalexample>
76 <literallayout class="monospaced">http://localhost:8080/jolokia/exec/java.lang:type=Memory/gc</literallayout>
77 </informalexample>
78 </para>
79 </section>
80
81 <section id="post-exec">
82 <title>POST exec request</title>
83
84 <table>
85 <title>POST Exec Request</title>
86 <thead>
87 <tr>
88 <td>Key</td>
89 <td>Description</td>
90 <td>Example</td>
91 </tr>
92 </thead>
93 <tr>
94 <td><constant>type</constant></td>
95 <td><emphasis role="bold">exec</emphasis></td>
96 <td/>
97 </tr>
98 <tr>
99 <td><constant>mbean</constant></td>
100 <td>MBean's ObjectName</td>
101 <td><literal>java.lang:type=Threading</literal></td>
102 </tr>
103 <tr>
104 <td><constant>operation</constant></td>
105 <td>The operation to execute, optionally with a signature as
106 described above.
107 </td>
108 <td><literal>dumpAllThreads</literal></td>
109 </tr>
110 <tr>
111 <td><constant>arguments</constant></td>
112 <td>
113 An array of arguments for invoking this operation. The value must be serializable as described in
114 <xref linkend="serialization-request"/>.
115 </td>
116 <td><literal>[true,true]</literal></td>
117 </tr>
118 </table>
119 <para>
120 The following request dumps all threads (along with locked
121 monitors and locked synchronizers, thats what the boolean
122 arguments are for):
123 </para>
124 <programlisting><![CDATA[
125 {
126 "type":"EXEC",
127 "mbean":"java.lang:type=Threading",
128 "operation":"dumpAllThreads",
129 "arguments":[true,true]
130 }]]></programlisting>
131
132 </section>
133
134 <section id="response-exec">
135 <title>Exec response</title>
136 <para>
137 For an <constant>exec</constant> operation, the response
138 contains the return value of the
139 operation. <constant>null</constant> is returned if either the
140 operation returns a null value or the operation is declared as
141 void. A typical response for an URL like
142 <synopsis><![CDATA[http://localhost:8080/jolokia/exec/java.util.logging:type=Logging/setLoggerLevel/global/INFO]]></synopsis>
143 looks like
144 </para>
145 <programlisting><![CDATA[
146 {
147 "value":null,
148 "status":200,
149 "request": {
150 "type":"exec",
151 "mbean":"java.util.logging:type=Logging",
152 "operation":"setLoggerLevel",
153 "arguments":["global","INFO"]
154 }
155 }
156
157 ]]></programlisting>
158 <para>
159 The return value get serialized as described in <xref linkend="serialization"/>.
160 </para>
161 </section>
162 </section>