mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
more componentlocator changes
This commit is contained in:
parent
e22968b5fc
commit
2628b0c994
@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/thirdparty/log4j-1.2.15.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/console-common"/>
|
||||
<classpathentry kind="lib" path="/thirdparty/gson.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/thirdparty/log4j-1.2.15.jar"/>
|
||||
<classpathentry kind="lib" path="/thirdparty/gson.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/console"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/console-common"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/console"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@ -82,6 +82,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
||||
protected static final Callback[] s_callbacks = new Callback[] { NoOp.INSTANCE, new DatabaseCallback() };
|
||||
protected static final CallbackFilter s_callbackFilter = new DatabaseCallbackFilter();
|
||||
protected static final HashMap<Class<?>, InjectInfo> s_factories = new HashMap<Class<?>, InjectInfo>();
|
||||
protected static Boolean s_once = false;
|
||||
|
||||
protected HashMap<String, Adapters<? extends Adapter>> _adapterMap;
|
||||
protected HashMap<String, ComponentInfo<Manager>> _managerMap;
|
||||
@ -91,17 +92,6 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
||||
protected Object _component;
|
||||
|
||||
static {
|
||||
File file = PropertiesUtil.findConfigFile("log4j-cloud.xml");
|
||||
if (file != null) {
|
||||
s_logger.info("log4j configuration found at " + file.getAbsolutePath());
|
||||
DOMConfigurator.configureAndWatch(file.getAbsolutePath());
|
||||
} else {
|
||||
file = PropertiesUtil.findConfigFile("log4j-cloud.properties");
|
||||
if (file != null) {
|
||||
s_logger.info("log4j configuration found at " + file.getAbsolutePath());
|
||||
PropertyConfigurator.configureAndWatch(file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
Runtime.getRuntime().addShutdownHook(new CleanupThread());
|
||||
}
|
||||
|
||||
@ -679,7 +669,24 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
||||
return new Adapters<Adapter>(key, new ArrayList<ComponentInfo<Adapter>>());
|
||||
}
|
||||
|
||||
protected static ComponentLocator getLocatorInternal(String server, boolean setInThreadLocal, String configFileName) {
|
||||
protected static ComponentLocator getLocatorInternal(String server, boolean setInThreadLocal, String configFileName, String log4jFilename) {
|
||||
synchronized(s_once) {
|
||||
if (!s_once) {
|
||||
File file = PropertiesUtil.findConfigFile(log4jFilename + ".xml");
|
||||
if (file != null) {
|
||||
s_logger.info("log4j configuration found at " + file.getAbsolutePath());
|
||||
DOMConfigurator.configureAndWatch(file.getAbsolutePath());
|
||||
} else {
|
||||
file = PropertiesUtil.findConfigFile(log4jFilename + ".properties");
|
||||
if (file != null) {
|
||||
s_logger.info("log4j configuration found at " + file.getAbsolutePath());
|
||||
PropertyConfigurator.configureAndWatch(file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
s_once = true;
|
||||
}
|
||||
}
|
||||
|
||||
ComponentLocator locator;
|
||||
synchronized (s_locators) {
|
||||
locator = s_locators.get(server);
|
||||
@ -700,8 +707,8 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
||||
return locator;
|
||||
}
|
||||
|
||||
public static ComponentLocator getLocator(String server, String configFileName) {
|
||||
return getLocatorInternal(server, true, configFileName);
|
||||
public static ComponentLocator getLocator(String server, String configFileName, String log4jFilename) {
|
||||
return getLocatorInternal(server, true, configFileName, log4jFilename);
|
||||
}
|
||||
|
||||
public static ComponentLocator getLocator(String server) {
|
||||
@ -713,7 +720,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
|
||||
configFile = "components.xml";
|
||||
}
|
||||
}
|
||||
return getLocatorInternal(server, true, configFile);
|
||||
return getLocatorInternal(server, true, configFile, "log4j-cloud");
|
||||
}
|
||||
|
||||
public static ComponentLocator getCurrentLocator() {
|
||||
|
||||
@ -33,7 +33,8 @@ public class ComponentTestCase extends Log4jEnabledTestCase {
|
||||
if(annotation instanceof ComponentSetup) {
|
||||
ComponentLocator.getLocator(
|
||||
((ComponentSetup)annotation).managerName(),
|
||||
((ComponentSetup)annotation).setupXml()
|
||||
((ComponentSetup)annotation).setupXml(),
|
||||
((ComponentSetup)annotation).log4j()
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user