View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.slf4j.impl;
20  
21  import org.slf4j.ILoggerFactory;
22  import org.slf4j.spi.LoggerFactoryBinder;
23  
24  /**
25   * SLF4J LoggerFactoryBinder implementation using MavenSimpleLogger.
26   * This class is part of the required classes used to specify an
27   * SLF4J logger provider implementation.
28   *
29   * @since 3.5.1
30   */
31  public final class StaticLoggerBinder implements LoggerFactoryBinder {
32      /**
33       * Declare the version of the SLF4J API this implementation is compiled
34       * against. The value of this field is usually modified with each release.
35       */
36      // to avoid constant folding by the compiler, this field must *not* be final
37      @SuppressWarnings({"checkstyle:staticvariablename", "checkstyle:visibilitymodifier"})
38      public static String REQUESTED_API_VERSION = "1.7.25"; // !final
39  
40      private static final String LOGGER_FACTORY_CLASS_STR = MavenLoggerFactory.class.getName();
41  
42      /**
43       * The unique instance of this class.
44       */
45      private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
46  
47      /**
48       * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
49       * method should always be the same object
50       */
51      private final ILoggerFactory loggerFactory;
52  
53      /**
54       * Private constructor to prevent instantiation
55       */
56      private StaticLoggerBinder() {
57          loggerFactory = new MavenLoggerFactory();
58      }
59  
60      /**
61       * Returns the singleton of this class.
62       */
63      public static StaticLoggerBinder getSingleton() {
64          return SINGLETON;
65      }
66  
67      /**
68       * Returns the factory.
69       */
70      @Override
71      public ILoggerFactory getLoggerFactory() {
72          return loggerFactory;
73      }
74  
75      /**
76       * Returns the class name.
77       */
78      @Override
79      public String getLoggerFactoryClassStr() {
80          return LOGGER_FACTORY_CLASS_STR;
81      }
82  }