001/**
002 * Copyright (c) 2004-2011 QOS.ch
003 * All rights reserved.
004 *
005 * Permission is hereby granted, free  of charge, to any person obtaining
006 * a  copy  of this  software  and  associated  documentation files  (the
007 * "Software"), to  deal in  the Software without  restriction, including
008 * without limitation  the rights to  use, copy, modify,  merge, publish,
009 * distribute,  sublicense, and/or sell  copies of  the Software,  and to
010 * permit persons to whom the Software  is furnished to do so, subject to
011 * the following conditions:
012 *
013 * The  above  copyright  notice  and  this permission  notice  shall  be
014 * included in all copies or substantial portions of the Software.
015 *
016 * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
017 * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
018 * MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
019 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
020 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
021 * OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
022 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
023 *
024 * Copyright (C) 2019 Michael N. Lipp (http://www.mnl.de)
025 * 
026 * Licensed under the Apache License, Version 2.0 (the "License");
027 * you may not use this file except in compliance with the License.
028 * You may obtain a copy of the License at
029 *
030 *        http://www.apache.org/licenses/LICENSE-2.0
031 *
032 * Unless required by applicable law or agreed to in writing, software
033 * distributed under the License is distributed on an "AS IS" BASIS,
034 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
035 * See the License for the specific language governing permissions and
036 * limitations under the License.
037 */
038
039package org.slf4j.impl;
040
041import org.slf4j.ILoggerFactory;
042import org.slf4j.LoggerFactory;
043import org.slf4j.helpers.NOPLoggerFactory;
044import org.slf4j.spi.LoggerFactoryBinder;
045
046/**
047 * The binding of {@link LoggerFactory} class with an actual instance of 
048 * {@link ILoggerFactory} is performed using information returned by this class. 
049 */
050public final class StaticLoggerBinder implements LoggerFactoryBinder {
051
052    /**
053     * Declare the version of the SLF4J API this implementation is compiled 
054     * against. The value of this field is modified with each major release. 
055     */
056    // to avoid constant folding by the compiler, this field must *not* be final
057    @SuppressWarnings("PMD.FieldNamingConventions")
058    public static String REQUESTED_API_VERSION = "1.7.0"; // !final
059
060    @SuppressWarnings("PMD.FieldNamingConventions")
061    private static final String loggerFactoryClassStr
062        = NOPLoggerFactory.class.getName();
063
064    /**
065     * The unique instance of this class.
066     * 
067     */
068    private static final StaticLoggerBinder SINGLETON
069        = new StaticLoggerBinder();
070
071    /** 
072     * The ILoggerFactory instance returned by the {@link #getLoggerFactory} 
073     * method should always be the same object
074     */
075    private final ILoggerFactory loggerFactory;
076
077    /**
078     * Return the singleton of this class.
079     * 
080     * @return the StaticLoggerBinder singleton
081     */
082    public static StaticLoggerBinder getSingleton() {
083        return SINGLETON;
084    }
085
086    private StaticLoggerBinder() {
087        loggerFactory = new Fwd2OsgiLoggerFactory();
088    }
089
090    public ILoggerFactory getLoggerFactory() {
091        return loggerFactory;
092    }
093
094    public String getLoggerFactoryClassStr() {
095        return loggerFactoryClassStr;
096    }
097}