LogFactoryService implements Commons Logging attribute methods
Issue: SPR-17302
This commit is contained in:
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package org.apache.commons.logging;
|
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,
|
* 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
|
* overriding the abstract {@code getInstance} lookup methods. This is just applied in
|
||||||
@@ -30,6 +33,9 @@ package org.apache.commons.logging;
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public class LogFactoryService extends LogFactory {
|
public class LogFactoryService extends LogFactory {
|
||||||
|
|
||||||
|
private final Map<String, Object> attributes = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Log getInstance(Class<?> clazz) {
|
public Log getInstance(Class<?> clazz) {
|
||||||
return getInstance(clazz.getName());
|
return getInstance(clazz.getName());
|
||||||
@@ -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() {
|
public void release() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user