[jbossws-commits] JBossWS SVN: r3516 - in branches/jbossws-2.0: integration/spi/src/main/java/org/jboss/wsf/spi/deployment and 1 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Fri Jun 8 15:55:32 EDT 2007


Author: thomas.diesler at jboss.com
Date: 2007-06-08 15:55:32 -0400 (Fri, 08 Jun 2007)
New Revision: 3516

Added:
   branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/LegacyContextRootDeployer.java
   branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/LegacyURLPatternDeployer.java
Modified:
   branches/jbossws-2.0/integration/native/src/main/resources/jbossws-native50.sar/META-INF/jbossws-beans.xml
   branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/deployment/ContextRootDeployer.java
   branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/deployment/URLPatternDeployer.java
Log:
Add legacy context/url-pattern deployer

Modified: branches/jbossws-2.0/integration/native/src/main/resources/jbossws-native50.sar/META-INF/jbossws-beans.xml
===================================================================
--- branches/jbossws-2.0/integration/native/src/main/resources/jbossws-native50.sar/META-INF/jbossws-beans.xml	2007-06-08 19:17:32 UTC (rev 3515)
+++ branches/jbossws-2.0/integration/native/src/main/resources/jbossws-native50.sar/META-INF/jbossws-beans.xml	2007-06-08 19:55:32 UTC (rev 3516)
@@ -135,7 +135,7 @@
     Each handles a single aspect of web service deployment 
   --> 
   <bean name="WSClassLoaderInjectionDeployer" class="org.jboss.wsf.container.jboss50.ClassLoaderInjectionDeployer"/>
-  <bean name="WSContextRootDeployer" class="org.jboss.wsf.spi.deployment.ContextRootDeployer"/>
+  <bean name="WSContextRootDeployer" class="org.jboss.ws.core.server.LegacyContextRootDeployer"/>
   <bean name="WSEagerInitializeDeployer" class="org.jboss.wsf.stack.jbws.EagerInitializeDeployer"/>
   <bean name="WSEndpointHandlerDeployer" class="org.jboss.wsf.spi.deployment.EndpointHandlerDeployer">
     <property name="requestHandler">org.jboss.wsf.stack.jbws.RequestHandlerImpl</property>
@@ -161,7 +161,7 @@
   <bean name="WSUnifiedDeploymentInfoDeployer" class="org.jboss.wsf.container.jboss50.UnifiedDeploymentInfoDeployer"/>
   <bean name="WSUnifiedMetaDataAssociationDeployer" class="org.jboss.wsf.stack.jbws.UnifiedMetaDataAssociationDeployer"/>
   <bean name="WSUnifiedMetaDataDeployer" class="org.jboss.wsf.stack.jbws.UnifiedMetaDataDeployer"/>
-  <bean name="WSURLPatternDeployer" class="org.jboss.wsf.spi.deployment.URLPatternDeployer"/>
+  <bean name="WSURLPatternDeployer" class="org.jboss.ws.core.server.LegacyURLPatternDeployer"/>
   <bean name="WSWebAppGeneratorDeployer" class="org.jboss.wsf.spi.deployment.WebAppGeneratorDeployer">
     <property name="securityHandlerEJB21"><inject bean="WSSecurityHandlerEJB21"/></property>
     <property name="securityHandlerEJB3"><inject bean="WSSecurityHandlerEJB3"/></property>

Modified: branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/deployment/ContextRootDeployer.java
===================================================================
--- branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/deployment/ContextRootDeployer.java	2007-06-08 19:17:32 UTC (rev 3515)
+++ branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/deployment/ContextRootDeployer.java	2007-06-08 19:55:32 UTC (rev 3516)
@@ -38,11 +38,18 @@
    @Override
    public void create(Deployment dep)
    {
-      String contextRoot = getContextRoot(dep);
+      String contextRoot = getExplicitContextRoot(dep);
+      if (contextRoot == null)
+         contextRoot = getImplicitContextRoot(dep);
+      
+      // Always prefix with '/'
+      if (contextRoot.startsWith("/") == false)
+         contextRoot = "/" + contextRoot;
+      
       dep.getService().setContextRoot(contextRoot);
    }
 
-   private String getContextRoot(Deployment dep)
+   protected String getExplicitContextRoot(Deployment dep)
    {
       String contextRoot = null;
 
@@ -75,23 +82,21 @@
          contextRoot = appMetaData.getWebServiceContextRoot();
       }
 
-      // #4 Use the implicit context root derived from the deployment name
-      if (contextRoot == null)
+      return contextRoot;
+   }
+
+   /** Use the implicit context root derived from the deployment name
+    */
+   protected String getImplicitContextRoot(Deployment dep)
+   {
+      UnifiedDeploymentInfo udi = dep.getContext().getAttachment(UnifiedDeploymentInfo.class);
+      String simpleName = udi.simpleName;
+      String contextRoot = simpleName.substring(0, simpleName.length() - 4);
+      if (udi.parent != null)
       {
-         UnifiedDeploymentInfo udi = dep.getContext().getAttachment(UnifiedDeploymentInfo.class);
-         String simpleName = udi.simpleName;
-         contextRoot = simpleName.substring(0, simpleName.length() - 4);
-         if (udi.parent != null)
-         {
-            simpleName = udi.parent.simpleName;
-            contextRoot = simpleName.substring(0, simpleName.length() - 4) + "-" + contextRoot;
-         }
+         simpleName = udi.parent.simpleName;
+         contextRoot = simpleName.substring(0, simpleName.length() - 4) + "-" + contextRoot;
       }
-
-      // Always prefix with '/'
-      if (contextRoot.startsWith("/") == false)
-         contextRoot = "/" + contextRoot;
-      
       return contextRoot;
    }
 }
\ No newline at end of file

Modified: branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/deployment/URLPatternDeployer.java
===================================================================
--- branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/deployment/URLPatternDeployer.java	2007-06-08 19:17:32 UTC (rev 3515)
+++ branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/deployment/URLPatternDeployer.java	2007-06-08 19:55:32 UTC (rev 3516)
@@ -42,12 +42,19 @@
    {
       for (Endpoint ep : dep.getService().getEndpoints())
       {
-         String urlPattern = getUrlPattern(dep, ep);
+         String urlPattern = getExplicitPattern(dep, ep);
+         if (urlPattern == null)
+            urlPattern = getImplicitPattern(dep, ep);
+         
+         // Always prefix with '/'
+         if (urlPattern.startsWith("/") == false)
+            urlPattern = "/" + urlPattern;
+
          ep.setURLPattern(urlPattern);
       }
    }
 
-   private String getUrlPattern(Deployment dep, Endpoint ep)
+   protected String getExplicitPattern(Deployment dep, Endpoint ep)
    {
       String urlPattern = null;
 
@@ -81,17 +88,14 @@
          if (anWebContext != null && anWebContext.urlPattern().length() > 0)
             urlPattern = anWebContext.urlPattern();
       }
+      
+      return urlPattern;
+   }
 
+   protected String getImplicitPattern(Deployment dep, Endpoint ep)
+   {
       // #4 Fallback to the ejb-name 
-      if (urlPattern == null)
-      {
-         urlPattern = ep.getShortName();
-      }
-      
-      // Always prefix with '/'
-      if (urlPattern.startsWith("/") == false)
-         urlPattern = "/" + urlPattern;
-
+      String urlPattern = ep.getShortName();
       return urlPattern;
    }
 }
\ No newline at end of file

Added: branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/LegacyContextRootDeployer.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/LegacyContextRootDeployer.java	                        (rev 0)
+++ branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/LegacyContextRootDeployer.java	2007-06-08 19:55:32 UTC (rev 3516)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ws.core.server;
+
+//$Id$
+
+import org.jboss.wsf.spi.deployment.ContextRootDeployer;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.metadata.j2ee.UnifiedApplicationMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.UnifiedBeanMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.UnifiedEjbPortComponentMetaData;
+
+/**
+ * A deployer that assigns the context root to the service.
+ * 
+ * This deployer uses the first token from the <port-component-uri>
+ * as the context root.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Apr-2007
+ */
+public class LegacyContextRootDeployer extends ContextRootDeployer
+{
+   @Override
+   protected String getExplicitContextRoot(Deployment dep)
+   {
+      String contextRoot = super.getExplicitContextRoot(dep);
+      if (contextRoot == null)
+      {
+         for (Endpoint ep : dep.getService().getEndpoints())
+         {
+            String urlPattern = getUrlPattern(dep, ep);
+            if (urlPattern != null)
+            {
+               String[] tokens = urlPattern.split("/");
+               if (tokens.length > 1)
+               {
+                  contextRoot = tokens[0];
+               }
+            }
+         }
+      }
+      return contextRoot;
+   }
+
+   private String getUrlPattern(Deployment dep, Endpoint ep)
+   {
+      String urlPattern = null;
+
+      UnifiedApplicationMetaData appMetaData = dep.getContext().getAttachment(UnifiedApplicationMetaData.class);
+      if (appMetaData != null && appMetaData.getBeanByEjbName(ep.getShortName()) != null)
+      {
+         UnifiedBeanMetaData bmd = appMetaData.getBeanByEjbName(ep.getShortName());
+         UnifiedEjbPortComponentMetaData pcmd = bmd.getPortComponent();
+         if (pcmd != null)
+         {
+            urlPattern = pcmd.getPortComponentURI();
+         }
+      }
+
+      return urlPattern;
+   }
+}
\ No newline at end of file


Property changes on: branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/LegacyContextRootDeployer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/LegacyURLPatternDeployer.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/LegacyURLPatternDeployer.java	                        (rev 0)
+++ branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/LegacyURLPatternDeployer.java	2007-06-08 19:55:32 UTC (rev 3516)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ws.core.server;
+
+//$Id$
+
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.URLPatternDeployer;
+
+/**
+ * A deployer that assigns the URLPattern to endpoints. 
+ *
+ * This deployer uses the first token from the <port-component-uri>
+ * as the context root.
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 19-May-2007
+ */
+public class LegacyURLPatternDeployer extends URLPatternDeployer
+{
+
+   @Override
+   protected String getExplicitPattern(Deployment dep, Endpoint ep)
+   {
+      String contextRoot = dep.getService().getContextRoot();
+      if (contextRoot == null)
+         throw new IllegalStateException("Cannot obtain context root");
+
+      String urlPattern = super.getExplicitPattern(dep, ep);
+      if (urlPattern != null)
+      {
+         if (urlPattern.startsWith("/") == false)
+            urlPattern = "/" + urlPattern;
+
+         String[] tokens = urlPattern.split("/");
+         if (tokens.length > 1 && urlPattern.startsWith(contextRoot))
+         {
+            urlPattern = urlPattern.substring(contextRoot.length());
+         }
+      }
+      return urlPattern;
+   }
+}
\ No newline at end of file


Property changes on: branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/LegacyURLPatternDeployer.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jbossws-commits mailing list