Currently in XWork's ConfigurationManager, it uses
static {
destroyConfiguration();
}
to do some configuration clean up when ConfigurationManager class is first loaded by jvm classloader.
I think we could do with out this static block. What destroyConfiguration() currently does is
public synchronized destroyConfiguration() {
synchronized (configurationProviders) {
clearConfigurationProviders(); // let's destroy the ConfigurationProvider first
configurationProviders = new ArrayList();
configurationInstance = null;
}
}
public static void clearConfigurationProviders() {
synchronized (configurationProviders) {
for (Iterator iterator = configurationProviders.iterator();
iterator.hasNext();) {
ConfigurationProvider provider = (ConfigurationProvider) iterator.next();
provider.destroy();
}
configurationProviders.clear();
}
}
It basically let individual configuration provider clear itself, clear the provider's list and nullify the Configuration instance. The provider list is declared as a member variable in ConfigurationManager as :-
private static List configurationProviders = new ArrayList();
and the Configuration instance is declared as :-
protected static Configuration configurationInstance;
which will by default be null.
So i guess there's really no need for the static block to exists. The test cases explicitly call ConfigurationManager's destroy() method.(XWorkTestCase) which test cases that make use of ConfigurationManager or deal with xwork configuration etc. should probably extends from.
I think we should also have WebWork call ConfigurationManager's destroy() method when webwork shutsdown eg. when FilterDispatcher destroy itself. More on that at
XW-522 (another issue where interceptor's destroy method is never called)
Any thouights guys?
changes at :-
tmjee@tmjee-laptop:~/development/xwork_1-2/src$ svn commit test/com/opensymphony/xwork/config/ConfigurationManagerTest.java java/com/opensymphony/xwork/XWorkTestCase.java java/com/opensymphony/xwork/config/ConfigurationManager.java
Sending java/com/opensymphony/xwork/XWorkTestCase.java
Sending java/com/opensymphony/xwork/config/ConfigurationManager.java
Sending test/com/opensymphony/xwork/config/ConfigurationManagerTest.java
Transmitting file data ...
Committed revision 1533.