cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r170660 - /cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java /cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java
Date Tue, 17 May 2005 20:44:56 GMT
Author: danielf
Date: Tue May 17 13:44:55 2005
New Revision: 170660

URL: http://svn.apache.org/viewcvs?rev=170660&view=rev
Log:
Agree with Bart Molenkamp that the LifecycleHelper should be used. disposed some object that
I had forgot to dispose.

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java
    cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java?rev=170660&r1=170659&r2=170660&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java Tue May 17
13:44:55 2005
@@ -27,7 +27,6 @@
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfiguration;
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.context.Contextualizable;
@@ -39,6 +38,7 @@
 import org.apache.cocoon.Constants;
 import org.apache.cocoon.Processor;
 import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.components.LifecycleHelper;
 import org.apache.cocoon.components.container.CocoonServiceManager;
 import org.apache.cocoon.components.container.ComponentContext;
 import org.apache.cocoon.components.treeprocessor.TreeProcessor;
@@ -160,8 +160,6 @@
 
         // Create an own service manager
         this.serviceManager = new CocoonServiceManager(this.parentServiceManager);
-        ContainerUtil.enableLogging(this.serviceManager, this.getLogger());
-        ContainerUtil.contextualize(this.serviceManager, this.context);
 
         // Hack to put a sitemap configuration for the main sitemap of
         // the block into the service manager
@@ -181,8 +179,11 @@
         conf.addChild(sitemapConf);
         conf.addChild(resolverConf);
 
-        ContainerUtil.configure(this.serviceManager, conf);
-        ContainerUtil.initialize(this.serviceManager);
+        LifecycleHelper.setupComponent(this.serviceManager,
+                                       this.getLogger(),
+                                       this.context,
+                                       null,
+                                       conf);
 
         this.sourceResolver = (SourceResolver)this.serviceManager.lookup(SourceResolver.ROLE);
         final Processor processor = EnvironmentHelper.getCurrentProcessor();
@@ -198,14 +199,22 @@
 
         this.environmentHelper = new EnvironmentHelper(
                 (URL)this.context.get(ContextHelper.CONTEXT_ROOT_URL));
-        ContainerUtil.enableLogging(this.environmentHelper, this.getLogger());
-        ContainerUtil.service(this.environmentHelper, this.serviceManager);
+        LifecycleHelper.setupComponent(this.environmentHelper,
+                                       this.getLogger(),
+                                       null,
+                                       this.serviceManager,
+                                       null);
     }
 
     public void dispose() {
+        if (this.environmentHelper != null) {
+            LifecycleHelper.dispose(this.environmentHelper);
+            this.environmentHelper = null;
+        }
         if (this.serviceManager != null) {
             this.serviceManager.release(this.sourceResolver);
             this.sourceResolver = null;
+            LifecycleHelper.dispose(this.serviceManager);
             this.serviceManager = null;
         }
         this.parentServiceManager = null;

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java?rev=170660&r1=170659&r2=170660&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java Tue May 17
13:44:55 2005
@@ -28,7 +28,6 @@
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.context.Contextualizable;
@@ -40,6 +39,7 @@
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.LifecycleHelper;
 import org.apache.cocoon.components.container.CocoonServiceManager;
 import org.apache.cocoon.core.Core;
 import org.apache.cocoon.core.CoreUtil;
@@ -57,6 +57,7 @@
     public static String CORE_COMPONENTS_XCONF =
         "resource://org/apache/cocoon/components/blocks/core-components.xconf";
     private ServiceManager serviceManager;
+    private CocoonServiceManager blockServiceManager;
     private SourceResolver resolver;
     private Context context;
 
@@ -115,10 +116,8 @@
         Core core = (Core)this.serviceManager.lookup(Core.ROLE);
         ServiceManager blockParentServiceManager =
             new CoreUtil.RootServiceManager(null, core);
-        CocoonServiceManager blockServiceManager =
+        this.blockServiceManager =
             new CocoonServiceManager(blockParentServiceManager);
-        ContainerUtil.enableLogging(blockServiceManager, this.getLogger());
-        ContainerUtil.contextualize(blockServiceManager, this.context);
 
         Source coreComponentsSource =
             this.resolver.resolveURI(CORE_COMPONENTS_XCONF);
@@ -126,8 +125,11 @@
         Configuration coreComponentsConf =
             builder.build(coreComponentsSource.getInputStream());
 
-        ContainerUtil.configure(blockServiceManager, coreComponentsConf);
-        ContainerUtil.initialize(blockServiceManager);
+        LifecycleHelper.setupComponent(blockServiceManager,
+                                       this.getLogger(),
+                                       this.context,
+                                       null,
+                                       coreComponentsConf);
 
         // Create and store all blocks
 
@@ -138,11 +140,11 @@
             getLogger().debug("Creating " + blockConf.getName() +
                               " id=" + blockConf.getAttribute("id"));
             BlockManager blockManager = new BlockManager();
-            ContainerUtil.enableLogging(blockManager, this.getLogger());
-            ContainerUtil.contextualize(blockManager, this.context);
-            ContainerUtil.service(blockManager, blockServiceManager);
-            ContainerUtil.configure(blockManager, blockConf);
-            ContainerUtil.initialize(blockManager);
+            LifecycleHelper.setupComponent(blockManager,
+                                           this.getLogger(),
+                                           this.context,
+                                           blockServiceManager,
+                                           blockConf);
             this.blocks.put(entry.getKey(), blockManager);
             String mountPath = blockConf.getChild("mount").getAttribute("path", null);
             if (mountPath != null) {
@@ -154,6 +156,16 @@
     }
 
     public void dispose() {
+        Iterator blocksIter = this.blocks.entrySet().iterator();
+        while (blocksIter.hasNext()) {
+            LifecycleHelper.dispose(blocksIter.next());
+        }
+        if (this.blockServiceManager != null) {
+            LifecycleHelper.dispose(this.blockServiceManager);
+            this.blockServiceManager = null;
+        }
+        this.blocks = null;
+        this.mountedBlocks = null;
         if (this.serviceManager != null) {
             this.serviceManager.release(this.resolver);
             this.resolver = null;



Mime
View raw message