geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r982482 - in /geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src: main/java/org/apache/geronimo/jetty8/ main/java/org/apache/geronimo/jetty8/handler/ test/java/org/apache/geronimo/jetty8/
Date Thu, 05 Aug 2010 06:35:04 GMT
Author: djencks
Date: Thu Aug  5 06:35:04 2010
New Revision: 982482

URL: http://svn.apache.org/viewvc?rev=982482&view=rev
Log:
GERONIMO-5506 Make servlet context createFoo methods use our object creation, and use the
createFoo methods for filters and servlets.  Listeners are yet to be created this way.

Modified:
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/FilterHolderWrapper.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/GeronimoServletHolder.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/FilterHolderWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/FilterHolderWrapper.java?rev=982482&r1=982481&r2=982482&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/FilterHolderWrapper.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/FilterHolderWrapper.java
Thu Aug  5 06:35:04 2010
@@ -81,11 +81,7 @@ public class FilterHolderWrapper impleme
             }
         }
 
-
-        public synchronized Object newInstance() throws InstantiationException, IllegalAccessException
{
-            return servletRegistration.newInstance(_className);
-        }
-
+        @Override
         public void destroyInstance(Object o) throws Exception {
             if (!destroyed) {
                 super.destroyInstance(o);

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/GeronimoServletHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/GeronimoServletHolder.java?rev=982482&r1=982481&r2=982482&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/GeronimoServletHolder.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/GeronimoServletHolder.java
Thu Aug  5 06:35:04 2010
@@ -41,9 +41,9 @@ public class GeronimoServletHolder exten
         }
     }
 
-    public synchronized Servlet newInstance() throws InstantiationException, IllegalAccessException
{
-        return (Servlet) servletRegistration.newInstance(_className);
-    }
+//    public synchronized Servlet newInstance() throws InstantiationException, IllegalAccessException
{
+//        return (Servlet) servletRegistration.newInstance(_className);
+//    }
 
     public void destroyInstance(Object o) throws Exception {
         super.destroyInstance(o);

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java?rev=982482&r1=982481&r2=982482&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
Thu Aug  5 06:35:04 2010
@@ -177,7 +177,7 @@ public class WebAppContextWrapper implem
 
         this.componentContext = contextSource.getContext();
         UserTransaction userTransaction = new GeronimoUserTransaction(transactionManager);
-        integrationContext = new IntegrationContext(this.componentContext, unshareableResources,
applicationManagedSecurityResources, trackedConnectionAssociator, userTransaction, bundle);
+        integrationContext = new IntegrationContext(this.componentContext, unshareableResources,
applicationManagedSecurityResources, trackedConnectionAssociator, userTransaction, bundle,
holder);
         webAppContext = new GeronimoWebAppContext(securityHandler, sessionHandler, servletHandler,
null, integrationContext, classLoader, modulePath);
         webAppContext.setContextPath(contextPath);
         //See Jetty-386.  Setting this to true can expose secured content.

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java?rev=982482&r1=982481&r2=982482&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
Thu Aug  5 06:35:04 2010
@@ -24,7 +24,10 @@ import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Enumeration;
+import java.util.EventListener;
 
+import javax.servlet.Filter;
+import javax.servlet.Servlet;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -54,12 +57,15 @@ public class GeronimoWebAppContext exten
 
     private final IntegrationContext integrationContext;
     private final String modulePath;
+    private final ClassLoader classLoader;
     private ServiceRegistration serviceRegistration;
 
     public GeronimoWebAppContext(SecurityHandler securityHandler, SessionHandler sessionHandler,
ServletHandler servletHandler, ErrorHandler errorHandler, IntegrationContext integrationContext,
ClassLoader classLoader, String modulePath) {
         super(sessionHandler, securityHandler, servletHandler, errorHandler);
+        _scontext = new Context();
         this.integrationContext = integrationContext;
         setClassLoader(classLoader);
+        this.classLoader = classLoader;
         setAttribute(WebApplicationConstants.BUNDLE_CONTEXT_ATTRIBUTE, integrationContext.getBundle().getBundleContext());
         this.modulePath = modulePath;
     }
@@ -203,4 +209,39 @@ public class GeronimoWebAppContext exten
             return true;
         }
     }
+
+    public class Context extends WebAppContext.Context {
+        @Override
+        public <T extends Filter> T createFilter(Class<T> c) throws ServletException
{
+            try {
+                return (T) integrationContext.getHolder().newInstance(c.getName(), classLoader,
integrationContext.getComponentContext());
+            } catch (IllegalAccessException e) {
+                throw new ServletException("Could not create filter " + c.getName(), e);
+            } catch (InstantiationException e) {
+                throw new ServletException("Could not create filter " + c.getName(), e);
+            }
+        }
+
+        @Override
+        public <T extends EventListener> T createListener(Class<T> c) throws
ServletException {
+            try {
+                return (T) integrationContext.getHolder().newInstance(c.getName(), classLoader,
integrationContext.getComponentContext());
+            } catch (IllegalAccessException e) {
+                throw new ServletException("Could not create listener " + c.getName(), e);
+            } catch (InstantiationException e) {
+                throw new ServletException("Could not create listener " + c.getName(), e);
+            }
+        }
+
+        @Override
+        public <T extends Servlet> T createServlet(Class<T> c) throws ServletException
{
+            try {
+                return (T) integrationContext.getHolder().newInstance(c.getName(), classLoader,
integrationContext.getComponentContext());
+            } catch (IllegalAccessException e) {
+                throw new ServletException("Could not create servlet " + c.getName(), e);
+            } catch (InstantiationException e) {
+                throw new ServletException("Could not create servlet " + c.getName(), e);
+            }
+        }
+    }
 }

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java?rev=982482&r1=982481&r2=982482&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
Thu Aug  5 06:35:04 2010
@@ -33,6 +33,7 @@ import javax.resource.ResourceException;
 import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
 import org.apache.geronimo.connector.outbound.connectiontracking.SharedConnectorInstanceContext;
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext;
+import org.apache.geronimo.j2ee.annotation.Holder;
 import org.apache.geronimo.naming.java.RootContext;
 import org.eclipse.jetty.server.Request;
 import org.osgi.framework.Bundle;
@@ -48,14 +49,16 @@ public class IntegrationContext {
     private final TrackedConnectionAssociator trackedConnectionAssociator;
     private final UserTransaction userTransaction;
     private final Bundle bundle;
+    private final Holder holder;
 
-    public IntegrationContext(Context componentContext, Set<String> unshareableResources,
Set<String> applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator,
UserTransaction userTransaction, Bundle bundle) {
+    public IntegrationContext(Context componentContext, Set<String> unshareableResources,
Set<String> applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator,
UserTransaction userTransaction, Bundle bundle, Holder holder) {
         this.componentContext = componentContext;
         this.unshareableResources = unshareableResources;
         this.applicationManagedSecurityResources = applicationManagedSecurityResources;
         this.trackedConnectionAssociator = trackedConnectionAssociator;
         this.userTransaction = userTransaction;
         this.bundle = bundle;
+        this.holder = holder;
     }
 
     public Context getComponentContext() {
@@ -82,6 +85,10 @@ public class IntegrationContext {
         return bundle;
     }
 
+    public Holder getHolder() {
+        return holder;
+    }
+
     public SharedConnectorInstanceContext newConnectorInstanceContext(Request baseRequest)
{
         return new SharedConnectorInstanceContext(getUnshareableResources(),
                 getApplicationManagedSecurityResources(),

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java?rev=982482&r1=982481&r2=982482&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
Thu Aug  5 06:35:04 2010
@@ -37,6 +37,7 @@ import javax.servlet.ServletResponse;
 
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
 import org.apache.geronimo.connector.outbound.connectiontracking.GeronimoTransactionListener;
+import org.apache.geronimo.j2ee.annotation.Holder;
 import org.apache.geronimo.j2ee.jndi.ContextSource;
 import org.apache.geronimo.j2ee.jndi.WebContextSource;
 import org.apache.geronimo.jetty8.connector.HTTPSocketConnector;
@@ -172,7 +173,7 @@ public class AbstractWebModuleTest exten
                 policyContextId,
                 securityHandlerFactory,
                 runAsSource,
-                null,
+                new Holder(),
                 null,
                 connectionTrackingCoordinator,
                 container,

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java?rev=982482&r1=982481&r2=982482&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/StatTest.java
Thu Aug  5 06:35:04 2010
@@ -32,20 +32,20 @@ import org.apache.geronimo.management.La
 public class StatTest extends AbstractWebModuleTest {
 
     private ObjectName webModuleName;
-    
+
     public void testContainerStats() throws Exception {
-	statsTest(container);
+        statsTest(container);
     }
 
     public void testConnectorStats() throws Exception {
-	statsTest(connector);
+        statsTest(connector);
     }
-    
-    public void statsTest(LazyStatisticsProvider component) throws Exception {       
+
+    public void statsTest(LazyStatisticsProvider component) throws Exception {
         // start statistics collection
         if (component instanceof LazyStatisticsProvider) {
-        assertTrue("Stats should be off initially", !component.isStatsOn());
-        component.setStatsOn(true);
+            assertTrue("Stats should be off initially", !component.isStatsOn());
+            component.setStatsOn(true);
         }
         int n = 4; // no of connections
         for (int k = 0; k < n; k++) {
@@ -54,7 +54,7 @@ public class StatTest extends AbstractWe
             assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
             BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
             assertEquals("Hello World", reader.readLine());
-            
+
             Stats stats = component.getStats();
             Statistic[] stts = stats.getStatistics();
             Statistic aStts;
@@ -64,9 +64,9 @@ public class StatTest extends AbstractWe
                 String sttsName = sttsNames[i];
                 assertFalse(sttsName.equals(stts[i].getName()));
                 try {
-                stats.getClass().getMethod("get" + sttsName, new Class[0]);
+                    stats.getClass().getMethod("get" + sttsName, new Class[0]);
                 } catch (NoSuchMethodException e) {
-            	continue; // ignore this statistics for now, JSR77.6.10.1.1
+                    continue; // ignore this statistics for now, JSR77.6.10.1.1
                 }
                 aStts = stats.getStatistic(sttsName);
                 assertTrue("startTime was not set for " + sttsName, aStts.getStartTime()
!= 0);
@@ -75,10 +75,10 @@ public class StatTest extends AbstractWe
             	    "  startTime = " + aStts.getStartTime());
                 System.out.println(aStts);*/
             }
-            if (k == n-2) component.resetStats(); // test reset
+            if (k == n - 2) component.resetStats(); // test reset
             connection.disconnect();
             Thread.sleep(1000);  // connection interval
-        }       
+        }
     }
 
     protected void setUp() throws Exception {



Mime
View raw message