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.Map;
020import java.util.Set;
021import java.util.concurrent.TimeUnit;
022
023import org.apache.camel.api.management.ManagedAttribute;
024import org.apache.camel.api.management.ManagedOperation;
025
026public interface ManagedCamelContextMBean extends ManagedPerformanceCounterMBean {
027
028    @ManagedAttribute(description = "Camel ID")
029    String getCamelId();
030
031    @ManagedAttribute(description = "Camel ManagementName")
032    String getManagementName();
033
034    @ManagedAttribute(description = "Camel Version")
035    String getCamelVersion();
036
037    @ManagedAttribute(description = "Camel State")
038    String getState();
039
040    @ManagedAttribute(description = "Uptime [human readable text]")
041    String getUptime();
042
043    @ManagedAttribute(description = "Uptime [milliseconds]")
044    long getUptimeMillis();
045
046    @ManagedAttribute(description = "Camel Management StatisticsLevel")
047    String getManagementStatisticsLevel();
048
049    @ManagedAttribute(description = "Camel Global Options")
050    Map<String, String> getGlobalOptions();
051
052    @ManagedAttribute(description = "ClassResolver class name")
053    String getClassResolver();
054
055    @ManagedAttribute(description = "PackageScanClassResolver class name")
056    String getPackageScanClassResolver();
057
058    @ManagedAttribute(description = "ApplicationContext class name")
059    String getApplicationContextClassName();
060
061    @ManagedAttribute(description = "HeadersMapFactory class name")
062    String getHeadersMapFactoryClassName();
063
064    /**
065     * Gets the value of a CamelContext global option
066     *
067     * @param  key       the global option key
068     * @return           the global option value
069     * @throws Exception when an error occurred
070     */
071    @ManagedOperation(description = "Gets the value of a Camel global option")
072    String getGlobalOption(String key) throws Exception;
073
074    /**
075     * Sets the value of a CamelContext property name
076     *
077     * @param  key       the global option key
078     * @param  value     the global option value
079     * @throws Exception when an error occurred
080     */
081    @ManagedOperation(description = "Sets the value of a Camel global option")
082    void setGlobalOption(String key, String value) throws Exception;
083
084    @ManagedAttribute(description = "Tracing")
085    Boolean getTracing();
086
087    @ManagedAttribute(description = "Tracing")
088    void setTracing(Boolean tracing);
089
090    @ManagedAttribute(description = "Total number of routes")
091    Integer getTotalRoutes();
092
093    @ManagedAttribute(description = "Current number of started routes")
094    Integer getStartedRoutes();
095
096    @ManagedAttribute(description = "Shutdown timeout")
097    void setTimeout(long timeout);
098
099    @ManagedAttribute(description = "Shutdown timeout")
100    long getTimeout();
101
102    @ManagedAttribute(description = "Shutdown timeout time unit")
103    void setTimeUnit(TimeUnit timeUnit);
104
105    @ManagedAttribute(description = "Shutdown timeout time unit")
106    TimeUnit getTimeUnit();
107
108    @ManagedAttribute(description = "Whether to force shutdown now when a timeout occurred")
109    void setShutdownNowOnTimeout(boolean shutdownNowOnTimeout);
110
111    @ManagedAttribute(description = "Whether to force shutdown now when a timeout occurred")
112    boolean isShutdownNowOnTimeout();
113
114    @ManagedAttribute(description = "Average load over the last minute")
115    String getLoad01();
116
117    @ManagedAttribute(description = "Average load over the last five minutes")
118    String getLoad05();
119
120    @ManagedAttribute(description = "Average load over the last fifteen minutes")
121    String getLoad15();
122
123    @ManagedAttribute(description = "Whether breadcrumbs is in use")
124    boolean isUseBreadcrumb();
125
126    @ManagedAttribute(description = "Whether allowing access to the original message during routing")
127    boolean isAllowUseOriginalMessage();
128
129    @ManagedAttribute(description = "Whether message history is enabled")
130    boolean isMessageHistory();
131
132    @ManagedAttribute(description = "Whether security mask for Logging is enabled")
133    boolean isLogMask();
134
135    @ManagedAttribute(description = "Whether MDC logging is supported")
136    boolean isUseMDCLogging();
137
138    @ManagedAttribute(description = "Whether Message DataType is enabled")
139    boolean isUseDataType();
140
141    @ManagedOperation(description = "Start Camel")
142    void start() throws Exception;
143
144    @ManagedOperation(description = "Stop Camel (shutdown)")
145    void stop() throws Exception;
146
147    @ManagedOperation(description = "Restart Camel (stop and then start)")
148    void restart() throws Exception;
149
150    @ManagedOperation(description = "Suspend Camel")
151    void suspend() throws Exception;
152
153    @ManagedOperation(description = "Resume Camel")
154    void resume() throws Exception;
155
156    @ManagedOperation(description = "Starts all the routes which currently is not started")
157    void startAllRoutes() throws Exception;
158
159    @ManagedOperation(description = "Whether its possible to send to the endpoint (eg the endpoint has a producer)")
160    boolean canSendToEndpoint(String endpointUri);
161
162    @ManagedOperation(description = "Send body (in only)")
163    void sendBody(String endpointUri, Object body) throws Exception;
164
165    @ManagedOperation(description = "Send body (String type) (in only)")
166    void sendStringBody(String endpointUri, String body) throws Exception;
167
168    @ManagedOperation(description = "Send body and headers (in only)")
169    void sendBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws Exception;
170
171    @ManagedOperation(description = "Request body (in out)")
172    Object requestBody(String endpointUri, Object body) throws Exception;
173
174    @ManagedOperation(description = "Request body (String type) (in out)")
175    Object requestStringBody(String endpointUri, String body) throws Exception;
176
177    @ManagedOperation(description = "Request body and headers (in out)")
178    Object requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws Exception;
179
180    @ManagedOperation(description = "Dumps the rests as XML")
181    String dumpRestsAsXml() throws Exception;
182
183    @ManagedOperation(description = "Dumps the rests as XML")
184    String dumpRestsAsXml(boolean resolvePlaceholders) throws Exception;
185
186    @ManagedOperation(description = "Dumps the routes as XML")
187    String dumpRoutesAsXml() throws Exception;
188
189    @ManagedOperation(description = "Dumps the routes as XML")
190    String dumpRoutesAsXml(boolean resolvePlaceholders) throws Exception;
191
192    @ManagedOperation(description = "Dumps the routes as XML")
193    String dumpRoutesAsXml(boolean resolvePlaceholders, boolean resolveDelegateEndpoints) throws Exception;
194
195    @ManagedOperation(description = "Dumps the CamelContext and routes stats as XML")
196    String dumpRoutesStatsAsXml(boolean fullStats, boolean includeProcessors) throws Exception;
197
198    @ManagedOperation(description = "Dumps the CamelContext and routes and steps stats as XML")
199    String dumpStepStatsAsXml(boolean fullStats) throws Exception;
200
201    @ManagedOperation(description = "Dumps the routes coverage as XML")
202    String dumpRoutesCoverageAsXml() throws Exception;
203
204    @ManagedOperation(description = "Dumps the route templates as XML")
205    String dumpRouteTemplatesAsXml() throws Exception;
206
207    @ManagedOperation(description = "Dumps all routes with mappings between node ids and their source location/line-number (currently only XML and YAML routes supported) as XML")
208    @Deprecated
209    String dumpRoutesSourceLocationsAsXml() throws Exception;
210
211    /**
212     * Creates the endpoint by the given uri
213     *
214     * @param  uri       uri of endpoint to create
215     * @return           <tt>true</tt> if a new endpoint was created, <tt>false</tt> if the endpoint already existed
216     * @throws Exception is thrown if error occurred
217     */
218    @ManagedOperation(description = "Creates the endpoint by the given URI")
219    boolean createEndpoint(String uri) throws Exception;
220
221    /**
222     * Removes the endpoint by the given pattern
223     *
224     * @param  pattern   the pattern
225     * @return           number of endpoints removed
226     * @throws Exception is thrown if error occurred
227     * @see              org.apache.camel.CamelContext#removeEndpoints(String)
228     */
229    @ManagedOperation(description = "Removes endpoints by the given pattern")
230    int removeEndpoints(String pattern) throws Exception;
231
232    /**
233     * Resets all the performance counters.
234     *
235     * @param  includeRoutes whether to reset all routes as well.
236     * @throws Exception     is thrown if error occurred
237     */
238    @ManagedOperation(description = "Reset counters")
239    void reset(boolean includeRoutes) throws Exception;
240
241    /**
242     * The names of the components currently registered
243     */
244    @ManagedOperation(description = "The names of the components currently registered")
245    Set<String> componentNames() throws Exception;
246
247    /**
248     * The names of the languages currently registered
249     */
250    @ManagedOperation(description = "The names of the languages currently registered")
251    Set<String> languageNames() throws Exception;
252
253    /**
254     * The names of the data formats currently registered
255     */
256    @ManagedOperation(description = "The names of the data formats currently registered")
257    Set<String> dataFormatNames() throws Exception;
258
259}