001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2014-2015 ForgeRock AS.
015 */
016package org.slf4j.impl;
017
018import org.opends.server.loggers.slf4j.OpenDJLoggerFactory;
019import org.slf4j.ILoggerFactory;
020import org.slf4j.spi.LoggerFactoryBinder;
021
022/**
023 * Binds {@link org.slf4j.LoggerFactory} class with an instance of {@link ILoggerFactory}.
024 */
025//@Checkstyle:off
026public class StaticLoggerBinder implements LoggerFactoryBinder {
027
028    private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
029
030    /**
031     * Declare the version of the SLF4J API this implementation is compiled
032     * against.
033     */
034    // to avoid constant folding by the compiler, this field must *not* be final
035
036    public static String REQUESTED_API_VERSION = "1.7.5";
037
038    private static final String FACTORY_CLASSNAME = OpenDJLoggerFactory.class.getName();
039
040    /**
041     * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
042     * method should always be the same object.
043     */
044    private final ILoggerFactory loggerFactory;
045
046    private StaticLoggerBinder() {
047        loggerFactory = new OpenDJLoggerFactory();
048    }
049
050    /**
051     * Return the singleton of this class.
052     *
053     * @return the StaticLoggerBinder singleton
054     */
055    public static StaticLoggerBinder getSingleton() {
056        return SINGLETON;
057    }
058
059    /** {@inheritDoc} */
060    @Override
061    public ILoggerFactory getLoggerFactory() {
062        return loggerFactory;
063    }
064
065    /** {@inheritDoc} */
066    @Override
067    public String getLoggerFactoryClassStr() {
068        return FACTORY_CLASSNAME;
069    }
070}