[Mashup-dev] svn commit r20158 - in branches/mashup/java/1.5/java/modules: core/conf core/src/org/wso2/mashup core/src/org/wso2/mashup/transport core/src/org/wso2/mashup/utils coreservices/scraperservice/src/org/wso2/mashup/coreservices/scraperservice hostobjects/src/org/wso2/mashup/hostobjects/wsrequest

keith at wso2.com keith at wso2.com
Wed Jul 30 02:06:25 PDT 2008


Author: keith
Date: Wed Jul 30 02:06:25 2008
New Revision: 20158
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=20158

Log:
Fixing Mashup-1007. Tested throughly using squid. Now we go through proxy for WSRequest, Scraping, system.getXML, feedReader and JSStubGenerator



Modified:
   branches/mashup/java/1.5/java/modules/core/conf/axis2.xml
   branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/MashupConstants.java
   branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java
   branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
   branches/mashup/java/1.5/java/modules/coreservices/scraperservice/src/org/wso2/mashup/coreservices/scraperservice/ScraperService.java
   branches/mashup/java/1.5/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java

Modified: branches/mashup/java/1.5/java/modules/core/conf/axis2.xml
URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/1.5/java/modules/core/conf/axis2.xml?rev=20158&r1=20157&r2=20158&view=diff
==============================================================================
--- branches/mashup/java/1.5/java/modules/core/conf/axis2.xml	(original)
+++ branches/mashup/java/1.5/java/modules/core/conf/axis2.xml	Wed Jul 30 02:06:25 2008
@@ -35,6 +35,28 @@
         org.wso2.wsas.util.TraceFilterImpl
     </parameter>
 
+     <!-- Please uncomment the following the following if you are running the WSO2 Mashup Server in a coperate proxy-->
+     <!--
+    <parameter name="Proxy">
+        <Configuration>
+            <ProxyHost>proxy.wso2.org</ProxyHost>
+            <ProxyPort>5678</ProxyPort>
+            <ProxyUser>EXAMPLE\keith</ProxyUser>
+            <ProxyPassword>keithsPassword</ProxyPassword>
+        </Configuration>
+    </parameter>
+    -->
+
+    <!-- The http.nonProxyHosts can be set to specify the hosts which should be connected to directly (not through the proxy server).
+    The value of the http.nonProxyHosts property can be a list of hosts, each separated by a |; it can also take a regular expression for matches;
+    for example: *.sfbay.sun.com would match any fully qualified hostname in the sfbay domain.
+
+    For more information refer to : http://java.sun.com/features/2002/11/hilevel_network.html
+    Note : Please add localhost to the list cause localhost calls need not go through the proxy-->
+     <!--
+     <parameter name="http.nonProxyHosts">localhost</parameter>
+    -->
+
     <!--
        This parameter decides where the traced messages from the Tracer is persisted.
 

Modified: branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/MashupConstants.java
URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/MashupConstants.java?rev=20158&r1=20157&r2=20158&view=diff
==============================================================================
--- branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/MashupConstants.java	(original)
+++ branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/MashupConstants.java	Wed Jul 30 02:06:25 2008
@@ -305,4 +305,8 @@
 
     // Key used to store queries in session. 
     public static final String QUERY_CACHE_KEY = "querycachekey";
+
+    public static final String HTTP_NON_PROXY_HOSTS = "http.nonProxyHosts";
+
+    public static final String PROXY = "Proxy";
 }

Modified: branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java
URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java?rev=20158&r1=20157&r2=20158&view=diff
==============================================================================
--- branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java	(original)
+++ branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/transport/MashupServerInitializer.java	Wed Jul 30 02:06:25 2008
@@ -20,6 +20,7 @@
 import org.apache.axis2.deployment.DeploymentEngine;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.Parameter;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.log4j.Logger;
 import org.wso2.mashup.MashupConstants;
@@ -52,6 +53,21 @@
 
     public void init(ConfigurationContext configurationContext) throws AxisFault, ServerException {
         AxisConfiguration configuration = configurationContext.getAxisConfiguration();
+
+        /**
+         * Validates for names that shouldn't be listered as proxies.
+         * The http.nonProxyHosts can be set to specify the hosts which should be
+         * connected to directly (not through the proxy server).
+         * The value of the http.nonProxyHosts property can be a list of hosts,
+         * each separated by a |; it can also take a regular expression for matches;
+         * for example: *.sfbay.sun.com would match any fully qualified hostname in the sfbay domain.
+         *
+         * For more information refer to : http://java.sun.com/features/2002/11/hilevel_network.html
+         */
+        Parameter parameter = configuration.getParameter(MashupConstants.HTTP_NON_PROXY_HOSTS);
+        if (parameter != null) {
+            System.setProperty(MashupConstants.HTTP_NON_PROXY_HOSTS, (String) parameter.getValue());
+        }
         UserRealm realm = (UserRealm) configuration
                 .getParameterValue(RegistryConstants.REGISTRY_REALM);
 

Modified: branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java
URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java?rev=20158&r1=20157&r2=20158&view=diff
==============================================================================
--- branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java	(original)
+++ branches/mashup/java/1.5/java/modules/core/src/org/wso2/mashup/utils/MashupUtils.java	Wed Jul 30 02:06:25 2008
@@ -38,6 +38,7 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.rpc.client.RPCServiceClient;
 import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.transport.http.ProxyConfiguration;
 import org.apache.axis2.transport.http.util.URIEncoderDecoder;
 import org.apache.axis2.util.XMLChar;
 import org.apache.axis2.util.JavaUtils;
@@ -1378,6 +1379,18 @@
             // Execute the method.
             config.setHost(targetURL.getHost(), port, targetProtocol);
         }
+
+        ServerManager serverManager = ServerManager.getInstance();
+        ConfigurationContext configurationContext = serverManager.configContext;
+        if (configurationContext != null) {
+            Parameter parameter = configurationContext.getAxisConfiguration().getParameter(MashupConstants.PROXY);
+            // The axis2.xml could have details of a proxy, If its present we should set those details
+            // on the scraper too
+            if (parameter != null) {
+                ProxyConfiguration proxyConfiguration = new ProxyConfiguration();
+                proxyConfiguration.configure(MessageContext.getCurrentMessageContext(), httpClient, config);
+            }
+        }
         return httpClient.executeMethod(config, method);
     }
 
@@ -1564,6 +1577,15 @@
                             MashupConstants.WORK_DIRECTORY + File.separator + MashupConstants
                             .REPO_DIRECTORY + File.separator + MashupConstants.REPO_DIRECTORY,
                                                               null);
+            ServerManager serverManager = ServerManager.getInstance();
+            ConfigurationContext configurationContext = serverManager.configContext;
+            if (configurationContext != null) {
+                Parameter param = configurationContext.getAxisConfiguration()
+                        .getParameter(MashupConstants.PROXY);
+                if (param != null) {
+                    configurationContextWithoutRepo.getAxisConfiguration().addParameter(param);
+                }
+            }
         }
         return configurationContextWithoutRepo;
     }
@@ -1582,6 +1604,15 @@
                     .createConfigurationContextFromFileSystem(wso2wsasHome + File.separator +
                             MashupConstants.WORK_DIRECTORY + File.separator + MashupConstants
                             .REPO_DIRECTORY, null);
+            ServerManager serverManager = ServerManager.getInstance();
+            ConfigurationContext configurationContext = serverManager.configContext;
+            if (configurationContext != null) {
+                Parameter param = configurationContext.getAxisConfiguration()
+                        .getParameter(MashupConstants.PROXY);
+                if (param != null) {
+                    configurationContextWithRepo.getAxisConfiguration().addParameter(param);
+                }
+            }
         }
         return configurationContextWithRepo;
     }

Modified: branches/mashup/java/1.5/java/modules/coreservices/scraperservice/src/org/wso2/mashup/coreservices/scraperservice/ScraperService.java
URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/1.5/java/modules/coreservices/scraperservice/src/org/wso2/mashup/coreservices/scraperservice/ScraperService.java?rev=20158&r1=20157&r2=20158&view=diff
==============================================================================
--- branches/mashup/java/1.5/java/modules/coreservices/scraperservice/src/org/wso2/mashup/coreservices/scraperservice/ScraperService.java	(original)
+++ branches/mashup/java/1.5/java/modules/coreservices/scraperservice/src/org/wso2/mashup/coreservices/scraperservice/ScraperService.java	Wed Jul 30 02:06:25 2008
@@ -29,6 +29,7 @@
 import org.webharvest.runtime.ScraperContext;
 import org.webharvest.runtime.variables.Variable;
 import org.wso2.mashup.MashupFault;
+import org.wso2.mashup.MashupConstants;
 import org.xml.sax.InputSource;
 
 import javax.xml.stream.XMLStreamConstants;
@@ -63,7 +64,7 @@
 
                 AxisConfiguration configuration =
                         context.getConfigurationContext().getAxisConfiguration();
-                Parameter parameter = configuration.getParameter("Proxy");
+                Parameter parameter = configuration.getParameter(MashupConstants.PROXY);
                 // The axis2.xml could have details of a proxy, If its present we should set those details
                 // on the scraper too
                 if (parameter != null) {

Modified: branches/mashup/java/1.5/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java
URL: http://wso2.org/svn/browse/wso2/branches/mashup/java/1.5/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java?rev=20158&r1=20157&r2=20158&view=diff
==============================================================================
--- branches/mashup/java/1.5/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java	(original)
+++ branches/mashup/java/1.5/java/modules/hostobjects/src/org/wso2/mashup/hostobjects/wsrequest/WSRequestHostImpl.java	Wed Jul 30 02:06:25 2008
@@ -34,6 +34,7 @@
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisEndpoint;
 import org.apache.axis2.description.AxisBindingMessage;
+import org.apache.axis2.description.Parameter;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HttpTransportProperties;
 import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator;
@@ -68,6 +69,7 @@
 import org.wso2.mashup.MashupFault;
 import org.wso2.mashup.utils.MashupUtils;
 import org.wso2.wsas.ServerConstants;
+import org.wso2.wsas.ServerManager;
 import org.wso2.utils.ServerConfiguration;
 
 import javax.wsdl.Definition;
@@ -541,6 +543,12 @@
                     .createConfigurationContextFromFileSystem(wso2wsasHome + File.separator +
                             MashupConstants.WORK_DIRECTORY + File.separator + MashupConstants
                             .REPO_DIRECTORY, null);
+            ServerManager serverManager = ServerManager.getInstance();
+            Parameter param = serverManager.configContext.getAxisConfiguration()
+                    .getParameter(MashupConstants.PROXY);
+            if (param != null) {
+                configurationContext.getAxisConfiguration().addParameter(param);
+            }
             wsRequest.sender =
                     new ServiceClient(configurationContext, definition, serviceQName, endpointName);
             if (optionsArray != null) {



More information about the Mashup-dev mailing list