cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r521665 - in /incubator/cxf/trunk: rt/databinding/jaxb/ rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/ systests/src/test/java/org/apache/cxf/systest/jaxws/
Date Fri, 23 Mar 2007 10:42:15 GMT
Author: ningjiang
Date: Fri Mar 23 03:42:14 2007
New Revision: 521665

URL: http://svn.apache.org/viewvc?view=rev&rev=521665
Log:
[CXF-452] Used forked Javac to compile the java source 

Modified:
    incubator/cxf/trunk/rt/databinding/jaxb/pom.xml
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/Messages.properties
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java

Modified: incubator/cxf/trunk/rt/databinding/jaxb/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/pom.xml?view=diff&rev=521665&r1=521664&r2=521665
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/pom.xml (original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/pom.xml Fri Mar 23 03:42:14 2007
@@ -106,6 +106,13 @@
             <artifactId>cxf-rt-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+       
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-tools-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
 
         <dependency>
             <groupId>org.apache.cxf</groupId>

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java?view=diff&rev=521665&r1=521664&r2=521665
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
Fri Mar 23 03:42:14 2007
@@ -27,6 +27,7 @@
 import java.net.URLClassLoader;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.xml.bind.JAXBContext;
@@ -61,7 +62,6 @@
 import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.Javac;
 import org.apache.tools.ant.types.DirSet;
 import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.types.Path;
@@ -142,7 +142,6 @@
 
     public Client createClient(String wsdlUrl, QName service, ClassLoader classLoader, QName
port) {
         URL u = composeUrl(wsdlUrl);
-
         ClientImpl client = new ClientImpl(bus, u, service, port);
 
         Service svc = client.getEndpoint().getService();
@@ -184,7 +183,6 @@
         if (!src.mkdir()) {
             throw new IllegalStateException("Unable to create working directory " + src.getPath());
         }
-
         try {
             FileCodeWriter writer = new FileCodeWriter(src);
             codeModel.build(writer);
@@ -192,36 +190,22 @@
             throw new IllegalStateException("Unable to write generated Java files for schemas:
"
                                             + e.getMessage(), e);
         }
-
         File classes = new File(tmpdir, stem + "-classes");
         if (!classes.mkdir()) {
             throw new IllegalStateException("Unable to create working directory " + src.getPath());
         }
-              
-
         Project project = new Project();
         project.setBaseDir(new File(tmpdir));
-
-        Javac javac = new Javac();
-        javac.setProject(project);
-
         Path classPath = new Path(project);
-        
         setupClasspath(classPath, classLoader);
-        //TODO need to check the tools.jar in the ClassPath and Check for IBM JDK       

-        javac.setClasspath(classPath);
-        
         Path srcPath = new Path(project);
-        DirSet dirSet = new DirSet();
-        dirSet.setFile(src);
-        srcPath.addDirset(dirSet);
-        javac.setSrcdir(srcPath);
-        javac.setDestdir(classes);
-        javac.setTarget("1.5");
-        //javac.setVerbose(true);        
-        javac.execute();
+        FileSet fileSet = new FileSet();
+        fileSet.setDir(src);
+        srcPath.addFileset(fileSet);
         
-        //delete the src dir
+        if (!compileJavaSrc(classPath, srcPath, classes.toString())) {
+            LOG.log(Level.SEVERE , new Message("COULD_NOT_COMIPLE_SRC", LOG, wsdlUrl).toString());
+        }
         FileUtils.removeDir(src);
         URLClassLoader cl;
         try {
@@ -239,7 +223,7 @@
             throw new IllegalStateException("Unable to create JAXBContext for generated packages:
"
                                             + jbe.getMessage(), jbe);
         }
-
+         
         JAXBDataBinding databinding = new JAXBDataBinding();
         databinding.setContext(context);
         svc.setDataBinding(databinding);
@@ -254,6 +238,27 @@
         // delete the classes files
         FileUtils.removeDir(classes);
         return client;
+    }
+    
+    static boolean compileJavaSrc(Path classPath, Path srcPath, String dest) {
+        String[] srcList = srcPath.list();        
+        String[] javacCommand = new String[srcList.length + 7];
+        
+        javacCommand[0] = "javac";
+        javacCommand[1] = "-classpath";
+        javacCommand[2] = classPath.toString();        
+        javacCommand[3] = "-d";
+        javacCommand[4] = dest.toString();
+        javacCommand[5] = "-target";
+        javacCommand[6] = "1.5";
+        
+        for (int i = 0; i < srcList.length; i++) {
+            javacCommand[7 + i] = srcList[i];            
+        }
+        org.apache.cxf.tools.util.Compiler javaCompiler 
+            = new org.apache.cxf.tools.util.Compiler();
+        
+        return javaCompiler.internalCompile(javacCommand, 7); 
     }
 
     static void setupClasspath(Path classPath, ClassLoader classLoader) {

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/Messages.properties?view=diff&rev=521665&r1=521664&r2=521665
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/Messages.properties
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/Messages.properties
Fri Mar 23 03:42:14 2007
@@ -19,4 +19,5 @@
 #
 #
 NO_JAXB_CLASS = No compiled schema dlement could be found for type {0}
-COULD_NOT_RESOLVE_URL = Could not resolve URL "{0}".
\ No newline at end of file
+COULD_NOT_RESOLVE_URL = Could not resolve URL "{0}".
+COULD_NOT_COMIPLE_SRC = Could not compile java files for {0}.
\ No newline at end of file

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?view=diff&rev=521665&r1=521664&r2=521665
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
Fri Mar 23 03:42:14 2007
@@ -704,8 +704,7 @@
                                    
     }
     
-    @Test
-    @Ignore
+    @Test   
     public void testDynamicClientFactory()  {
         URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
         assertNotNull(wsdl);
@@ -713,8 +712,8 @@
         try {
             wsdlUrl = wsdl.toURI().toString();
         } catch (URISyntaxException e) {
-            fail("Can't get the hello_world.wsdl url");
             e.printStackTrace();
+            fail("Can't get the hello_world.wsdl url");            
         }
         try {
             //TODO test fault exceptions 
@@ -723,10 +722,11 @@
             client.invoke("greetMe", "test");        
             Object[] result = client.invoke("sayHi");
             assertNotNull("no response received from service", result);
+            System.out.println(result[0]);
             assertEquals("Bonjour", result[0]);
-        } catch (Exception e) {
-            fail("There is some excpetion happened ");
+        } catch (Exception e) {            
             e.printStackTrace();
+            fail("There is some excpetion happened ");
         }    
         
     }



Mime
View raw message