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.main;
018
019import org.apache.camel.CamelContext;
020
021/**
022 * A lifecycle listener to receive callbacks when the main is started and stopped.
023 */
024public interface MainListener {
025
026    /**
027     * Callback before the CamelContext(s) is being created and started.
028     *
029     * @param main  the main instance
030     */
031    void beforeStart(MainSupport main);
032
033    /**
034     * Callback to configure <b>each</b> created CamelContext.
035     * <p/>
036     * Notice this callback will be invoked for <b>each</b> CamelContext and therefore can be invoked
037     * multiple times if there is 2 or more CamelContext's being created.
038     *
039     * @param context the created CamelContext
040     */
041    void configure(CamelContext context);
042
043    /**
044     * Callback after the CamelContext(s) has been started.
045     *
046     * @param main  the main instance
047     */
048    void afterStart(MainSupport main);
049
050    /**
051     * Callback before the CamelContext(s) is being stopped.
052     *
053     * @param main  the main instance
054     */
055    void beforeStop(MainSupport main);
056
057    /**
058     * Callback after the CamelContext(s) has been stopped.
059     *
060     * @param main  the main instance
061     */
062    void afterStop(MainSupport main);
063}