geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r928862 - in /geronimo/server/trunk/plugins: axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/ cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/ jaxws/geronimo-jaxws-builder/src/main/java/or...
Date Mon, 29 Mar 2010 18:46:49 GMT
Author: gawor
Date: Mon Mar 29 18:46:48 2010
New Revision: 928862

URL: http://svn.apache.org/viewvc?rev=928862&view=rev
Log:
updated the jaxws deployment code so that it doesn't blow up with bundle-based deployment

Modified:
    geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
    geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
    geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java?rev=928862&r1=928861&r2=928862&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
Mon Mar 29 18:46:48 2010
@@ -29,6 +29,7 @@ import java.util.jar.JarFile;
 
 import org.apache.geronimo.axis2.pojo.POJOWebServiceContainerFactoryGBean;
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.Deployable;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
@@ -78,7 +79,7 @@ public class Axis2Builder extends JAXWSS
     
     protected Map<String, PortInfo> parseWebServiceDescriptor(InputStream in,
                                                               URL wsDDUrl,
-                                                              JarFile moduleFile,
+                                                              Deployable deployable,
                                                               boolean isEJB,
                                                               Map correctedPortLocations)
             throws DeploymentException {

Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java?rev=928862&r1=928861&r2=928862&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java
(original)
+++ geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java
Mon Mar 29 18:46:48 2010
@@ -42,6 +42,7 @@ import org.apache.cxf.jaxws.javaee.Webse
 import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.cxf.pojo.POJOWebServiceContainerFactoryGBean;
+import org.apache.geronimo.deployment.Deployable;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
@@ -85,7 +86,7 @@ public class CXFBuilder extends JAXWSSer
 
     protected Map<String, PortInfo> parseWebServiceDescriptor(InputStream in,
                                                               URL wsDDUrl,
-                                                              JarFile moduleFile,
+                                                              Deployable deployable,
                                                               boolean isEJB,
                                                               Map correctedPortLocations)
             throws DeploymentException {

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java?rev=928862&r1=928861&r2=928862&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java
(original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java
Mon Mar 29 18:46:48 2010
@@ -23,7 +23,6 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.kernel.osgi.BundleClassLoader;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.WebModule;
 import org.apache.geronimo.jaxws.JAXWSUtils;
@@ -72,7 +71,7 @@ public class AdvancedWARWebServiceFinder
             // partial web.xml, discover all web service classes
 
             Map<String, List<String>> classServletMap = createClassServetMap(webApp);
-            List<Class> services = WARWebServiceFinder.discoverWebServices(module.getModuleFile(),
false, new BundleClassLoader(bundle));
+            List<Class> services = WARWebServiceFinder.discoverWebServices(module,
bundle, false);
             String contextRoot = ((WebModule) module).getContextRoot();
             for (Class service : services) {
                 // skip interfaces and such

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java?rev=928862&r1=928861&r2=928862&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
(original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
Mon Mar 29 18:46:48 2010
@@ -21,11 +21,11 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Map;
-import java.util.jar.JarFile;
 
 import javax.xml.ws.http.HTTPBinding;
 
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.Deployable;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.gbean.AbstractName;
@@ -43,7 +43,6 @@ import org.apache.geronimo.jaxws.annotat
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.kernel.util.JarUtils;
 import org.osgi.framework.Bundle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -73,12 +72,17 @@ public abstract class JAXWSServiceBuilde
                                 Map sharedContext) throws DeploymentException {
         Map portMap = null;
         String path = isEJB ? "META-INF/webservices.xml" : "WEB-INF/webservices.xml";
-        JarFile moduleFile = module.getModuleFile();
-        try {
-            URL wsDDUrl = JarUtils.createJarURL(moduleFile, path);
-            InputStream in = wsDDUrl.openStream();
-            portMap = parseWebServiceDescriptor(in, wsDDUrl, moduleFile, isEJB, servletLocations);
-        } catch (IOException e) {
+        Deployable deployable = module.getDeployable();
+        URL wsDDUrl = deployable.getResource(path);
+        if (wsDDUrl != null) {
+            InputStream in;
+            try {
+                in = wsDDUrl.openStream();
+            } catch (IOException e) {
+                throw new DeploymentException("Failed to parse " + path, e);
+            }
+            portMap = parseWebServiceDescriptor(in, wsDDUrl, deployable, isEJB, servletLocations);
+        } else {
             // webservices.xml does not exist
             portMap = discoverWebServices(module, isEJB, servletLocations);
         }
@@ -102,7 +106,7 @@ public abstract class JAXWSServiceBuilde
 
     protected abstract Map<String, PortInfo> parseWebServiceDescriptor(InputStream
in,
                                                                        URL wsDDUrl,
-                                                                       JarFile moduleFile,
+                                                                       Deployable deployable,

                                                                        boolean isEJB,
                                                                        Map correctedPortLocations)
             throws DeploymentException;

Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java?rev=928862&r1=928861&r2=928862&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java
(original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java
Mon Mar 29 18:46:48 2010
@@ -33,14 +33,22 @@ import javax.jws.WebService;
 import javax.xml.ws.WebServiceProvider;
 
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.Deployable;
+import org.apache.geronimo.deployment.DeployableBundle;
+import org.apache.geronimo.deployment.DeployableJarFile;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.geronimo.kernel.classloader.TemporaryClassLoader;
+import org.apache.geronimo.kernel.osgi.BundleAnnotationFinder;
+import org.apache.geronimo.kernel.osgi.BundleClassLoader;
 import org.apache.geronimo.kernel.util.FileUtils;
 import org.apache.geronimo.kernel.util.JarUtils;
 import org.apache.geronimo.kernel.util.NestedJarFile;
 import org.apache.geronimo.kernel.util.UnpackedJarFile;
 import org.apache.xbean.finder.ClassFinder;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -76,6 +84,48 @@ public class WARWebServiceFinder impleme
      * Returns a list of any classes annotated with @WebService or
      * @WebServiceProvider annotation.
      */
+    static List<Class> discoverWebServices(Module module, 
+                                           Bundle bundle,
+                                           boolean isEJB) 
+            throws DeploymentException {
+        Deployable deployable = module.getDeployable();
+        if (deployable instanceof DeployableJarFile) {
+            return discoverWebServices( ((DeployableJarFile) deployable).getJarFile(), isEJB,
new BundleClassLoader(bundle));
+        } else if (deployable instanceof DeployableBundle) {
+            return discoverWebServices( ((DeployableBundle) deployable).getBundle(), isEJB);
+        } else {
+            throw new DeploymentException("Unsupported deployable: " + deployable.getClass());
+        }
+    }
+
+    /**
+     * Returns a list of any classes annotated with @WebService or
+     * @WebServiceProvider annotation.
+     */
+    static List<Class> discoverWebServices(Bundle bundle, 
+                                           boolean isEJB) 
+            throws DeploymentException {
+        LOG.debug("Discovering web service classes");
+        
+        ServiceReference sr = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
+        PackageAdmin packageAdmin = (PackageAdmin) bundle.getBundleContext().getService(sr);
+        try {
+            BundleAnnotationFinder classFinder = new BundleAnnotationFinder(packageAdmin,
bundle);
+            List<Class> classes = new ArrayList<Class>();
+            classes.addAll(classFinder.findAnnotatedClasses(WebService.class));
+            classes.addAll(classFinder.findAnnotatedClasses(WebServiceProvider.class));
+            return classes;
+        } catch (Exception e) {
+            throw new DeploymentException("Error scanning for web service annotations in
bundle", e);
+        } finally {
+            bundle.getBundleContext().ungetService(sr);
+        }
+    }
+    
+    /**
+     * Returns a list of any classes annotated with @WebService or
+     * @WebServiceProvider annotation.
+     */
     static List<Class> discoverWebServices(JarFile moduleFile,
                                            boolean isEJB,
                                            ClassLoader parentClassLoader)



Mime
View raw message