View Javadoc
1   /*
2    * This entire file is sublicensed to you under GPLv3 or (at your option) any
3    * later version. The original copyright notice is retained below.
4    */
5   /*
6    * Portions of this file are
7    * Copyright (C) 2016 Ronald Jack Jenkins Jr.
8    *
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as published by
11   * the Free Software Foundation, either version 3 of the License, or
12   * (at your option) any later version.
13   *
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   *
19   * You should have received a copy of the GNU General Public License
20   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21   */
22  /**
23   * Copyright (c) 2004-2011 QOS.ch
24   * All rights reserved.
25   *
26   * Permission is hereby granted, free  of charge, to any person obtaining
27   * a  copy  of this  software  and  associated  documentation files  (the
28   * "Software"), to  deal in  the Software without  restriction, including
29   * without limitation  the rights to  use, copy, modify,  merge, publish,
30   * distribute,  sublicense, and/or sell  copies of  the Software,  and to
31   * permit persons to whom the Software  is furnished to do so, subject to
32   * the following conditions:
33   *
34   * The  above  copyright  notice  and  this permission  notice  shall  be
35   * included in all copies or substantial portions of the Software.
36   *
37   * THE  SOFTWARE IS  PROVIDED  "AS  IS", WITHOUT  WARRANTY  OF ANY  KIND,
38   * EXPRESS OR  IMPLIED, INCLUDING  BUT NOT LIMITED  TO THE  WARRANTIES OF
39   * MERCHANTABILITY,    FITNESS    FOR    A   PARTICULAR    PURPOSE    AND
40   * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
41   * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
42   * OF CONTRACT, TORT OR OTHERWISE,  ARISING FROM, OUT OF OR IN CONNECTION
43   * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44   */
45  package org.slf4j.impl;
46  
47  import org.slf4j.ILoggerFactory;
48  import org.slf4j.LoggerFactory;
49  import org.slf4j.spi.LoggerFactoryBinder;
50  
51  /**
52   * The binding of {@link LoggerFactory} class with an actual instance of
53   * {@link ILoggerFactory} is performed using information returned by this class.
54   *
55   * @author Ceki G&uuml;lc&uuml;
56   * @author Ronald Jack Jenkins Jr.
57   */
58  public class StaticLoggerBinder implements LoggerFactoryBinder {
59  
60    /**
61     * Declare the version of the SLF4J API this implementation is compiled
62     * against. The value of this field is modified with each major release.
63     */
64    // to avoid constant folding by the compiler, this field must *not* be final
65    public static String                    REQUESTED_API_VERSION = "1.6.99";                                 // !final
66  
67    private static final String             loggerFactoryClassStr = BukkitPluginLoggerFactory.class.getName();
68  
69    /**
70     * The unique instance of this class.
71     */
72    private static final StaticLoggerBinder SINGLETON             = new StaticLoggerBinder();
73  
74    /**
75     * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
76     * method should always be the same object
77     */
78    private final ILoggerFactory            loggerFactory;
79  
80    private StaticLoggerBinder() {
81      this.loggerFactory = new BukkitPluginLoggerFactory();
82    }
83  
84    /**
85     * Return the singleton of this class.
86     *
87     * @return the StaticLoggerBinder singleton
88     */
89    public static final StaticLoggerBinder getSingleton() {
90      return StaticLoggerBinder.SINGLETON;
91    }
92  
93    @Override
94    public ILoggerFactory getLoggerFactory() {
95      return this.loggerFactory;
96    }
97  
98    @Override
99    public String getLoggerFactoryClassStr() {
100     return StaticLoggerBinder.loggerFactoryClassStr;
101   }
102 
103 }