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

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

Author: reinhard
Date: Mon Apr 10 06:00:12 2006
New Revision: 392941

URL: http://svn.apache.org/viewcvs?rev=392941&view=rev
Log:
- add some comments

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=392941&r1=392940&r2=392941&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 10 06:00:12 2006
@@ -41,6 +41,9 @@
 import org.osgi.service.component.ComponentContext;
 
 /**
+ * Use this servlet as entry point to Cocoon. It wraps the @link {@link TreeProcessor} and delegates
+ * all requests to it.
+ * 
  * @version $Id$
  */
 public class SitemapServlet extends HttpServlet {
@@ -56,6 +59,9 @@
 	private Processor processor;	
 	private Settings settings;
 
+	/**
+	 * Initialize the servlet. The main purpose of this method is creating a configured @link {@link TreeProcessor}.
+	 */
     public void init(ServletConfig config) throws ServletException {
     	super.init(config);
     	
@@ -72,11 +78,11 @@
         org.apache.avalon.framework.context.Context avalonContext = (org.apache.avalon.framework.context.Context) 
         	this.beanFactory.getBean(ProcessingUtil.CONTEXT_ROLE);
         
-        // create the processor
+        // create the tree processor
         try {
-			TreeProcessor treeProcessor = (TreeProcessor) 
-				this.getClass().getClassLoader().loadClass(TreeProcessor.class.getName()).newInstance();
+			TreeProcessor treeProcessor =  new TreeProcessor();
             treeProcessor.setBeanFactory(this.beanFactory);			
+            // TODO (DF/RP) The treeProcessor doesn't need to be a managed component at all. 
             this.processor = (Processor) LifecycleHelper.setupComponent(treeProcessor,
                     this.logger,
                     avalonContext,
@@ -87,18 +93,10 @@
 		}
 		
     }
-
-	private Configuration createTreeProcessorConfiguration() {
-		DefaultConfiguration treeProcessorConf = new DefaultConfiguration("treeProcessorConfiguration");
-        treeProcessorConf.setAttribute("check-reload", true);
-        treeProcessorConf.setAttribute("file", this.sitemapPath);
-        
-//        DefaultConfiguration sitemapFileConf = new DefaultConfiguration("file");
-//        sitemapFileConf.setValue(this.sitemapPath);
-//        treeProcessorConf.addChild(sitemapFileConf);
-		return treeProcessorConf;
-	}	
     
+    /**
+     * Process the incoming request using the Cocoon tree processor.
+     */
 	protected void service(HttpServletRequest request, HttpServletResponse response) 
 		throws ServletException, IOException {
 		
@@ -113,6 +111,10 @@
 	    } 
 	}    
 	
+	/**
+	 * This method takes the servlet request and response and creates a Cocoon 
+	 * environment (@link {@link Environment}) out of it.
+	 */
     protected Environment createCocoonEnvironment(HttpServletRequest req, 
     		HttpServletResponse res) throws IOException  {
     	
@@ -128,15 +130,36 @@
 		env.enableLogging(this.logger);
 		return env;
 	}
+    
+    /**
+     * Create an Avalon Configuration @link {@link Configuration} that configures the tree processor.
+     */
+	private Configuration createTreeProcessorConfiguration() {
+		DefaultConfiguration treeProcessorConf = new DefaultConfiguration("treeProcessorConfiguration");
+        treeProcessorConf.setAttribute("check-reload", true);
+        treeProcessorConf.setAttribute("file", this.sitemapPath);
+		return treeProcessorConf;
+	}	    
 
+	/**
+	 * Get a Spring BeanFactory injected by OSGi declarative services.
+	 */
 	protected void setBeanFactory(CocoonSpringBeanRegistry beanFactory) {
 		this.beanFactory = beanFactory;
 	}
 	
+	/**
+	 * Set the path of the sitemap
+	 */
 	public void setSitemapPath(String sitemapPath) {
 		this.sitemapPath = sitemapPath;
 	}	
 
+	/**
+	 * This Method is used in an OSGi environment to activate this servlet as bundle.
+	 * 
+	 * @param componentContext - The component context is made available and gives access to OSGi framework information
+	 */
 	protected void activate(ComponentContext componentContext) throws Exception {
 		this.setSitemapPath((String) componentContext.getProperties().get(SITEMAP_PATH_PROPERTY));			
 	}