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 CamelContext and routes and steps stats as XML")
205    String dumpStepStatsAsXml(boolean fullStats) throws Exception;
206
207    @ManagedOperation(description = "Dumps the routes coverage as XML")
208    String dumpRoutesCoverageAsXml() throws Exception;
209
210    /**
211     * Creates the endpoint by the given uri
212     *
213     * @param uri uri of endpoint to create
214     * @return <tt>true</tt> if a new endpoint was created, <tt>false</tt> if the endpoint already existed
215     * @throws Exception is thrown if error occurred
216     */
217    @ManagedOperation(description = "Creates the endpoint by the given URI")
218    boolean createEndpoint(String uri) throws Exception;
219
220    /**
221     * Removes the endpoint by the given pattern
222     *
223     * @param pattern the pattern
224     * @return number of endpoints removed
225     * @throws Exception is thrown if error occurred
226     * @see org.apache.camel.CamelContext#removeEndpoints(String)
227     */
228    @ManagedOperation(description = "Removes endpoints by the given pattern")
229    int removeEndpoints(String pattern) throws Exception;
230
231    /**
232     * Find information about all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}.
233     *
234     * @return a map with the component name, and value with component details.
235     * @throws Exception is thrown if error occurred
236     */
237    @ManagedOperation(description = "Find all Camel components available in the classpath")
238    Map<String, Properties> findComponents() throws Exception;
239
240    /**
241     * Find information about all the EIPs from camel-core.
242     *
243     * @return a map with node id, and value with EIP details.
244     * @throws Exception is thrown if error occurred
245     */
246    @ManagedOperation(description = "Find all Camel EIPs from camel-core")
247    Map<String, Properties> findEips() throws Exception;
248
249    /**
250     * Find the names of all the EIPs from camel-core.
251     *
252     * @return a list with the names of the camel EIPs
253     * @throws Exception is thrown if error occurred
254     */
255    @ManagedOperation(description = "Find all Camel EIP names from camel-core")
256    List<String> findEipNames() throws Exception;
257
258    /**
259     * Find the names of all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}.
260     *
261     * @return a list with the names of the camel components
262     * @throws Exception is thrown if error occurred
263     */
264    @ManagedOperation(description = "Find all Camel components names available in the classpath")
265    List<String> findComponentNames() throws Exception;
266
267    /**
268     * Find information about all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}.
269     *
270     * @return a list with the data
271     * @throws Exception is thrown if error occurred
272     */
273    @ManagedOperation(description = "List all Camel components available in the classpath")
274    TabularData listComponents() throws Exception;
275
276    /**
277     * Find information about all the EIPs from camel-core.
278     *
279     * @return a list with the data
280     * @throws Exception is thrown if error occurred
281     */
282    @ManagedOperation(description = "List all Camel EIPs from camel-core")
283    TabularData listEips() throws Exception;
284
285    /**
286     * Returns the JSON schema representation with information about the component and the endpoint parameters it supports
287     *
288     * @param componentName the name of the component to lookup
289     * @throws Exception is thrown if error occurred
290     */
291    @ManagedOperation(description = "Returns the JSON schema representation of the endpoint parameters for the given component name")
292    @Deprecated
293    String componentParameterJsonSchema(String componentName) throws Exception;
294
295    /**
296     * Returns the JSON schema representation with information about the data format and the parameters it supports
297     *
298     * @param dataFormatName the name of the data format to lookup
299     * @throws Exception is thrown if error occurred
300     */
301    @ManagedOperation(description = "Returns the JSON schema representation of the data format parameters for the given data format name")
302    String dataFormatParameterJsonSchema(String dataFormatName) throws Exception;
303
304    /**
305     * Returns the JSON schema representation with information about the language and the parameters it supports
306     *
307     * @param languageName the name of the language to lookup
308     * @throws Exception is thrown if error occurred
309     */
310    @ManagedOperation(description = "Returns the JSON schema representation of the language parameters for the given language name")
311    String languageParameterJsonSchema(String languageName) throws Exception;
312
313    /**
314     * Returns the JSON schema representation with information about the EIP and the parameters it supports
315     *
316     * @param eipName the name of the EIP to lookup
317     * @throws Exception is thrown if error occurred
318     */
319    @ManagedOperation(description = "Returns the JSON schema representation of the EIP parameters for the given EIP name")
320    String eipParameterJsonSchema(String eipName) throws Exception;
321
322    /**
323     * Returns a JSON schema representation of the EIP parameters for the given EIP by its id.
324     *
325     * @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.
326     * @param includeAllOptions whether to include non configured options also (eg default options)
327     * @return the json or <tt>null</tt> if the eipName or the id was not found
328     */
329    @ManagedOperation(description = "Returns a JSON schema representation of the EIP parameters for the given EIP by its id")
330    String explainEipJson(String nameOrId, boolean includeAllOptions);
331
332    /**
333     * Returns a JSON schema representation of the component parameters (not endpoint parameters) for the given component by its id.
334     *
335     * @param componentName the id of the component
336     * @param includeAllOptions whether to include non configured options also (eg default options)
337     */
338    @ManagedOperation(description = " Returns a JSON schema representation of the component parameters for the given component by its id")
339    String explainComponentJson(String componentName, boolean includeAllOptions) throws Exception;
340
341    /**
342     * Returns a JSON schema representation of the endpoint parameters for the given endpoint uri
343     *
344     * @param uri the endpoint uri
345     * @param includeAllOptions whether to include non configured options also (eg default options)
346     */
347    @ManagedOperation(description = " Returns a JSON schema representation of the endpoint parameters for the given endpoint uri")
348    String explainEndpointJson(String uri, boolean includeAllOptions) throws Exception;
349
350    /**
351     * Resets all the performance counters.
352     *
353     * @param includeRoutes  whether to reset all routes as well.
354     * @throws Exception is thrown if error occurred
355     */
356    @ManagedOperation(description = "Reset counters")
357    void reset(boolean includeRoutes) throws Exception;
358
359    @ManagedOperation(description = "Returns the JSON representation of all the static and dynamic endpoints defined in all the routes")
360    String createRouteStaticEndpointJson();
361
362    @ManagedOperation(description = "Returns the JSON representation of all the static endpoints (and possible dynamic) defined in all the routes")
363    String createRouteStaticEndpointJson(boolean includeDynamic);
364
365}