cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r449461 - in /cocoon/trunk/core: cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/ cocoon-core/src/main/java/org/apache/cocoon/sitemap/
Date Sun, 24 Sep 2006 19:08:05 GMT
Author: danielf
Date: Sun Sep 24 12:08:05 2006
New Revision: 449461

URL: http://svn.apache.org/viewvc?view=rev&rev=449461
Log:
* Inheritance of properties in block context from parent context partly implemented.
* Created a sub container in the block servlet to get block local resources resolved relative
the local block context. It seem to work for the Spring resolver, but I don't understand how
to make it work with the Avalon resolver yet.
* Some cleanup and bug fixes for the sitemap servlet.


Modified:
    cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
    cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockServlet.java
    cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/DispatcherServlet.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java

Modified: cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java?view=diff&rev=449461&r1=449460&r2=449461
==============================================================================
--- cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
(original)
+++ cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockContext.java
Sun Sep 24 12:08:05 2006
@@ -58,13 +58,13 @@
      * @see javax.servlet.ServletContext#getAttribute(java.lang.String)
      */
     /*
-     *  TODO It would probably be usefull to inherit context attribute from the 
-     *  surounding servlet context and also to be able to inject context
-     *  attributes in the container  
+     *  TODO ineritance of attributes from the parent context is only
+     *  partly implemented: removeAttribute and getAttributeNames
+     *  doesn't respect inheritance yet.  
      */
     public Object getAttribute(String name) {
         Object value = this.attributes.get(name);
-        return value;
+        return value != null ? value : super.getAttribute(name);
     }
 
     /*
@@ -131,6 +131,8 @@
      */
     // FIXME, this should be defined in the config instead
     public String getInitParameter(String name) {
+        if (this.properties == null)
+            return null;
         String value = (String) this.properties.get(name);
         // Ask the super block for the property
         if (value == null) {

Modified: cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockServlet.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockServlet.java?view=diff&rev=449461&r1=449460&r2=449461
==============================================================================
--- cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockServlet.java
(original)
+++ cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/BlockServlet.java
Sun Sep 24 12:08:05 2006
@@ -29,6 +29,9 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.cocoon.blocks.util.ServletConfigurationWrapper;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.GenericWebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
 
 /**
  * @version $Id$
@@ -44,6 +47,19 @@
     public void init(ServletConfig servletConfig) throws ServletException {
         super.init(servletConfig);
         this.blockContext.setServletContext(servletConfig.getServletContext());
+
+        // create a sub container that resolves paths relative to the block
+        // context rather than the parent context and make it available in
+        // a context attribute
+        WebApplicationContext parentContainer =
+            WebApplicationContextUtils.getRequiredWebApplicationContext(servletConfig.getServletContext());
+        GenericWebApplicationContext container = new GenericWebApplicationContext();
+        container.setParent(parentContainer);
+        container.setServletContext(this.blockContext);
+        container.refresh();
+        this.blockContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
container);
+        
+        // create a servlet config based on the block servlet context
         ServletConfig blockServletConfig =
             new ServletConfigurationWrapper(servletConfig, this.blockContext) {
 
@@ -56,8 +72,9 @@
                 public Enumeration getInitParameterNames() {
                     return super.getServletContext().getInitParameterNames();
                 }
-            
         };
+        
+        // create and initialize the embeded servlet
         try {
             this.blockServlet =
                 (Servlet) this.getClass().getClassLoader().loadClass(this.blockServletClass).newInstance();

Modified: cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/DispatcherServlet.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/DispatcherServlet.java?view=diff&rev=449461&r1=449460&r2=449461
==============================================================================
--- cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/DispatcherServlet.java
(original)
+++ cocoon/trunk/core/cocoon-blocks-fw/cocoon-blocks-fw-impl/src/main/java/org/apache/cocoon/blocks/DispatcherServlet.java
Sun Sep 24 12:08:05 2006
@@ -131,6 +131,10 @@
                 }
             
         };
+        this.log("DispatcherServlet: service servlet=" + servlet +
+                " mountPath=" + mountPath +
+                " servletPath=" + request.getServletPath() +
+                " pathInfo=" + request.getPathInfo());
         servlet.service(request, res);
     }
 }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java?view=diff&rev=449461&r1=449460&r2=449461
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java
Sun Sep 24 12:08:05 2006
@@ -49,9 +49,8 @@
  */
 public class SitemapServlet extends HttpServlet {
 
-	private static final String MANIFEST_FILE = "/META-INF/MANIFEST.MF";
     private static final String DEFAULT_CONTAINER_ENCODING = "ISO-8859-1";
-	private static final String DEFAULT_SITEMAP_PATH = "/COB-INF/sitemap.xmap";	
+	private static final String DEFAULT_SITEMAP_PATH = "context://sitemap.xmap";	
 	private static final String SITEMAP_PATH_PROPERTY = "sitemapPath";
 
 	private BeanFactory beanFactory;
@@ -86,16 +85,13 @@
     	// create the Cocoon context out of the Servlet context
         this.cocoonContext = new HttpContext(config.getServletContext());
         
-        // get the Avalon context
-        org.apache.avalon.framework.context.Context avalonContext = (org.apache.avalon.framework.context.Context)
this.beanFactory.getBean(ProcessingUtil.CONTEXT_ROLE);
-        
         // create the tree processor
         try {
 			TreeProcessor treeProcessor =  new TreeProcessor();
             // TODO (DF/RP) The treeProcessor doesn't need to be a managed component at all.

             this.processor = (Processor) LifecycleHelper.setupComponent(treeProcessor,
                     this.logger,
-                    avalonContext,
+                    null,
                     serviceManager,
                     createTreeProcessorConfiguration());
 		} catch (Exception e) {
@@ -114,10 +110,13 @@
 		try {
 	        EnvironmentHelper.enterProcessor(this.processor, environment);			
 			this.processor.process(environment);
+            environment.commitResponse();
 		} catch (Exception e) {
+            environment.tryResetResponse();
 			throw new ServletException(e);
 		} finally { 
-            EnvironmentHelper.leaveProcessor();	
+            EnvironmentHelper.leaveProcessor();
+            environment.finishingProcessing();
 	    } 
 	}    
 	



Mime
View raw message