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.io.IOException;
020import java.util.List;
021import java.util.Map;
022import java.util.Properties;
023import java.util.concurrent.TimeUnit;
024
025import javax.management.openmbean.TabularData;
026
027import org.apache.camel.api.management.ManagedAttribute;
028import org.apache.camel.api.management.ManagedOperation;
029
030public interface ManagedCamelContextMBean extends ManagedPerformanceCounterMBean {
031
032    @ManagedAttribute(description = "Camel ID")
033    String getCamelId();
034
035    @ManagedAttribute(description = "Camel ManagementName")
036    String getManagementName();
037
038    @ManagedAttribute(description = "Camel Version")
039    String getCamelVersion();
040
041    @ManagedAttribute(description = "Camel State")
042    String getState();
043
044    @ManagedAttribute(description = "Uptime [human readable text]")
045    String getUptime();
046
047    @ManagedAttribute(description = "Uptime [milliseconds]")
048    long getUptimeMillis();
049
050    @ManagedAttribute(description = "Camel Management StatisticsLevel")
051    String getManagementStatisticsLevel();
052
053    @Deprecated
054    @ManagedAttribute(description = "Camel Properties")
055    Map<String, String> getProperties();
056
057    @ManagedAttribute(description = "Camel Global Options")
058    Map<String, String> getGlobalOptions();
059
060    @ManagedAttribute(description = "ClassResolver class name")
061    String getClassResolver();
062
063    @ManagedAttribute(description = "PackageScanClassResolver class name")
064    String getPackageScanClassResolver();
065
066    @ManagedAttribute(description = "ApplicationContext class name")
067    String getApplicationContextClassName();
068
069    @ManagedAttribute(description = "HeadersMapFactory class name")
070    String getHeadersMapFactoryClassName();
071
072    @Deprecated
073    @ManagedOperation(description = "Gets the value of a Camel global option")
074    String getProperty(String key) throws Exception;
075
076    /**
077     * Gets the value of a CamelContext global option
078     *
079     * @param key the global option key
080     * @return the global option value
081     * @throws Exception when an error occurred
082     */
083    @ManagedOperation(description = "Gets the value of a Camel global option")
084    String getGlobalOption(String key) throws Exception;
085
086    @Deprecated
087    @ManagedOperation(description = "Sets the value of a Camel global option")
088    void setProperty(String key, String value) throws Exception;
089
090    /**
091     * Sets the value of a CamelContext property name
092     *
093     * @param key the global option key
094     * @param value the global option value
095     * @throws Exception when an error occurred
096     */
097    @ManagedOperation(description = "Sets the value of a Camel global option")
098    void setGlobalOption(String key, String value) throws Exception;
099
100    @ManagedAttribute(description = "Tracing")
101    Boolean getTracing();
102
103    @ManagedAttribute(description = "Tracing")
104    void setTracing(Boolean tracing);
105
106    /**
107     * @deprecated use {@link #getExchangesInflight()}
108     */
109    @ManagedAttribute(description = "Current number of inflight Exchanges")
110    @Deprecated
111    Integer getInflightExchanges();
112
113    @ManagedAttribute(description = "Total number of routes")
114    Integer getTotalRoutes();
115
116    @ManagedAttribute(description = "Current number of started routes")
117    Integer getStartedRoutes();
118
119    @ManagedAttribute(description = "Shutdown timeout")
120    void setTimeout(long timeout);
121
122    @ManagedAttribute(description = "Shutdown timeout")
123    long getTimeout();
124
125    @ManagedAttribute(description = "Shutdown timeout time unit")
126    void setTimeUnit(TimeUnit timeUnit);
127
128    @ManagedAttribute(description = "Shutdown timeout time unit")
129    TimeUnit getTimeUnit();
130
131    @ManagedAttribute(description = "Whether to force shutdown now when a timeout occurred")
132    void setShutdownNowOnTimeout(boolean shutdownNowOnTimeout);
133
134    @ManagedAttribute(description = "Whether to force shutdown now when a timeout occurred")
135    boolean isShutdownNowOnTimeout();
136
137    @ManagedAttribute(description = "Average load over the last minute")
138    String getLoad01();
139
140    @ManagedAttribute(description = "Average load over the last five minutes")
141    String getLoad05();
142
143    @ManagedAttribute(description = "Average load over the last fifteen minutes")
144    String getLoad15();
145
146    @ManagedAttribute(description = "Whether breadcrumbs is in use")
147    boolean isUseBreadcrumb();
148
149    @ManagedAttribute(description = "Whether allowing access to the original message during routing")
150    boolean isAllowUseOriginalMessage();
151
152    @ManagedAttribute(description = "Whether message history is enabled")
153    boolean isMessageHistory();
154
155    @ManagedAttribute(description = "Whether security mask for Logging is enabled")
156    boolean isLogMask();
157
158    @ManagedAttribute(description = "Whether MDC logging is supported")
159    boolean isUseMDCLogging();
160
161    @ManagedAttribute(description = "Whether Message DataType is enabled")
162    boolean isUseDataType();
163
164    @ManagedOperation(description = "Start Camel")
165    void start() throws Exception;
166
167    @ManagedOperation(description = "Stop Camel (shutdown)")
168    void stop() throws Exception;
169
170    @ManagedOperation(description = "Restart Camel (stop and then start)")
171    void restart() throws Exception;
172
173    @ManagedOperation(description = "Suspend Camel")
174    void suspend() throws Exception;
175
176    @ManagedOperation(description = "Resume Camel")
177    void resume() throws Exception;
178
179    @ManagedOperation(description = "Starts all the routes which currently is not started")
180    void startAllRoutes() throws Exception;
181
182    @ManagedOperation(description = "Whether its possible to send to the endpoint (eg the endpoint has a producer)")
183    boolean canSendToEndpoint(String endpointUri);
184
185    @ManagedOperation(description = "Send body (in only)")
186    void sendBody(String endpointUri, Object body) throws Exception;
187
188    @ManagedOperation(description = "Send body (String type) (in only)")
189    void sendStringBody(String endpointUri, String body) throws Exception;
190
191    @ManagedOperation(description = "Send body and headers (in only)")
192    void sendBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws Exception;
193
194    @ManagedOperation(description = "Request body (in out)")
195    Object requestBody(String endpointUri, Object body) throws Exception;
196
197    @ManagedOperation(description = "Request body (String type) (in out)")
198    Object requestStringBody(String endpointUri, String body) throws Exception;
199
200    @ManagedOperation(description = "Request body and headers (in out)")
201    Object requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws Exception;
202
203    @ManagedOperation(description = "Dumps the rests as XML")
204    String dumpRestsAsXml() throws Exception;
205
206    @ManagedOperation(description = "Dumps the rests as XML")
207    String dumpRestsAsXml(boolean resolvePlaceholders) throws Exception;
208
209    @ManagedOperation(description = "Dumps the routes as XML")
210    String dumpRoutesAsXml() throws Exception;
211
212    @ManagedOperation(description = "Dumps the routes as XML")
213    String dumpRoutesAsXml(boolean resolvePlaceholders) throws Exception;
214
215    @ManagedOperation(description = "Adds or updates existing routes from XML")
216    void addOrUpdateRoutesFromXml(String xml) throws Exception;
217
218    @ManagedOperation(description = "Adds or updates existing routes from XML")
219    void addOrUpdateRoutesFromXml(String xml, boolean urlDecode) throws Exception;
220
221    @ManagedOperation(description = "Dumps the CamelContext and routes stats as XML")
222    String dumpRoutesStatsAsXml(boolean fullStats, boolean includeProcessors) throws Exception;
223
224    @ManagedOperation(description = "Dumps the routes coverage as XML")
225    String dumpRoutesCoverageAsXml() throws Exception;
226
227    /**
228     * Creates the endpoint by the given uri
229     *
230     * @param uri uri of endpoint to create
231     * @return <tt>true</tt> if a new endpoint was created, <tt>false</tt> if the endpoint already existed
232     * @throws Exception is thrown if error occurred
233     */
234    @ManagedOperation(description = "Creates the endpoint by the given URI")
235    boolean createEndpoint(String uri) throws Exception;
236
237    /**
238     * Removes the endpoint by the given pattern
239     *
240     * @param pattern the pattern
241     * @return number of endpoints removed
242     * @throws Exception is thrown if error occurred
243     * @see org.apache.camel.CamelContext#removeEndpoints(String)
244     */
245    @ManagedOperation(description = "Removes endpoints by the given pattern")
246    int removeEndpoints(String pattern) throws Exception;
247
248    /**
249     * Find information about all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}.
250     *
251     * @return a map with the component name, and value with component details.
252     * @throws Exception is thrown if error occurred
253     */
254    @ManagedOperation(description = "Find all Camel components available in the classpath")
255    Map<String, Properties> findComponents() throws Exception;
256
257    /**
258     * Find information about all the EIPs from camel-core.
259     *
260     * @return a map with node id, and value with EIP details.
261     * @throws Exception is thrown if error occurred
262     */
263    @ManagedOperation(description = "Find all Camel EIPs from camel-core")
264    Map<String, Properties> findEips() throws Exception;
265
266    /**
267     * Find the names of all the EIPs from camel-core.
268     *
269     * @return a list with the names of the camel EIPs
270     * @throws Exception is thrown if error occurred
271     */
272    @ManagedOperation(description = "Find all Camel EIP names from camel-core")
273    List<String> findEipNames() throws Exception;
274
275    /**
276     * Find the names of all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}.
277     *
278     * @return a list with the names of the camel components
279     * @throws Exception is thrown if error occurred
280     */
281    @ManagedOperation(description = "Find all Camel components names available in the classpath")
282    List<String> findComponentNames() throws Exception;
283
284    /**
285     * Find information about all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}.
286     *
287     * @return a list with the data
288     * @throws Exception is thrown if error occurred
289     */
290    @ManagedOperation(description = "List all Camel components available in the classpath")
291    TabularData listComponents() throws Exception;
292
293    /**
294     * Find information about all the EIPs from camel-core.
295     *
296     * @return a list with the data
297     * @throws Exception is thrown if error occurred
298     */
299    @ManagedOperation(description = "List all Camel EIPs from camel-core")
300    TabularData listEips() throws Exception;
301
302    /**
303     * Returns the JSON schema representation with information about the component and the endpoint parameters it supports
304     *
305     * @param componentName the name of the component to lookup
306     * @throws Exception is thrown if error occurred
307     */
308    @ManagedOperation(description = "Returns the JSON schema representation of the endpoint parameters for the given component name")
309    @Deprecated
310    String componentParameterJsonSchema(String componentName) throws Exception;
311
312    /**
313     * Returns the JSON schema representation with information about the data format and the parameters it supports
314     *
315     * @param dataFormatName the name of the data format to lookup
316     * @throws Exception is thrown if error occurred
317     */
318    @ManagedOperation(description = "Returns the JSON schema representation of the data format parameters for the given data format name")
319    String dataFormatParameterJsonSchema(String dataFormatName) throws Exception;
320
321    /**
322     * Returns the JSON schema representation with information about the language and the parameters it supports
323     *
324     * @param languageName the name of the language to lookup
325     * @throws Exception is thrown if error occurred
326     */
327    @ManagedOperation(description = "Returns the JSON schema representation of the language parameters for the given language name")
328    String languageParameterJsonSchema(String languageName) throws Exception;
329
330    /**
331     * Returns the JSON schema representation with information about the EIP and the parameters it supports
332     *
333     * @param eipName the name of the EIP to lookup
334     * @throws Exception is thrown if error occurred
335     */
336    @ManagedOperation(description = "Returns the JSON schema representation of the EIP parameters for the given EIP name")
337    String eipParameterJsonSchema(String eipName) throws Exception;
338
339    /**
340     * Returns a JSON schema representation of the EIP parameters for the given EIP by its id.
341     *
342     * @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.
343     * @param includeAllOptions whether to include non configured options also (eg default options)
344     * @return the json or <tt>null</tt> if the eipName or the id was not found
345     */
346    @ManagedOperation(description = "Returns a JSON schema representation of the EIP parameters for the given EIP by its id")
347    String explainEipJson(String nameOrId, boolean includeAllOptions);
348
349    /**
350     * Returns a JSON schema representation of the component parameters (not endpoint parameters) for the given component by its id.
351     *
352     * @param componentName the id of the component
353     * @param includeAllOptions whether to include non configured options also (eg default options)
354     */
355    @ManagedOperation(description = " Returns a JSON schema representation of the component parameters for the given component by its id")
356    String explainComponentJson(String componentName, boolean includeAllOptions) throws Exception;
357
358    /**
359     * Returns a JSON schema representation of the endpoint parameters for the given endpoint uri
360     *
361     * @param uri the endpoint uri
362     * @param includeAllOptions whether to include non configured options also (eg default options)
363     */
364    @ManagedOperation(description = " Returns a JSON schema representation of the endpoint parameters for the given endpoint uri")
365    String explainEndpointJson(String uri, boolean includeAllOptions) throws Exception;
366
367    /**
368     * Resets all the performance counters.
369     *
370     * @param includeRoutes  whether to reset all routes as well.
371     * @throws Exception is thrown if error occurred
372     */
373    @ManagedOperation(description = "Reset counters")
374    void reset(boolean includeRoutes) throws Exception;
375
376    /**
377     * Helper method for tooling which returns the completion list of the endpoint path
378     * from the given endpoint name, properties and current path expression.
379     * <p/>
380     * For example if using the file endpoint, this should complete a list of files (rather like bash completion)
381     * or for an ActiveMQ component this should complete the list of queues or topics.
382     *
383     * @param componentName  the component name
384     * @param endpointParameters  parameters of the endpoint
385     * @param completionText  the entered text which we want to have completion suggestions for
386     * @throws Exception is thrown if error occurred
387     */
388    @ManagedOperation(description = "Returns the list of available endpoint paths for the given component name, endpoint properties and completion text")
389    @Deprecated
390    List<String> completeEndpointPath(String componentName, Map<String, Object> endpointParameters, String completionText) throws Exception;
391
392    /**
393     * Returns the HTML documentation for the given camel component
394     *
395     * @param componentName  the component name
396     * @deprecated use camel-catalog instead
397     */
398    @ManagedOperation(description = "Returns the HTML documentation for the given camel component")
399    @Deprecated
400    String getComponentDocumentation(String componentName) throws IOException;
401
402    @ManagedOperation(description = "Returns the JSON representation of all the static and dynamic endpoints defined in all the routes")
403    String createRouteStaticEndpointJson();
404
405    @ManagedOperation(description = "Returns the JSON representation of all the static endpoints (and possible dynamic) defined in all the routes")
406    String createRouteStaticEndpointJson(boolean includeDynamic);
407
408}