You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2012/12/13 10:00:03 UTC

svn commit: r1421148 - in /cxf/branches/2.5.x-fixes: ./ maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java

Author: ffang
Date: Thu Dec 13 09:00:00 2012
New Revision: 1421148

URL: http://svn.apache.org/viewvc?rev=1421148&view=rev
Log:
Merged revisions 1421102 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

................
  r1421102 | ffang | 2012-12-13 15:35:49 +0800 (四, 13 12 2012) | 9 lines
  
  Merged revisions 1421097 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1421097 | ffang | 2012-12-13 15:24:50 +0800 (四, 13 12 2012) | 1 line
    
    [CXF-4687]cxf-codegen-plugin breaks mvn deploy when proxy exists
  ........
................

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Dec 13 09:00:00 2012
@@ -0,0 +1,2 @@
+/cxf/branches/2.6.x-fixes:1421102
+/cxf/trunk:1421097

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.5.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java?rev=1421148&r1=1421147&r2=1421148&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java (original)
+++ cxf/branches/2.5.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java Thu Dec 13 09:00:00 2012
@@ -34,6 +34,7 @@ import java.util.Set;
 
 import org.apache.commons.lang.SystemUtils;
 import org.apache.cxf.Bus;
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.tools.util.URIParserUtil;
@@ -61,6 +62,23 @@ import org.codehaus.plexus.util.cli.Comm
 import org.codehaus.plexus.util.cli.StreamConsumer;
 
 public abstract class AbstractCodegenMoho extends AbstractMojo {
+    
+    /**
+     * JVM/System property name holding the hostname of the http proxy.
+     */
+    private static final String HTTP_PROXY_HOST = "http.proxyHost";
+
+    /**
+     * JVM/System property name holding the port of the http proxy.
+     */
+    private static final String HTTP_PROXY_PORT = "http.proxyPort";
+
+    /**
+     * JVM/System property name holding the list of hosts/patterns that
+     * should not use the proxy configuration.
+     */
+    private static final String HTTP_NON_PROXY_HOSTS = "http.nonProxyHosts";
+    
 
     /**
      * @parameter expression="${project.build.outputDirectory}"
@@ -227,6 +245,10 @@ public abstract class AbstractCodegenMoh
        
         markerDirectory.mkdirs();
 
+        String originalProxyHost = SystemPropertyAction.getProperty(HTTP_PROXY_HOST);
+        String originalProxyPort = SystemPropertyAction.getProperty(HTTP_PROXY_PORT);
+        String originalNonProxyHosts = SystemPropertyAction.getProperty(HTTP_NON_PROXY_HOSTS);
+        
         configureProxyServerSettings();
 
         List<GenericWsdlOption> effectiveWsdlOptions = createWsdlOptionsFromScansAndExplicitWsdlOptions();
@@ -263,6 +285,7 @@ public abstract class AbstractCodegenMoh
                 bus.shutdown(true);
             }
             classLoaderSwitcher.restoreClassLoader();
+            restoreProxySetting(originalProxyHost, originalProxyPort, originalNonProxyHosts);
         }
 
         // add the generated source into compile source
@@ -276,6 +299,13 @@ public abstract class AbstractCodegenMoh
         System.gc();
     }
 
+    private void restoreProxySetting(String originalProxyHost, String originalProxyPort,
+                                     String originalNonProxyHosts) {
+        System.setProperty(HTTP_PROXY_HOST, originalProxyHost);
+        System.setProperty(HTTP_PROXY_PORT, originalProxyPort);
+        System.setProperty(HTTP_NON_PROXY_HOSTS, originalNonProxyHosts);        
+    }
+
     protected abstract Bus generate(GenericWsdlOption o, 
                                     Bus bus, Set<URI> cp) throws MojoExecutionException;
 
@@ -318,9 +348,9 @@ public abstract class AbstractCodegenMoh
             if (proxy.getHost() == null) {
                 throw new MojoExecutionException("Proxy in settings.xml has no host");
             } else {
-                System.setProperty("proxySet", "true");
-                System.setProperty("proxyHost", proxy.getHost());
-                System.setProperty("proxyPort", String.valueOf(proxy.getPort()));
+                System.setProperty(HTTP_PROXY_HOST, proxy.getHost());
+                System.setProperty(HTTP_PROXY_PORT, String.valueOf(proxy.getPort()));
+                System.setProperty(HTTP_NON_PROXY_HOSTS, proxy.getNonProxyHosts());
             }
 
         }