jakarta-cactus-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ken...@apache.org
Subject svn commit: r292559 - in /jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus: ./ internal/server/ server/
Date Thu, 29 Sep 2005 21:36:54 GMT
Author: kenney
Date: Thu Sep 29 14:36:43 2005
New Revision: 292559

URL: http://svn.apache.org/viewcvs?rev=292559&view=rev
Log:
Decoupled share-12-13-14 from Wrapper implementations using reflection
(a newInstance method in the AbstractXXXWrapper).

Updated Wrapper-implementation references to use the Abstract base class.

Modified:
    jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/JspTestCase.java
    jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/ServletTestCase.java
    jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/internal/server/JspTestCaller.java
    jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/internal/server/ServletTestCaller.java
    jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractHttpServletRequestWrapper.java
    jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractPageContextWrapper.java
    jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractServletConfigWrapper.java
    jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractServletContextWrapper.java
    jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/RequestDispatcherWrapper.java

Modified: jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/JspTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/JspTestCase.java?rev=292559&r1=292558&r2=292559&view=diff
==============================================================================
--- jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/JspTestCase.java
(original)
+++ jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/JspTestCase.java
Thu Sep 29 14:36:43 2005
@@ -25,7 +25,7 @@
 
 import org.apache.cactus.internal.client.connector.http.HttpProtocolHandler;
 import org.apache.cactus.internal.configuration.DefaultJspConfiguration;
-import org.apache.cactus.server.PageContextWrapper;
+import org.apache.cactus.server.AbstractPageContextWrapper;
 import org.apache.cactus.spi.client.connector.ProtocolHandler;
 
 /**
@@ -44,7 +44,7 @@
      * <code>beginXXX()</code> or <code>endXXX()</code> methods it
will
      * have the <code>null</code> value.
      */
-    public PageContextWrapper pageContext;
+    public AbstractPageContextWrapper pageContext;
 
     /**
      * Valid <code>JspWriter</code> object that you can access from

Modified: jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/ServletTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/ServletTestCase.java?rev=292559&r1=292558&r2=292559&view=diff
==============================================================================
--- jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/ServletTestCase.java
(original)
+++ jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/ServletTestCase.java
Thu Sep 29 14:36:43 2005
@@ -28,7 +28,8 @@
 import org.apache.cactus.internal.CactusTestCase;
 import org.apache.cactus.internal.client.connector.http.HttpProtocolHandler;
 import org.apache.cactus.internal.configuration.DefaultServletConfiguration;
-import org.apache.cactus.server.ServletConfigWrapper;
+import org.apache.cactus.server.AbstractHttpServletRequestWrapper;
+import org.apache.cactus.server.AbstractServletConfigWrapper;
 import org.apache.cactus.spi.client.connector.ProtocolHandler;
 
 /**
@@ -48,7 +49,7 @@
      * <code>beginXXX()</code> or <code>endXXX()</code> methods it
will
      * have the <code>null</code> value.
      */
-    public org.apache.cactus.server.HttpServletRequestWrapper request;
+    public AbstractHttpServletRequestWrapper request;
 
     /**
      * Valid <code>HttpServletResponse</code> object that you can access from
@@ -75,7 +76,7 @@
      * <code>beginXXX()</code> or <code>endXXX()</code> methods it
will
      * have the <code>null</code> value.
      */
-    public ServletConfigWrapper config;
+    public AbstractServletConfigWrapper config;
 
     /**
      * @see AbstractCactusTestCase#AbstractCactusTestCase()

Modified: jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/internal/server/JspTestCaller.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/internal/server/JspTestCaller.java?rev=292559&r1=292558&r2=292559&view=diff
==============================================================================
--- jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/internal/server/JspTestCaller.java
(original)
+++ jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/internal/server/JspTestCaller.java
Thu Sep 29 14:36:43 2005
@@ -30,7 +30,7 @@
 
 import org.apache.cactus.JspTestCase;
 import org.apache.cactus.ServletURL;
-import org.apache.cactus.server.PageContextWrapper;
+import org.apache.cactus.server.AbstractPageContextWrapper;
 
 /**
  * Call the test method on the server side after assigning the JSP implicit
@@ -76,8 +76,8 @@
 
         Field pageContextField = jspInstance.getClass().getField("pageContext");
 
-        pageContextField.set(jspInstance, 
-            new PageContextWrapper(jspImplicitObjects.getPageContext(), url));
+        pageContextField.set( jspInstance,
+            AbstractPageContextWrapper.newInstance( jspImplicitObjects.getPageContext(),
url) );
 
         // Set the JSP writer field of the test case class
         // -----------------------------------------------

Modified: jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/internal/server/ServletTestCaller.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/internal/server/ServletTestCaller.java?rev=292559&r1=292558&r2=292559&view=diff
==============================================================================
--- jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/internal/server/ServletTestCaller.java
(original)
+++ jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/internal/server/ServletTestCaller.java
Thu Sep 29 14:36:43 2005
@@ -31,8 +31,8 @@
 
 import org.apache.cactus.ServletTestCase;
 import org.apache.cactus.ServletURL;
-import org.apache.cactus.server.HttpServletRequestWrapper;
-import org.apache.cactus.server.ServletConfigWrapper;
+import org.apache.cactus.server.AbstractHttpServletRequestWrapper;
+import org.apache.cactus.server.AbstractServletConfigWrapper;
 
 /**
  * Responsible for instanciating the <code>TestCase</code> class on the server
@@ -76,7 +76,7 @@
         Field requestField = servletInstance.getClass().getField("request");
 
         requestField.set(servletInstance, 
-            new HttpServletRequestWrapper(request, url));
+            AbstractHttpServletRequestWrapper.newInstance(request, url));
 
         // Set the response field of the test case class
         // ---------------------------------------------
@@ -89,8 +89,8 @@
         // -------------------------------------------
         Field configField = servletInstance.getClass().getField("config");
 
-        configField.set(servletInstance, new ServletConfigWrapper(
-            servletImplicitObjects.getServletConfig()));
+        configField.set(servletInstance, AbstractServletConfigWrapper.
+			newInstance(servletImplicitObjects.getServletConfig()));
 
         // Set the session field of the test case class
         // --------------------------------------------

Modified: jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractHttpServletRequestWrapper.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractHttpServletRequestWrapper.java?rev=292559&r1=292558&r2=292559&view=diff
==============================================================================
--- jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractHttpServletRequestWrapper.java
(original)
+++ jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractHttpServletRequestWrapper.java
Thu Sep 29 14:36:43 2005
@@ -23,6 +23,8 @@
 import java.io.File;
 import java.io.IOException;
 
+import java.lang.reflect.Constructor;
+
 import java.security.Principal;
 
 import java.util.Enumeration;
@@ -35,9 +37,12 @@
 import javax.servlet.http.HttpSession;
 
 import org.apache.cactus.ServletURL;
+import org.apache.cactus.util.ChainedRuntimeException;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+
 /**
  * Abstract wrapper around {@link HttpServletRequest}. This class provides
  * a common implementation of the wrapper for the different Servlet APIs.
@@ -106,6 +111,26 @@
         this.request = theRequest;
         this.url = theURL;
     }
+
+    public static AbstractHttpServletRequestWrapper newInstance(
+        HttpServletRequest originalRequest, ServletURL theURL )
+    {
+        try
+        {
+            Class clazz = Class.forName( "org.apache.cactus.server.HttpServletRequestWrapper"
);
+            Object[] args = new Object[] { originalRequest, theURL };
+
+            Constructor constructor = clazz.getConstructor(new Class[] {
+                HttpServletRequest.class, ServletURL.class } );
+
+            return (AbstractHttpServletRequestWrapper) constructor.newInstance(args);
+        }
+        catch ( Throwable t )
+        {
+            throw new ChainedRuntimeException("Failed to create HttpServletRequestWrapper",
t );
+        }
+    }
+
 
     /**
      * @return the original request object

Modified: jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractPageContextWrapper.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractPageContextWrapper.java?rev=292559&r1=292558&r2=292559&view=diff
==============================================================================
--- jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractPageContextWrapper.java
(original)
+++ jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractPageContextWrapper.java
Thu Sep 29 14:36:43 2005
@@ -21,6 +21,8 @@
 
 import java.io.IOException;
 
+import java.lang.reflect.Constructor;
+
 import java.util.Enumeration;
 
 import javax.servlet.Servlet;
@@ -36,6 +38,8 @@
 import javax.servlet.jsp.tagext.BodyContent;
 
 import org.apache.cactus.ServletURL;
+import org.apache.cactus.util.ChainedRuntimeException;
+
 
 /**
  * Abstract wrapper around <code>PageContext</code>. This class provides
@@ -71,6 +75,25 @@
         this.url = theURL;
     }
 
+    public static AbstractPageContextWrapper newInstance( PageContext
+        originalPageContext, ServletURL servletURL )
+    {
+        try
+        {
+            Class clazz = Class.forName( "org.apache.cactus.server.PageContextWrapper" );
+            Object[] args = new Object[] { originalPageContext, servletURL };
+
+            Constructor constructor = clazz.getConstructor(new Class[] {
+                PageContext.class, ServletURL.class } );
+
+            return (AbstractPageContextWrapper) constructor.newInstance(args);
+        }
+        catch ( Throwable t )
+        {
+            throw new ChainedRuntimeException("Failed to create PageContextWrapper", t );
+        }
+    }
+
     // New methods ---------------------------------------------------------
 
     /**
@@ -91,7 +114,7 @@
     public ServletRequest getRequest()
     {
         // Note: we only manage HttpServletRequest here
-        return new HttpServletRequestWrapper(
+        return AbstractHttpServletRequestWrapper.newInstance(
             (HttpServletRequest) this.originalPageContext.getRequest(), 
             this.url);
     }
@@ -101,7 +124,7 @@
      */
     public ServletConfig getServletConfig()
     {
-        return new ServletConfigWrapper(
+        return AbstractServletConfigWrapper.newInstance(
             this.originalPageContext.getServletConfig());
     }
 
@@ -110,8 +133,8 @@
      */
     public ServletContext getServletContext()
     {
-        return new ServletContextWrapper(
-            this.originalPageContext.getServletContext());
+        return AbstractServletContextWrapper.newInstance(
+            originalPageContext.getServletContext() );
     }
 
     // Unmodified overridden methods -----------------------------------------

Modified: jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractServletConfigWrapper.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractServletConfigWrapper.java?rev=292559&r1=292558&r2=292559&view=diff
==============================================================================
--- jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractServletConfigWrapper.java
(original)
+++ jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractServletConfigWrapper.java
Thu Sep 29 14:36:43 2005
@@ -19,6 +19,8 @@
  */
 package org.apache.cactus.server;
 
+import java.lang.reflect.Constructor;
+
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Vector;
@@ -26,6 +28,8 @@
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 
+import org.apache.cactus.util.ChainedRuntimeException;
+
 /**
  * Abstract wrapper around <code>ServletConfig</code> which overrides the
  * <code>getServletContext()</code> method to return our own wrapper around
@@ -61,6 +65,25 @@
         this.initParameters = new Hashtable();
     }
 
+	public static AbstractServletConfigWrapper newInstance(
+		ServletConfig theOriginalConfig )
+	{
+        try
+        {
+            Class clazz = Class.forName( "org.apache.cactus.server.ServletConfigWrapper"
);
+            Object[] args = new Object[] { theOriginalConfig };
+
+            Constructor constructor = clazz.getConstructor(new Class[] {
+                ServletConfig.class } );
+
+            return (AbstractServletConfigWrapper) constructor.newInstance(args);
+        }
+        catch ( Throwable t )
+        {
+            throw new ChainedRuntimeException("Failed to create ServletConfigWrapper", t
);
+        }
+    }
+
     /**
      * Sets a parameter as if it were set in the <code>web.xml</code> file.
      *
@@ -99,7 +122,7 @@
      */
     public ServletContext getServletContext()
     {
-        return new ServletContextWrapper(
+        return AbstractServletContextWrapper.newInstance(
             this.originalConfig.getServletContext());
     }
 

Modified: jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractServletContextWrapper.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractServletContextWrapper.java?rev=292559&r1=292558&r2=292559&view=diff
==============================================================================
--- jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractServletContextWrapper.java
(original)
+++ jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/AbstractServletContextWrapper.java
Thu Sep 29 14:36:43 2005
@@ -21,6 +21,8 @@
 
 import java.io.InputStream;
 
+import java.lang.reflect.Constructor;
+
 import java.net.MalformedURLException;
 import java.net.URL;
 
@@ -33,6 +35,8 @@
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 
+import org.apache.cactus.util.ChainedRuntimeException;
+
 /**
  * Abstract wrapper around <code>ServletContext</code>. This class provides
  * a common implementation of the wrapper for the different servlet API. In
@@ -73,6 +77,25 @@
         this.initParameters = new Hashtable();
     }
 
+    public static AbstractServletContextWrapper newInstance( ServletContext
+        theOriginalContext )
+    {
+        try
+        {
+            Class clazz = Class.forName( "org.apache.cactus.server.ServletContextWrapper"
);
+            Object[] args = new Object[] { theOriginalContext };
+
+            Constructor constructor = clazz.getConstructor(new Class[] {
+                ServletContext.class } );
+
+            return (AbstractServletContextWrapper) constructor.newInstance(args);
+        }
+        catch ( Throwable t )
+        {
+            throw new ChainedRuntimeException("Failed to create ServletContextWrapper", t
);
+        }
+    }
+
     // New methods ---------------------------------------------------------
 
     /**
@@ -387,7 +410,7 @@
      */
     public ServletContext getContext(String theUripath)
     {
-        ServletContext context = new ServletContextWrapper(
+        ServletContext context = AbstractServletContextWrapper.newInstance(
             this.originalContext.getContext(theUripath));
 
         return context;

Modified: jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/RequestDispatcherWrapper.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/RequestDispatcherWrapper.java?rev=292559&r1=292558&r2=292559&view=diff
==============================================================================
--- jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/RequestDispatcherWrapper.java
(original)
+++ jakarta/cactus/branches/CACTUS_TRUNK_MAVEN2_BRANCH/cactus-framework/cactus-framework-share-12-13-14/src/main/java/org/apache/cactus/server/RequestDispatcherWrapper.java
Thu Sep 29 14:36:43 2005
@@ -62,11 +62,10 @@
         throws IOException, ServletException
     {
         // Always pass the original request to the forward() call.
-        if (HttpServletRequestWrapper.class.isAssignableFrom(
-            theRequest.getClass()))
+        if ( theRequest instanceof AbstractHttpServletRequestWrapper )
         {
-            HttpServletRequestWrapper request = 
-                (HttpServletRequestWrapper) theRequest;
+            AbstractHttpServletRequestWrapper request = 
+                (AbstractHttpServletRequestWrapper) theRequest;
 
             this.originalDispatcher.forward(request.getOriginalRequest(),
                 theResponse);
@@ -91,11 +90,10 @@
         throws IOException, ServletException
     {
         // Always pass the original request to the forward() call.
-        if (HttpServletRequestWrapper.class.isAssignableFrom(
-            theRequest.getClass()))
+        if ( theRequest instanceof AbstractHttpServletRequestWrapper )
         {
-            HttpServletRequestWrapper request = 
-                (HttpServletRequestWrapper) theRequest;
+            AbstractHttpServletRequestWrapper request = 
+                (AbstractHttpServletRequestWrapper) theRequest;
 
             this.originalDispatcher.include(request.getOriginalRequest(), 
                 theResponse);



---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org


Mime
View raw message