geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r527495 - in /geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder: Axis2Builder.java Axis2BuilderUtil.java
Date Wed, 11 Apr 2007 13:56:48 GMT
Author: dims
Date: Wed Apr 11 06:56:47 2007
New Revision: 527495

URL: http://svn.apache.org/viewvc?view=rev&rev=527495
Log:
Let's see if we can get rid of NCDFE for com/sun/mirror/apt/AnnotationProcessorFactory by
explicitly creating a classloader (with system class loader as parent).


Modified:
    geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
    geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java

Modified: geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java?view=diff&rev=527495&r1=527494&r2=527495
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2Builder.java
Wed Apr 11 06:56:47 2007
@@ -25,10 +25,13 @@
 import java.io.StringWriter;
 import java.net.URI;
 import java.net.URL;
+import java.net.MalformedURLException;
+import java.net.URLClassLoader;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.jar.JarFile;
+import java.lang.reflect.Method;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.WebServiceException;
@@ -66,8 +69,6 @@
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
 
-import com.sun.tools.ws.spi.WSToolsObjectFactory;
-
 /**
  * @version $Rev$ $Date$
  */
@@ -319,9 +320,15 @@
 
         EARContext moduleContext = module.getEarContext();
         outputDir = moduleContext.getBaseDir().getAbsolutePath();
-        
+
+        URL[] urls;
         //let's figure out the classpath for wsgen tools
-        String classPath = Axis2BuilderUtil.getWsgenClasspath(module, context);
+        try {
+             urls = Axis2BuilderUtil.getWsgenClasspath(module, context);
+        } catch (MalformedURLException e) {
+            log.warn("unable to generate the wsdl file using wsgen.", e);
+            return "";
+        }
 
         //create arguments;
         String[] arguments = null;       
@@ -330,8 +337,7 @@
                         SOAPBinding.SOAP11HTTP_MTOM_BINDING)) {
             log.info("wsgen - Generating WSDL with SOAP 1.1 binding type, based on type "
+ bindingType);
             log.info("outputDir is " + outputDir);
-            log.info("classPath is " + classPath);
-            arguments = new String[]{"-cp", classPath, sei, "-keep", "-wsdl:soap1.1", "-d",

+            arguments = new String[]{sei, "-keep", "-wsdl:soap1.1", "-d",
                     outputDir};
         } else if (bindingType.equals(SOAPBinding.SOAP12HTTP_BINDING) || bindingType.equals(
                 SOAPBinding.SOAP12HTTP_MTOM_BINDING)) { 
@@ -339,8 +345,7 @@
             //used in conjunction with the -extension option
             log.info("wsgen - Generating WSDL with SOAP 1.2 binding type, based on type "
+ bindingType);
             log.info("outputDir is " + outputDir);
-            log.info("classPath is " + classPath);
-            arguments =  new String[]{"-cp", classPath, sei, "-keep", "-extension", 
+            arguments =  new String[]{sei, "-keep", "-extension",
                     "-wsdl:Xsoap1.2", "-d", outputDir};
         } else {
             throw new WebServiceException("The bindingType specified by " + sei 
@@ -348,16 +353,19 @@
         }
         
         try {
-            WSToolsObjectFactory factory = WSToolsObjectFactory.newInstance();
+            URLClassLoader loader = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
+            Class clazz = loader.loadClass("com.sun.tools.ws.spi.WSToolsObjectFactory");
+            Object factory = clazz.newInstance();
+            Method method = clazz.getMethod("wsgen", OutputStream.class, String[].class);
             OutputStream os = new ByteArrayOutputStream();
-            boolean result = factory.wsgen(os, arguments);   
+            Boolean result = (Boolean) method.invoke(factory, os, arguments);
             os.close();
             if (result) //check to see if the file is created.
                 return "SOAPService.wsdl"; //this is the default name of the wsdl file. 
TODO: can we overwrite it?
             else
                 return "";
-        } catch (IOException ex) {
-            log.warn("unable to generate the wsdl file using wsgen.");
+        } catch (Exception e) {
+            log.warn("unable to generate the wsdl file using wsgen.", e);
             return "";
         }
     }

Modified: geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java?view=diff&rev=527495&r1=527494&r2=527495
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2BuilderUtil.java
Wed Apr 11 06:56:47 2007
@@ -17,22 +17,21 @@
 
 package org.apache.geronimo.axis2.builder;
 
-import java.io.File;
-import java.util.Collection;
-import java.util.List;
-
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.DeploymentConfigurationManager;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
-import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Repository;
 
-/**
- * @version $Rev$ $Date$
- */
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
 public class Axis2BuilderUtil {
 
     //TODO: need to update to released jars when they are avail.
@@ -49,8 +48,8 @@
     private final static Artifact GERONIMO_WS_METADATA_ARTIFACT = new Artifact("org.apache.geronimo.specs","geronimo-ws-metadata_2.0_spec",
"1.1-SNAPSHOT", "jar");    
     private final static String TOOLS = "tools.jar";
     
-    protected static String getWsgenClasspath(Module module, DeploymentContext context) throws
DeploymentException {
-   
+    protected static URL[] getWsgenClasspath(Module module, DeploymentContext context) throws
DeploymentException, MalformedURLException {
+        ArrayList<URL> jars = new ArrayList();
         EARContext moduleContext = module.getEarContext();
         String baseDir = moduleContext.getBaseDir().getAbsolutePath();
         List<String> moduleClassPath = context.getConfiguration().getClassPath(); 
@@ -59,31 +58,31 @@
         Collection<Repository> repositories = cm.getRepositories();
 
         //start classpath with path to tools.jar
-        String classpath = getLocation(repositories, JAXB_API_ARTIFACT) + java.io.File.pathSeparator
-            + getLocation(repositories, JAXB_IMPL_ARTIFACT) + java.io.File.pathSeparator
-            + getLocation(repositories, JAXB_XJC_ARTIFACT) + java.io.File.pathSeparator
-            + getLocation(repositories, JAXWS_TOOLS_ARTIFACT) + java.io.File.pathSeparator
-            + getLocation(repositories, JAXWS_RT_ARTIFACT) + java.io.File.pathSeparator
-            + getLocation(repositories, AXIS2_JAXWS_API_ARTIFACT) + java.io.File.pathSeparator
-            + getLocation(repositories, AXIS2_SAAJ_API_ARTIFACT) + java.io.File.pathSeparator
-            + getLocation(repositories, AXIS2_SAAJ_ARTIFACT) + java.io.File.pathSeparator
-            + getLocation(repositories, GERONIMO_ACTIVATION_SPEC_ARTIFACT) + java.io.File.pathSeparator
-            + getLocation(repositories, GERONIMO_ANNOTATION_ARTIFACT) + java.io.File.pathSeparator
-            + getLocation(repositories, GERONIMO_WS_METADATA_ARTIFACT) + java.io.File.pathSeparator
-            + getToolsJarLoc() + java.io.File.pathSeparator
-            + getModuleClassPath(baseDir, moduleClassPath);
+        jars.add(getLocation(repositories, JAXB_API_ARTIFACT));
+        jars.add(getLocation(repositories, JAXB_IMPL_ARTIFACT));
+        jars.add(getLocation(repositories, JAXB_XJC_ARTIFACT));
+        jars.add(getLocation(repositories, JAXWS_TOOLS_ARTIFACT));
+        jars.add(getLocation(repositories, JAXWS_RT_ARTIFACT));
+        jars.add(getLocation(repositories, AXIS2_JAXWS_API_ARTIFACT));
+        jars.add(getLocation(repositories, AXIS2_SAAJ_API_ARTIFACT));
+        jars.add(getLocation(repositories, AXIS2_SAAJ_ARTIFACT));
+        jars.add(getLocation(repositories, GERONIMO_ACTIVATION_SPEC_ARTIFACT));
+        jars.add(getLocation(repositories, GERONIMO_ANNOTATION_ARTIFACT));
+        jars.add(getLocation(repositories, GERONIMO_WS_METADATA_ARTIFACT));
+        jars.add(new File(getToolsJarLoc()).toURL());
+        jars.addAll(getModuleClassPath(baseDir, moduleClassPath));
          
-        return classpath;    
+        return jars.toArray(new URL[jars.size()]);
         
     }
     
-    private static String getLocation(Collection<Repository> repositories, Artifact
artifact) throws DeploymentException {
+    private static URL getLocation(Collection<Repository> repositories, Artifact artifact)
throws DeploymentException, MalformedURLException {
         File file = null;
         
         for (Repository repository : repositories) {
             if (repository.contains(artifact)) {
                 file = repository.getLocation(artifact);
-                return file.getAbsolutePath();
+                return file.getAbsoluteFile().toURL();
             }
         }
         if (file == null) {
@@ -117,14 +116,13 @@
         }
     }
     
-    private static String getModuleClassPath(String baseDir, List<String> moduleClassPath)
{
-        String classpath = "";
+    private static List getModuleClassPath(String baseDir, List<String> moduleClassPath)
throws MalformedURLException {
+        ArrayList jars = new ArrayList();
         for (String s : moduleClassPath) {
             if (s.contains("/"))
                 s = s.replace("/", java.io.File.separator);
-            classpath += baseDir + java.io.File.separator + s + java.io.File.pathSeparator;
+            jars.add(new File(baseDir + java.io.File.separator + s).toURL());
         }
-        System.out.println("getModuleClasspath: " + classpath);
-        return classpath;
+        return jars;
     }
 }



Mime
View raw message