geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r522431 - in /geronimo/server/trunk/modules: geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/ geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/
Date Mon, 26 Mar 2007 05:47:36 GMT
Author: gawor
Date: Sun Mar 25 22:47:35 2007
New Revision: 522431

URL: http://svn.apache.org/viewvc?view=rev&rev=522431
Log:
spec-compliant default endpoint address for ejb web services

Modified:
    geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSEJBModuleBuilderExtension.java
    geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
    geronimo/server/trunk/modules/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java

Modified: geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSEJBModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSEJBModuleBuilderExtension.java?view=diff&rev=522431&r1=522430&r2=522431
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSEJBModuleBuilderExtension.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSEJBModuleBuilderExtension.java
Sun Mar 25 22:47:35 2007
@@ -118,6 +118,7 @@
             GBeanData ejbWebServiceGBean = new GBeanData(ejbWebServiceName, this.wsGBeanInfo);
 
             ejbWebServiceGBean.setAttribute("ejbName", ejbName);
+            ejbWebServiceGBean.setAttribute("ejbClass", bean.ejbClass);
             
             if (jaxwsBuilder.configureEJB(ejbWebServiceGBean, bean.ejbClass, ejbModule.getModuleFile(),

                                           ejbModule.getSharedContext(), cl)) {
@@ -126,7 +127,7 @@
                     earContext.addGBean(ejbWebServiceGBean);
                 } catch (GBeanAlreadyExistsException e) {
                     throw new DeploymentException(
-                            "Could not add axis ejb web service gbean to context",
+                            "Could not add ejb web service gbean to context",
                             e);
                 }
                 
@@ -138,6 +139,7 @@
             }
             
             ejbWebServiceGBean.clearAttribute("ejbName");
+            ejbWebServiceGBean.clearAttribute("ejbClass");
             
         }
     }

Modified: geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java?view=diff&rev=522431&r1=522430&r2=522431
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
Sun Mar 25 22:47:35 2007
@@ -305,7 +305,7 @@
 
         // verify that the class is loadable
         ClassLoader classLoader = context.getClassLoader();
-        loadSEI(seiClassName, classLoader);
+        loadClass(seiClassName, classLoader);
 
         AbstractName containerFactoryName = context.getNaming().createChildName(targetGBean.getAbstractName(),
getContainerFactoryGBeanInfo().getName(), NameFactory.GERONIMO_SERVICE);
         GBeanData containerFactoryData = new GBeanData(containerFactoryName, getContainerFactoryGBeanInfo());
@@ -350,11 +350,13 @@
         }
         
         String shortEjbName = (String)targetGBean.getAttribute("ejbName");
+        String ejbClass = (String)targetGBean.getAttribute("ejbClass");
                 
-        // FIXME: kind of a hack now, need better solution
         String location = portInfo.getLocation();
-        if (location == null) {            
-            location = "/" + trimPath(new File(moduleFile.getName()).getName()) + "/" + shortEjbName;
+        if (location == null) {                   
+            // set default location, i.e. /@WebService.serviceName/@WebService.name
+            Class beanClass = loadClass(ejbClass, classLoader);
+            location = "/" + JAXWSUtils.getServiceName(beanClass) + "/" + JAXWSUtils.getName(beanClass);
             portInfo.setLocation(location);
         }
 
@@ -365,26 +367,11 @@
         return true;
     }
     
-    private String trimPath(String path) {
-        if (path == null) {
-            return null;
-        }
-
-        if (path.endsWith(".war") || path.endsWith(".jar")) {
-            path = path.substring(0, path.length() - 4);
-        }
-        if (path.endsWith("/")) {
-            path = path.substring(0, path.length() - 1);
-        }
-
-        return path;
-    }
-
-    Class<?> loadSEI(String className, ClassLoader loader) throws DeploymentException
{
+    Class<?> loadClass(String className, ClassLoader loader) throws DeploymentException
{
         try {
             return loader.loadClass(className);
         } catch (ClassNotFoundException ex) {
-            throw new DeploymentException("unable to load Service Endpoint Interface: " +
className, ex);
+            throw new DeploymentException("Unable to load Web Service class: " + className);
         }
     }
 }

Modified: geronimo/server/trunk/modules/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java?view=diff&rev=522431&r1=522430&r2=522431
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java
Sun Mar 25 22:47:35 2007
@@ -103,4 +103,48 @@
             return name.trim();
         }       
     }
+    
+    public static String getName(Class clazz) {
+        WebService webService = 
+            (WebService)clazz.getAnnotation(WebService.class);
+        if (webService == null) {
+            WebServiceProvider webServiceProvider = 
+                (WebServiceProvider)clazz.getAnnotation(WebServiceProvider.class);
+            if (webServiceProvider == null) {
+                throw new IllegalArgumentException("The " + clazz.getName() + " is not annotated");
+            } 
+            return clazz.getSimpleName();         
+        } else {
+            String sei = webService.endpointInterface();
+            if (sei == null || sei.trim().length() == 0) {
+                return getName(clazz, webService.name());
+            } else {
+                try {
+                    Class seiClass = clazz.getClassLoader().loadClass(sei.trim());
+                    return getNameFromSEI(seiClass);
+                } catch (ClassNotFoundException e) {
+                    throw new RuntimeException("Unable to load SEI class: " + sei);
+                }
+            }
+        }
+        
+    }
+        
+    private static String getNameFromSEI(Class seiClass) {
+        WebService webService = 
+            (WebService)seiClass.getAnnotation(WebService.class);
+        if (webService == null) {
+            throw new IllegalArgumentException("The " + seiClass.getName() + " is not annotated");
+        } 
+        return getName(seiClass, webService.name());
+    }
+    
+    private static String getName(Class clazz, String name) {
+        if (name == null || name.trim().length() == 0) {
+            return clazz.getSimpleName();
+        } else {
+            return name.trim();
+        }  
+    }
+    
 }



Mime
View raw message