001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.api.management.mbean;
018
019import java.util.List;
020import java.util.Map;
021import java.util.Properties;
022import java.util.concurrent.TimeUnit;
023
024import javax.management.openmbean.TabularData;
025
026import org.apache.camel.api.management.ManagedAttribute;
027import org.apache.camel.api.management.ManagedOperation;
028
029public interface ManagedCamelContextMBean extends ManagedPerformanceCounterMBean {
030
031    @ManagedAttribute(description = "Camel ID")
032    String getCamelId();
033
034    @ManagedAttribute(description = "Camel ManagementName")
035    String getManagementName();
036
037    @ManagedAttribute(description = "Camel Version")
038    String getCamelVersion();
039
040    @ManagedAttribute(description = "Camel State")
041    String getState();
042
043    @ManagedAttribute(description = "Uptime [human readable text]")
044    String getUptime();
045
046    @ManagedAttribute(description = "Uptime [milliseconds]")
047    long getUptimeMillis();
048
049    @ManagedAttribute(description = "Camel Management StatisticsLevel")
050    String getManagementStatisticsLevel();
051
052    @ManagedAttribute(description = "Camel Global Options")
053    Map<String, String> getGlobalOptions();
054
055    @ManagedAttribute(description = "ClassResolver class name")
056    String getClassResolver();
057
058    @ManagedAttribute(description = "PackageScanClassResolver class name")
059    String getPackageScanClassResolver();
060
061    @ManagedAttribute(description = "ApplicationContext class name")
062    String getApplicationContextClassName();
063
064    @ManagedAttribute(description = "HeadersMapFactory class name")
065    String getHeadersMapFactoryClassName();
066
067    /**
068     * Gets the value of a CamelContext global option
069     *
070     * @param key the global option key
071     * @return the global option value
072     * @throws Exception when an error occurred
073     */
074    @ManagedOperation(description = "Gets the value of a Camel global option")
075    String getGlobalOption(String key) throws Exception;
076
077    /**
078     * Sets the value of a CamelContext property name
079     *
080     * @param key the global option key
081     * @param value the global option value
082     * @throws Exception when an error occurred
083     */
084    @ManagedOperation(description = "Sets the value of a Camel global option")
085    void setGlobalOption(String key, String value) throws Exception;
086
087    @ManagedAttribute(description = "Tracing")
088    Boolean getTracing();
089
090    @ManagedAttribute(description = "Tracing")
091    void setTracing(Boolean tracing);
092
093    @ManagedAttribute(description = "Total number of routes")
094    Integer getTotalRoutes();
095
096    @ManagedAttribute(description = "Current number of started routes")
097    Integer getStartedRoutes();
098
099    @ManagedAttribute(description = "Shutdown timeout")
100    void setTimeout(long timeout);
101
102    @ManagedAttribute(description = "Shutdown timeout")
103    long getTimeout();
104
105    @ManagedAttribute(description = "Shutdown timeout time unit")
106    void setTimeUnit(TimeUnit timeUnit);
107
108    @ManagedAttribute(description = "Shutdown timeout time unit")
109    TimeUnit getTimeUnit();
110
111    @ManagedAttribute(description = "Whether to force shutdown now when a timeout occurred")
112    void setShutdownNowOnTimeout(boolean shutdownNowOnTimeout);
113
114    @ManagedAttribute(description = "Whether to force shutdown now when a timeout occurred")
115    boolean isShutdownNowOnTimeout();
116
117    @ManagedAttribute(description = "Average load over the last minute")
118    String getLoad01();
119
120    @ManagedAttribute(description = "Average load over the last five minutes")
121    String getLoad05();
122
123    @ManagedAttribute(description = "Average load over the last fifteen minutes")
124    String getLoad15();
125
126    @ManagedAttribute(description = "Whether breadcrumbs is in use")
127    boolean isUseBreadcrumb();
128
129    @ManagedAttribute(description = "Whether allowing access to the original message during routing")
130    boolean isAllowUseOriginalMessage();
131
132    @ManagedAttribute(description = "Whether message history is enabled")
133    boolean isMessageHistory();
134
135    @ManagedAttribute(description = "Whether security mask for Logging is enabled")
136    boolean isLogMask();
137
138    @ManagedAttribute(description = "Whether MDC logging is supported")
139    boolean isUseMDCLogging();
140
141    @ManagedAttribute(description = "Whether Message DataType is enabled")
142    boolean isUseDataType();
143
144    @ManagedOperation(description = "Start Camel")
145    void start() throws Exception;
146
147    @ManagedOperation(description = "Stop Camel (shutdown)")
148    void stop() throws Exception;
149
150    @ManagedOperation(description = "Restart Camel (stop and then start)")
151    void restart() throws Exception;
152
153    @ManagedOperation(description = "Suspend Camel")
154    void suspend() throws Exception;
155
156    @ManagedOperation(description = "Resume Camel")
157    void resume() throws Exception;
158
159    @ManagedOperation(description = "Starts all the routes which currently is not started")
160    void startAllRoutes() throws Exception;
161
162    @ManagedOperation(description = "Whether its possible to send to the endpoint (eg the endpoint has a producer)")
163    boolean canSendToEndpoint(String endpointUri);
164
165    @ManagedOperation(description = "Send body (in only)")
166    void sendBody(String endpointUri, Object body) throws Exception;
167
168    @ManagedOperation(description = "Send body (String type) (in only)")
169    void sendStringBody(String endpointUri, String body) throws Exception;
170
171    @ManagedOperation(description = "Send body and headers (in only)")
172    void sendBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws Exception;
173
174    @ManagedOperation(description = "Request body (in out)")
175    Object requestBody(String endpointUri, Object body) throws Exception;
176
177    @ManagedOperation(description = "Request body (String type) (in out)")
178    Object requestStringBody(String endpointUri, String body) throws Exception;
179
180    @ManagedOperation(description = "Request body and headers (in out)")
181    Object requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws Exception;
182
183    @ManagedOperation(description = "Dumps the rests as XML")
184    String dumpRestsAsXml() throws Exception;
185
186    @ManagedOperation(description = "Dumps the rests as XML")
187    String dumpRestsAsXml(boolean resolvePlaceholders) throws Exception;
188
189    @ManagedOperation(description = "Dumps the routes as XML")
190    String dumpRoutesAsXml() throws Exception;
191
192    @ManagedOperation(description = "Dumps the routes as XML")
193    String dumpRoutesAsXml(boolean resolvePlaceholders) throws Exception;
194
195    @ManagedOperation(description = "Adds or updates existing routes from XML")
196    void addOrUpdateRoutesFromXml(String xml) throws Exception;
197
198    @ManagedOperation(description = "Adds or updates existing routes from XML")
199    void addOrUpdateRoutesFromXml(String xml, boolean urlDecode) throws Exception;
200
201    @ManagedOperation(description = "Dumps the CamelContext and routes stats as XML")
202    String dumpRoutesStatsAsXml(boolean fullStats, boolean includeProcessors) throws Exception;
203
204    @ManagedOperation(description = "Dumps the routes coverage as XML")
205    String dumpRoutesCoverageAsXml() throws Exception;
206
207    /**
208     * Creates the endpoint by the given uri
209     *
210     * @param uri uri of endpoint to create
211     * @return <tt>true</tt> if a new endpoint was created, <tt>false</tt> if the endpoint already existed
212     * @throws Exception is thrown if error occurred
213     */
214    @ManagedOperation(description = "Creates the endpoint by the given URI")
215    boolean createEndpoint(String uri) throws Exception;
216
217    /**
218     * Removes the endpoint by the given pattern
219     *
220     * @param pattern the pattern
221     * @return number of endpoints removed
222     * @throws Exception is thrown if error occurred
223     * @see org.apache.camel.CamelContext#removeEndpoints(String)
224     */
225    @ManagedOperation(description = "Removes endpoints by the given pattern")
226    int removeEndpoints(String pattern) throws Exception;
227
228    /**
229     * Find information about all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}.
230     *
231     * @return a map with the component name, and value with component details.
232     * @throws Exception is thrown if error occurred
233     */
234    @ManagedOperation(description = "Find all Camel components available in the classpath")
235    Map<String, Properties> findComponents() throws Exception;
236
237    /**
238     * Find information about all the EIPs from camel-core.
239     *
240     * @return a map with node id, and value with EIP details.
241     * @throws Exception is thrown if error occurred
242     */
243    @ManagedOperation(description = "Find all Camel EIPs from camel-core")
244    Map<String, Properties> findEips() throws Exception;
245
246    /**
247     * Find the names of all the EIPs from camel-core.
248     *
249     * @return a list with the names of the camel EIPs
250     * @throws Exception is thrown if error occurred
251     */
252    @ManagedOperation(description = "Find all Camel EIP names from camel-core")
253    List<String> findEipNames() throws Exception;
254
255    /**
256     * Find the names of all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}.
257     *
258     * @return a list with the names of the camel components
259     * @throws Exception is thrown if error occurred
260     */
261    @ManagedOperation(description = "Find all Camel components names available in the classpath")
262    List<String> findComponentNames() throws Exception;
263
264    /**
265     * Find information about all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}.
266     *
267     * @return a list with the data
268     * @throws Exception is thrown if error occurred
269     */
270    @ManagedOperation(description = "List all Camel components available in the classpath")
271    TabularData listComponents() throws Exception;
272
273    /**
274     * Find information about all the EIPs from camel-core.
275     *
276     * @return a list with the data
277     * @throws Exception is thrown if error occurred
278     */
279    @ManagedOperation(description = "List all Camel EIPs from camel-core")
280    TabularData listEips() throws Exception;
281
282    /**
283     * Returns the JSON schema representation with information about the component and the endpoint parameters it supports
284     *
285     * @param componentName the name of the component to lookup
286     * @throws Exception is thrown if error occurred
287     */
288    @ManagedOperation(description = "Returns the JSON schema representation of the endpoint parameters for the given component name")
289    @Deprecated
290    String componentParameterJsonSchema(String componentName) throws Exception;
291
292    /**
293     * Returns the JSON schema representation with information about the data format and the parameters it supports
294     *
295     * @param dataFormatName the name of the data format to lookup
296     * @throws Exception is thrown if error occurred
297     */
298    @ManagedOperation(description = "Returns the JSON schema representation of the data format parameters for the given data format name")
299    String dataFormatParameterJsonSchema(String dataFormatName) throws Exception;
300
301    /**
302     * Returns the JSON schema representation with information about the language and the parameters it supports
303     *
304     * @param languageName the name of the language to lookup
305     * @throws Exception is thrown if error occurred
306     */
307    @ManagedOperation(description = "Returns the JSON schema representation of the language parameters for the given language name")
308    String languageParameterJsonSchema(String languageName) throws Exception;
309
310    /**
311     * Returns the JSON schema representation with information about the EIP and the parameters it supports
312     *
313     * @param eipName the name of the EIP to lookup
314     * @throws Exception is thrown if error occurred
315     */
316    @ManagedOperation(description = "Returns the JSON schema representation of the EIP parameters for the given EIP name")
317    String eipParameterJsonSchema(String eipName) throws Exception;
318
319    /**
320     * Returns a JSON schema representation of the EIP parameters for the given EIP by its id.
321     *
322     * @param nameOrId the name of the EIP ({@link org.apache.camel.NamedNode#getShortName()} or a node id to refer to a specific node from the routes.
323     * @param includeAllOptions whether to include non configured options also (eg default options)
324     * @return the json or <tt>null</tt> if the eipName or the id was not found
325     */
326    @ManagedOperation(description = "Returns a JSON schema representation of the EIP parameters for the given EIP by its id")
327    String explainEipJson(String nameOrId, boolean includeAllOptions);
328
329    /**
330     * Returns a JSON schema representation of the component parameters (not endpoint parameters) for the given component by its id.
331     *
332     * @param componentName the id of the component
333     * @param includeAllOptions whether to include non configured options also (eg default options)
334     */
335    @ManagedOperation(description = " Returns a JSON schema representation of the component parameters for the given component by its id")
336    String explainComponentJson(String componentName, boolean includeAllOptions) throws Exception;
337
338    /**
339     * Returns a JSON schema representation of the endpoint parameters for the given endpoint uri
340     *
341     * @param uri the endpoint uri
342     * @param includeAllOptions whether to include non configured options also (eg default options)
343     */
344    @ManagedOperation(description = " Returns a JSON schema representation of the endpoint parameters for the given endpoint uri")
345    String explainEndpointJson(String uri, boolean includeAllOptions) throws Exception;
346
347    /**
348     * Resets all the performance counters.
349     *
350     * @param includeRoutes  whether to reset all routes as well.
351     * @throws Exception is thrown if error occurred
352     */
353    @ManagedOperation(description = "Reset counters")
354    void reset(boolean includeRoutes) throws Exception;
355
356    @ManagedOperation(description = "Returns the JSON representation of all the static and dynamic endpoints defined in all the routes")
357    String createRouteStaticEndpointJson();
358
359    @ManagedOperation(description = "Returns the JSON representation of all the static endpoints (and possible dynamic) defined in all the routes")
360    String createRouteStaticEndpointJson(boolean includeDynamic);
361
362}