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 "PMD.MutableStaticState" }) 059 public static String REQUESTED_API_VERSION = "1.7.0"; // !final 060 061 @SuppressWarnings("PMD.FieldNamingConventions") 062 private static final String loggerFactoryClassStr 063 = NOPLoggerFactory.class.getName(); 064 065 /** 066 * The unique instance of this class. 067 * 068 */ 069 private static final StaticLoggerBinder SINGLETON 070 = new StaticLoggerBinder(); 071 072 /** 073 * The ILoggerFactory instance returned by the {@link #getLoggerFactory} 074 * method should always be the same object 075 */ 076 private final ILoggerFactory loggerFactory; 077 078 /** 079 * Return the singleton of this class. 080 * 081 * @return the StaticLoggerBinder singleton 082 */ 083 public static StaticLoggerBinder getSingleton() { 084 return SINGLETON; 085 } 086 087 private StaticLoggerBinder() { 088 loggerFactory = new Fwd2OsgiLoggerFactory(); 089 } 090 091 public ILoggerFactory getLoggerFactory() { 092 return loggerFactory; 093 } 094 095 public String getLoggerFactoryClassStr() { 096 return loggerFactoryClassStr; 097 } 098}