Author: cziegeler Date: Tue Oct 19 13:05:39 2004 New Revision: 55094 Modified: cocoon/whiteboard/ecmplus/src/java/org/apache/cocoon/components/container/AbstractServiceManager.java cocoon/whiteboard/ecmplus/src/java/org/apache/cocoon/components/container/CocoonServiceManager.java cocoon/whiteboard/ecmplus/src/java/org/apache/cocoon/components/container/CocoonServiceSelector.java Log: More cosmetics
Modified: cocoon/whiteboard/ecmplus/src/java/org/apache/cocoon/components/container/AbstractServiceManager.java ============================================================================== --- cocoon/whiteboard/ecmplus/src/java/org/apache/cocoon/components/container/AbstractServiceManager.java (original) +++ cocoon/whiteboard/ecmplus/src/java/org/apache/cocoon/components/container/AbstractServiceManager.java Tue Oct 19 13:05:39 2004 @@ -21,6 +21,8 @@ import java.util.Map; import org.apache.avalon.excalibur.logger.LoggerManager; +import org.apache.avalon.framework.activity.Disposable; +import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.context.Context; @@ -37,7 +39,7 @@ */ public abstract class AbstractServiceManager extends AbstractLogEnabled -implements Contextualizable, ThreadSafe { +implements Contextualizable, ThreadSafe, Disposable, Initializable { /** The classloader used for this system. */ protected final ClassLoader loader; @@ -167,4 +169,19 @@ protected abstract void addComponent(Object role, Class clazz, Configuration config) throws ServiceException; + + + /* (non-Javadoc) + * @see org.apache.avalon.framework.activity.Disposable#dispose() + */ + public void dispose() { + this.disposed = true; + } + + /* (non-Javadoc) + * @see org.apache.avalon.framework.activity.Initializable#initialize() + */ + public void initialize() throws Exception { + this.initialized = true; + } } Modified: cocoon/whiteboard/ecmplus/src/java/org/apache/cocoon/components/container/CocoonServiceManager.java ============================================================================== --- cocoon/whiteboard/ecmplus/src/java/org/apache/cocoon/components/container/CocoonServiceManager.java (original) +++ cocoon/whiteboard/ecmplus/src/java/org/apache/cocoon/components/container/CocoonServiceManager.java Tue Oct 19 13:05:39 2004 @@ -22,8 +22,6 @@ import java.util.List; import java.util.Map; -import org.apache.avalon.framework.activity.Disposable; -import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; @@ -41,7 +39,7 @@ */ public class CocoonServiceManager extends AbstractServiceManager -implements ServiceManager, Configurable, Initializable, Disposable { +implements ServiceManager, Configurable { /** The parent ComponentLocator */ private final ServiceManager parentManager; @@ -95,8 +93,7 @@ AbstractComponentHandler handler = (AbstractComponentHandler)this.componentHandlers.get( role ); // Retrieve the instance of the requested component - if ( handler == null ) - { + if ( handler == null ) { if( this.parentManager != null ) { try { return this.parentManager.lookup( role ); @@ -326,7 +323,7 @@ */ public void initialize() throws Exception { - this.initialized = true; + super.initialize(); for( int i = 0; i < this.newComponentHandlers.size(); i++ ) { @@ -432,8 +429,7 @@ forceDisposal = true; } } - - this.disposed = true; + super.dispose(); } /** Modified: cocoon/whiteboard/ecmplus/src/java/org/apache/cocoon/components/container/CocoonServiceSelector.java ============================================================================== --- cocoon/whiteboard/ecmplus/src/java/org/apache/cocoon/components/container/CocoonServiceSelector.java (original) +++ cocoon/whiteboard/ecmplus/src/java/org/apache/cocoon/components/container/CocoonServiceSelector.java Tue Oct 19 13:05:39 2004 @@ -21,8 +21,6 @@ import java.util.List; import java.util.Map; -import org.apache.avalon.framework.activity.Disposable; -import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; @@ -39,7 +37,7 @@ */ public class CocoonServiceSelector extends AbstractServiceManager -implements ServiceSelector, Serviceable, Configurable, Initializable, Disposable { +implements ServiceSelector, Serviceable, Configurable { /** The application context for components */ @@ -270,27 +268,26 @@ /* (non-Javadoc) * @see org.apache.avalon.framework.activity.Initializable#initialize() */ - public void initialize() { - synchronized( this ) { - this.initialized = true; - - List keys = new ArrayList( this.componentHandlers.keySet() ); - - for( int i = 0; i < keys.size(); i++ ) { - final Object key = keys.get( i ); - final AbstractComponentHandler handler = - (AbstractComponentHandler)this.componentHandlers.get( key ); - - try { - handler.initialize(); - } catch( Exception e ) { - if( this.getLogger().isDebugEnabled() ) { - this.getLogger().debug( "Caught an exception trying to initialize " - + "of the component handler.", e ); - } - } + public void initialize() + throws Exception { + super.initialize(); + + List keys = new ArrayList( this.componentHandlers.keySet() ); + + for( int i = 0; i < keys.size(); i++ ) { + final Object key = keys.get( i ); + final AbstractComponentHandler handler = + (AbstractComponentHandler)this.componentHandlers.get( key ); + try { + handler.initialize(); + } catch( Exception e ) { + if( this.getLogger().isDebugEnabled() ) { + this.getLogger().debug( "Caught an exception trying to initialize " + + "of the component handler.", e ); + } } + } } @@ -298,36 +295,34 @@ * @see org.apache.avalon.framework.activity.Disposable#dispose() */ public void dispose() { - synchronized( this ) { - Iterator keys = this.componentHandlers.keySet().iterator(); - List keyList = new ArrayList(); + Iterator keys = this.componentHandlers.keySet().iterator(); + List keyList = new ArrayList(); - while( keys.hasNext() ) { - Object key = keys.next(); - AbstractComponentHandler handler = - (AbstractComponentHandler)this.componentHandlers.get( key ); + while( keys.hasNext() ) { + Object key = keys.next(); + AbstractComponentHandler handler = + (AbstractComponentHandler)this.componentHandlers.get( key ); - handler.dispose(); + handler.dispose(); - keyList.add( key ); - } + keyList.add( key ); + } - keys = keyList.iterator(); + keys = keyList.iterator(); - while( keys.hasNext() ) { - this.componentHandlers.remove( keys.next() ); - } - - keyList.clear(); + while( keys.hasNext() ) { + this.componentHandlers.remove( keys.next() ); + } - if ( this.parentLocator != null ) { - this.parentLocator.release( this.parentSelector ); - this.parentLocator = null; - this.parentSelector = null; - } + keyList.clear(); - this.disposed = true; + if ( this.parentLocator != null ) { + this.parentLocator.release( this.parentSelector ); + this.parentLocator = null; + this.parentSelector = null; } + + super.dispose(); } /**