You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by da...@apache.org on 2006/04/18 00:22:38 UTC

svn commit: r394789 - /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java

Author: danielf
Date: Mon Apr 17 15:22:34 2006
New Revision: 394789

URL: http://svn.apache.org/viewcvs?rev=394789&view=rev
Log:
Create the Avalon context localy and use the current servlet context instead of using the Avalon context from the container that not has any knowledge about the current servlet context.

Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/sitemap/SitemapServlet.java?rev=394789&r1=394788&r2=394789&view=diff
==============================================================================
--- 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 Mon Apr 17 15:22:34 2006
@@ -16,6 +16,7 @@
 package org.apache.cocoon.sitemap;
 
 import java.io.IOException;
+import java.net.MalformedURLException;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
@@ -31,6 +32,7 @@
 import org.apache.cocoon.Processor;
 import org.apache.cocoon.components.LifecycleHelper;
 import org.apache.cocoon.components.treeprocessor.TreeProcessor;
+import org.apache.cocoon.core.CoreUtil;
 import org.apache.cocoon.core.Settings;
 import org.apache.cocoon.core.osgi.CocoonSpringBeanRegistry;
 import org.apache.cocoon.environment.Context;
@@ -48,7 +50,8 @@
  */
 public class SitemapServlet extends HttpServlet {
 
-	private static final String DEFAULT_CONTAINER_ENCODING = "ISO-8859-1";
+	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 SITEMAP_PATH_PROPERTY = "sitemapPath";
 
@@ -58,6 +61,7 @@
     protected Context cocoonContext;
 	private Processor processor;	
 	private Settings settings;
+    private String contextUrl;
 
 	/**
 	 * Initialize the servlet. The main purpose of this method is creating a configured @link {@link TreeProcessor}.
@@ -72,11 +76,16 @@
     		this.beanFactory.getBean("org.apache.avalon.framework.service.ServiceManager");    	
     	
     	// create the Cocoon context out of the Servlet context
-        this.cocoonContext = new HttpContext(config.getServletContext());  
+        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 Avalon context
+        this.contextUrl = CoreUtil.getContextUrl(this.cocoonContext, MANIFEST_FILE);
+        org.apache.avalon.framework.context.Context avalonContext;
+        try {
+            avalonContext = CoreUtil.createContext(this.settings, this.cocoonContext, this.contextUrl, null, null);
+        } catch (MalformedURLException e) {
+            throw new ServletException(e);
+        }
         
         // create the tree processor
         try {