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