[jbossws-commits] JBossWS SVN: r8352 - in stack/metro/trunk/modules/server/src/main: resources/jbossws-metro-server.jar/META-INF/services and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Mon Oct 6 12:37:22 EDT 2008


Author: richard.opalka at jboss.com
Date: 2008-10-06 12:37:22 -0400 (Mon, 06 Oct 2008)
New Revision: 8352

Added:
   stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/AspectizedEndpointServlet.java
   stack/metro/trunk/modules/server/src/main/resources/jbossws-metro-server.jar/META-INF/services/org.jboss.wsf.spi.DeploymentAspectManagerLocator
Modified:
   stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/EndpointServlet.java
Log:
[JBWS-2246][JBWS-2264][JBAS-5732] provide aspectized servlet + enhance BC compatible servlet

Added: stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/AspectizedEndpointServlet.java
===================================================================
--- stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/AspectizedEndpointServlet.java	                        (rev 0)
+++ stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/AspectizedEndpointServlet.java	2008-10-06 16:37:22 UTC (rev 8352)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.metro;
+
+import org.jboss.wsf.spi.DeploymentAspectManagerLocator;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.DeploymentAspectManager;
+
+/**
+ * Endpoint servlet with WS framework aspects support called on servlet lifecycle methods
+ * @author richard.opalka at jboss.com
+ */
+public class AspectizedEndpointServlet extends EndpointServlet
+{
+
+   protected DeploymentAspectManager aspectsManager;
+
+   protected void initDeploymentAspectManager()
+   {
+      SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+      DeploymentAspectManagerLocator locator = spiProvider.getSPI(DeploymentAspectManagerLocator.class);
+      aspectsManager = locator.locateDeploymentAspectManager("WSServletAspectManager");
+   }
+   
+   protected void callRuntimeAspects()
+   {
+      Deployment dep = endpoint.getService().getDeployment();
+      aspectsManager.create(dep, null);
+      aspectsManager.start(dep, null);
+   }
+   
+   public void destroy()
+   {
+      try
+      {
+         Deployment dep = endpoint.getService().getDeployment();
+         aspectsManager.stop(dep, null);
+         aspectsManager.destroy(dep, null);
+      }
+      finally
+      {
+         super.destroy();
+      }
+   }
+   
+}

Modified: stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/EndpointServlet.java
===================================================================
--- stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/EndpointServlet.java	2008-10-06 16:04:51 UTC (rev 8351)
+++ stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/EndpointServlet.java	2008-10-06 16:37:22 UTC (rev 8352)
@@ -41,8 +41,9 @@
 import java.io.IOException;
 
 /**
+ * A servlet that is installed for every web service endpoint.
+ * @author richard.opalka at jboss.com
  * @author Heiko.Braun at jboss.com
- *         Created: Jul 24, 2007
  */
 public class EndpointServlet extends HttpServlet
 {
@@ -52,18 +53,20 @@
    public void init(ServletConfig servletConfig) throws ServletException
    {
       super.init(servletConfig);
+      this.initRegistry();
+      this.initDeploymentAspectManager();
+      String contextPath = servletConfig.getServletContext().getContextPath();
+      this.initServiceEndpoint(contextPath);
+   }
+   
+   protected void initRegistry()
+   {
       SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
       epRegistry = spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
    }
 
    public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    {
-      if (endpoint == null)
-      {
-         String contextPath = req.getContextPath();
-         initServiceEndpoint(contextPath);
-      }
-
       try
       {
          EndpointAssociation.setEndpoint(endpoint);
@@ -80,7 +83,14 @@
     */
    protected void initServiceEndpoint(String contextPath)
    {
-      WebAppResolver resolver = new WebAppResolver(contextPath, getServletName());
+      this.initEndpoint(contextPath, getServletName());
+      this.setRuntimeLoader();
+      this.callRuntimeAspects();
+   }
+
+   private void initEndpoint(String contextPath, String servletName)
+   {
+      WebAppResolver resolver = new WebAppResolver(contextPath, servletName);
       this.endpoint = epRegistry.resolve(resolver);
 
       if (this.endpoint == null)
@@ -91,7 +101,10 @@
          );
          throw new WebServiceException("Cannot obtain endpoint for: " + oname);
       }
-
+   }
+   
+   private void setRuntimeLoader()
+   {
       // Set the runtime classloader for JSE endpoints, this should be the tomcat classloader
       Deployment dep = endpoint.getService().getDeployment();
       if (dep.getType() == Deployment.DeploymentType.JAXRPC_JSE || dep.getType() == Deployment.DeploymentType.JAXWS_JSE)
@@ -100,4 +113,21 @@
          dep.setRuntimeClassLoader(classLoader);
       }
    }
+   
+   /**
+    * Template method
+    */
+   protected void initDeploymentAspectManager()
+   {
+      // does nothing (because of BC)
+   }
+   
+   /**
+    * Template method
+    */
+   protected void callRuntimeAspects()
+   {
+      // does nothing (because of BC)
+   }
+   
 }

Added: stack/metro/trunk/modules/server/src/main/resources/jbossws-metro-server.jar/META-INF/services/org.jboss.wsf.spi.DeploymentAspectManagerLocator
===================================================================
--- stack/metro/trunk/modules/server/src/main/resources/jbossws-metro-server.jar/META-INF/services/org.jboss.wsf.spi.DeploymentAspectManagerLocator	                        (rev 0)
+++ stack/metro/trunk/modules/server/src/main/resources/jbossws-metro-server.jar/META-INF/services/org.jboss.wsf.spi.DeploymentAspectManagerLocator	2008-10-06 16:37:22 UTC (rev 8352)
@@ -0,0 +1 @@
+org.jboss.wsf.framework.DeploymentAspectManagerLocatorImpl
\ No newline at end of file




More information about the jbossws-commits mailing list