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    /**
020     * Allows a {@link org.apache.camel.Service} to prepare for shutdown.
021     * <p/>
022     * <b>Important: </b> Implementators of this interface must be a {@link org.apache.camel.Service} as well.
023     * <p/>
024     * This allows {@link org.apache.camel.Processor}s to prepare for shutdown, such as when
025     * {@link org.apache.camel.CamelContext} or a {@link org.apache.camel.Route} is shutting down.
026     * The {@link org.apache.camel.Processor} could be a stateful EIP such as the
027     * {@link org.apache.camel.processor.aggregate.AggregateProcessor}, allowing it to do custom work
028     * to prepare for shutdown.
029     */
030    public interface ShutdownPrepared {
031    
032        /**
033         * Prepares for shutdown.
034         * <p/>
035         * The {@link ShutdownStrategy} supports preparing for shutdown using two steps.
036         * First a regular preparation, where the given forced parameter will be <tt>false</tt>.
037         * And if the shutdown times out, then the {@link ShutdownStrategy} performs a more aggressive
038         * shutdown, calling this method a second time with <tt>true</tt> for the given forced parameter.
039         * <p/>
040         * For example by graceful stopping any threads or the likes.
041         * <p/>
042         * For forced shutdown, then the service is expected to aggressively shutdown any child services, such
043         * as thread pools etc. This is the last chance it has to perform such duties.
044         * 
045         * @param forced <tt>true</tt> is forcing a more aggressive shutdown, <tt>false</tt> is for preparing to shutdown. 
046         */
047        void prepareShutdown(boolean forced);
048    
049    }