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") 044 String getUptime(); 045 046 @ManagedAttribute(description = "Camel Properties") 047 Map<String, String> getProperties(); 048 049 @ManagedAttribute(description = "ClassResolver class name") 050 String getClassResolver(); 051 052 @ManagedAttribute(description = "PackageScanClassResolver class name") 053 String getPackageScanClassResolver(); 054 055 @ManagedAttribute(description = "ApplicationContext class name") 056 String getApplicationContextClassName(); 057 058 /** 059 * Gets the value of a CamelContext property name 060 * 061 * @param name the name of the property 062 * @return String the value of the property 063 * @throws Exception is thrown if error occurred 064 */ 065 @ManagedOperation(description = "Get the value of a Camel property") 066 String getProperty(String name) throws Exception; 067 068 /** 069 * Sets the value of a CamelContext property name 070 * 071 * @param name the name of the property 072 * @param value the new value of the property 073 * @throws Exception is thrown if error occurred 074 */ 075 @ManagedOperation(description = "Set the value of a Camel property") 076 void setProperty(String name, String value) throws Exception; 077 078 @ManagedAttribute(description = "Tracing") 079 Boolean getTracing(); 080 081 @ManagedAttribute(description = "Tracing") 082 void setTracing(Boolean tracing); 083 084 /** 085 * @deprecated use {@link #getExchangesInflight()} 086 */ 087 @ManagedAttribute(description = "Current number of inflight Exchanges") 088 Integer getInflightExchanges(); 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 MDC logging is supported") 133 boolean isUseMDCLogging(); 134 135 @ManagedOperation(description = "Start Camel") 136 void start() throws Exception; 137 138 @ManagedOperation(description = "Stop Camel (shutdown)") 139 void stop() throws Exception; 140 141 @ManagedOperation(description = "Restart Camel (stop and then start)") 142 void restart() throws Exception; 143 144 @ManagedOperation(description = "Suspend Camel") 145 void suspend() throws Exception; 146 147 @ManagedOperation(description = "Resume Camel") 148 void resume() throws Exception; 149 150 @ManagedOperation(description = "Starts all the routes which currently is not started") 151 void startAllRoutes() throws Exception; 152 153 @ManagedOperation(description = "Whether its possible to send to the endpoint (eg the endpoint has a producer)") 154 boolean canSendToEndpoint(String endpointUri); 155 156 @ManagedOperation(description = "Send body (in only)") 157 void sendBody(String endpointUri, Object body) throws Exception; 158 159 @ManagedOperation(description = "Send body (String type) (in only)") 160 void sendStringBody(String endpointUri, String body) throws Exception; 161 162 @ManagedOperation(description = "Send body and headers (in only)") 163 void sendBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws Exception; 164 165 @ManagedOperation(description = "Request body (in out)") 166 Object requestBody(String endpointUri, Object body) throws Exception; 167 168 @ManagedOperation(description = "Request body (String type) (in out)") 169 Object requestStringBody(String endpointUri, String body) throws Exception; 170 171 @ManagedOperation(description = "Request body and headers (in out)") 172 Object requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws Exception; 173 174 @ManagedOperation(description = "Dumps the rests as XML") 175 String dumpRestsAsXml() throws Exception; 176 177 @ManagedOperation(description = "Dumps the routes as XML") 178 String dumpRoutesAsXml() throws Exception; 179 180 @ManagedOperation(description = "Adds or updates existing routes from XML") 181 void addOrUpdateRoutesFromXml(String xml) throws Exception; 182 183 @ManagedOperation(description = "Adds or updates existing routes from XML") 184 void addOrUpdateRoutesFromXml(String xml, boolean urlDecode) throws Exception; 185 186 @ManagedOperation(description = "Dumps the CamelContext and routes stats as XML") 187 String dumpRoutesStatsAsXml(boolean fullStats, boolean includeProcessors) throws Exception; 188 189 /** 190 * Creates the endpoint by the given uri 191 * 192 * @param uri uri of endpoint to create 193 * @return <tt>true</tt> if a new endpoint was created, <tt>false</tt> if the endpoint already existed 194 * @throws Exception is thrown if error occurred 195 */ 196 @ManagedOperation(description = "Creates the endpoint by the given URI") 197 boolean createEndpoint(String uri) throws Exception; 198 199 /** 200 * Removes the endpoint by the given pattern 201 * 202 * @param pattern the pattern 203 * @return number of endpoints removed 204 * @throws Exception is thrown if error occurred 205 * @see org.apache.camel.CamelContext#removeEndpoints(String) 206 */ 207 @ManagedOperation(description = "Removes endpoints by the given pattern") 208 int removeEndpoints(String pattern) throws Exception; 209 210 /** 211 * Find information about all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}. 212 * 213 * @return a map with the component name, and value with component details. 214 * @throws Exception is thrown if error occurred 215 */ 216 @ManagedOperation(description = "Find all Camel components available in the classpath") 217 Map<String, Properties> findComponents() throws Exception; 218 219 /** 220 * Find information about all the EIPs from camel-core. 221 * 222 * @return a map with node id, and value with EIP details. 223 * @throws Exception is thrown if error occurred 224 */ 225 @ManagedOperation(description = "Find all Camel EIPs from camel-core") 226 Map<String, Properties> findEips() throws Exception; 227 228 /** 229 * Find the names of all the EIPs from camel-core. 230 * 231 * @return a list with the names of the camel EIPs 232 * @throws Exception is thrown if error occurred 233 */ 234 @ManagedOperation(description = "Find all Camel EIP names from camel-core") 235 List<String> findEipNames() throws Exception; 236 237 /** 238 * Find the names of all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}. 239 * 240 * @return a list with the names of the camel components 241 * @throws Exception is thrown if error occurred 242 */ 243 @ManagedOperation(description = "Find all Camel components names available in the classpath") 244 List<String> findComponentNames() throws Exception; 245 246 /** 247 * Find information about all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}. 248 * 249 * @return a list with the data 250 * @throws Exception is thrown if error occurred 251 */ 252 @ManagedOperation(description = "List all Camel components available in the classpath") 253 TabularData listComponents() throws Exception; 254 255 /** 256 * Find information about all the EIPs from camel-core. 257 * 258 * @return a list with the data 259 * @throws Exception is thrown if error occurred 260 */ 261 @ManagedOperation(description = "List all Camel EIPs from camel-core") 262 TabularData listEips() throws Exception; 263 264 /** 265 * Returns the JSON schema representation with information about the component and the endpoint parameters it supports 266 * 267 * @param componentName the name of the component to lookup 268 * @throws Exception is thrown if error occurred 269 */ 270 @ManagedOperation(description = "Returns the JSON schema representation of the endpoint parameters for the given component name") 271 String componentParameterJsonSchema(String componentName) throws Exception; 272 273 /** 274 * Returns the JSON schema representation with information about the data format and the parameters it supports 275 * 276 * @param dataFormatName the name of the data format to lookup 277 * @throws Exception is thrown if error occurred 278 */ 279 @ManagedOperation(description = "Returns the JSON schema representation of the data format parameters for the given data format name") 280 String dataFormatParameterJsonSchema(String dataFormatName) throws Exception; 281 282 /** 283 * Returns the JSON schema representation with information about the language and the parameters it supports 284 * 285 * @param languageName the name of the language to lookup 286 * @throws Exception is thrown if error occurred 287 */ 288 @ManagedOperation(description = "Returns the JSON schema representation of the language parameters for the given language name") 289 String languageParameterJsonSchema(String languageName) throws Exception; 290 291 /** 292 * Returns the JSON schema representation with information about the EIP and the parameters it supports 293 * 294 * @param eipName the name of the EIP to lookup 295 * @throws Exception is thrown if error occurred 296 */ 297 @ManagedOperation(description = "Returns the JSON schema representation of the EIP parameters for the given EIP name") 298 String eipParameterJsonSchema(String eipName) throws Exception; 299 300 /** 301 * Returns a JSON schema representation of the EIP parameters for the given EIP by its id. 302 * 303 * @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. 304 * @param includeAllOptions whether to include non configured options also (eg default options) 305 * @return the json or <tt>null</tt> if the eipName or the id was not found 306 */ 307 @ManagedOperation(description = "Returns a JSON schema representation of the EIP parameters for the given EIP by its id") 308 String explainEipJson(String nameOrId, boolean includeAllOptions); 309 310 /** 311 * Returns a JSON schema representation of the component parameters (not endpoint parameters) for the given component by its id. 312 * 313 * @param componentName the id of the component 314 * @param includeAllOptions whether to include non configured options also (eg default options) 315 */ 316 @ManagedOperation(description = " Returns a JSON schema representation of the component parameters for the given component by its id") 317 String explainComponentJson(String componentName, boolean includeAllOptions) throws Exception; 318 319 /** 320 * Returns a JSON schema representation of the endpoint parameters for the given endpoint uri 321 * 322 * @param uri the endpoint uri 323 * @param includeAllOptions whether to include non configured options also (eg default options) 324 */ 325 @ManagedOperation(description = " Returns a JSON schema representation of the endpoint parameters for the given endpoint uri") 326 String explainEndpointJson(String uri, boolean includeAllOptions) throws Exception; 327 328 /** 329 * Resets all the performance counters. 330 * 331 * @param includeRoutes whether to reset all routes as well. 332 * @throws Exception is thrown if error occurred 333 */ 334 @ManagedOperation(description = "Reset counters") 335 void reset(boolean includeRoutes) throws Exception; 336 337 /** 338 * Helper method for tooling which returns the completion list of the endpoint path 339 * from the given endpoint name, properties and current path expression. 340 * <p/> 341 * For example if using the file endpoint, this should complete a list of files (rather like bash completion) 342 * or for an ActiveMQ component this should complete the list of queues or topics. 343 * 344 * @param componentName the component name 345 * @param endpointParameters parameters of the endpoint 346 * @param completionText the entered text which we want to have completion suggestions for 347 * @throws Exception is thrown if error occurred 348 */ 349 @ManagedOperation(description = "Returns the list of available endpoint paths for the given component name, endpoint properties and completion text") 350 List<String> completeEndpointPath(String componentName, Map<String, Object> endpointParameters, String completionText) throws Exception; 351 352 /** 353 * Returns the HTML documentation for the given camel component 354 * 355 * @param componentName the component name 356 */ 357 @ManagedOperation(description = "Returns the HTML documentation for the given camel component") 358 String getComponentDocumentation(String componentName) throws IOException; 359 360 @ManagedOperation(description = "Returns the JSON representation of all the static and dynamic endpoints defined in all the routes") 361 String createRouteStaticEndpointJson(); 362 363 @ManagedOperation(description = "Returns the JSON representation of all the static endpoints (and possible dynamic) defined in all the routes") 364 String createRouteStaticEndpointJson(boolean includeDynamic); 365 366}