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;
018
019import org.apache.camel.api.management.mbean.ManagedCamelContextMBean;
020import org.apache.camel.api.management.mbean.ManagedConsumerMBean;
021import org.apache.camel.api.management.mbean.ManagedProcessorMBean;
022import org.apache.camel.api.management.mbean.ManagedRouteMBean;
023import org.apache.camel.api.management.mbean.ManagedStepMBean;
024
025public interface ManagedCamelContext {
026
027    /**
028     * Gets the managed Camel CamelContext client api
029     */
030    ManagedCamelContextMBean getManagedCamelContext();
031
032    /**
033     * Gets the managed processor client api from any of the routes which with the given id
034     *
035     * @param  id id of the processor
036     * @return    the processor or <tt>null</tt> if not found
037     */
038    default ManagedProcessorMBean getManagedProcessor(String id) {
039        return getManagedProcessor(id, ManagedProcessorMBean.class);
040    }
041
042    /**
043     * Gets the managed processor client api from any of the routes which with the given id
044     *
045     * @param  id                       id of the processor
046     * @param  type                     the managed processor type from the
047     *                                  {@link org.apache.camel.api.management.mbean} package.
048     * @return                          the processor or <tt>null</tt> if not found
049     * @throws IllegalArgumentException if the type is not compliant
050     */
051    <T extends ManagedProcessorMBean> T getManagedProcessor(String id, Class<T> type);
052
053    /**
054     * Gets the managed step client api from any of the routes which with the given id
055     *
056     * @param  id id of the step
057     * @return    the step or <tt>null</tt> if not found
058     */
059    ManagedStepMBean getManagedStep(String id);
060
061    /**
062     * Gets the managed route client api with the given route id
063     *
064     * @param  routeId id of the route
065     * @return         the route or <tt>null</tt> if not found
066     */
067    default ManagedRouteMBean getManagedRoute(String routeId) {
068        return getManagedRoute(routeId, ManagedRouteMBean.class);
069    }
070
071    /**
072     * Gets the managed route client api with the given route id
073     *
074     * @param  routeId                  id of the route
075     * @param  type                     the managed route type from the {@link org.apache.camel.api.management.mbean}
076     *                                  package.
077     * @return                          the route or <tt>null</tt> if not found
078     * @throws IllegalArgumentException if the type is not compliant
079     */
080    <T extends ManagedRouteMBean> T getManagedRoute(String routeId, Class<T> type);
081
082    /**
083     * Gets the managed consumer client api from any of the routes which with the given route id
084     *
085     * @param  id route id having the consumer
086     * @return    the consumer or <tt>null</tt> if not found
087     */
088    default ManagedConsumerMBean getManagedConsumer(String id) {
089        return getManagedConsumer(id, ManagedConsumerMBean.class);
090    }
091
092    /**
093     * Gets the managed consumer client api from any of the routes which with the given route id
094     *
095     * @param  id                       route id having the consumer
096     * @param  type                     the managed consumer type from the {@link org.apache.camel.api.management.mbean}
097     *                                  package.
098     * @return                          the consumer or <tt>null</tt> if not found
099     * @throws IllegalArgumentException if the type is not compliant
100     */
101    <T extends ManagedConsumerMBean> T getManagedConsumer(String id, Class<T> type);
102
103}