svn commit: r1416462 - in /cocoon/subprojects/cocoon-servlet-service-impl/trunk: pom.xml src/main/java/org/apache/cocoon/servletservice/ServletServiceContext.java

[email protected]
Newsgroups gmane.text.xml.cocoon.cvs
Message-ID <[email protected]>
Author: ilgrosso
Date: Mon Dec  3 11:51:04 2012
New Revision: 1416462

URL: http://svn.apache.org/viewvc?rev=1416462&view=rev
Log:
Reverting previously applied patch for COCOO3-105

Modified:
    cocoon/subprojects/cocoon-servlet-service-impl/trunk/pom.xml
    cocoon/subprojects/cocoon-servlet-service-impl/trunk/src/main/java/org/apache/cocoon/servletservice/ServletServiceContext.java

Modified: cocoon/subprojects/cocoon-servlet-service-impl/trunk/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/subprojects/cocoon-servlet-service-impl/trunk/pom.xml?rev=1416462&r1=1416461&r2=1416462&view=diff
==============================================================================
--- cocoon/subprojects/cocoon-servlet-service-impl/trunk/pom.xml (original)
+++ cocoon/subprojects/cocoon-servlet-service-impl/trunk/pom.xml Mon Dec  3 11:51:04 2012
@@ -103,11 +103,6 @@
       <artifactId>cocoon-jnet</artifactId>
       <version>1.2.2</version>
     </dependency>
-    <dependency>
-      <groupId>org.apache.cocoon</groupId>
-      <artifactId>cocoon-block-deployment</artifactId>
-      <version>1.2.2-SNAPSHOT</version>
-    </dependency>
     <!-- commons -->
     <dependency>
       <groupId>commons-collections</groupId>
@@ -130,7 +125,7 @@
     <plugins>
       <plugin>
         <artifactId>maven-release-plugin</artifactId>
-        <version>2.2.2</version>
+        <version>2.3.2</version>
         <configuration>
           <tagBase>https://svn.apache.org/repos/asf/cocoon/subprojects/cocoon-servlet-service-impl/tags/</tagBase>
         </configuration>
@@ -139,14 +134,14 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-site-plugin</artifactId>
-        <version>3.0</version>
+        <version>3.2</version>
         <configuration>
           <locales>en</locales>
           <reportPlugins>
             <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-project-info-reports-plugin</artifactId>
-              <version>2.4</version>
+              <version>2.6</version>
               <configuration>
                 <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
                 <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
@@ -165,7 +160,7 @@
             <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-changes-plugin</artifactId>
-              <version>2.7.1</version>
+              <version>2.8</version>
               <reportSets>
                 <reportSet>
                   <reports>

Modified: cocoon/subprojects/cocoon-servlet-service-impl/trunk/src/main/java/org/apache/cocoon/servletservice/ServletServiceContext.java
URL: http://svn.apache.org/viewvc/cocoon/subprojects/cocoon-servlet-service-impl/trunk/src/main/java/org/apache/cocoon/servletservice/ServletServiceContext.java?rev=1416462&r1=1416461&r2=1416462&view=diff
==============================================================================
--- cocoon/subprojects/cocoon-servlet-service-impl/trunk/src/main/java/org/apache/cocoon/servletservice/ServletServiceContext.java (original)
+++ cocoon/subprojects/cocoon-servlet-service-impl/trunk/src/main/java/org/apache/cocoon/servletservice/ServletServiceContext.java Mon Dec  3 11:51:04 2012
@@ -27,12 +27,11 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Hashtable;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.Vector;
-
 import javax.servlet.RequestDispatcher;
 import javax.servlet.Servlet;
 import javax.servlet.ServletContext;
@@ -41,40 +40,41 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
-import org.apache.cocoon.blockdeployment.BlockContextURLStreamHandler;
-import org.apache.cocoon.blockdeployment.BlockDeploymentServletContextListener;
 import org.apache.cocoon.servletservice.util.ServletContextWrapper;
-import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 /**
- * @version $Id: ServletServiceContext.java 664527 2008-06-08 17:19:35Z reinhard
- *          $
+ * @version $Id$
  * @since 1.0.0
  */
-public class ServletServiceContext extends ServletContextWrapper implements
-        Absolutizable {
+public class ServletServiceContext extends ServletContextWrapper implements Absolutizable {
 
     public static final String SUPER = "super";
 
     private final Log logger = LogFactory.getLog(ServletServiceContext.class);
 
-    private Map attributes = new Hashtable();
+    private Map attributes = new HashMap();
+
     private Servlet servlet;
+
     private String mountPath;
+
     private String contextPath;
+
     private URL contextPathURL;
+
     private Map properties;
+
     private Map connections;
+
     private Map connectionServiceNames;
+
     private String serviceName;
 
     /*
-     * TODO inheritance of attributes from the parent context is only partly
-     * implemented: removeAttribute and getAttributeNames doesn't respect
-     * inheritance yet.
+     * TODO inheritance 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);
@@ -94,8 +94,7 @@ public class ServletServiceContext exten
     }
 
     /**
-     * @param map
-     *            the attributes to set
+     * @param map the attributes to set
      */
     public void setAttributes(Map map) {
         if (map != null) {
@@ -103,28 +102,19 @@ public class ServletServiceContext exten
         }
     }
 
-    @Override
     public URL getResource(String path) throws MalformedURLException {
         if (path == null || !path.startsWith("/")) {
-            throw new MalformedURLException(
-                    "The path must begin with a '/' and is interpreted "
-                            + "as relative to the current context root.");
+            throw new MalformedURLException("The path must begin with a '/' and is interpreted "
+                    + "as relative to the current context root.");
         }
 
         // lazy initialization of the base URL
         synchronized (this) {
             if (this.contextPathURL == null) {
-                final Map<String, String> blockContexts = (Map<String, String>) WebAppContextUtils
-                        .getCurrentWebApplicationContext()
-                        .getServletContext()
-                        .getAttribute(
-                                BlockDeploymentServletContextListener.BLOCK_CONTEXT_MAP);
-                this.contextPathURL = new URL(null, this.contextPath,
-                        new BlockContextURLStreamHandler(blockContexts));
+                this.contextPathURL = new URL(this.contextPath);
             }
             return new URL(this.contextPathURL, path.substring(1));
         }
-
     }
 
     public String getRealPath(String path) {
@@ -156,7 +146,7 @@ public class ServletServiceContext exten
     }
 
     public Enumeration getInitParameterNames() {
-        Vector names = new Vector();
+        List names = new ArrayList();
 
         // add all names of the parent servlet context
         Enumeration enumeration = super.getInitParameterNames();
@@ -178,7 +168,7 @@ public class ServletServiceContext exten
             names.addAll(this.properties.keySet());
         }
 
-        return names.elements();
+        return Collections.enumeration(names);
     }
 
     public InputStream getResourceAsStream(String path) {
@@ -211,8 +201,7 @@ public class ServletServiceContext exten
         ArrayList filenames = new ArrayList();
 
         if (!file.isDirectory()) {
-            filenames.add("/"
-                    + file.toString().substring(pathPrefix.length() - 1));
+            filenames.add("/" + file.toString().substring(pathPrefix.length() - 1));
             return filenames;
         }
 
@@ -273,10 +262,9 @@ public class ServletServiceContext exten
     }
 
     // Servlet service specific methods
-
     /**
      * Set the servlet of the context
-     * 
+     *
      * @param servlet
      */
     public void setServlet(Servlet servlet) {
@@ -284,9 +272,8 @@ public class ServletServiceContext exten
     }
 
     /**
-     * Takes the scheme specific part of a servlet service URI (the scheme is
-     * the responsibilty of the ServletSource) and resolve it with respect to
-     * the servlets mount point.
+     * Takes the scheme specific part of a servlet service URI (the scheme is the responsibilty of the ServletSource)
+     * and resolve it with respect to the servlets mount point.
      */
     public URI absolutizeURI(URI uri) throws URISyntaxException {
         String servletServiceName = uri.getScheme();
@@ -296,18 +283,15 @@ public class ServletServiceContext exten
             servletServiceContext = this;
         } else {
             // another servlet service
-            servletServiceContext = (ServletServiceContext) this
-                    .getNamedContext(servletServiceName);
+            servletServiceContext = (ServletServiceContext) this.getNamedContext(servletServiceName);
             if (servletServiceContext == null) {
-                throw new URISyntaxException(uri.toString(),
-                        "Unknown servlet service name");
+                throw new URISyntaxException(uri.toString(), "Unknown servlet service name");
             }
         }
 
         String mountPath = servletServiceContext.getMountPath();
         if (mountPath == null) {
-            throw new URISyntaxException(uri.toString(),
-                    "No mount point for this URI");
+            throw new URISyntaxException(uri.toString(), "No mount point for this URI");
         }
         if (mountPath.endsWith("/")) {
             mountPath = mountPath.substring(0, mountPath.length() - 1);
@@ -315,8 +299,7 @@ public class ServletServiceContext exten
 
         String absoluteURI = mountPath + uri.getSchemeSpecificPart();
         if (this.logger.isInfoEnabled()) {
-            this.logger.info("Resolving " + uri.toString() + " to "
-                    + absoluteURI);
+            this.logger.info("Resolving " + uri.toString() + " to " + absoluteURI);
         }
 
         return new URI(absoluteURI);
@@ -343,8 +326,7 @@ public class ServletServiceContext exten
         if (servlet == null && !name.equals(SUPER)) {
             Servlet _super = (Servlet) this.connections.get(SUPER);
             if (_super != null) {
-                ServletContext c = _super.getServletConfig()
-                        .getServletContext();
+                ServletContext c = _super.getServletConfig().getServletContext();
                 if (c instanceof ServletServiceContext) {
                     return ((ServletServiceContext) c).getNamedContext(name);
                 }
@@ -352,13 +334,11 @@ public class ServletServiceContext exten
                 return null;
             }
         }
-        return servlet != null ? servlet.getServletConfig().getServletContext()
-                : null;
+        return servlet != null ? servlet.getServletConfig().getServletContext() : null;
     }
 
     /**
-     * @param mountPath
-     *            The mountPath to set.
+     * @param mountPath The mountPath to set.
      */
     public void setMountPath(String mountPath) {
         this.mountPath = mountPath;
@@ -387,32 +367,28 @@ public class ServletServiceContext exten
     }
 
     /**
-     * @param properties
-     *            The properties to set.
+     * @param properties The properties to set.
      */
     public void setInitParams(Map properties) {
         this.properties = properties;
     }
 
     /**
-     * @param connections
-     *            the connections to set
+     * @param connections the connections to set
      */
     public void setConnections(Map connections) {
         this.connections = connections;
     }
 
     /**
-     * @param connections
-     *            the service names of the connections
+     * @param connections the service names of the connections
      */
     public void setConnectionServiceNames(Map connectionServletServiceNames) {
         this.connectionServiceNames = connectionServletServiceNames;
     }
 
     /**
-     * @param serviceName
-     *            the name of the
+     * @param serviceName the name of the
      */
     public void setServiceName(String serviceName) {
         this.serviceName = serviceName;
@@ -432,49 +408,41 @@ public class ServletServiceContext exten
 
             // Call to a named servlet service that exists in the current
             // context
-            this.context = ServletServiceContext.this
-                    .getNamedContext(this.servletServiceName);
+            this.context = ServletServiceContext.this.getNamedContext(this.servletServiceName);
         }
 
         protected boolean exists() {
             return this.context != null;
         }
 
-        public void forward(ServletRequest request, ServletResponse response)
-                throws ServletException, IOException {
+        public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException {
             // Call to named servlet service
 
             if (ServletServiceContext.this.logger.isInfoEnabled()) {
                 ServletServiceContext.this.logger
-                        .info("Enter processing in servlet service "
-                                + this.servletServiceName);
+                        .info("Enter processing in servlet service " + this.servletServiceName);
             }
-            RequestDispatcher dispatcher = this.context
-                    .getRequestDispatcher(((HttpServletRequest) request)
-                            .getPathInfo());
+            RequestDispatcher dispatcher = this.context.getRequestDispatcher(((HttpServletRequest) request)
+                    .getPathInfo());
             if (dispatcher != null && dispatcher instanceof PathDispatcher) {
-                ((PathDispatcher) dispatcher).forward(request, response,
-                        this.superCall);
+                ((PathDispatcher) dispatcher).forward(request, response, this.superCall);
             } else {
                 // Cannot happen
                 throw new IllegalStateException();
             }
             if (ServletServiceContext.this.logger.isInfoEnabled()) {
-                ServletServiceContext.this.logger
-                        .info("Leaving processing in servlet service "
-                                + this.servletServiceName);
+                ServletServiceContext.this.logger.info("Leaving processing in servlet service "
+                        + this.servletServiceName);
             }
         }
 
-        public void include(ServletRequest request, ServletResponse response)
-                throws ServletException, IOException {
+        public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException {
             throw new UnsupportedOperationException();
         }
     }
 
     /**
-     * Limited functionality, assumes that there is at most one servlet in the
-     * context
+     * Limited functionality, assumes that there is at most one servlet in the context
      */
     private class PathDispatcher implements RequestDispatcher {
 
@@ -487,13 +455,11 @@ public class ServletServiceContext exten
             return ServletServiceContext.this.servlet != null;
         }
 
-        public void forward(ServletRequest request, ServletResponse response)
-                throws ServletException, IOException {
+        public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException {
             this.forward(request, response, false);
         }
 
-        protected void forward(ServletRequest request,
-                ServletResponse response, boolean superCall)
+        protected void forward(ServletRequest request, ServletResponse response, boolean superCall)
                 throws ServletException, IOException {
             try {
                 HttpServletResponseBufferingWrapper wrappedResponse = new HttpServletResponseBufferingWrapper(
@@ -505,34 +471,28 @@ public class ServletServiceContext exten
                     // It is important to set the current context each time
                     // a new context is entered, this is used for the servlet
                     // protocol
-                    CallStackHelper.enterServlet(ServletServiceContext.this,
-                            (HttpServletRequest) request, wrappedResponse);
+                    CallStackHelper.enterServlet(ServletServiceContext.this, (HttpServletRequest) request,
+                            wrappedResponse);
                 } else {
                     // A super servlet service should be called in the context
                     // of the called servlet service to get polymorphic calls
                     // resolved in the right way. We still need to register the
                     // current context for resolving super calls relative it.
-                    CallStackHelper.enterSuperServlet(
-                            ServletServiceContext.this,
-                            (HttpServletRequest) request, wrappedResponse);
+                    CallStackHelper.enterSuperServlet(ServletServiceContext.this, (HttpServletRequest) request,
+                            wrappedResponse);
                 }
 
-                ServletServiceContext.this.servlet.service(request,
-                        wrappedResponse);
+                ServletServiceContext.this.servlet.service(request, wrappedResponse);
 
                 int status = wrappedResponse.getStatusCode();
-                NamedDispatcher _super = (NamedDispatcher) ServletServiceContext.this
-                        .getNamedDispatcher(SUPER);
-                if (status == HttpServletResponse.SC_NOT_FOUND
-                        && _super != null) {
-                    // if servlet returned NOT_FOUND (404) and has super servlet
-                    // declared let's reset everything and ask
+                NamedDispatcher _super = (NamedDispatcher) ServletServiceContext.this.getNamedDispatcher(SUPER);
+                if (status == HttpServletResponse.SC_NOT_FOUND && _super != null) {
+                    // if servlet returned NOT_FOUND (404) and has super servlet declared let's reset everything and ask
                     // the super servlet
 
                     // wrapping object resets underlying response as well
                     wrappedResponse.resetBufferedResponse();
-                    // here we don't need to pass wrappedResponse object because
-                    // it's not our concern to buffer response
+                    // here we don't need to pass wrappedResponse object because it's not our concern to buffer response
                     // anymore
                     // this avoids many overlapping buffers
                     _super.forward(request, response);
@@ -544,10 +504,8 @@ public class ServletServiceContext exten
             }
         }
 
-        public void include(ServletRequest request, ServletResponse response)
-                throws ServletException, IOException {
+        public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException {
             throw new UnsupportedOperationException();
         }
     }
-
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.