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.spi;
018    
019    import java.util.Collection;
020    
021    import org.apache.camel.CamelContext;
022    import org.apache.camel.Component;
023    import org.apache.camel.Endpoint;
024    import org.apache.camel.Processor;
025    import org.apache.camel.Route;
026    import org.apache.camel.Service;
027    import org.apache.camel.builder.ErrorHandlerBuilder;
028    
029    /**
030     * Strategy for lifecycle notifications.
031     */
032    public interface LifecycleStrategy {
033    
034        /**
035         * Notification on starting a {@link CamelContext}.
036         *
037         * @param context the camel context
038         */
039        void onContextStart(CamelContext context);
040    
041        /**
042         * Notification on stopping a {@link CamelContext}.
043         *
044         * @param context the camel context
045         */
046        void onContextStop(CamelContext context);
047    
048        /**
049         * Notification on adding an {@link org.apache.camel.Component}.
050         *
051         * @param name the unique name of this component
052         * @param component the added component
053         */
054        void onComponentAdd(String name, Component component);
055    
056        /**
057         * Notification on removing an {@link org.apache.camel.Component}.
058         *
059         * @param name the unique name of this component
060         * @param component the removed component
061         */
062        void onComponentRemove(String name, Component component);
063    
064        /**
065         * Notification on adding an {@link Endpoint}.
066         *
067         * @param endpoint the added endpoint
068         */
069        void onEndpointAdd(Endpoint endpoint);
070    
071        /**
072         * Notification on removing an {@link Endpoint}.
073         *
074         * @param endpoint the removed endpoint
075         */
076        void onEndpointRemove(Endpoint endpoint);
077    
078        /**
079         * Notification on adding a {@link Service}.
080         *
081         * @param context the camel context
082         * @param service the added service
083         * @param route   the route the service belongs to if any possible to determine
084         */
085        void onServiceAdd(CamelContext context, Service service, Route route);
086    
087        /**
088         * Notification on removing a {@link Service}.
089         *
090         * @param context the camel context
091         * @param service the removed service
092         * @param route   the route the service belongs to if any possible to determine
093         */
094        void onServiceRemove(CamelContext context, Service service, Route route);
095    
096        /**
097         * Notification on adding {@link Route}(s).
098         *
099         * @param routes the added routes
100         */
101        void onRoutesAdd(Collection<Route> routes);
102    
103        /**
104         * Notification on removing {@link Route}(s).
105         *
106         * @param routes the removed routes
107         */
108        void onRoutesRemove(Collection<Route> routes);
109    
110        /**
111         * Notification on adding {@link RouteContext}(s).
112         *
113         * @param routeContext the added route context
114         */
115        void onRouteContextCreate(RouteContext routeContext);
116    
117        /**
118         * Notification on adding error handler.
119         *
120         * @param routeContext        the added route context
121         * @param errorHandler        the error handler
122         * @param errorHandlerBuilder the error handler builder
123         */
124        void onErrorHandlerAdd(RouteContext routeContext, Processor errorHandler, ErrorHandlerBuilder errorHandlerBuilder);
125    
126    }