Browse Source

LogFactoryService implements Commons Logging attribute methods

Issue: SPR-17302
pull/1970/head
Juergen Hoeller 6 years ago
parent
commit
d6dfde3e5b
  1. 30
      spring-jcl/src/main/java/org/apache/commons/logging/LogFactoryService.java

30
spring-jcl/src/main/java/org/apache/commons/logging/LogFactoryService.java

@ -16,6 +16,9 @@ @@ -16,6 +16,9 @@
package org.apache.commons.logging;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* A minimal subclass of the standard Apache Commons Logging's {@code LogFactory} class,
* overriding the abstract {@code getInstance} lookup methods. This is just applied in
@ -30,6 +33,9 @@ package org.apache.commons.logging; @@ -30,6 +33,9 @@ package org.apache.commons.logging;
@Deprecated
public class LogFactoryService extends LogFactory {
private final Map<String, Object> attributes = new ConcurrentHashMap<>();
@Override
public Log getInstance(Class<?> clazz) {
return getInstance(clazz.getName());
@ -41,7 +47,29 @@ public class LogFactoryService extends LogFactory { @@ -41,7 +47,29 @@ public class LogFactoryService extends LogFactory {
}
// Just in case some code happens to call Commons Logging's LogFactory.release()
// Just in case some code happens to call uncommon Commons Logging methods...
public void setAttribute(String name, Object value) {
if (value != null) {
this.attributes.put(name, value);
}
else {
this.attributes.remove(name);
}
}
public void removeAttribute(String name) {
this.attributes.remove(name);
}
public Object getAttribute(String name) {
return this.attributes.get(name);
}
public String[] getAttributeNames() {
return this.attributes.keySet().toArray(new String[0]);
}
public void release() {
}

Loading…
Cancel
Save