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 08:35:50 UTC

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

Author: ffang
Date: Thu Dec 13 07:35:49 2012
New Revision: 1421102

URL: http://svn.apache.org/viewvc?rev=1421102&view=rev
Log:
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.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:1421097

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

Modified: cxf/branches/2.6.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.6.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java?rev=1421102&r1=1421101&r2=1421102&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java (original)
+++ cxf/branches/2.6.x-fixes/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractCodegenMoho.java Thu Dec 13 07:35:49 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.common.util.URIParserUtil;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.FileUtils;
@@ -62,6 +63,23 @@ import org.codehaus.plexus.util.cli.Stre
 import org.sonatype.plexus.build.incremental.BuildContext;
 
 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}"
@@ -248,6 +266,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();
@@ -284,6 +306,7 @@ public abstract class AbstractCodegenMoh
                 bus.shutdown(true);
             }
             classLoaderSwitcher.restoreClassLoader();
+            restoreProxySetting(originalProxyHost, originalProxyPort, originalNonProxyHosts);
         }
 
         // refresh the generated sources
@@ -296,6 +319,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;
 
@@ -338,9 +368,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());
             }
 
         }