cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r349280 - in /cocoon/trunk/src: java/org/apache/cocoon/components/blocks/ test/org/apache/cocoon/test/components/blocks/core/COB-INF/
Date Sun, 27 Nov 2005 19:17:09 GMT
Author: danielf
Date: Sun Nov 27 11:16:57 2005
New Revision: 349280

URL: http://svn.apache.org/viewcvs?rev=349280&view=rev
Log:
Making the core block reading components from the component section as well.

Modified:
    cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java
    cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockWiring.java
    cocoon/trunk/src/java/org/apache/cocoon/components/blocks/InterBlockServiceManager.java
    cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/core/COB-INF/block.xml

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=349280&r1=349279&r2=349280&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 Sun Nov 27
11:16:57 2005
@@ -38,9 +38,7 @@
 import org.apache.cocoon.components.LifecycleHelper;
 import org.apache.cocoon.components.container.CocoonServiceManager;
 import org.apache.cocoon.components.container.ComponentContext;
-import org.apache.cocoon.core.Core;
 import org.apache.cocoon.core.container.CoreServiceManager;
-import org.apache.cocoon.core.container.SingleComponentServiceManager;
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
@@ -52,8 +50,6 @@
     extends AbstractLogEnabled
     implements Block, Configurable, Contextualizable, Disposable, Initializable, Serviceable
{ 
 
-    public static String CORE_COMPONENTS_XCONF =
-        "resource://org/apache/cocoon/components/blocks/core-components.xconf";
     public static String ROLE = BlockManager.class.getName();
 
     private Context context;
@@ -96,29 +92,28 @@
         String confLocation = this.blockWiring.getContextURL() + "::";
 
         if (this.blockWiring.isCore()) {
-            this.serviceManager = this.createCoreSM(newContext, confLocation);
+            this.getLogger().debug("Block with core=true");
+            this.serviceManager = this.parentServiceManager;
        } else {
             // Create a service manager for getting components from other blocks
             ServiceManager topServiceManager = new InterBlockServiceManager(this.blockWiring,
this.blocksManager);
             ((InterBlockServiceManager)topServiceManager).enableLogging(this.getLogger());
 
-            ServiceManager sourceResolverSM =
+            this.serviceManager =
                 this.createLocalSourceResolverSM(newContext, topServiceManager, confLocation);
-
-            // Create a service manager with the exposed components of the block
-            if (this.blockWiring.getComponentConfiguration() != null) {
-                DefaultConfiguration componentConf =
-                    new DefaultConfiguration("components", confLocation);
-                componentConf.addAll(this.blockWiring.getComponentConfiguration());
-                this.serviceManager = new CocoonServiceManager(sourceResolverSM);
-                LifecycleHelper.setupComponent(this.serviceManager,
-                        this.getLogger(),
-                        newContext,
-                        null,
-                        componentConf);
-            } else {
-                this.serviceManager = sourceResolverSM;
-            }
+        }
+        
+        // Create a service manager with the exposed components of the block
+        if (this.blockWiring.getComponentConfiguration() != null) {
+            DefaultConfiguration componentConf =
+                new DefaultConfiguration("components", confLocation);
+            componentConf.addAll(this.blockWiring.getComponentConfiguration());
+            this.serviceManager = new CocoonServiceManager(this.serviceManager);
+            LifecycleHelper.setupComponent(this.serviceManager,
+                    this.getLogger(),
+                    newContext,
+                    null,
+                    componentConf);
         }
 
         // Create a processor for the block
@@ -150,38 +145,6 @@
         newContext.makeReadOnly();
         
         return newContext;
-    }
-
-    /**
-     * Gets the Core and creates some components that always are needed. 
-     * FIXME: Would be better to configure these components from the block.xml, but it is
somewhat
-     * tricky to get the source resolving right. 
-     * 
-     * @param newContext
-     * @param confLocation
-     * @return
-     * @throws Exception
-     */
-    private ServiceManager createCoreSM(Context newContext, String confLocation) throws Exception
{
-        // Create a root service manager for blocks.
-        Core core = (Core)this.parentServiceManager.lookup(Core.ROLE);
-        ServiceManager coreServiceManager =
-            new SingleComponentServiceManager(null, core, Core.ROLE);
-        DefaultConfiguration coreConf =
-            new DefaultConfiguration("components", confLocation);
-        DefaultConfiguration coreInclude =
-            new DefaultConfiguration("include");
-        coreInclude.setAttribute("src", CORE_COMPONENTS_XCONF);
-        coreConf.addChild(coreInclude);
-        ServiceManager serviceManager =
-            new CoreServiceManager(coreServiceManager);
-        LifecycleHelper.setupComponent(
-                serviceManager,
-                this.getLogger(),
-                newContext,
-                null,
-                coreConf);
-        return serviceManager;
     }
 
     /**

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockWiring.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockWiring.java?rev=349280&r1=349279&r2=349280&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockWiring.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockWiring.java Sun Nov 27
11:16:57 2005
@@ -74,7 +74,7 @@
         this.location = config.getAttribute("location");
         this.mountPath = config.getChild("mount").getAttribute("path", null);
 
-        getLogger().debug("BlockContext configure: " +
+        getLogger().debug("BlockWiring configure: " +
                           " id=" + this.id +
                           " location=" + this.location +
                           " mountPath=" + this.mountPath);

Modified: cocoon/trunk/src/java/org/apache/cocoon/components/blocks/InterBlockServiceManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/blocks/InterBlockServiceManager.java?rev=349280&r1=349279&r2=349280&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/blocks/InterBlockServiceManager.java
(original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/blocks/InterBlockServiceManager.java
Sun Nov 27 11:16:57 2005
@@ -111,6 +111,8 @@
                     if (manager != null && manager.hasService(role)) {
                         return manager;
                     }
+                } else {
+                    this.getLogger().debug("Serching for role=" + role + " in blockId=" +
blockId + " that isn't setup.");
                 }
             }
             String superId = this.blockWiring.getBlockId(Block.SUPER);
@@ -122,6 +124,8 @@
                     if (manager.hasService(role)) {
                         return manager;
                     }
+                } else {
+                    this.getLogger().debug("Serching for role=" + role + " in blockId=" +
superId + " that isn't setup.");
                 }
             }
         } finally {

Modified: cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/core/COB-INF/block.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/core/COB-INF/block.xml?rev=349280&r1=349279&r2=349280&view=diff
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/core/COB-INF/block.xml
(original)
+++ cocoon/trunk/src/test/org/apache/cocoon/test/components/blocks/core/COB-INF/block.xml
Sun Nov 27 11:16:57 2005
@@ -28,5 +28,7 @@
          implementation="stable"/>
   <license href="http://www.apache.org/licenses/">Apache License 2.0</license>
   <author href="http://cocoon.apache.org">Apache Cocoon community</author>
-  <components core="true"/>
+  <components core="true">
+    <include src="resource://org/apache/cocoon/components/blocks/core-components.xconf"/>
+  </components>
 </block>



Mime
View raw message