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