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     */
017    package org.apache.camel.api.management.mbean;
018    
019    import java.io.IOException;
020    import java.util.List;
021    import java.util.Map;
022    import java.util.Properties;
023    import java.util.concurrent.TimeUnit;
024    
025    import org.apache.camel.api.management.ManagedAttribute;
026    import org.apache.camel.api.management.ManagedOperation;
027    
028    public interface ManagedCamelContextMBean extends ManagedPerformanceCounterMBean {
029    
030        @ManagedAttribute(description = "Camel ID")
031        String getCamelId();
032    
033        @ManagedAttribute(description = "Camel Management Name")
034        String getManagementName();
035    
036        @ManagedAttribute(description = "Camel Version")
037        String getCamelVersion();
038    
039        @ManagedAttribute(description = "Camel State")
040        String getState();
041    
042        @ManagedAttribute(description = "Uptime")
043        String getUptime();
044    
045        @ManagedAttribute(description = "Camel Properties")
046        Map<String, String> getProperties();
047    
048        @ManagedAttribute(description = "ClassResolver class name")
049        String getClassResolver();
050    
051        @ManagedAttribute(description = "PackageScanClassResolver class name")
052        String getPackageScanClassResolver();
053    
054        @ManagedAttribute(description = "ApplicationContext class name")
055        String getApplicationContextClassName();
056    
057        /**
058         * Gets the value of a CamelContext property name
059         *
060         * @param name the name of the property
061         * @return String the value of the property
062         * @throws Exception is thrown if error occurred
063         */
064        @ManagedOperation(description = "Get the value of a Camel property")
065        String getProperty(String name) throws Exception;
066        
067        /**
068         * Sets the value of a CamelContext property name
069         *
070         * @param name the name of the property
071         * @param value the new value of the property
072         * @throws Exception is thrown if error occurred
073         */
074        @ManagedOperation(description = "Set the value of a Camel property")
075        void setProperty(String name, String value) throws Exception;
076        
077        @ManagedAttribute(description = "Tracing")
078        Boolean getTracing();
079    
080        @ManagedAttribute(description = "Tracing")
081        void setTracing(Boolean tracing);
082    
083        @ManagedAttribute(description = "Message History")
084        Boolean getMessageHistory();
085    
086        @ManagedAttribute(description = "Current number of inflight Exchanges")
087        Integer getInflightExchanges();
088    
089        @ManagedAttribute(description = "Total number of routes")
090        Integer getTotalRoutes();
091    
092        @ManagedAttribute(description = "Current number of started routes")
093        Integer getStartedRoutes();
094    
095        @ManagedAttribute(description = "Shutdown timeout")
096        void setTimeout(long timeout);
097    
098        @ManagedAttribute(description = "Shutdown timeout")
099        long getTimeout();
100    
101        @ManagedAttribute(description = "Shutdown timeout time unit")
102        void setTimeUnit(TimeUnit timeUnit);
103    
104        @ManagedAttribute(description = "Shutdown timeout time unit")
105        TimeUnit getTimeUnit();
106    
107        @ManagedAttribute(description = "Whether to force shutdown now when a timeout occurred")
108        void setShutdownNowOnTimeout(boolean shutdownNowOnTimeout);
109    
110        @ManagedAttribute(description = "Whether to force shutdown now when a timeout occurred")
111        boolean isShutdownNowOnTimeout();
112    
113        @ManagedAttribute(description = "Average load over the last minute")
114        String getLoad01();
115    
116        @ManagedAttribute(description = "Average load over the last five minutes")
117        String getLoad05();
118    
119        @ManagedAttribute(description = "Average load over the last fifteen minutes")
120        String getLoad15();
121    
122        @ManagedAttribute(description = "Whether breadcrumbs is in use")
123        boolean isUseBreadcrumb();
124    
125        @ManagedAttribute(description = "Whether allowing access to the original message during routing")
126        boolean isAllowUseOriginalMessage();
127    
128        @ManagedAttribute(description = "Whether message history is enabled")
129        boolean isMessageHistory();
130    
131        @ManagedAttribute(description = "Whether MDC logging is supported")
132        boolean isUseMDCLogging();
133    
134        @ManagedOperation(description = "Start Camel")
135        void start() throws Exception;
136    
137        @ManagedOperation(description = "Stop Camel (shutdown)")
138        void stop() throws Exception;
139    
140        @ManagedOperation(description = "Restart Camel (stop and then start)")
141        void restart() throws Exception;
142    
143        @ManagedOperation(description = "Suspend Camel")
144        void suspend() throws Exception;
145    
146        @ManagedOperation(description = "Resume Camel")
147        void resume() throws Exception;
148    
149        @ManagedOperation(description = "Send body (in only)")
150        void sendBody(String endpointUri, Object body) throws Exception;
151    
152        @ManagedOperation(description = "Send body (String type) (in only)")
153        void sendStringBody(String endpointUri, String body) throws Exception;
154    
155        @ManagedOperation(description = "Send body and headers (in only)")
156        void sendBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws Exception;
157    
158        @ManagedOperation(description = "Request body (in out)")
159        Object requestBody(String endpointUri, Object body) throws Exception;
160    
161        @ManagedOperation(description = "Request body (String type) (in out)")
162        Object requestStringBody(String endpointUri, String body) throws Exception;
163    
164        @ManagedOperation(description = "Request body and headers (in out)")
165        Object requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws Exception;
166    
167        @ManagedOperation(description = "Dumps the routes as XML")
168        String dumpRoutesAsXml() throws Exception;
169    
170        @ManagedOperation(description = "Adds or updates existing routes from XML")
171        void addOrUpdateRoutesFromXml(String xml) throws Exception;
172    
173        @ManagedOperation(description = "Adds or updates existing routes from XML")
174        void addOrUpdateRoutesFromXml(String xml, boolean urlDecode) throws Exception;
175    
176        @ManagedOperation(description = "Dumps the routes stats as XML")
177        String dumpRoutesStatsAsXml(boolean fullStats, boolean includeProcessors) throws Exception;
178    
179        /**
180         * Creates the endpoint by the given uri
181         *
182         * @param uri uri of endpoint to create
183         * @return <tt>true</tt> if a new endpoint was created, <tt>false</tt> if the endpoint already existed
184         * @throws Exception is thrown if error occurred
185         */
186        @ManagedOperation(description = "Creates the endpoint by the given URI")
187        boolean createEndpoint(String uri) throws Exception;
188    
189        /**
190         * Removes the endpoint by the given pattern
191         *
192         * @param pattern the pattern
193         * @return number of endpoints removed
194         * @throws Exception is thrown if error occurred
195         * @see org.apache.camel.CamelContext#removeEndpoints(String)
196         */
197        @ManagedOperation(description = "Removes endpoints by the given pattern")
198        int removeEndpoints(String pattern) throws Exception;
199    
200        /**
201         * Find information about all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}.
202         *
203         * @return a map with the component name, and value with component details.
204         * @throws Exception is thrown if error occurred
205         */
206        @ManagedOperation(description = "Find all Camel components available in the classpath")
207        Map<String, Properties> findComponents() throws Exception;
208    
209        /**
210         * Find the names of all the Camel components available in the classpath and {@link org.apache.camel.spi.Registry}.
211         *
212         * @return a list with the names of the camel components
213         * @throws Exception is thrown if error occurred
214         */
215        @ManagedOperation(description = "Find all Camel components names available in the classpath")
216        List<String> findComponentNames() throws Exception;
217    
218    
219        /**
220         * Returns the JSON schema representation of the endpoint parameters for the given component name
221         *
222         * @param componentName the name of the component to lookup
223         * @throws Exception is thrown if error occurred
224         */
225        @ManagedOperation(description = "Returns the JSON schema representation of the endpoint parameters for the given component name")
226        String componentParameterJsonSchema(String componentName) throws Exception;
227    
228        /**
229         * Resets all the performance counters.
230         *
231         * @param includeRoutes  whether to reset all routes as well.
232         * @throws Exception is thrown if error occurred
233         */
234        @ManagedOperation(description = "Reset counters")
235        void reset(boolean includeRoutes) throws Exception;
236    
237    
238        /**
239         * Helper method for tooling which returns the completion list of the endpoint path
240         * from the given endpoint name, properties and current path expression.
241         * <p/>
242         * For example if using the file endpoint, this should complete a list of files (rather like bash completion)
243         * or for an ActiveMQ component this should complete the list of queues or topics.
244         *
245         * @param componentName  the component name
246         * @param endpointParameters  parameters of the endpoint
247         * @param completionText  the entered text which we want to have completion suggestions for
248         * @throws Exception is thrown if error occurred
249         */
250        @ManagedOperation(description = "Returns the list of available endpoint paths for the given component name, endpoint properties and completion text")
251        List<String> completeEndpointPath(String componentName, Map<String, Object> endpointParameters, String completionText) throws Exception;
252    
253        /**
254         * Returns the HTML documentation for the given camel component
255         *
256         * @param componentName  the component name
257         */
258        @ManagedOperation(description = "Returns the HTML documentation for the given camel component")
259        String getComponentDocumentation(String componentName) throws IOException;
260    
261        @ManagedOperation(description = "Returns the JSON representation of all the static endpoints defined in all the routes")
262        String createRouteStaticEndpointJson();
263    
264    }