History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XW-523
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: tm_jee
Reporter: tm_jee
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XWork

eliminate the use of static block to call ConfigurationManager's destroyConfiguration() method

Created: 28/May/07 12:38 PM   Updated: 02/Jun/07 04:02 AM
Component/s: None
Affects Version/s: 1.2.2
Fix Version/s: 1.2.3


 Description  « Hide
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?



 All   Comments   Change History      Sort Order:
tm_jee - [02/Jun/07 04:02 AM ]
fixed. Kindly review

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.