[jboss-svn-commits] JBL Code SVN: r13915 - in labs/jbossesb/trunk/product/services/soap: src/main/java/org/jboss/soa/esb/actions/soap and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jul 31 12:40:22 EDT 2007
Author: tfennelly
Date: 2007-07-31 12:40:22 -0400 (Tue, 31 Jul 2007)
New Revision: 13915
Added:
labs/jbossesb/trunk/product/services/soap/lib/ext/build-time/servlet-api-2.3.jar
Modified:
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WebserviceContractPublisher.java
Log:
Added dynamic proxy for HttpServletRequest injected into JBossWS ServletRequestContext.
Added: labs/jbossesb/trunk/product/services/soap/lib/ext/build-time/servlet-api-2.3.jar
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/trunk/product/services/soap/lib/ext/build-time/servlet-api-2.3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WebserviceContractPublisher.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WebserviceContractPublisher.java 2007-07-31 16:38:41 UTC (rev 13914)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WebserviceContractPublisher.java 2007-07-31 16:40:22 UTC (rev 13915)
@@ -24,8 +24,12 @@
import java.io.IOException;
import java.net.URI;
import java.util.List;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import javax.xml.transform.stream.StreamResult;
+import javax.servlet.http.HttpServletRequest;
import org.jboss.internal.soa.esb.publish.ActionContractPublisher;
import org.jboss.internal.soa.esb.publish.ContractInfo;
@@ -38,16 +42,19 @@
import org.jboss.wsf.spi.invocation.BasicInvocationContext;
import org.jboss.wsf.spi.invocation.InvocationContext;
import org.jboss.wsf.spi.invocation.RequestHandler;
+import org.jboss.ws.core.server.ServletRequestContext;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
+import org.apache.log4j.Logger;
/**
* Contract publisher for a Webservice endpoint.
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
public class WebserviceContractPublisher implements ActionContractPublisher {
-
+
+ private static Logger logger = Logger.getLogger(WebserviceContractPublisher.class);
private String endpointName;
/**
@@ -82,9 +89,16 @@
public ContractInfo getContractInfo(EPR epr) {
Endpoint endpoint = SOAPProcessor.getServiceEndpoint(endpointName);
RequestHandler requestHandler = endpoint.getRequestHandler();
- InvocationContext invocationContext = new BasicInvocationContext();
ByteArrayOutputStream wsdlStream = new ByteArrayOutputStream();
+ HttpServletRequest httpServletRequestProxy;
+ InvocationContext invocationContext;
+ httpServletRequestProxy = (HttpServletRequest) Proxy.newProxyInstance(HttpServletRequest.class.getClassLoader(),
+ new Class[] { HttpServletRequest.class },
+ new HttpServletRequestHandler());
+
+ invocationContext = new ServletRequestContext(null, httpServletRequestProxy, null);
+
try {
// Generate the WSDL...
requestHandler.handleWSDLRequest(endpoint, wsdlStream, invocationContext);
@@ -92,6 +106,7 @@
return new ContractInfo("text/xml", wsdl);
} catch (Exception e) {
+ logger.error("Failed to load contract information from JBossWS Endpoint '" + endpointName + "'.", e);
return new ContractInfo("text/plain", "Unavailable: " + e.getMessage());
}
}
@@ -121,4 +136,14 @@
return new String(wsdlStream.toByteArray()).trim();
}
+
+ private class HttpServletRequestHandler implements InvocationHandler {
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if(method.getName().equals("getRequestURL")) {
+ return new StringBuffer("http://www.jboss.org");
+ }
+
+ return null;
+ }
+ }
}
More information about the jboss-svn-commits
mailing list