Mathieu Lirzin
2018-10-21 21:35:38 UTC
Hello,
I have a question regarding the
‘org.apache.ofbiz.base.start.StartupControlPanel#loadStartupLoaders()’
current implementation:
--8<---------------cut here---------------start------------->8---
private static void loadStartupLoaders(Config config,
List<StartupLoader> loaders,
List<StartupCommand> ofbizCommands,
AtomicReference<ServerState> serverState) throws StartupException {
String startupLoaderName = "org.apache.ofbiz.base.container.ContainerLoader";
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
synchronized (loaders) {
if (serverState.get() == ServerState.STOPPING) {
return;
}
try {
Class<?> loaderClass = classloader.loadClass(startupLoaderName);
StartupLoader loader = (StartupLoader) loaderClass.newInstance();
loaders.add(loader); // add before loading, so unload can occur if error during loading
loader.load(config, ofbizCommands);
} catch (ReflectiveOperationException e) {
throw new StartupException(e);
}
}
serverState.compareAndSet(ServerState.STARTING, ServerState.RUNNING);
}
--8<---------------cut here---------------end--------------->8---
I don't understand the goal of using reflection for instantiating the
‘ContainerLoader’ class. Can't we just have something like the following
instead?
--8<---------------cut here---------------start------------->8---
private static void loadStartupLoaders(Config config,
List<StartupLoader> loaders,
List<StartupCommand> ofbizCommands,
AtomicReference<ServerState> serverState) throws StartupException {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
synchronized (loaders) {
if (serverState.get() == ServerState.STOPPING) {
return;
}
StartupLoader loader = new ContainerLoader();
loaders.add(loader); // add before loading, so unload can occur if error during loading
loader.load(config, ofbizCommands);
}
serverState.compareAndSet(ServerState.STARTING, ServerState.RUNNING);
}
--8<---------------cut here---------------end--------------->8---
If this is required, I will be happy if someone could add an inline
comment giving a rationale for the current implementation. If that's
not the case, I can open a JIRA with a proper patch if needed.
Thanks.
I have a question regarding the
‘org.apache.ofbiz.base.start.StartupControlPanel#loadStartupLoaders()’
current implementation:
--8<---------------cut here---------------start------------->8---
private static void loadStartupLoaders(Config config,
List<StartupLoader> loaders,
List<StartupCommand> ofbizCommands,
AtomicReference<ServerState> serverState) throws StartupException {
String startupLoaderName = "org.apache.ofbiz.base.container.ContainerLoader";
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
synchronized (loaders) {
if (serverState.get() == ServerState.STOPPING) {
return;
}
try {
Class<?> loaderClass = classloader.loadClass(startupLoaderName);
StartupLoader loader = (StartupLoader) loaderClass.newInstance();
loaders.add(loader); // add before loading, so unload can occur if error during loading
loader.load(config, ofbizCommands);
} catch (ReflectiveOperationException e) {
throw new StartupException(e);
}
}
serverState.compareAndSet(ServerState.STARTING, ServerState.RUNNING);
}
--8<---------------cut here---------------end--------------->8---
I don't understand the goal of using reflection for instantiating the
‘ContainerLoader’ class. Can't we just have something like the following
instead?
--8<---------------cut here---------------start------------->8---
private static void loadStartupLoaders(Config config,
List<StartupLoader> loaders,
List<StartupCommand> ofbizCommands,
AtomicReference<ServerState> serverState) throws StartupException {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
synchronized (loaders) {
if (serverState.get() == ServerState.STOPPING) {
return;
}
StartupLoader loader = new ContainerLoader();
loaders.add(loader); // add before loading, so unload can occur if error during loading
loader.load(config, ofbizCommands);
}
serverState.compareAndSet(ServerState.STARTING, ServerState.RUNNING);
}
--8<---------------cut here---------------end--------------->8---
If this is required, I will be happy if someone could add an inline
comment giving a rationale for the current implementation. If that's
not the case, I can open a JIRA with a proper patch if needed.
Thanks.
--
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761 070D 0ADE E100 9460 4D37
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761 070D 0ADE E100 9460 4D37