cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r369020 - in /cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src: main/java/org/apache/cocoon/blocks/ main/java/org/apache/cocoon/blocks/util/ test/resources/org/apache/cocoon/blocks/
Date Sat, 14 Jan 2006 13:30:39 GMT
Author: danielf
Date: Sat Jan 14 05:30:21 2006
New Revision: 369020

URL: http://svn.apache.org/viewcvs?rev=369020&view=rev
Log:
Started to tidy context path handling and preparing to move block configuration files to their
proper locations.

Added:
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockConstants.java
  (with props)
Modified:
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockManager.java
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockWiring.java
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlocksManager.java
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/SitemapServlet.java
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/util/CoreUtil.java
    cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/test/resources/org/apache/cocoon/blocks/wiring.xml

Added: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockConstants.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockConstants.java?rev=369020&view=auto
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockConstants.java
(added)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockConstants.java
Sat Jan 14 05:30:21 2006
@@ -0,0 +1,38 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.blocks;
+
+/**
+ * BlockConstants used in the blocks framework
+ * @version $Id$
+ */
+public final class BlockConstants {
+    
+    /** Name of the meta directory of a webapp */
+    public static final String WEBAPP_META_DIR = "WEB-INF";
+
+    /** Name of the meta directory of a block */
+    public static final String BLOCK_META_DIR = "COB-INF";
+
+    /** Name of the resource directory of a block */
+    public static final String BLOCK_RESOURCES_DIR = "";
+    
+    /** Path to the wiring file in the context */
+    public static final String WIRING = "/wiring.xml";
+
+    /** Path to the block configuration file in the block context */
+    public static final String BLOCK_CONF = "/" + BLOCK_META_DIR + "/block.xml";
+}

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockConstants.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java?rev=369020&r1=369019&r2=369020&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
Sat Jan 14 05:30:21 2006
@@ -99,9 +99,7 @@
             path = path.substring(1);
         }
         String location = this.wiring.getLocation();
-        if (location.length() > 0 && location.charAt(0) != '/') {
-            location = "/" + location;
-        }
+
         return super.servletContext.getResource(location + path);
     }
 

Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockManager.java?rev=369020&r1=369019&r2=369020&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockManager.java
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockManager.java
Sat Jan 14 05:30:21 2006
@@ -93,7 +93,7 @@
 
         this.blockContext =
             new BlockContext(this.getServletContext(), this.blockWiring, this);
-        this.contextURL = CoreUtil.getContextURL(this.blockContext, "COB-INF/block.xml");
+        this.contextURL = CoreUtil.getContextURL(this.blockContext, BlockConstants.BLOCK_CONF);
         Context newContext = this.getAvalonContext();
         String confLocation = this.contextURL + "::";
 

Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockWiring.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockWiring.java?rev=369020&r1=369019&r2=369020&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockWiring.java
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockWiring.java
Sat Jan 14 05:30:21 2006
@@ -97,10 +97,7 @@
         }
 
         // Read the block.xml file
-        String blockPath = this.location + "COB-INF/block.xml";
-        if (blockPath.charAt(0) != '/') {
-            blockPath = "/" + blockPath;
-        }
+        String blockPath = this.location + BlockConstants.BLOCK_CONF;
         URL blockURL;
         Configuration block = null;
 
@@ -108,7 +105,7 @@
             blockURL = this.servletContext.getResource(blockPath);
             if (blockURL == null) {
                 // FIXME: Have used different locations for block.xml in the OSGi and the
block stuff.
-                blockPath = this.location + "WEB-INF/block.xml";
+                blockPath = this.location + "/WEB-INF/block.xml";
                 blockURL = this.servletContext.getResource(blockPath);                  
       
             }
             DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();

Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlocksManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlocksManager.java?rev=369020&r1=369019&r2=369020&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlocksManager.java
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlocksManager.java
Sat Jan 14 05:30:21 2006
@@ -33,7 +33,6 @@
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.logger.Logger;
-import org.apache.cocoon.Constants;
 import org.apache.cocoon.Modifiable;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.blocks.util.CoreUtil;
@@ -62,7 +61,6 @@
     private Context context;
     private BlocksContext blocksContext;
 
-    private String wiringFileName = "/" + Constants.WIRING;
     private Source wiringFile;
     private HashMap blocks = new HashMap();
     private TreeMap mountedBlocks = new TreeMap(new InverseLexicographicalOrder());
@@ -73,7 +71,7 @@
         super.init(servletConfig);
         this.blocksContext = new BlocksContext(this.getServletContext(), this);
         
-        CoreUtil coreUtil = new CoreUtil(this.getServletConfig(), Constants.WIRING);
+        CoreUtil coreUtil = new CoreUtil(this.getServletConfig(), BlockConstants.WIRING);
         Core core = coreUtil.getCore();
         Settings settings = coreUtil.getSettings();
         this.context = core.getContext();
@@ -83,15 +81,15 @@
         
         InputSource is = null;
         try {
-            this.getLogger().debug("Wiring file: " + this.getServletContext().getResource(this.wiringFileName));
+            this.getLogger().debug("Wiring file: " + this.getServletContext().getResource(BlockConstants.WIRING));
             URLSource urlSource = new URLSource();
-            urlSource.init(this.getServletContext().getResource(this.wiringFileName), null);
+            urlSource.init(this.getServletContext().getResource(BlockConstants.WIRING), null);
             this.wiringFile = new DelayedRefreshSourceWrapper(urlSource, 1000);
             is = SourceUtil.getInputSource(this.wiringFile);
         } catch (IOException e) {
-            throw new ServletException("Could not open configuration file: " + this.wiringFileName,
e);
+            throw new ServletException("Could not open configuration file: " + BlockConstants.WIRING,
e);
         } catch (ProcessingException e) {
-            throw new ServletException("Could not open configuration file: " + this.wiringFileName,
e);                 
+            throw new ServletException("Could not open configuration file: " + BlockConstants.WIRING,
e);                 
         }
         
         DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
@@ -99,7 +97,7 @@
         try {
             wiring = builder.build(is);
         } catch (Exception e) {
-            throw new ServletException("Could not create configuration from file: " + this.wiringFileName,
e);                  
+            throw new ServletException("Could not create configuration from file: " + BlockConstants.WIRING,
e);                  
         }
         
         ServletConfig blocksConfig =

Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/SitemapServlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/SitemapServlet.java?rev=369020&r1=369019&r2=369020&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/SitemapServlet.java
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/SitemapServlet.java
Sat Jan 14 05:30:21 2006
@@ -84,7 +84,7 @@
     }
 
     public void initialize() throws Exception {
-        this.contextURL = CoreUtil.getContextURL(this.getServletContext(), "COB-INF/block.xml");
+        this.contextURL = CoreUtil.getContextURL(this.getServletContext(), BlockConstants.BLOCK_CONF);
 
         // Create an own service manager
         this.serviceManager = new CocoonServiceManager(this.parentServiceManager);

Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/util/CoreUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/util/CoreUtil.java?rev=369020&r1=369019&r2=369020&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/util/CoreUtil.java
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/util/CoreUtil.java
Sat Jan 14 05:30:21 2006
@@ -103,7 +103,7 @@
     private String contextURL;
 
     public CoreUtil(ServletConfig config) throws ServletException {
-        this(config, "WEB-INF/web.xml");
+        this(config, "/WEB-INF/web.xml");
     }
 
     /**
@@ -148,14 +148,19 @@
         if (path == null) {
             // Try to figure out the path of the root from that of a known file
             servletContext.log("Figuring out root from " + knownFile);
+            URL url;
             try {
-                path = servletContext.getResource("/" + knownFile).toString();
-                servletContext.log("Got " + path);
+                url = servletContext.getResource(knownFile); 
             } catch (MalformedURLException me) {
                 throw new ServletException("Unable to get resource '"
                         + knownFile + "'.", me);
             }
-            path = path.substring(0, path.length() - knownFile.length());
+            if (url == null)
+                throw new ServletException("Couldn't find " + knownFile);
+            path = url.toString();
+            servletContext.log("Got " + path);
+
+            path = path.substring(0, path.length() - (knownFile.length() - 1));
             servletContext.log("And servlet root " + path);
         }
         try {

Modified: cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/test/resources/org/apache/cocoon/blocks/wiring.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/test/resources/org/apache/cocoon/blocks/wiring.xml?rev=369020&r1=369019&r2=369020&view=diff
==============================================================================
--- cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/test/resources/org/apache/cocoon/blocks/wiring.xml
(original)
+++ cocoon/trunk/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/test/resources/org/apache/cocoon/blocks/wiring.xml
Sat Jan 14 05:30:21 2006
@@ -20,9 +20,9 @@
         xsi:schemaLocation="http://apache.org/cocoon/blocks/wiring/1.0 wiring-schema-1.0.xsd"
 >
 
-  <block id="core" location="core/"/>
+  <block id="core" location="/core/"/>
 
-  <block id="test1id" location="test1/">
+  <block id="test1id" location="/test1/">
     <mount path="/test1"/>
     <connections>
       <connection name="core" block="core"/>
@@ -33,14 +33,14 @@
     </properties>
   </block>
 
-  <block id="test2id" location="test2/">
+  <block id="test2id" location="/test2/">
     <mount path="/test2"/>
     <connections>
       <connection name="core" block="core"/>
     </connections>
   </block>
 
-  <block id="test3id" location="test3/">
+  <block id="test3id" location="/test3/">
     <mount path="/test3"/>
     <connections>
       <connection name="core" block="core"/>



Mime
View raw message