[
https://issues.apache.org/jira/browse/OFBIZ-10638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16754876#comment-16754876
]
Mathieu Lirzin commented on OFBIZ-10638:
----------------------------------------
Hello Taher,
After studying “Java concurrency in practice” by Brian Goetz, I have updated
[^OFBIZ-10638_Remove-StartupLoader-interface.patch] with the following change.
The initial code for {{loadStartupLoaders}} with multiple loaders was the
following:
{code:java}
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);
}
}
{code}
my first patch was relaxing the invariants by removing the synchronization
between the check of the server state and the loading of the component
container:
{code:java}
if (serverState.get() == ServerState.STOPPING) {
return;
}
loader.load(config, ofbizCommands);
{code}
the updated patch reintroduce that invariant to preserve the initial
concurrency semantics
{code:java}
synchronized (StartupControlPanel.class) {
if (serverState.get() == ServerState.STOPPING) {
return;
}
loader.load(config, ofbizCommands);
}
{code}
To avoid delaying the close of that ticket, I have removed the extra
refactoring patches which I keep for a later ticket.
> The ‘StartupLoader’ interface should be removed
> -----------------------------------------------
>
> Key: OFBIZ-10638
> URL: https://issues.apache.org/jira/browse/OFBIZ-10638
> Project: OFBiz
> Issue Type: Improvement
> Affects Versions: Trunk
> Reporter: Mathieu Lirzin
> Assignee: Taher Alkhateeb
> Priority: Minor
> Fix For: Upcoming Branch
>
> Attachments: OFBIZ-10638_Remove-StartupLoader-interface.patch
>
>
> OFBiz used to provide alternate Startup loaders. Nowadays only the container
> loaders is used. As suggested by Taher [on the dev mailing
> list|https://lists.apache.org/thread.html/f99d6f661eb8197df8eac6d8ba7db3fa9b7fe2569a4a24ef2fef5cae@%3Cdev.ofbiz.apache.org%3E],
> the {{StartupLoader}} interface should be removed and startup code using it
> should be adapted.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)