cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r754707 - /cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java
Date Sun, 15 Mar 2009 17:51:49 GMT
Author: reinhard
Date: Sun Mar 15 17:51:48 2009
New Revision: 754707

URL: http://svn.apache.org/viewvc?rev=754707&view=rev
Log:
add comments to the service() method

Modified:
    cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java

Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java?rev=754707&r1=754706&r2=754707&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/XMLSitemapServlet.java
Sun Mar 15 17:51:48 2009
@@ -70,7 +70,8 @@
         this.initVersionNumber();
     }
 
-    public void invoke(String requestURI, Map<String, Object> parameters, OutputStream
outputStream) throws ServletException {
+    public void invoke(String requestURI, Map<String, Object> parameters, OutputStream
outputStream)
+            throws ServletException {
         InvocationImpl invocation = (InvocationImpl) this.beanFactory.getBean(Invocation.class.getName());
 
         invocation.setBaseURL(this.getBaseURL());
@@ -87,7 +88,8 @@
     }
 
     @Override
-    protected void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
+    protected void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException,
+            IOException {
         long start = System.nanoTime();
         this.logRequest(request);
 
@@ -114,9 +116,7 @@
 
             // collect meta information from the previous run of the sitemap engine
             long lastModified = LastModifiedCollector.getLastModified();
-            String mimeType = MimeTypeCollector.getMimeType();
             int contentLengh = baos.size();
-            int statusCode = StatusCodeCollector.getStatusCode();
 
             // send the Last-Modified header
             if (lastModified > -1) {
@@ -133,15 +133,16 @@
             if (ifLastModifiedSince > 0 && ifLastModifiedSince / 1000 >= lastModified
/ 1000 && lastModified > 0) {
                 response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                 if (this.logger.isInfoEnabled()) {
-                    this.logger.info("The requested resource " + request.getRequestURI()
+ " hasn't changed: ifLastModifiedSince="
-                            + ifLastModifiedSince + ", lastModified=" + lastModified
-                            + ". Hence 304 (NOT_MODIFIED) was sent as status code.");
+                    this.logger.info("The requested resource " + request.getRequestURI()
+                            + " hasn't changed: ifLastModifiedSince=" + ifLastModifiedSince
+ ", lastModified="
+                            + lastModified + ". Hence 304 (NOT_MODIFIED) was sent as status
code.");
                 }
 
                 return;
             }
 
-            // write the sitemap result to the output stream
+            // Content-Type handling
+            String mimeType = MimeTypeCollector.getMimeType();
             if (mimeType == null || "".equals(mimeType) || "content/unknown".equals(mimeType))
{
                 mimeType = this.servletConfig.getServletContext().getMimeType(request.getRequestURI());
             }
@@ -149,8 +150,11 @@
                 response.setContentType(mimeType);
             }
 
+            // Status code handling
+            int statusCode = StatusCodeCollector.getStatusCode();
             response.setStatus(statusCode);
 
+            // write the sitemap result to the output stream
             if (contentLengh > 0) {
                 response.setContentLength(contentLengh);
                 if (this.logger.isInfoEnabled()) {
@@ -178,7 +182,8 @@
         try {
             return this.servletConfig.getServletContext().getResource("/");
         } catch (MalformedURLException e) {
-            throw this.wrapException(e, "An exception occurred while retrieving the base
" + "URL from the servlet context.");
+            throw this.wrapException(e, "An exception occurred while retrieving the base
"
+                    + "URL from the servlet context.");
         }
     }
 
@@ -211,8 +216,8 @@
      * Read versioning information from the Cocoon 3 Servlet module
      */
     private void initVersionNumber() {
-        String servletModuleVersion = ResourceUtils.getPOMProperties("org.apache.cocoon.servlet",
"cocoon-servlet").getProperty(
-                "version");
+        String servletModuleVersion = ResourceUtils.getPOMProperties("org.apache.cocoon.servlet",
"cocoon-servlet")
+                .getProperty("version");
         if (servletModuleVersion != null) {
             this.version = servletModuleVersion;
         }
@@ -236,7 +241,8 @@
     private synchronized void lazyInitialize() throws ServletException {
         if (!this.initialized) {
             try {
-                SitemapBuilder sitemapBuilder = (SitemapBuilder) this.beanFactory.getBean(SitemapBuilder.class.getName());
+                SitemapBuilder sitemapBuilder = (SitemapBuilder) this.beanFactory.getBean(SitemapBuilder.class
+                        .getName());
                 URL url = this.servletConfig.getServletContext().getResource(this.getSitemapPath());
                 this.sitemap = sitemapBuilder.build(url);
             } catch (Exception e) {
@@ -248,7 +254,8 @@
 
     private void logRequest(HttpServletRequest request) throws ServletException {
         if (this.logger.isInfoEnabled()) {
-            this.logger.info("Performing " + request.getMethod().toUpperCase() + " request
at " + request.getRequestURI());
+            this.logger.info("Performing " + request.getMethod().toUpperCase() + " request
at "
+                    + request.getRequestURI());
         }
         if (this.logger.isDebugEnabled()) {
             this.logger.debug("The base URL for this request is " + this.getBaseURL());



Mime
View raw message