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