Author: keith
Date: Wed Mar 26 06:16:15 2008
New Revision: 15133

Log:

Potential fix for mashup-723. Getting proxy deyails from axis2.xml and setting 
it to the scraper object



Modified:
   
trunk/mashup/java/modules/coreservices/scraperservice/src/org/wso2/mashup/coreservices/scraperservice/ScraperService.java

Modified: 
trunk/mashup/java/modules/coreservices/scraperservice/src/org/wso2/mashup/coreservices/scraperservice/ScraperService.java
==============================================================================
--- 
trunk/mashup/java/modules/coreservices/scraperservice/src/org/wso2/mashup/coreservices/scraperservice/ScraperService.java
   (original)
+++ 
trunk/mashup/java/modules/coreservices/scraperservice/src/org/wso2/mashup/coreservices/scraperservice/ScraperService.java
   Wed Mar 26 06:16:15 2008
@@ -19,6 +19,10 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.transport.http.ProxyConfiguration;
+import org.apache.commons.httpclient.HttpClient;
 import org.webharvest.definition.ScraperConfiguration;
 import org.webharvest.exception.FileException;
 import org.webharvest.runtime.Scraper;
@@ -43,10 +47,12 @@
         if (config != null) {
             // We have saxon in the lib of the service. Hence we have to 
switch to that classLoader.
             // Taking that classLoader and aticking it into the thread
-            
MessageContext.getCurrentMessageContext().getAxisService().getClassLoader();
+            MessageContext context = MessageContext.getCurrentMessageContext();
+            context.getAxisService().getClassLoader();
             ClassLoader newCl = Thread.currentThread().getContextClassLoader();
             ClassLoader preCl = Thread.currentThread().getContextClassLoader();
             Thread.currentThread().setContextClassLoader(newCl);
+
             OMFactory omFactory = OMAbstractFactory.getOMFactory();
             OMElement responseElement = omFactory.createOMElement("response", 
null);
             try {
@@ -54,6 +60,18 @@
                 InputSource inputSource = new InputSource(in);
                 ScraperConfiguration scraperConfiguration = new 
ScraperConfiguration(inputSource);
                 Scraper scraper = new Scraper(scraperConfiguration, 
resourcesFolderPath);
+
+                AxisConfiguration configuration =
+                        
context.getConfigurationContext().getAxisConfiguration();
+                Parameter parameter = configuration.getParameter("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();
+                    HttpClient httpClient = 
scraper.getHttpClientManager().getHttpClient();
+                    proxyConfiguration.configure(context, httpClient, 
httpClient.getHostConfiguration());
+                }
+
                 // Execute the scraper config
                 scraper.execute();
                 ScraperContext scraperContext = scraper.getContext();

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to