cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dani...@apache.org
Subject svn commit: r569093 - in /cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice: ServletService.java ServletServiceContext.java ServletServiceContextAware.java spring/ServletFactoryBean.java
Date Thu, 23 Aug 2007 18:04:09 GMT
Author: danielf
Date: Thu Aug 23 11:04:07 2007
New Revision: 569093

URL: http://svn.apache.org/viewvc?rev=569093&view=rev
Log:
Simplifying servlet services:
* Removed the ServletServiceContextAware interface and the getServletServiceContext() method
and let the servlet service context become available through the ordinary getServletContext()
method. AFAICS it should work and it seem to work while testing. IIRC the need for having
two methods for handling the original and the servlet service context was needed in some earlier
version of the FW, hopefully I got it right and it isn't needed anymore.
* Added noop methods for init and destroy for the servlet proxy created in the ServletFactoryBean.
It is the responsibility of the factory bean to handle the life cycle of the servlet. This
protects the state from other containers.

Removed:
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/ServletServiceContextAware.java
Modified:
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/ServletService.java
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/ServletServiceContext.java
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/spring/ServletFactoryBean.java

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/ServletService.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/ServletService.java?rev=569093&r1=569092&r2=569093&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/ServletService.java
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/ServletService.java
Thu Aug 23 11:04:07 2007
@@ -46,7 +46,7 @@
  */
 public class ServletService extends HttpServlet
     implements ApplicationContextAware, ServletContextAware, BeanNameAware,
-    InitializingBean, DisposableBean, ServletServiceContextAware {
+    InitializingBean, DisposableBean {
     
     private ServletServiceContext servletServiceContext;
     private String embeddedServletClass;
@@ -63,7 +63,6 @@
      * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
      */
     public void init(ServletConfig servletConfig) throws ServletException {
-        super.init(servletConfig);
         this.servletServiceContext.setServletContext(servletConfig.getServletContext());
 
         // create a sub container that resolves paths relative to the block
@@ -92,6 +91,8 @@
                     return super.getServletContext().getInitParameterNames();
                 }
             };
+            
+        super.init(blockServletConfig);
 
         // create and initialize the embedded servlet
         this.embeddedServlet = createEmbeddedServlet(this.embeddedServletClass, blockServletConfig);
@@ -126,13 +127,6 @@
     public void destroy() {
         this.embeddedServlet.destroy();        
         super.destroy();
-    }
-    
-    /**
-     * @return the servletServiceContext
-     */
-    public ServletServiceContext getServletServiceContext() {
-        return this.servletServiceContext;
     }
     
     public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/ServletServiceContext.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/ServletServiceContext.java?rev=569093&r1=569092&r2=569093&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/ServletServiceContext.java
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/ServletServiceContext.java
Thu Aug 23 11:04:07 2007
@@ -415,7 +415,7 @@
         }
 
         Servlet servlet = (Servlet) this.connections.get(name);
-        return servlet != null ? ((ServletServiceContextAware) servlet).getServletServiceContext()
: null;
+        return servlet != null ? servlet.getServletConfig().getServletContext() : null;
     }
 
     /**

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/spring/ServletFactoryBean.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/spring/ServletFactoryBean.java?rev=569093&r1=569092&r2=569093&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/spring/ServletFactoryBean.java
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-impl/src/main/java/org/apache/cocoon/servletservice/spring/ServletFactoryBean.java
Thu Aug 23 11:04:07 2007
@@ -30,7 +30,6 @@
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.cocoon.servletservice.Mountable;
 import org.apache.cocoon.servletservice.ServletServiceContext;
-import org.apache.cocoon.servletservice.ServletServiceContextAware;
 import org.springframework.aop.framework.ProxyFactory;
 import org.springframework.aop.support.DefaultIntroductionAdvisor;
 import org.springframework.aop.support.DelegatingIntroductionInterceptor;
@@ -199,7 +198,6 @@
         if (this.mountPath != null) {
             proxyFactory.addAdvisor(new MountableMixinAdvisor());
         }
-        proxyFactory.addAdvisor(new ServletServiceContextMixinAdvisor());
         return proxyFactory.getProxy();
     }
 
@@ -231,6 +229,12 @@
                         ServletFactoryBean.this.servletServiceContext.getRequestDispatcher(request.getPathInfo());
                 dispatcher.forward(request, response);
                 return null;
+            } else if ("init".equals(invocation.getMethod().getName())) {
+                // The embedded servlet is initialized by this factory bean, ignore other
containers
+                return null;                
+            } else if ("destroy".equals(invocation.getMethod().getName())) {
+                // The embedded servlet is destroyed up by this factory bean, ignore other
containers
+                return null;
             }
 
             return invocation.proceed();
@@ -249,21 +253,6 @@
 
         public MountableMixinAdvisor() {
             super(new MountableMixin(), Mountable.class);
-        }
-    }
-
-    private class ServletServiceContextMixin extends DelegatingIntroductionInterceptor
-                                             implements ServletServiceContextAware {
-
-        public ServletServiceContext getServletServiceContext() {
-            return ServletFactoryBean.this.servletServiceContext;
-        }
-    }
-
-    private class ServletServiceContextMixinAdvisor extends DefaultIntroductionAdvisor {
-
-        public ServletServiceContextMixinAdvisor() {
-            super(new ServletServiceContextMixin(), ServletServiceContextAware.class);
         }
     }
 }



Mime
View raw message