cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1240243 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/rs/ rt/frontend/jaxrs/src/test/java/org/ap...
Date Fri, 03 Feb 2012 16:54:37 GMT
Author: sergeyb
Date: Fri Feb  3 16:54:37 2012
New Revision: 1240243

URL: http://svn.apache.org/viewvc?rev=1240243&view=rev
Log:
[CXF-4087] Moving SourceGenerator to tools/wadlto, dropping CodeGeneratorProvider

Added:
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
      - copied, changed from r1240153, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
Removed:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/rs/
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ext/codegen/CodeGeneratorProviderTest.java
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
    cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java?rev=1240243&r1=1240242&r2=1240243&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
Fri Feb  3 16:54:37 2012
@@ -31,12 +31,10 @@ import javax.ws.rs.core.UriInfo;
 
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.jaxrs.ext.RequestHandler;
-import org.apache.cxf.jaxrs.ext.codegen.CodeGeneratorProvider;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
-import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.message.Message;
 
 public class RequestPreprocessor {
@@ -83,9 +81,6 @@ public class RequestPreprocessor {
         handleCType(m, queries);
         handleMethod(m, queries, new HttpHeadersImpl(m));
         Response r = checkMetadataRequest(m, u);
-        if (r == null) {
-            r = checkCodeRequest(m);
-        }
         if (r != null) {
             m.getExchange().put(Response.class, r);
         }
@@ -226,22 +221,5 @@ public class RequestPreprocessor {
         return value.endsWith("/") ? value.substring(0, value.length() - 1) : value;
     }
     
-    public Response checkCodeRequest(Message m) {
-        String query = (String)m.get(Message.QUERY_STRING);
-        if (query != null && (query.contains(CodeGeneratorProvider.CODE_QUERY) 
-            || query.contains(CodeGeneratorProvider.SOURCE_QUERY))) {
-            String requestURI = (String)m.get(Message.REQUEST_URI);
-            String baseAddress = HttpUtils.getBaseAddress(m);
-            if (baseAddress.equals(requestURI)) {
-                List<ProviderInfo<RequestHandler>> shs = ProviderFactory.getInstance(m).getRequestHandlers();
-                for (ProviderInfo<RequestHandler> provider : shs) {
-                    if (provider.getProvider() instanceof CodeGeneratorProvider) { 
-                        InjectionUtils.injectContextMethods(provider.getProvider(), provider,
m);
-                        return provider.getProvider().handleRequest(m, null);
-                    }
-                }
-            }
-        }
-        return null;
-    }
+    
 }

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java?rev=1240243&r1=1240242&r2=1240243&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
Fri Feb  3 16:54:37 2012
@@ -21,37 +21,23 @@ package org.apache.cxf.systest.jaxrs;
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
+
 import java.net.HttpURLConnection;
 import java.net.Socket;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.net.URL;
-import java.net.URLClassLoader;
 import java.net.URLConnection;
-import java.util.Collections;
 import java.util.List;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.jaxrs.ext.codegen.CodeGeneratorProvider;
-import org.apache.cxf.jaxrs.ext.xml.XMLSource;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
-import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.transport.http.HTTPConduit;
 
@@ -116,68 +102,6 @@ public class JAXRSClientServerResourceCr
         checkPetStoreInfo(resourceEls.get(0));
     }
     
-    @Test
-    public void testPetStoreSource() throws Exception {
-        try {
-            WebClient wc = WebClient.create("http://localhost:" + PORT + "/webapp/resources/petstore");
-            HTTPConduit conduit = WebClient.getConfig(wc).getHttpConduit();
-            conduit.getClient().setReceiveTimeout(1000000);
-            conduit.getClient().setConnectionTimeout(1000000);
-            XMLSource source = wc.query("_code", "").query("_os", getOs()).get(XMLSource.class);
-            String link = source.getValue("ns:html/ns:body/ns:ul/ns:a/@href", 
-                                          Collections.singletonMap("ns", "http://www.w3.org/1999/xhtml"));
-            WebClient wc2 = WebClient.create(link);
-            HTTPConduit conduit2 = WebClient.getConfig(wc2).getHttpConduit();
-            conduit2.getClient().setReceiveTimeout(1000000);
-            conduit2.getClient().setConnectionTimeout(1000000);
-            InputStream is = wc2.accept("application/zip").get(InputStream.class);
-            String tmpdir = System.getProperty("java.io.tmpdir");
-            File classes = new File(tmpdir, "cxf-jaxrs-test-compiled-src");
-            if (!classes.mkdir()) {
-                fail();
-            }
-            File unzippedSrc = new File(tmpdir, "cxf-jaxrs-test-unzipped-src");
-            if (!unzippedSrc.mkdir()) {
-                fail();
-            }
-            try {             
-                compileSrc(classes, unzippedSrc, is);
-                verifyClasses(classes);
-            } finally {
-                FileUtils.removeDir(classes);
-                FileUtils.removeDir(unzippedSrc);
-            }
-        } finally {
-            ClassResourceInfo cri = 
-                ResourceUtils.createClassResourceInfo(PetStore.class, PetStore.class, true,
true);
-            new CodeGeneratorProvider().removeCode(cri);
-        }
-    }
- 
-    private void verifyClasses(File classesDir) {
-        List<File> clsFiles = FileUtils.getFilesRecurse(classesDir, ".+\\.class$");
-        assertEquals(1, clsFiles.size());
-        assertTrue(checkContains(clsFiles, "org.apache.cxf.systest.jaxrs.PetStore.class"));
-    }
-    
-    private boolean checkContains(List<File> clsFiles, String name) {
-        
-        for (File f : clsFiles) {
-            if (f.getAbsolutePath().replace(getPathSep(), ".").endsWith(name)) {
-                return true;
-            }
-        }
-        return false;
-    }
-    
-    private String getPathSep() {
-        String os = System.getProperty("os.name");
-        if (os.toLowerCase().contains("win")) {
-            return "\\";
-        } else {
-            return "/";
-        }
-    }
     
     private void checkBookStoreInfo(Element resource) {
         assertEquals("/bookstore", resource.getAttribute("path"));
@@ -325,136 +249,4 @@ public class JAXRSClientServerResourceCr
         return IOUtils.toString(in);
     }
 
-    private void compileSrc(File classes, File unzippedSrc, InputStream zipFile) throws Exception
{
-        unzip(zipFile, unzippedSrc);
-        StringBuilder classPath = new StringBuilder();
-        try {
-            setupClasspath(classPath, this.getClass().getClassLoader());
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-        
-        List<File> srcFiles = FileUtils.getFilesRecurse(unzippedSrc, ".+\\.java$");

-        if (!compileJavaSrc(classPath.toString(), srcFiles, classes.toString())) {
-            fail("Could not compile classes");
-        }
-    }
-
-    private void unzip(InputStream fin, File unzippedSrc) throws Exception {
-        ZipInputStream zin = new ZipInputStream(fin);
-        ZipEntry ze = null;
-        while ((ze = zin.getNextEntry()) != null) {
-            String entryName = ze.getName();
-            int index = entryName.lastIndexOf(System.getProperty("file.separator"));
-            File packageDir = new File(unzippedSrc, entryName.substring(0, index));
-            packageDir.mkdirs();
-            FileOutputStream fout = new FileOutputStream(
-                                        new File(packageDir, entryName.substring(index +
1)));
-            for (int c = zin.read(); c != -1; c = zin.read()) {
-                fout.write(c);
-            }
-            zin.closeEntry();
-            fout.close();
-        }
-        zin.close();
-    }
-    
-    protected boolean compileJavaSrc(String classPath, List<File> srcList, String dest)
{
-        org.apache.cxf.common.util.Compiler javaCompiler 
-            = new org.apache.cxf.common.util.Compiler();
-        
-        javaCompiler.setTarget("1.5");
-        javaCompiler.setOutputDir(dest);
-        javaCompiler.setClassPath(classPath);
-        
-        return javaCompiler.compileFiles(srcList); 
-    }
-    
-    static void setupClasspath(StringBuilder classPath, ClassLoader classLoader)
-        throws URISyntaxException, IOException {
-        
-        ClassLoader scl = ClassLoader.getSystemClassLoader();        
-        ClassLoader tcl = classLoader;
-        do {
-            if (tcl instanceof URLClassLoader) {
-                URL[] urls = ((URLClassLoader)tcl).getURLs();
-                if (urls == null) {
-                    urls = new URL[0];
-                }
-                for (URL url : urls) {
-                    if (url.getProtocol().startsWith("file")) {
-                        File file;
-                        if (url.toURI().getPath() == null) {
-                            continue;
-                        }
-                        try { 
-                            file = new File(url.toURI().getPath()); 
-                        } catch (URISyntaxException urise) { 
-                            if (url.getPath() == null) {
-                                continue;
-                            }
-                            file = new File(url.getPath()); 
-                        } 
-    
-                        if (file.exists()) { 
-                            classPath.append(file.getAbsolutePath()) 
-                                .append(System 
-                                        .getProperty("path.separator")); 
-    
-                            if (file.getName().endsWith(".jar")) { 
-                                addClasspathFromManifest(classPath, file); 
-                            }                         
-                        }     
-                    }
-                }
-            }
-            tcl = tcl.getParent();
-            if (null == tcl) {
-                break;
-            }
-        } while(!tcl.equals(scl.getParent()));
-    }
-
-    static void addClasspathFromManifest(StringBuilder classPath, File file) 
-        throws URISyntaxException, IOException {
-        
-        JarFile jar = new JarFile(file);
-        Attributes attr = null;
-        if (jar.getManifest() != null) {
-            attr = jar.getManifest().getMainAttributes();
-        }
-        if (attr != null) {
-            String cp = attr.getValue("Class-Path");
-            while (cp != null) {
-                String fileName = cp;
-                int idx = fileName.indexOf(' ');
-                if (idx != -1) {
-                    fileName = fileName.substring(0, idx);
-                    cp =  cp.substring(idx + 1).trim();
-                } else {
-                    cp = null;
-                }
-                URI uri = new URI(fileName);
-                File f2;
-                if (uri.isAbsolute()) {
-                    f2 = new File(uri);
-                } else {
-                    f2 = new File(file, fileName);
-                }
-                if (f2.exists()) {
-                    classPath.append(f2.getAbsolutePath());
-                    classPath.append(System.getProperty("path.separator"));
-                }
-            }
-        }         
-    }
-    
-    private String getOs() {
-        String os = System.getProperty("os.name");
-        if (os.toLowerCase().contains("win")) {
-            return "win";
-        } else {
-            return "unix";
-        }
-    }
 }

Modified: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml?rev=1240243&r1=1240242&r2=1240243&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml Fri
Feb  3 16:54:37 2012
@@ -35,7 +35,6 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
         </jaxrs:serviceBeans>
         <jaxrs:providers>
             <bean class="org.apache.cxf.systest.jaxrs.BadgerFishProvider"/>
-            <bean class="org.apache.cxf.jaxrs.ext.codegen.CodeGeneratorProvider"/>
             <ref bean="exceptionMapper"/>
             <ref bean="exceptionMapper2"/>
             <ref bean="plainTextProvider"/>

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java?rev=1240243&r1=1240242&r2=1240243&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java
(original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainer.java
Fri Feb  3 16:54:37 2012
@@ -31,7 +31,6 @@ import java.util.Set;
 import org.xml.sax.InputSource;
 import org.apache.cxf.common.util.URIParserUtil;
 import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.jaxrs.ext.codegen.SourceGenerator;
 import org.apache.cxf.tools.common.AbstractCXFToolContainer;
 import org.apache.cxf.tools.common.ClassUtils;
 import org.apache.cxf.tools.common.ToolException;

Copied: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
(from r1240153, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java?p2=cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java&p1=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java&r1=1240153&r2=1240243&rev=1240243&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
(original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
Fri Feb  3 16:54:37 2012
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.jaxrs.ext.codegen;
+package org.apache.cxf.tools.wadlto.jaxrs;
 
 import java.io.File;
 import java.io.FileNotFoundException;



Mime
View raw message