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.slf4j.impl;
018
019import org.slf4j.ILoggerFactory;
020import org.slf4j.helpers.Log4jLoggerFactory;
021import org.slf4j.spi.LoggerFactoryBinder;
022
023/**
024 *
025 */
026public final class StaticLoggerBinder implements LoggerFactoryBinder {
027
028    /**
029     * Declare the version of the SLF4J API this implementation is compiled
030     * against. The value of this field is usually modified with each release.
031     */
032    // to avoid constant folding by the compiler, this field must *not* be final
033    public static String REQUESTED_API_VERSION = "1.6"; // !final
034
035    private static final String LOGGER_FACTORY_CLASS_STR = Log4jLoggerFactory.class.getName();
036
037    /**
038     * The unique instance of this class.
039     */
040    private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
041
042    /**
043     * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
044     * method should always be the same object
045     */
046    private final ILoggerFactory loggerFactory;
047
048    /**
049     * Private constructor to prevent instantiation
050     */
051    private StaticLoggerBinder() {
052        loggerFactory = new Log4jLoggerFactory();
053    }
054
055    /**
056     * Returns the singleton of this class.
057     *
058     * @return the StaticLoggerBinder singleton
059     */
060    public static StaticLoggerBinder getSingleton() {
061        return SINGLETON;
062    }
063
064    /**
065     * Returns the factory.
066     * @return the factor.
067     */
068    @Override
069    public ILoggerFactory getLoggerFactory() {
070        return loggerFactory;
071    }
072
073    /**
074     * Returns the class name.
075     * @return the class name;
076     */
077    @Override
078    public String getLoggerFactoryClassStr() {
079        return LOGGER_FACTORY_CLASS_STR;
080    }
081}