001/* 002 * Copyright 2002-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.apache.commons.logging; 018 019import java.util.Map; 020import java.util.concurrent.ConcurrentHashMap; 021 022/** 023 * A minimal subclass of the standard Apache Commons Logging's {@code LogFactory} class, 024 * overriding the abstract {@code getInstance} lookup methods. This is just applied in 025 * case of the standard {@code commons-logging} jar accidentally ending up on the classpath, 026 * with the standard {@code LogFactory} class performing its META-INF service discovery. 027 * This implementation simply delegates to Spring's common {@link Log} factory methods. 028 * 029 * @author Juergen Hoeller 030 * @since 5.1 031 * @deprecated since it is only meant to be used in the above-mentioned fallback scenario 032 */ 033@Deprecated 034public class LogFactoryService extends LogFactory { 035 036 private final Map<String, Object> attributes = new ConcurrentHashMap<>(); 037 038 039 @Override 040 public Log getInstance(Class<?> clazz) { 041 return getInstance(clazz.getName()); 042 } 043 044 @Override 045 public Log getInstance(String name) { 046 return LogAdapter.createLog(name); 047 } 048 049 050 // Just in case some code happens to call uncommon Commons Logging methods... 051 052 public void setAttribute(String name, Object value) { 053 if (value != null) { 054 this.attributes.put(name, value); 055 } 056 else { 057 this.attributes.remove(name); 058 } 059 } 060 061 public void removeAttribute(String name) { 062 this.attributes.remove(name); 063 } 064 065 public Object getAttribute(String name) { 066 return this.attributes.get(name); 067 } 068 069 public String[] getAttributeNames() { 070 return this.attributes.keySet().toArray(new String[0]); 071 } 072 073 public void release() { 074 } 075 076}