    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
    018    package org.apache.logging.log4j.core.util;
    019
    020    import org.apache.logging.log4j.Marker;
    021    import org.apache.logging.log4j.MarkerManager;
    022
    023    /**
    024     * Registry used for Runnable shutdown callback instances. Due to differing requirements of how late in the JVM
    025     * lifecycle Log4j should be shut down, this interface is provided for customizing how to register shutdown hook
    026     * callbacks. Implementations may optionally implement {@link org.apache.logging.log4j.core.LifeCycle}.
    027     *
    028     * @since 2.1
    029     */
    030    public interface ShutdownCallbackRegistry {
    031
    032        /**
    033         * System property to set to choose the ShutdownCallbackRegistry.
    034         */
    035        String SHUTDOWN_CALLBACK_REGISTRY = "log4j.shutdownCallbackRegistry";
    036
    037        /**
    038         * System property to set to override the global ability to register shutdown hooks.
    039         */
    040        String SHUTDOWN_HOOK_ENABLED = "log4j.shutdownHookEnabled";
    041
    042        /**
    043         * Shared Marker to indicate log messages corresponding to shutdown hooks.
    044         */
    045        Marker SHUTDOWN_HOOK_MARKER = MarkerManager.getMarker("SHUTDOWN HOOK");
    046
    047        /**
    048         * Adds a Runnable shutdown callback to this class.
    049         *
    050         * @param callback the shutdown callback to be executed upon shutdown.
    051         * @return a Cancellable wrapper of the provided callback or {@code null} if the shutdown hook is disabled and
    052         * cannot be added.
    053         * @since 2.1
    054         */
    055        Cancellable addShutdownCallback(Runnable callback);
    056    }