cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r766763 - in /cxf/trunk: api/src/main/java/org/apache/cxf/tools/common/ maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/databinding/jaxb/src/main/java/org/apache/c...
Date Mon, 20 Apr 2009 17:29:02 GMT
Author: dkulp
Date: Mon Apr 20 17:29:01 2009
New Revision: 766763

URL: http://svn.apache.org/viewvc?rev=766763&view=rev
Log:
[CXF-2177, CXF-2174, CXF-2175] Patches from Juan Uys, Ted Leung applied
Add NPE check to DynamicClient

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
    cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
    cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
    cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
    cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?rev=766763&r1=766762&r2=766763&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/tools/common/ToolConstants.java Mon Apr 20
17:29:01 2009
@@ -40,6 +40,7 @@
     public static final String CFG_OUTPUTFILE = "outputfile";
     public static final String CFG_WSDLURL = "wsdlurl";
     public static final String CFG_WSDLLOCATION = "wsdlLocation";
+    public static final String CFG_WSDLLIST = "wsdlList";
     public static final String CFG_NAMESPACE = "namespace";
     public static final String CFG_VERBOSE = "verbose";
     public static final String CFG_PORT = "port";

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java?rev=766763&r1=766762&r2=766763&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/Option.java
Mon Apr 20 17:29:01 2009
@@ -90,6 +90,12 @@
     String wsdlLocation = DEFAULT_WSDL_LOCATION;
 
     /**
+     * Specifies that the wsdlurl contains a plain text, new line delimited,
+     * list of wsdlurls instead of the wsdl itself.
+     */
+    boolean wsdlList;
+
+    /**
      * Specifies the frontend. Default is JAXWS. Currently supports only JAXWS frontend.
      */
     String frontEnd;
@@ -213,6 +219,14 @@
         return !DEFAULT_WSDL_LOCATION.equals(wsdlLocation);
     }
 
+    public boolean isWsdlList() {
+        return wsdlList;
+    }
+
+    public void setWsdlList(boolean wsdlList) {
+        this.wsdlList = wsdlList;
+    }
+
     public String getFrontEnd() {
         return frontEnd;
     }

Modified: cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java?rev=766763&r1=766762&r2=766763&view=diff
==============================================================================
--- cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
(original)
+++ cxf/trunk/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/WSDL2JavaMojo.java
Mon Apr 20 17:29:01 2009
@@ -459,6 +459,9 @@
             list.add("-wsdlLocation");
             list.add(wsdlOption.getWsdlLocation() == null ? "" : wsdlOption.getWsdlLocation());
         }
+        if (wsdlOption.isWsdlList()) {
+            list.add("-wsdlList");
+        }
         if (getLog().isDebugEnabled() && !list.contains("-verbose")) {
             list.add("-verbose");            
         }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java?rev=766763&r1=766762&r2=766763&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java Mon
Apr 20 17:29:01 2009
@@ -83,6 +83,18 @@
         }
     }
 
+    /**
+     * Transform the string before display. The implementation in this class 
+     * does nothing. Override this method if you want to change the contents of the 
+     * logged message before it is delivered to the output. 
+     * For example, you can use this to mask out sensitive information.
+     * @param originalLogString the raw log message.
+     * @return transformed data
+     */
+    protected String transform(String originalLogString) {
+        return originalLogString;
+    } 
+
     private void logging(Message message) throws Fault {
         String id = (String)message.getExchange().get(LoggingMessage.ID_KEY);
         if (id == null) {
@@ -139,9 +151,9 @@
         }
 
         if (writer != null) {
-            writer.println(buffer.toString());
+            writer.println(transform(buffer.toString()));
         } else if (LOG.isLoggable(Level.INFO)) {
-            LOG.info(buffer.toString());
+            LOG.info(transform(buffer.toString()));
         }
     }
 }

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java?rev=766763&r1=766762&r2=766763&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
Mon Apr 20 17:29:01 2009
@@ -561,10 +561,16 @@
                 }
                 for (URL url : urls) {
                     if (url.getProtocol().startsWith("file")) {
-                        File 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()); 
                         } 
 

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java?rev=766763&r1=766762&r2=766763&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
Mon Apr 20 17:29:01 2009
@@ -306,9 +306,16 @@
         if (!isHideServiceList) {
             List<ServletDestination> destinations = getServletDestinations();
 
+            boolean renderWsdlList = "true".equals(request.getParameter("wsdlList"));
+            
             for (ServletDestination sd : destinations) {
                 String address = sd.getEndpointInfo().getAddress();
                 response.getWriter().write(address);
+                
+                if (renderWsdlList) {
+                    response.getWriter().write("?wsdl");
+                }
+                
                 response.getWriter().write('\n');
             }
         }

Modified: cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java?rev=766763&r1=766762&r2=766763&view=diff
==============================================================================
--- cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java (original)
+++ cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolContext.java Mon
Apr 20 17:29:01 2009
@@ -97,7 +97,7 @@
     public Object get(String key) {
         return (paramMap == null) ? null : paramMap.get(key);
     }
-
+    
     public Object get(String key, Object defaultValue) {
         if (!optionSet(key)) {
             return defaultValue;
@@ -263,4 +263,28 @@
     public boolean isPackageNameChanged() {
         return packageNameChanged;
     }
+    
+    /**
+     * This method attempts to do a deep copy of items which may change in this ToolContext.
+     * The intent of this is to be able to take a snapshot of the state of the ToolContext
+     * after it's initialised so we can run a tool multiple times with the same setup
+     * while not having the state preserved between multiple runs. I didn't want 
+     * to call this clone() as it neither does a deep nor shallow copy. It does a mix
+     * based on my best guess at what changes and what doesn't.
+     */
+    public ToolContext makeCopy() {
+        ToolContext newCopy = new ToolContext();
+        
+        newCopy.javaModel = javaModel;
+        newCopy.paramMap = new HashMap<String, Object>(paramMap);
+        newCopy.packageName = packageName;
+        newCopy.packageNameChanged = packageNameChanged;
+        newCopy.namespacePackageMap = new HashMap<String, String>(namespacePackageMap);
+        newCopy.excludeNamespacePackageMap = new HashMap<String, String>(excludeNamespacePackageMap);
+        newCopy.jaxbBindingFiles = new ArrayList<InputSource>(jaxbBindingFiles);
+        newCopy.excludePkgList = new ArrayList<String>(excludePkgList);
+        newCopy.excludeFileList = new ArrayList<String>(excludeFileList);
+        
+        return newCopy;
+    }    
 }

Modified: cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java?rev=766763&r1=766762&r2=766763&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
(original)
+++ cxf/trunk/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java
Mon Apr 20 17:29:01 2009
@@ -19,9 +19,11 @@
 
 package org.apache.cxf.tools.wsdlto;
 
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -91,117 +93,151 @@
         return WSDLConstants.getVersion(version);
     }
 
-    @SuppressWarnings("unchecked")
     public void execute() throws ToolException {
-        if (!hasInfoOption()) {
-            // TODO: After runtime support w3c EPR mapping ,this will be removed
-            //context.put(ToolConstants.CFG_NO_ADDRESS_BINDING, 
-            //            ToolConstants.CFG_NO_ADDRESS_BINDING);
-            buildToolContext();
-            validate(context);
-            FrontEndProfile frontend = context.get(FrontEndProfile.class);
-
-            if (frontend == null) {
-                throw new ToolException(new Message("FOUND_NO_FRONTEND", LOG));
-            }
-
-            WSDLConstants.WSDLVersion version = getWSDLVersion();
-
-            String wsdlURL = (String)context.get(ToolConstants.CFG_WSDLURL);
-            List<ServiceInfo> serviceList = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
-            if (serviceList == null) {
-                serviceList = new ArrayList<ServiceInfo>();
-
-                // Build the ServiceModel from the WSDLModel
-                if (version == WSDLConstants.WSDLVersion.WSDL11) {
-                    AbstractWSDLBuilder<Definition> builder = (AbstractWSDLBuilder<Definition>)frontend
-                        .getWSDLBuilder();
-                    builder.setContext(context);
-                    builder.setBus(getBus());
-                    context.put(Bus.class, getBus());
-                    wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
-                    builder.build(wsdlURL);
-                    builder.customize();
-                    Definition definition = builder.getWSDLModel();
-
-                    context.put(Definition.class, definition);
-
-                    builder.validate(definition);
-
-                    WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
-                    serviceBuilder.setIgnoreUnknownBindings(true);
-                    String serviceName = (String)context.get(ToolConstants.CFG_SERVICENAME);
-
-                    if (serviceName != null) {
-                        List<ServiceInfo> services = serviceBuilder
-                            .buildServices(definition, getServiceQName(definition));
-                        serviceList.addAll(services);
-                    } else if (definition.getServices().size() > 0) {
-                        serviceList = serviceBuilder.buildServices(definition);
-                    } else {
-                        serviceList = serviceBuilder.buildMockServices(definition);
-                    }
+        if (hasInfoOption()) {
+            return;
+        }
 
-                } else {
-                    // TODO: wsdl2.0 support
-                }
-            }
-            context.put(ToolConstants.SERVICE_LIST, serviceList);
-            
-            Map<String, InterfaceInfo> interfaces = new LinkedHashMap<String, InterfaceInfo>();
+        buildToolContext();
+        
+        boolean isWsdlList = context.optionSet(ToolConstants.CFG_WSDLLIST);
+
+        if (isWsdlList) {
+            try {
+                ToolContext initialContextState = context.makeCopy();
+                String wsdlURL = (String)context.get(ToolConstants.CFG_WSDLURL);
+                wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
+
+                URL url = new URL(wsdlURL);
+                InputStream is = (InputStream)url.getContent();
+                BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+                String tempLine = null;
+                while ((tempLine = reader.readLine()) != null) {                    
+                    ToolContext freshContext = initialContextState.makeCopy();
+                    freshContext.put(ToolConstants.CFG_WSDLURL, tempLine);
+                    setContext(freshContext);
+                    buildToolContext();
+                    
+                    processWsdl();
+                }
+            } catch (IOException e) {
+                throw new ToolException(e);
+            }       
+        } else {
+            processWsdl();
+        }
+    }
+
+    private void processWsdl() {
+        // TODO: After runtime support w3c EPR mapping ,this will be removed
+        //context.put(ToolConstants.CFG_NO_ADDRESS_BINDING, 
+        //            ToolConstants.CFG_NO_ADDRESS_BINDING);
+        validate(context);
+        FrontEndProfile frontend = context.get(FrontEndProfile.class);
+
+        if (frontend == null) {
+            throw new ToolException(new Message("FOUND_NO_FRONTEND", LOG));
+        }
+
+        WSDLConstants.WSDLVersion version = getWSDLVersion();
+
+        String wsdlURL = (String)context.get(ToolConstants.CFG_WSDLURL);
+
+        @SuppressWarnings("unchecked")
+        List<ServiceInfo> serviceList = (List<ServiceInfo>)context.get(ToolConstants.SERVICE_LIST);
+        if (serviceList == null) {
+            serviceList = new ArrayList<ServiceInfo>();
+
+            // Build the ServiceModel from the WSDLModel
+            if (version == WSDLConstants.WSDLVersion.WSDL11) {
+                @SuppressWarnings("unchecked")
+                AbstractWSDLBuilder<Definition> builder = (AbstractWSDLBuilder<Definition>)frontend
+                    .getWSDLBuilder();
+                builder.setContext(context);
+                builder.setBus(getBus());
+                context.put(Bus.class, getBus());
+                wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
+                builder.build(wsdlURL);
+                builder.customize();
+                Definition definition = builder.getWSDLModel();
 
-            ServiceInfo service0 = serviceList.get(0);
-            SchemaCollection schemaCollection = service0.getXmlSchemaCollection();
-            context.put(ToolConstants.XML_SCHEMA_COLLECTION, schemaCollection);
-            
-            context.put(ToolConstants.PORTTYPE_MAP, interfaces);
-            context.put(ClassCollector.class, new ClassCollector());
-            Processor processor = frontend.getProcessor();
-            if (processor instanceof ClassNameProcessor) {
-                processor.setEnvironment(context);
-                for (ServiceInfo service : serviceList) {
+                context.put(Definition.class, definition);
 
-                    context.put(ServiceInfo.class, service);
+                builder.validate(definition);
 
-                    ((ClassNameProcessor)processor).processClassNames();
+                WSDLServiceBuilder serviceBuilder = new WSDLServiceBuilder(getBus());
+                serviceBuilder.setIgnoreUnknownBindings(true);
+                String serviceName = (String)context.get(ToolConstants.CFG_SERVICENAME);
 
-                    context.put(ServiceInfo.class, null);
+                if (serviceName != null) {
+                    List<ServiceInfo> services = serviceBuilder
+                        .buildServices(definition, getServiceQName(definition));
+                    serviceList.addAll(services);
+                } else if (definition.getServices().size() > 0) {
+                    serviceList = serviceBuilder.buildServices(definition);
+                } else {
+                    serviceList = serviceBuilder.buildMockServices(definition);
                 }
+
+            } else {
+                // TODO: wsdl2.0 support
             }
-            generateTypes();
+        }
+        context.put(ToolConstants.SERVICE_LIST, serviceList);
+        
+        Map<String, InterfaceInfo> interfaces = new LinkedHashMap<String, InterfaceInfo>();
 
+        ServiceInfo service0 = serviceList.get(0);
+        SchemaCollection schemaCollection = service0.getXmlSchemaCollection();
+        context.put(ToolConstants.XML_SCHEMA_COLLECTION, schemaCollection);
+        
+        context.put(ToolConstants.PORTTYPE_MAP, interfaces);
+        context.put(ClassCollector.class, new ClassCollector());
+        Processor processor = frontend.getProcessor();
+        if (processor instanceof ClassNameProcessor) {
+            processor.setEnvironment(context);
             for (ServiceInfo service : serviceList) {
 
                 context.put(ServiceInfo.class, service);
 
-                validate(service);
+                ((ClassNameProcessor)processor).processClassNames();
 
-                // Build the JavaModel from the ServiceModel
-                processor.setEnvironment(context);
-                processor.process();
-
-                if (!isSuppressCodeGen()) {
-                    // Generate artifacts
-                    for (FrontEndGenerator generator : frontend.getGenerators()) {
-                        generator.generate(context);
-                    }
-                }
+                context.put(ServiceInfo.class, null);
             }
-            context.remove(ToolConstants.SERVICE_LIST);
+        }
+        generateTypes();
 
-            // Build projects: compile classes and copy resources etc.
-            if (context.optionSet(ToolConstants.CFG_COMPILE)) {
-                new ClassUtils().compile(context);
-            }
+        for (ServiceInfo service : serviceList) {
 
-            if (context.isExcludeNamespaceEnabled()) {
-                try {
-                    removeExcludeFiles();
-                } catch (IOException e) {
-                    throw new ToolException(e);
+            context.put(ServiceInfo.class, service);
+
+            validate(service);
+
+            // Build the JavaModel from the ServiceModel
+            processor.setEnvironment(context);
+            processor.process();
+
+            if (!isSuppressCodeGen()) {
+                // Generate artifacts
+                for (FrontEndGenerator generator : frontend.getGenerators()) {
+                    generator.generate(context);
                 }
             }
         }
+        context.remove(ToolConstants.SERVICE_LIST);
+
+        // Build projects: compile classes and copy resources etc.
+        if (context.optionSet(ToolConstants.CFG_COMPILE)) {
+            new ClassUtils().compile(context);
+        }
+
+        if (context.isExcludeNamespaceEnabled()) {
+            try {
+                removeExcludeFiles();
+            } catch (IOException e) {
+                throw new ToolException(e);
+            }
+        }
     }
 
     private boolean isSuppressCodeGen() {

Modified: cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml?rev=766763&r1=766762&r2=766763&view=diff
==============================================================================
--- cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
(original)
+++ cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/jaxws-toolspec.xml
Mon Apr 20 17:29:01 2009
@@ -315,6 +315,16 @@
                 <switch>q</switch>
             </option>
 
+	        <option id="wsdlList" maxOccurs="1">
+	            <annotation>
+	                Indicates the wsdlurl is a plain text list of wsdlurls that are new line
delimited.
+	                As an example the wsdlurl might point to 
+	                http://127.0.0.1:8080/context_path/ws?formatted=false&amp;wsdlList=true
on a cxf 
+	                server. 
+	            </annotation>
+	            <switch>wsdlList</switch>
+	        </option>
+
         </optionGroup>
         <argument id="wsdlurl" minOccurs="1" maxOccurs="1">
             <annotation>



Mime
View raw message