You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by tt...@apache.org on 2007/04/27 14:23:23 UTC
svn commit: r533074 [2/4] - in
/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src:
main/java/org/apache/servicemix/http/
main/java/org/apache/servicemix/http/endpoints/
main/java/org/apache/servicemix/http/jetty/ main/java/or...
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java?view=diff&rev=533074&r1=533073&r2=533074
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerEndpoint.java Fri Apr 27 05:23:20 2007
@@ -16,15 +16,20 @@
*/
package org.apache.servicemix.http.endpoints;
+import java.io.IOException;
+
import javax.jbi.management.DeploymentException;
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.wsdl.Definition;
import javax.wsdl.Port;
import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.extensions.soap12.SOAP12Address;
import javax.xml.namespace.QName;
+import org.w3c.dom.Element;
+
import org.apache.servicemix.common.DefaultComponent;
import org.apache.servicemix.common.ServiceUnit;
import org.apache.servicemix.soap.api.Policy;
@@ -39,7 +44,6 @@
import org.apache.woden.wsdl20.Endpoint;
import org.apache.woden.wsdl20.xml.DescriptionElement;
import org.springframework.core.io.Resource;
-import org.w3c.dom.Element;
/**
*
@@ -53,7 +57,7 @@
private boolean useJbiWrapper = true;
private boolean validateWsdl = true;
private Policy[] policies;
-
+
public HttpSoapConsumerEndpoint() {
super();
}
@@ -108,77 +112,9 @@
description = DomUtil.parse(wsdl.getInputStream());
Element elem = description.getDocumentElement();
if (WSDLUtils.WSDL1_NAMESPACE.equals(elem.getNamespaceURI())) {
- Definition def = WSDLUtils.createWSDL11Reader().readWSDL(wsdl.getURL().toString());
- if (validateWsdl) {
- WSIBPValidator validator = new WSIBPValidator(def);
- if (!validator.isValid()) {
- throw new DeploymentException("WSDL is not WS-I BP compliant: " + validator.getErrors());
- }
- }
- Service svc;
- if (getService() != null) {
- svc = def.getService(getService());
- if (svc == null) {
- throw new DeploymentException("Could not find service '" + getService() + "' in wsdl");
- }
- } else if (def.getServices().size() == 1) {
- svc = (Service) def.getServices().values().iterator().next();
- setService(svc.getQName());
- } else {
- throw new DeploymentException("If service is not set, the WSDL must contain a single service definition");
- }
- Port port;
- if (getEndpoint() != null) {
- port = svc.getPort(getEndpoint());
- if (port == null) {
- throw new DeploymentException("Cound not find port '" + getEndpoint() + "' in wsdl for service '" + getService() + "'");
- }
- } else if (svc.getPorts().size() == 1) {
- port = (Port) svc.getPorts().values().iterator().next();
- setEndpoint(port.getName());
- } else {
- throw new DeploymentException("If endpoint is not set, the WSDL service '" + getService() + "' must contain a single port definition");
- }
- SOAPAddress soapAddress = WSDLUtils.getExtension(port, SOAPAddress.class);
- if (soapAddress != null) {
- soapAddress.setLocationURI(getLocationURI());
- } else {
- SOAP12Address soap12Address = WSDLUtils.getExtension(port, SOAP12Address.class);
- if (soap12Address != null) {
- soap12Address.setLocationURI(getLocationURI());
- }
- }
- description = WSDLUtils.getWSDL11Factory().newWSDLWriter().getDocument(def);
- marshaler.setBinding(BindingFactory.createBinding(port));
+ validateWsdl1(marshaler);
} else if (WSDLUtils.WSDL2_NAMESPACE.equals(elem.getNamespaceURI())) {
- WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
- DescriptionElement descElement = reader.readWSDL(wsdl.getURL().toString());
- Description desc = descElement.toComponent();
- org.apache.woden.wsdl20.Service svc;
- if (getService() != null) {
- svc = desc.getService(getService());
- if (svc == null) {
- throw new DeploymentException("Could not find service '" + getService() + "' in wsdl");
- }
- } else if (desc.getServices().length == 1) {
- svc = desc.getServices()[0];
- setService(svc.getName());
- } else {
- throw new DeploymentException("If service is not set, the WSDL must contain a single service definition");
- }
- Endpoint endpoint;
- if (getEndpoint() != null) {
- endpoint = svc.getEndpoint(new NCName(getEndpoint()));
- if (endpoint == null) {
- throw new DeploymentException("Cound not find endpoint '" + getEndpoint() + "' in wsdl for service '" + getService() + "'");
- }
- } else if (svc.getEndpoints().length == 1) {
- endpoint = svc.getEndpoints()[0];
- setEndpoint(endpoint.getName().toString());
- } else {
- throw new DeploymentException("If endpoint is not set, the WSDL service '" + getService() + "' must contain a single port definition");
- }
- marshaler.setBinding(BindingFactory.createBinding(endpoint));
+ validateWsdl2(marshaler);
} else {
throw new DeploymentException("Unrecognized wsdl namespace: " + elem.getNamespaceURI());
}
@@ -196,7 +132,91 @@
}
super.validate();
}
-
+
+ private void validateWsdl2(HttpSoapConsumerMarshaler marshaler) throws org.apache.woden.WSDLException, IOException,
+ DeploymentException {
+ WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+ DescriptionElement descElement = reader.readWSDL(wsdl.getURL().toString());
+ Description desc = descElement.toComponent();
+ org.apache.woden.wsdl20.Service svc;
+ if (getService() != null) {
+ svc = desc.getService(getService());
+ if (svc == null) {
+ throw new DeploymentException("Could not find service '" + getService() + "' in wsdl");
+ }
+ } else if (desc.getServices().length == 1) {
+ svc = desc.getServices()[0];
+ setService(svc.getName());
+ } else {
+ throw new DeploymentException(
+ "If service is not set, the WSDL must contain a single service definition");
+ }
+ Endpoint endpoint;
+ if (getEndpoint() != null) {
+ endpoint = svc.getEndpoint(new NCName(getEndpoint()));
+ if (endpoint == null) {
+ throw new DeploymentException("Cound not find endpoint '" + getEndpoint()
+ + "' in wsdl for service '" + getService() + "'");
+ }
+ } else if (svc.getEndpoints().length == 1) {
+ endpoint = svc.getEndpoints()[0];
+ setEndpoint(endpoint.getName().toString());
+ } else {
+ throw new DeploymentException("If endpoint is not set, the WSDL service '" + getService()
+ + "' must contain a single port definition");
+ }
+ marshaler.setBinding(BindingFactory.createBinding(endpoint));
+ }
+
+ private void validateWsdl1(HttpSoapConsumerMarshaler marshaler) throws WSDLException, IOException,
+ DeploymentException {
+ Definition def = WSDLUtils.createWSDL11Reader().readWSDL(wsdl.getURL().toString());
+ if (validateWsdl) {
+ WSIBPValidator validator = new WSIBPValidator(def);
+ if (!validator.isValid()) {
+ throw new DeploymentException("WSDL is not WS-I BP compliant: " + validator.getErrors());
+ }
+ }
+ Service svc;
+ if (getService() != null) {
+ svc = def.getService(getService());
+ if (svc == null) {
+ throw new DeploymentException("Could not find service '" + getService() + "' in wsdl");
+ }
+ } else if (def.getServices().size() == 1) {
+ svc = (Service) def.getServices().values().iterator().next();
+ setService(svc.getQName());
+ } else {
+ throw new DeploymentException(
+ "If service is not set, the WSDL must contain a single service definition");
+ }
+ Port port;
+ if (getEndpoint() != null) {
+ port = svc.getPort(getEndpoint());
+ if (port == null) {
+ throw new DeploymentException("Cound not find port '" + getEndpoint()
+ + "' in wsdl for service '" + getService() + "'");
+ }
+ } else if (svc.getPorts().size() == 1) {
+ port = (Port) svc.getPorts().values().iterator().next();
+ setEndpoint(port.getName());
+ } else {
+ throw new DeploymentException("If endpoint is not set, the WSDL service '" + getService()
+ + "' must contain a single port definition");
+ }
+ SOAPAddress soapAddress = WSDLUtils.getExtension(port, SOAPAddress.class);
+ if (soapAddress != null) {
+ soapAddress.setLocationURI(getLocationURI());
+ } else {
+ SOAP12Address soap12Address = WSDLUtils.getExtension(port, SOAP12Address.class);
+ if (soap12Address != null) {
+ soap12Address.setLocationURI(getLocationURI());
+ }
+ }
+ description = WSDLUtils.getWSDL11Factory().newWSDLWriter().getDocument(def);
+ marshaler.setBinding(BindingFactory.createBinding(port));
+ }
+
protected void loadStaticResources() {
addResource(MAIN_WSDL, description);
}
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerMarshaler.java?view=diff&rev=533074&r1=533073&r2=533074
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerMarshaler.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapConsumerMarshaler.java Fri Apr 27 05:23:20 2007
@@ -30,9 +30,9 @@
import javax.xml.namespace.QName;
import org.apache.servicemix.soap.api.InterceptorChain;
+import org.apache.servicemix.soap.api.InterceptorProvider.Phase;
import org.apache.servicemix.soap.api.Message;
import org.apache.servicemix.soap.api.Policy;
-import org.apache.servicemix.soap.api.InterceptorProvider.Phase;
import org.apache.servicemix.soap.api.model.Binding;
import org.apache.servicemix.soap.bindings.http.HttpConstants;
import org.apache.servicemix.soap.bindings.soap.SoapFault;
@@ -95,15 +95,16 @@
request.setAttribute(Message.class.getName(), msg);
InterceptorChain phase = getChain(Phase.ServerIn);
phase.doIntercept(msg);
- MessageExchange me = msg.getContent(MessageExchange.class);
- return me;
+ return msg.getContent(MessageExchange.class);
}
- public void sendAccepted(MessageExchange exchange, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public void sendAccepted(MessageExchange exchange, HttpServletRequest request, HttpServletResponse response)
+ throws Exception {
response.setStatus(HttpServletResponse.SC_ACCEPTED);
}
- public void sendOut(MessageExchange exchange, NormalizedMessage outMsg, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public void sendOut(MessageExchange exchange, NormalizedMessage outMsg, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
Message in = (Message) request.getAttribute(Message.class.getName());
Message msg = binding.createMessage(in);
msg.setContent(OutputStream.class, response.getOutputStream());
@@ -113,10 +114,11 @@
msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
InterceptorChain phase = getChain(Phase.ServerOut);
phase.doIntercept(msg);
- // TODO: handle http headers: Content-Type, ...
+ // TODO: handle http headers: Content-Type, ...
}
-
- public void sendError(MessageExchange exchange, Exception error, HttpServletRequest request, HttpServletResponse response) throws Exception {
+
+ public void sendError(MessageExchange exchange, Exception error, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
Message in = (Message) request.getAttribute(Message.class.getName());
Message msg = binding.createMessage(in);
@@ -135,7 +137,8 @@
phase.doIntercept(msg);
}
- public void sendFault(MessageExchange exchange, Fault fault, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public void sendFault(MessageExchange exchange, Fault fault, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
Message in = (Message) request.getAttribute(Message.class.getName());
Message msg = binding.createMessage(in);
@@ -150,7 +153,7 @@
SoapFault soapFault = new SoapFault(code, reason, null, null, fault.getContent());
msg.setContent(Exception.class, soapFault);
phase.doIntercept(msg);
- // TODO: handle http headers: Content-Type, ...
+ // TODO: handle http headers: Content-Type, ...
}
protected InterceptorChain getChain(Phase phase) {
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SerializedMarshaler.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SerializedMarshaler.java?view=diff&rev=533074&r1=533073&r2=533074
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SerializedMarshaler.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/endpoints/SerializedMarshaler.java Fri Apr 27 05:23:20 2007
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.servicemix.http.endpoints;
import java.io.IOException;
@@ -16,109 +32,110 @@
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.xml.DomDriver;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.servicemix.jbi.jaxp.StringSource;
-import com.thoughtworks.xstream.XStream;
-import com.thoughtworks.xstream.io.xml.DomDriver;
-
/**
- * A marshaler that handles Java serialized content from the InputStream of the
- * HttpServletRequest object and to the OutputStream of the HttpServletResponse
- * object. This class is intended to handle requests initiated by the Spring
- * <a href="http://www.springframework.org/docs/api/org/springframework/remoting/httpinvoker/package-summary.html">httpinvoker package</a>
- * so the marshaled/unmarshaled XML invocation will be Spring
- * <a href="http://www.springframework.org/docs/api/org/springframework/remoting/support/RemoteInvocation.html">RemoteInvocation</a>/
- * <a href="http://www.springframework.org/docs/api/org/springframework/remoting/support/RemoteInvocationResult.html">RemoteInvocationResult</a>
- * objects respectively.
+ * A marshaler that handles Java serialized content from the InputStream of the HttpServletRequest object and to the
+ * OutputStream of the HttpServletResponse object. This class is intended to handle requests initiated by the Spring <a
+ * href="http://www.springframework.org/docs/api/org/springframework/remoting/httpinvoker/package-summary.html">httpinvoker
+ * package</a> so the marshaled/unmarshaled XML invocation will be Spring <a
+ * href="http://www.springframework.org/docs/api/org/springframework/remoting/support/RemoteInvocation.html">RemoteInvocation</a>/
+ * <a href="http://www.springframework.org/docs/api/org/springframework/remoting/support/RemoteInvocationResult.html">
+ * RemoteInvocationResult</a> objects respectively.
*
* <p>
- * This class makes no assumptions about how XML should be marshaled/unmarshaled.
- * I.e., there is currently no way to customize the marshaled XML invocation. So
- * this marshaler will need to pass the XML to a component that can transform it
- * into some custom XML. The servicemix-saxon component can handle this very
- * easily via XLST.
+ * This class makes no assumptions about how XML should be marshaled/unmarshaled. I.e., there is currently no way to
+ * customize the marshaled XML invocation. So this marshaler will need to pass the XML to a component that can transform
+ * it into some custom XML. The servicemix-saxon component can handle this very easily via XLST.
*
* @author bsnyder, aco
* @org.apache.xbean.XBean element="serializedMarshaler"
*/
public class SerializedMarshaler extends DefaultHttpConsumerMarshaler {
-
- private static Log log = LogFactory.getLog(SerializedMarshaler.class);
-
- public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception {
- MessageExchange me =
- context.getDeliveryChannel().createExchangeFactory().createExchange(getDefaultMep());
- NormalizedMessage in = me.createMessage();
- in.setContent(marshal(request.getInputStream()));
+
+ private static Log log = LogFactory.getLog(SerializedMarshaler.class);
+
+ public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception {
+ MessageExchange me = context.getDeliveryChannel().createExchangeFactory().createExchange(getDefaultMep());
+ NormalizedMessage in = me.createMessage();
+ in.setContent(marshal(request.getInputStream()));
me.setMessage(in, "in");
return me;
- }
+ }
- public void sendOut(MessageExchange exchange, NormalizedMessage outMsg, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public void sendOut(MessageExchange exchange, NormalizedMessage outMsg, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
if (outMsg.getContent() != null) {
unmarshal(response.getOutputStream(), outMsg.getContent());
}
}
/**
- * Marshal the byte content of the input stream to an XML source. This method
- * is marshaling the contents of the Spring <a href="http://www.springframework.org/docs/api/org/springframework/remoting/support/RemoteInvocation.html">RemoteInvocation</a>
- * object. Below is an example of what this method emits:
+ * Marshal the byte content of the input stream to an XML source. This method is marshaling the contents of the
+ * Spring <a
+ * href="http://www.springframework.org/docs/api/org/springframework/remoting/support/RemoteInvocation.html">RemoteInvocation</a>
+ * object. Below is an example of what this method emits:
*
* <pre>
- * <?xml version="1.0" encoding="UTF-8"?><org.springframework.remoting.support.RemoteInvocation>
- * <methodName>login</methodName>
- * <parameterTypes>
- * <java-class>java.lang.String</java-class>
- * <java-class>java.lang.String</java-class>
- * </parameterTypes>
- * <arguments>
- * <string>foo</string>
- * <string>bar</string>
- * </arguments>
- * </org.springframework.remoting.support.RemoteInvocation>
+ * <?xml version="1.0" encoding="UTF-8"?><org.springframework.remoting.support.RemoteInvocation>
+ * <methodName>login</methodName>
+ * <parameterTypes>
+ * <java-class>java.lang.String</java-class>
+ * <java-class>java.lang.String</java-class>
+ * </parameterTypes>
+ * <arguments>
+ * <string>foo</string>
+ * <string>bar</string>
+ * </arguments>
+ * </org.springframework.remoting.support.RemoteInvocation>
* </pre>
*
- * @param is - input stream to read the object from
+ * @param is -
+ * input stream to read the object from
* @return xml source
* @throws IOException
* @throws ClassNotFoundException
*/
private Source marshal(InputStream is) throws IOException, ClassNotFoundException {
- Object obj = new ObjectInputStream(is).readObject();
- Writer w = new StringWriter();
- XStream xstream = new XStream(new DomDriver());
- xstream.toXML(obj, w);
- String request = w.toString();
-
- if (log.isDebugEnabled()) {
- log.debug("Remote invocation request: " + request);
- }
-
- return new StringSource(request);
- }
+ Object obj = new ObjectInputStream(is).readObject();
+ Writer w = new StringWriter();
+ XStream xstream = new XStream(new DomDriver());
+ xstream.toXML(obj, w);
+ String request = w.toString();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Remote invocation request: " + request);
+ }
+
+ return new StringSource(request);
+ }
/**
- * Unmarshal the XML content to the specified output stream. This method is
- * unmarshaling XML into the Spring <a href="http://www.springframework.org/docs/api/org/springframework/remoting/support/RemoteInvocationResult.html">RemoteInvocationResult</a>
- * object. Below is an example of the XML expected by this method:
+ * Unmarshal the XML content to the specified output stream. This method is unmarshaling XML into the Spring
+ * <a href="http://www.springframework.org/docs/api/org/springframework/remoting/support/RemoteInvocationResult.html">
+ * RemoteInvocationResult</a> object. Below is an example of the XML expected by this method:
*
* <pre>
- * <?xml version="1.0" encoding="UTF-8"?>
- * <org.springframework.remoting.support.RemoteInvocationResult>
- * <value class="com.example.foo.bar.Baz">
- * <firstName>myfirstname</firstName>
- * <lastName>mylastname</lastName>
- * <phone>12312312</phone>
- * </value>
- * </org.springframework.remoting.support.RemoteInvocationResult>
- * </pre>
+ * <?xml version="1.0" encoding="UTF-8"?>
+ * <org.springframework.remoting.support.RemoteInvocationResult>
+ * <value class="com.example.foo.bar.Baz">
+ * <firstName>myfirstname</firstName>
+ * <lastName>mylastname</lastName>
+ * <phone>12312312</phone>
+ * </value>
+ * </org.springframework.remoting.support.RemoteInvocationResult>
+ * </pre>
*
- * @param os - output stream to unmarshal to
- * @param content - XML source
+ * @param os -
+ * output stream to unmarshal to
+ * @param content -
+ * XML source
* @throws TransformerException
* @throws IOException
*/
@@ -126,11 +143,11 @@
SourceTransformer transform = new SourceTransformer();
XStream xstream = new XStream(new DomDriver());
String result = transform.toString(content);
-
- if (log.isDebugEnabled()) {
- log.debug("Remote invocation result: " + result);
- }
-
+
+ if (log.isDebugEnabled()) {
+ log.debug("Remote invocation result: " + result);
+ }
+
Object obj = xstream.fromXML(result);
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(obj);
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JCLLogger.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JCLLogger.java?view=diff&rev=533074&r1=533073&r2=533074
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JCLLogger.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JCLLogger.java Fri Apr 27 05:23:20 2007
@@ -27,9 +27,21 @@
*/
public class JCLLogger implements Logger {
+ static final char DELIM_START = '{';
+ static final char DELIM_STOP = '}';
+
private final String name;
private final Log log;
-
+
+ public JCLLogger() {
+ this("org.mortbay.jetty");
+ }
+
+ public JCLLogger(String name) {
+ this.name = name;
+ this.log = LogFactory.getLog(name);
+ }
+
public static void init() {
// TODO: use org.mortbay.log.Log#setLog when available (beta18)
String old = System.getProperty("org.mortbay.log.class");
@@ -49,15 +61,6 @@
}
}
- public JCLLogger() {
- this("org.mortbay.jetty");
- }
-
- public JCLLogger(String name) {
- this.name = name;
- this.log = LogFactory.getLog(name);
- }
-
public void debug(String msg, Throwable th) {
log.debug(msg, th);
}
@@ -68,11 +71,11 @@
}
}
- public Logger getLogger(String name) {
- if (name == null) {
+ public Logger getLogger(String loggerName) {
+ if (loggerName == null) {
return null;
}
- return new JCLLogger(this.name + "." + name);
+ return new JCLLogger(this.name + "." + loggerName);
}
public void info(String msg, Object arg0, Object arg1) {
@@ -98,10 +101,7 @@
log.warn(arrayFormat(msg, new Object[] {arg0, arg1}));
}
}
-
- static final char DELIM_START = '{';
- static final char DELIM_STOP = '}';
-
+
public static String arrayFormat(String messagePattern, Object[] argArray) {
if (messagePattern == null) {
return null;
@@ -112,7 +112,7 @@
StringBuffer sbuf = new StringBuffer(messagePattern.length() + 50);
- for (int L = 0; L < argArray.length; L++) {
+ for (int index = 0; index < argArray.length; index++) {
char escape = 'x';
@@ -123,7 +123,7 @@
if (i == 0) { // this is a simple string
return messagePattern;
} else { // add the tail string which contains no variables
- // and return the result.
+ // and return the result.
sbuf.append(messagePattern.substring(i, messagePattern.length()));
return sbuf.toString();
}
@@ -134,19 +134,19 @@
}
if (escape == '\\') {
- L--; // DELIM_START was escaped, thus should not be
- // incremented
+ index--; // DELIM_START was escaped, thus should not be
+ // incremented
sbuf.append(messagePattern.substring(i, j - 1));
sbuf.append(DELIM_START);
i = j + 1;
- } else if ((delimStop != DELIM_STOP)) {
+ } else if (delimStop != DELIM_STOP) {
// invalid DELIM_START/DELIM_STOP pair
sbuf.append(messagePattern.substring(i, messagePattern.length()));
return sbuf.toString();
} else {
// normal case
sbuf.append(messagePattern.substring(i, j));
- sbuf.append(argArray[L]);
+ sbuf.append(argArray[index]);
i = j + 2;
}
}
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JaasJettyPrincipal.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JaasJettyPrincipal.java?view=diff&rev=533074&r1=533073&r2=533074
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JaasJettyPrincipal.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JaasJettyPrincipal.java Fri Apr 27 05:23:20 2007
@@ -24,7 +24,7 @@
private final String name;
private Subject subject;
-
+
public JaasJettyPrincipal(String name) {
this.name = name;
}
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JaasUserRealm.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JaasUserRealm.java?view=diff&rev=533074&r1=533073&r2=533074
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JaasUserRealm.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JaasUserRealm.java Fri Apr 27 05:23:20 2007
@@ -22,6 +22,8 @@
import javax.security.auth.Subject;
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.jbi.security.auth.AuthenticationService;
@@ -29,17 +31,15 @@
import org.mortbay.jetty.Request;
import org.mortbay.jetty.security.UserRealm;
-import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
-
/**
* A JAAS based implementation of a realm for jetty 6.
*
* @author gnodet
*/
public class JaasUserRealm implements UserRealm {
-
- private static final Log log = LogFactory.getLog(JaasUserRealm.class);
-
+
+ private static final Log LOG = LogFactory.getLog(JaasUserRealm.class);
+
private String name = getClass().getName();
private String domain = "servicemix-domain";
private AuthenticationService authenticationService = new JAASAuthenticationService();
@@ -53,7 +53,8 @@
}
/**
- * @param authenticationService the authenticationService to set
+ * @param authenticationService
+ * the authenticationService to set
*/
public void setAuthenticationService(AuthenticationService authenticationService) {
this.authenticationService = authenticationService;
@@ -67,7 +68,8 @@
}
/**
- * @param domain the domain to set
+ * @param domain
+ * the domain to set
*/
public void setDomain(String domain) {
this.domain = domain;
@@ -81,28 +83,29 @@
}
/**
- * @param name the name to set
+ * @param name
+ * the name to set
*/
public void setName(String name) {
this.name = name;
}
-
+
public Principal authenticate(final String username, final Object credentials, Request request) {
try {
if ((username != null) && (!username.equals(""))) {
JaasJettyPrincipal userPrincipal = (JaasJettyPrincipal) userMap.get(username);
- //user has been previously authenticated, but
- //re-authentication has been requested, so remove them
+ // user has been previously authenticated, but
+ // re-authentication has been requested, so remove them
if (userPrincipal != null) {
userMap.remove(username);
}
- //set up the login context
+ // set up the login context
Subject subject = new Subject();
authenticationService.authenticate(subject, domain, username, credentials);
- //login success
+ // login success
userPrincipal = new JaasJettyPrincipal(username);
userPrincipal.setSubject(subject);
@@ -110,12 +113,12 @@
return userPrincipal;
} else {
- log.debug("Login Failed - null userID");
+ LOG.debug("Login Failed - null userID");
return null;
}
} catch (GeneralSecurityException e) {
- log.debug("Login Failed", e);
+ LOG.debug("Login Failed", e);
return null;
}
}
@@ -149,7 +152,7 @@
public boolean reauthenticate(Principal user) {
// get the user out of the cache
- return (userMap.get(user.getName()) != null);
+ return userMap.get(user.getName()) != null;
}
}
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java?view=diff&rev=533074&r1=533073&r2=533074
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/JettyContextManager.java Fri Apr 27 05:23:20 2007
@@ -24,7 +24,6 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
import javax.jbi.JBIException;
import javax.management.MBeanServer;
@@ -68,37 +67,38 @@
public class JettyContextManager implements ContextManager {
- private static final Log logger = LogFactory.getLog(JettyContextManager.class);
-
- private Map servers;
+ private static final Log LOGGER = LogFactory.getLog(JettyContextManager.class);
+
+ private Map<String, Server> servers;
private HttpConfiguration configuration;
private BoundedThreadPool threadPool;
private Map sslParams;
- private MBeanServer mbeanServer;
+ private MBeanServer mBeanServer;
private MBeanContainer mbeanContainer;
-
+
/**
* @return the mbeanServer
*/
public MBeanServer getMBeanServer() {
- return mbeanServer;
+ return mBeanServer;
}
/**
- * @param mbeanServer the mbeanServer to set
+ * @param mBeanServer
+ * the mbeanServer to set
*/
- public void setMBeanServer(MBeanServer mbeanServer) {
- this.mbeanServer = mbeanServer;
+ public void setMBeanServer(MBeanServer mBeanServer) {
+ this.mBeanServer = mBeanServer;
}
public void init() throws Exception {
if (configuration == null) {
configuration = new HttpConfiguration();
}
- if (mbeanServer != null && !configuration.isManaged() && configuration.isJettyManagement()) {
- mbeanContainer = new MBeanContainer(mbeanServer);
+ if (mBeanServer != null && !configuration.isManaged() && configuration.isJettyManagement()) {
+ mbeanContainer = new MBeanContainer(mBeanServer);
}
- servers = new HashMap();
+ servers = new HashMap<String, Server>();
sslParams = new HashMap();
BoundedThreadPool btp = new BoundedThreadPool();
btp.setMaxThreads(this.configuration.getJettyThreadPoolSize());
@@ -134,9 +134,8 @@
}
threadPool.stop();
}
-
- public synchronized Object createContext(String strUrl,
- HttpProcessor processor) throws Exception {
+
+ public synchronized Object createContext(String strUrl, HttpProcessor processor) throws Exception {
URL url = new URL(strUrl);
Server server = getServer(url);
if (server == null) {
@@ -145,7 +144,8 @@
// Check ssl params
SslParameters ssl = (SslParameters) sslParams.get(getKey(url));
if (ssl != null && !ssl.equals(processor.getSsl())) {
- throw new Exception("An https server is already created on port " + url.getPort() + " but SSL parameters do not match");
+ throw new Exception("An https server is already created on port " + url.getPort()
+ + " but SSL parameters do not match");
}
}
String path = url.getPath();
@@ -165,9 +165,9 @@
if (handlers[i] instanceof ContextHandler) {
ContextHandler h = (ContextHandler) handlers[i];
String handlerPath = h.getContextPath() + "/";
- if (handlerPath.startsWith(pathSlash) ||
- pathSlash.startsWith(handlerPath)) {
- throw new Exception("The requested context for path '" + path + "' overlaps with an existing context for path: '" + h.getContextPath() + "'");
+ if (handlerPath.startsWith(pathSlash) || pathSlash.startsWith(handlerPath)) {
+ throw new Exception("The requested context for path '" + path
+ + "' overlaps with an existing context for path: '" + h.getContextPath() + "'");
}
}
}
@@ -179,25 +179,25 @@
holder.setName("jbiServlet");
holder.setClassName(HttpBridgeServlet.class.getName());
ServletHandler handler = new ServletHandler();
- handler.setServlets(new ServletHolder[] { holder });
+ handler.setServlets(new ServletHolder[] {holder});
ServletMapping mapping = new ServletMapping();
mapping.setServletName("jbiServlet");
mapping.setPathSpec("/*");
- handler.setServletMappings(new ServletMapping[] { mapping });
+ handler.setServletMappings(new ServletMapping[] {mapping});
if (processor.getAuthMethod() != null) {
SecurityHandler secHandler = new SecurityHandler();
ConstraintMapping constraintMapping = new ConstraintMapping();
Constraint constraint = new Constraint();
constraint.setAuthenticate(true);
- constraint.setRoles(new String[] { "*" });
+ constraint.setRoles(new String[] {"*"});
constraintMapping.setConstraint(constraint);
constraintMapping.setPathSpec("/");
- secHandler.setConstraintMappings(new ConstraintMapping[] { constraintMapping });
+ secHandler.setConstraintMappings(new ConstraintMapping[] {constraintMapping});
secHandler.setHandler(handler);
secHandler.setAuthMethod(processor.getAuthMethod());
JaasUserRealm realm = new JaasUserRealm();
if (configuration.getAuthenticationService() != null) {
- realm.setAuthenticationService(configuration.getAuthenticationService());
+ realm.setAuthenticationService(configuration.getAuthenticationService());
}
secHandler.setUserRealm(realm);
context.setHandler(secHandler);
@@ -211,7 +211,7 @@
context.start();
return context;
}
-
+
public synchronized void remove(Object context) throws Exception {
((ContextHandler) context).stop();
for (Iterator it = servers.values().iterator(); it.hasNext();) {
@@ -220,16 +220,15 @@
ContextHandlerCollection contexts = (ContextHandlerCollection) handlerCollection.getHandlers()[0];
Handler[] handlers = contexts.getHandlers();
if (handlers != null && handlers.length > 0) {
- contexts.setHandlers((Handler[])LazyList.removeFromArray(handlers, context));
+ contexts.setHandlers((Handler[]) LazyList.removeFromArray(handlers, context));
}
}
}
protected Server getServer(URL url) {
- Server server = (Server) servers.get(getKey(url));
- return server;
+ return (Server) servers.get(getKey(url));
}
-
+
protected String getKey(URL url) {
String host = url.getHost();
try {
@@ -238,11 +237,11 @@
host = InetAddress.getLocalHost().getHostName();
}
} catch (UnknownHostException e) {
+ //unable to lookup host name, using IP address instead
}
- String key = url.getProtocol() + "://" + host + ":" + url.getPort();
- return key;
+ return url.getProtocol() + "://" + host + ":" + url.getPort();
}
-
+
protected Server createServer(URL url, SslParameters ssl) throws Exception {
boolean isSsl = false;
if (url.getProtocol().equals("https")) {
@@ -257,76 +256,21 @@
// Create a new server
Connector connector;
if (isSsl && ssl.isManaged()) {
- String keyStore = ssl.getKeyStore();
- if (keyStore == null) {
- throw new IllegalArgumentException("keyStore must be set");
- }
- ServiceMixSslSocketConnector sslConnector = new ServiceMixSslSocketConnector();
- sslConnector.setSslKeyManagerFactoryAlgorithm(ssl.getKeyManagerFactoryAlgorithm());
- sslConnector.setSslTrustManagerFactoryAlgorithm(ssl.getTrustManagerFactoryAlgorithm());
- sslConnector.setProtocol(ssl.getProtocol());
- sslConnector.setConfidentialPort(url.getPort());
- sslConnector.setKeystore(keyStore);
- sslConnector.setKeyAlias(ssl.getKeyAlias());
- sslConnector.setNeedClientAuth(ssl.isNeedClientAuth());
- sslConnector.setWantClientAuth(ssl.isWantClientAuth());
- sslConnector.setKeystoreManager(getConfiguration().getKeystoreManager());
- // important to set this values for selfsigned keys
- // otherwise the standard truststore of the jre is used
- sslConnector.setTruststore(ssl.getTrustStore());
- if (ssl.getTrustStorePassword() != null) {
- // check is necessary because if a null password is set
- // jetty would ask for a password on the comandline
- sslConnector.setTrustPassword(ssl.getTrustStorePassword());
- }
- sslConnector.setTruststoreType(ssl.getTrustStoreType());
- connector = sslConnector;
+ connector = setupManagerSslConnector(url, ssl);
} else if (isSsl) {
- String keyStore = ssl.getKeyStore();
- if (keyStore == null) {
- keyStore = System.getProperty("javax.net.ssl.keyStore", "");
- if (keyStore == null) {
- throw new IllegalArgumentException("keyStore or system property javax.net.ssl.keyStore must be set");
- }
- }
- if (keyStore.startsWith("classpath:")) {
- try {
- String res = keyStore.substring(10);
- URL resurl = new ClassPathResource(res).getURL();
- keyStore = resurl.toString();
- } catch (IOException e) {
- throw new JBIException("Unable to find keystore " + keyStore, e);
- }
- }
- String keyStorePassword = ssl.getKeyStorePassword();
- if (keyStorePassword == null) {
- keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword");
- if (keyStorePassword == null) {
- throw new IllegalArgumentException("keyStorePassword or system property javax.net.ssl.keyStorePassword must be set");
- }
- }
- SslSocketConnector sslConnector = new SslSocketConnector();
- sslConnector.setSslKeyManagerFactoryAlgorithm(ssl.getKeyManagerFactoryAlgorithm());
- sslConnector.setSslTrustManagerFactoryAlgorithm(ssl.getTrustManagerFactoryAlgorithm());
- sslConnector.setProtocol(ssl.getProtocol());
- sslConnector.setConfidentialPort(url.getPort());
- sslConnector.setPassword(ssl.getKeyStorePassword());
- sslConnector.setKeyPassword(ssl.getKeyPassword() != null ? ssl.getKeyPassword() : keyStorePassword);
- sslConnector.setKeystore(keyStore);
- sslConnector.setKeystoreType(ssl.getKeyStoreType());
- sslConnector.setNeedClientAuth(ssl.isNeedClientAuth());
- sslConnector.setWantClientAuth(ssl.isWantClientAuth());
- connector = sslConnector;
+ connector = setupSslConnector(url, ssl);
} else {
String connectorClassName = configuration.getJettyConnectorClassName();
try {
connector = (Connector) Class.forName(connectorClassName).newInstance();
} catch (Exception e) {
- logger.warn("Could not create a jetty connector of class '" + connectorClassName + "'. Defaulting to " + HttpConfiguration.DEFAULT_JETTY_CONNECTOR_CLASS_NAME);
- if (logger.isDebugEnabled()) {
- logger.debug("Reason: " + e.getMessage(), e);
+ LOGGER.warn("Could not create a jetty connector of class '" + connectorClassName + "'. Defaulting to "
+ + HttpConfiguration.DEFAULT_JETTY_CONNECTOR_CLASS_NAME);
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Reason: " + e.getMessage(), e);
}
- connector = (Connector) Class.forName(HttpConfiguration.DEFAULT_JETTY_CONNECTOR_CLASS_NAME).newInstance();
+ connector = (Connector) Class.forName(HttpConfiguration.DEFAULT_JETTY_CONNECTOR_CLASS_NAME)
+ .newInstance();
}
}
connector.setHost(url.getHost());
@@ -334,10 +278,10 @@
connector.setMaxIdleTime(this.configuration.getConnectorMaxIdleTime());
Server server = new Server();
server.setThreadPool(new ThreadPoolWrapper());
- server.setConnectors(new Connector[] { connector });
+ server.setConnectors(new Connector[] {connector});
ContextHandlerCollection contexts = new ContextHandlerCollection();
HandlerCollection handlers = new HandlerCollection();
- handlers.setHandlers(new Handler[] { contexts, new DisplayServiceHandler() });
+ handlers.setHandlers(new Handler[] {contexts, new DisplayServiceHandler()});
server.setHandler(handlers);
server.start();
servers.put(getKey(url), server);
@@ -348,6 +292,77 @@
return server;
}
+ private Connector setupSslConnector(URL url, SslParameters ssl) throws JBIException {
+ Connector connector;
+ String keyStore = ssl.getKeyStore();
+ if (keyStore == null) {
+ keyStore = System.getProperty("javax.net.ssl.keyStore", "");
+ if (keyStore == null) {
+ throw new IllegalArgumentException(
+ "keyStore or system property javax.net.ssl.keyStore must be set");
+ }
+ }
+ if (keyStore.startsWith("classpath:")) {
+ try {
+ String res = keyStore.substring(10);
+ URL resurl = new ClassPathResource(res).getURL();
+ keyStore = resurl.toString();
+ } catch (IOException e) {
+ throw new JBIException("Unable to find keystore " + keyStore, e);
+ }
+ }
+ String keyStorePassword = ssl.getKeyStorePassword();
+ if (keyStorePassword == null) {
+ keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword");
+ if (keyStorePassword == null) {
+ throw new IllegalArgumentException(
+ "keyStorePassword or system property javax.net.ssl.keyStorePassword must be set");
+ }
+ }
+ SslSocketConnector sslConnector = new SslSocketConnector();
+ sslConnector.setSslKeyManagerFactoryAlgorithm(ssl.getKeyManagerFactoryAlgorithm());
+ sslConnector.setSslTrustManagerFactoryAlgorithm(ssl.getTrustManagerFactoryAlgorithm());
+ sslConnector.setProtocol(ssl.getProtocol());
+ sslConnector.setConfidentialPort(url.getPort());
+ sslConnector.setPassword(ssl.getKeyStorePassword());
+ sslConnector.setKeyPassword(ssl.getKeyPassword() != null ? ssl.getKeyPassword() : keyStorePassword);
+ sslConnector.setKeystore(keyStore);
+ sslConnector.setKeystoreType(ssl.getKeyStoreType());
+ sslConnector.setNeedClientAuth(ssl.isNeedClientAuth());
+ sslConnector.setWantClientAuth(ssl.isWantClientAuth());
+ connector = sslConnector;
+ return connector;
+ }
+
+ private Connector setupManagerSslConnector(URL url, SslParameters ssl) {
+ Connector connector;
+ String keyStore = ssl.getKeyStore();
+ if (keyStore == null) {
+ throw new IllegalArgumentException("keyStore must be set");
+ }
+ ServiceMixSslSocketConnector sslConnector = new ServiceMixSslSocketConnector();
+ sslConnector.setSslKeyManagerFactoryAlgorithm(ssl.getKeyManagerFactoryAlgorithm());
+ sslConnector.setSslTrustManagerFactoryAlgorithm(ssl.getTrustManagerFactoryAlgorithm());
+ sslConnector.setProtocol(ssl.getProtocol());
+ sslConnector.setConfidentialPort(url.getPort());
+ sslConnector.setKeystore(keyStore);
+ sslConnector.setKeyAlias(ssl.getKeyAlias());
+ sslConnector.setNeedClientAuth(ssl.isNeedClientAuth());
+ sslConnector.setWantClientAuth(ssl.isWantClientAuth());
+ sslConnector.setKeystoreManager(getConfiguration().getKeystoreManager());
+ // important to set this values for selfsigned keys
+ // otherwise the standard truststore of the jre is used
+ sslConnector.setTruststore(ssl.getTrustStore());
+ if (ssl.getTrustStorePassword() != null) {
+ // check is necessary because if a null password is set
+ // jetty would ask for a password on the comandline
+ sslConnector.setTrustPassword(ssl.getTrustStorePassword());
+ }
+ sslConnector.setTruststoreType(ssl.getTrustStoreType());
+ connector = sslConnector;
+ return connector;
+ }
+
public HttpConfiguration getConfiguration() {
return configuration;
}
@@ -359,37 +374,37 @@
public ThreadPool getThreadPool() {
return threadPool;
}
-
+
protected class DisplayServiceHandler extends AbstractHandler {
- public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException {
- if (response.isCommitted() || HttpConnection.getCurrentConnection().getRequest().isHandled())
+ public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
+ throws IOException, ServletException {
+ if (response.isCommitted() || HttpConnection.getCurrentConnection().getRequest().isHandled()) {
return;
-
+ }
+
String method = request.getMethod();
-
+
if (!method.equals(HttpMethods.GET) || !request.getRequestURI().equals("/")) {
response.sendError(404);
- return;
+ return;
}
response.setStatus(404);
response.setContentType(MimeTypes.TEXT_HTML);
-
+
ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer(1500);
String uri = request.getRequestURI();
uri = StringUtil.replace(uri, "<", "<");
uri = StringUtil.replace(uri, ">", ">");
-
+
writer.write("<HTML>\n<HEAD>\n<TITLE>Error 404 - Not Found");
writer.write("</TITLE>\n<BODY>\n<H2>Error 404 - Not Found.</H2>\n");
writer.write("No service matched or handled this request.<BR>");
writer.write("Known services are: <ul>");
- Set servers = JettyContextManager.this.servers.keySet();
- for (Iterator iter = servers.iterator(); iter.hasNext();) {
- String serverUri = (String) iter.next();
+ for (String serverUri : servers.keySet()) {
Server server = (Server) JettyContextManager.this.servers.get(serverUri);
Handler[] handlers = server.getChildHandlersByClass(ContextHandler.class);
for (int i = 0; handlers != null && i < handlers.length; i++) {
@@ -419,11 +434,11 @@
}
}
}
-
- for (int i=0; i < 10; i++) {
+
+ for (int i = 0; i < 10; i++) {
writer.write("\n<!-- Padding for IE -->");
}
-
+
writer.write("\n</BODY>\n</HTML>\n");
writer.flush();
response.setContentLength(writer.size());
@@ -431,14 +446,14 @@
writer.writeTo(out);
out.close();
}
-
+
}
-
+
protected class ThreadPoolWrapper extends AbstractLifeCycle implements ThreadPool {
public boolean dispatch(Runnable job) {
- if (logger.isDebugEnabled()) {
- logger.debug("Dispatching job: " + job);
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Dispatching job: " + job);
}
return threadPool.dispatch(job);
}
@@ -462,5 +477,5 @@
public HttpProcessor getMainProcessor() {
throw new IllegalStateException("ServerManager is not managed");
}
-
+
}
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/ServiceMixSslSocketConnector.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/ServiceMixSslSocketConnector.java?view=diff&rev=533074&r1=533073&r2=533074
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/ServiceMixSslSocketConnector.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/jetty/ServiceMixSslSocketConnector.java Fri Apr 27 05:23:20 2007
@@ -24,11 +24,11 @@
public class ServiceMixSslSocketConnector extends SslSocketConnector {
private String trustStore;
-
+
private String keyAlias;
-
+
private KeystoreManager keystoreManager;
-
+
/**
* @return the keystoreManager
*/
@@ -37,7 +37,8 @@
}
/**
- * @param keystoreManager the keystoreManager to set
+ * @param keystoreManager
+ * the keystoreManager to set
*/
public void setKeystoreManager(KeystoreManager keystoreManager) {
this.keystoreManager = keystoreManager;
@@ -51,7 +52,8 @@
}
/**
- * @param keyAlias the keyAlias to set
+ * @param keyAlias
+ * the keyAlias to set
*/
public void setKeyAlias(String keyAlias) {
this.keyAlias = keyAlias;
@@ -65,19 +67,15 @@
}
/**
- * @param trustStore the trustStore to set
+ * @param trustStore
+ * the trustStore to set
*/
public void setTrustStore(String trustStore) {
this.trustStore = trustStore;
}
protected SSLServerSocketFactory createFactory() throws Exception {
- return keystoreManager.createSSLServerFactory(
- getProvider(),
- getProtocol(),
- getSslKeyManagerFactoryAlgorithm(),
- getKeystore(),
- getKeyAlias(),
- getTrustStore());
+ return keystoreManager.createSSLServerFactory(getProvider(), getProtocol(), getSslKeyManagerFactoryAlgorithm(),
+ getKeystore(), getKeyAlias(), getTrustStore());
}
}
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzer.java?view=diff&rev=533074&r1=533073&r2=533074
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzer.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/packaging/HttpServiceUnitAnalyzer.java Fri Apr 27 05:23:20 2007
@@ -23,7 +23,6 @@
import org.apache.servicemix.common.Endpoint;
import org.apache.servicemix.common.packaging.Consumes;
-import org.apache.servicemix.common.packaging.ServiceUnitAnalyzer;
import org.apache.servicemix.common.xbean.AbstractXBeanServiceUnitAnalyzer;
import org.apache.servicemix.http.HttpEndpoint;
@@ -31,46 +30,42 @@
* Implementation of the ServiceUnitAnalyzer can be used in tooling to provide a
* way to parse the artifact for the service unit and provide a list of consumes
* and provides
- *
+ *
* @author Philip Dodds
- * @since 3.0
* @see ServiceUnitAnalyzer, {@link ServiceUnitAnalyzer}
- *
+ * @since 3.0
*/
public class HttpServiceUnitAnalyzer extends AbstractXBeanServiceUnitAnalyzer {
- protected List getConsumes(Endpoint endpoint) {
- List consumesList = new ArrayList();
- Consumes consumes;
- if (endpoint.getRole().equals(MessageExchange.Role.CONSUMER)) {
- consumes = new Consumes();
- HttpEndpoint httpEndpoint = (HttpEndpoint) endpoint;
- consumes.setEndpointName(httpEndpoint.getTargetEndpoint());
- consumes.setInterfaceName(httpEndpoint.getTargetInterfaceName());
- consumes.setServiceName(httpEndpoint.getTargetService());
- if (consumes.isValid())
- consumesList.add(consumes);
- else {
- consumes = new Consumes();
- consumes.setEndpointName(endpoint.getEndpoint());
- consumes.setInterfaceName(endpoint.getInterfaceName());
- consumes.setServiceName(endpoint.getService());
- consumesList.add(consumes);
- }
- }
+ protected List getConsumes(Endpoint endpoint) {
+ List consumesList = new ArrayList();
+ Consumes consumes;
+ if (endpoint.getRole().equals(MessageExchange.Role.CONSUMER)) {
+ consumes = new Consumes();
+ HttpEndpoint httpEndpoint = (HttpEndpoint) endpoint;
+ consumes.setEndpointName(httpEndpoint.getTargetEndpoint());
+ consumes.setInterfaceName(httpEndpoint.getTargetInterfaceName());
+ consumes.setServiceName(httpEndpoint.getTargetService());
+ if (consumes.isValid()) {
+ consumesList.add(consumes);
+ } else {
+ consumes = new Consumes();
+ consumes.setEndpointName(endpoint.getEndpoint());
+ consumes.setInterfaceName(endpoint.getInterfaceName());
+ consumes.setServiceName(endpoint.getService());
+ consumesList.add(consumes);
+ }
+ }
- return consumesList;
- }
+ return consumesList;
+ }
- protected String getXBeanFile() {
- return "xbean.xml";
- }
+ protected String getXBeanFile() {
+ return "xbean.xml";
+ }
- protected boolean isValidEndpoint(Object bean) {
- if (bean instanceof HttpEndpoint)
- return true;
- else
- return false;
- }
+ protected boolean isValidEndpoint(Object bean) {
+ return bean instanceof HttpEndpoint;
+ }
}
Added: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/AbstractProcessor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/AbstractProcessor.java?view=auto&rev=533074
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/AbstractProcessor.java (added)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/AbstractProcessor.java Fri Apr 27 05:23:20 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.http.processors;
+
+import org.apache.servicemix.http.HttpComponent;
+import org.apache.servicemix.http.HttpConfiguration;
+import org.apache.servicemix.http.HttpEndpoint;
+
+/**
+ * Abstract base class for provider and consumer processor.
+ */
+public class AbstractProcessor {
+
+ public static final String HEADER_SOAP_ACTION = "SOAPAction";
+ public static final String HEADER_CONTENT_TYPE = "Content-Type";
+ public static final String HEADER_CONTENT_LENGTH = "Content-Length";
+
+ protected HttpEndpoint endpoint;
+
+ AbstractProcessor(HttpEndpoint endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ protected HttpConfiguration getConfiguration() {
+ HttpComponent comp = (HttpComponent) endpoint.getServiceUnit().getComponent();
+ return comp.getConfiguration();
+ }
+}
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/CommonsHttpSSLSocketFactory.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/CommonsHttpSSLSocketFactory.java?view=diff&rev=533074&r1=533073&r2=533074
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/CommonsHttpSSLSocketFactory.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/CommonsHttpSSLSocketFactory.java Fri Apr 27 05:23:20 2007
@@ -42,7 +42,7 @@
public class CommonsHttpSSLSocketFactory implements SecureProtocolSocketFactory {
private SSLSocketFactory factory;
-
+
public CommonsHttpSSLSocketFactory(SslParameters ssl, KeystoreManager keystoreManager) throws Exception {
if (ssl.isManaged()) {
createManagedFactory(ssl, keystoreManager);
@@ -50,18 +50,13 @@
createUnmanagedFactory(ssl);
}
}
-
- protected void createManagedFactory(SslParameters ssl, KeystoreManager keystoreManager) throws Exception {
- factory = keystoreManager.createSSLFactory(
- ssl.getProvider(),
- ssl.getProtocol(),
- ssl.getKeyManagerFactoryAlgorithm(),
- ssl.getKeyStore(),
- ssl.getKeyAlias(),
- ssl.getTrustStore());
+
+ protected final void createManagedFactory(SslParameters ssl, KeystoreManager keystoreManager) throws Exception {
+ factory = keystoreManager.createSSLFactory(ssl.getProvider(), ssl.getProtocol(), ssl
+ .getKeyManagerFactoryAlgorithm(), ssl.getKeyStore(), ssl.getKeyAlias(), ssl.getTrustStore());
}
-
- protected void createUnmanagedFactory(SslParameters ssl) throws Exception {
+
+ protected final void createUnmanagedFactory(SslParameters ssl) throws Exception {
SSLContext context;
if (ssl.getProvider() == null) {
context = SSLContext.getInstance(ssl.getProtocol());
@@ -89,7 +84,8 @@
if (keyStorePassword == null) {
keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword");
if (keyStorePassword == null) {
- throw new IllegalArgumentException("keyStorePassword or system property javax.net.ssl.keyStorePassword must be set");
+ throw new IllegalArgumentException(
+ "keyStorePassword or system property javax.net.ssl.keyStorePassword must be set");
}
}
String trustStore = ssl.getTrustStore();
@@ -111,34 +107,41 @@
if (trustStorePassword == null) {
trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword");
if (trustStorePassword == null) {
- throw new IllegalArgumentException("trustStorePassword or system property javax.net.ssl.trustStorePassword must be set");
+ throw new IllegalArgumentException(
+ "trustStorePassword or system property javax.net.ssl.trustStorePassword must be set");
}
}
}
KeyStore ks = KeyStore.getInstance(ssl.getKeyStoreType());
ks.load(Resource.newResource(keyStore).getInputStream(), keyStorePassword.toCharArray());
- keyManagerFactory.init(ks, ssl.getKeyPassword() != null ? ssl.getKeyPassword().toCharArray() : keyStorePassword.toCharArray());
+ keyManagerFactory.init(ks, ssl.getKeyPassword() != null ? ssl.getKeyPassword().toCharArray() : keyStorePassword
+ .toCharArray());
if (trustStore != null) {
KeyStore ts = KeyStore.getInstance(ssl.getTrustStoreType());
ts.load(Resource.newResource(trustStore).getInputStream(), trustStorePassword.toCharArray());
- TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(ssl.getTrustManagerFactoryAlgorithm());
+ TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(ssl
+ .getTrustManagerFactoryAlgorithm());
trustManagerFactory.init(ts);
- context.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), new java.security.SecureRandom());
+ context.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(),
+ new java.security.SecureRandom());
} else {
context.init(keyManagerFactory.getKeyManagers(), null, new java.security.SecureRandom());
}
factory = context.getSocketFactory();
}
-
- public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {
+
+ public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException,
+ UnknownHostException {
return factory.createSocket(socket, host, port, autoClose);
}
- public Socket createSocket(String host, int port, InetAddress localAddress, int localPort) throws IOException, UnknownHostException {
+ public Socket createSocket(String host, int port, InetAddress localAddress, int localPort) throws IOException,
+ UnknownHostException {
return factory.createSocket(host, port, localAddress, localPort);
}
- public Socket createSocket(String host, int port, InetAddress localAddress, int localPort, HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
+ public Socket createSocket(String host, int port, InetAddress localAddress, int localPort,
+ HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
if (params == null) {
throw new IllegalArgumentException("Parameters may not be null");
}
@@ -158,6 +161,5 @@
public Socket createSocket(String host, int port) throws IOException, UnknownHostException {
return factory.createSocket(host, port);
}
-
-}
+}
Modified: incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?view=diff&rev=533074&r1=533073&r2=533074
==============================================================================
--- incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java (original)
+++ incubator/servicemix/trunk/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java Fri Apr 27 05:23:20 2007
@@ -30,10 +30,11 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.w3c.dom.Node;
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.servicemix.JbiConstants;
@@ -55,19 +56,15 @@
import org.mortbay.jetty.RetryRequest;
import org.mortbay.util.ajax.Continuation;
import org.mortbay.util.ajax.ContinuationSupport;
-import org.w3c.dom.Node;
-import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
-
-public class ConsumerProcessor implements ExchangeProcessor, HttpProcessor {
+public class ConsumerProcessor extends AbstractProcessor implements ExchangeProcessor, HttpProcessor {
public static final URI IN_ONLY = URI.create("http://www.w3.org/2004/08/wsdl/in-only");
public static final URI IN_OUT = URI.create("http://www.w3.org/2004/08/wsdl/in-out");
public static final URI ROBUST_IN_ONLY = URI.create("http://www.w3.org/2004/08/wsdl/robust-in-only");
private static Log log = LogFactory.getLog(ConsumerProcessor.class);
-
- protected HttpEndpoint endpoint;
+
protected Object httpContext;
protected ComponentContext context;
protected DeliveryChannel channel;
@@ -77,11 +74,11 @@
protected int suspentionTime = 60000;
public ConsumerProcessor(HttpEndpoint endpoint) {
- this.endpoint = endpoint;
+ super(endpoint);
this.soapHelper = new SoapHelper(endpoint);
this.locks = new ConcurrentHashMap();
this.exchanges = new ConcurrentHashMap();
- this.suspentionTime = ((HttpComponent) endpoint.getServiceUnit().getComponent()).getConfiguration().getConsumerProcessorSuspendTime();
+ this.suspentionTime = getConfiguration().getConsumerProcessorSuspendTime();
}
public SslParameters getSsl() {
@@ -124,33 +121,7 @@
log.debug("Receiving HTTP request: " + request);
}
if ("GET".equals(request.getMethod())) {
- String query = request.getQueryString();
- if (query != null && query.trim().equalsIgnoreCase("wsdl")) {
- String uri = request.getRequestURI();
- if (!uri.endsWith("/")) {
- uri += "/";
- }
- uri += "main.wsdl";
- response.sendRedirect(uri);
- return;
- }
- String path = request.getPathInfo();
- if (path.lastIndexOf('/') >= 0) {
- path = path.substring(path.lastIndexOf('/') + 1);
- }
-
- // Set protocol, host, and port in the component
- HttpComponent comp = (HttpComponent) endpoint.getServiceUnit().getComponent();
- comp.setProtocol(request.getScheme());
- comp.setHost(request.getServerName());
- comp.setPort(request.getServerPort());
- comp.setPath(request.getContextPath());
-
- // Reload the wsdl
- endpoint.reloadWsdl();
-
- Node node = (Node) endpoint.getWsdls().get(path);
- generateDocument(response, node);
+ processGetRequest(request, response);
return;
}
if (!"POST".equals(request.getMethod())) {
@@ -165,18 +136,18 @@
try {
SoapMessage message = soapHelper.getSoapMarshaler().createReader().read(
request.getInputStream(),
- request.getHeader(Constants.HEADER_CONTENT_TYPE));
- Context context = soapHelper.createContext(message);
+ request.getHeader(HEADER_CONTENT_TYPE));
+ Context ctx = soapHelper.createContext(message);
if (request.getUserPrincipal() != null) {
if (request.getUserPrincipal() instanceof JaasJettyPrincipal) {
Subject subject = ((JaasJettyPrincipal) request.getUserPrincipal()).getSubject();
- context.getInMessage().setSubject(subject);
+ ctx.getInMessage().setSubject(subject);
} else {
- context.getInMessage().addPrincipal(request.getUserPrincipal());
+ ctx.getInMessage().addPrincipal(request.getUserPrincipal());
}
}
- request.setAttribute(Context.class.getName(), context);
- exchange = soapHelper.onReceive(context);
+ request.setAttribute(Context.class.getName(), ctx);
+ exchange = soapHelper.onReceive(ctx);
NormalizedMessage inMessage = exchange.getMessage("in");
inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(request));
locks.put(exchange.getExchangeId(), cont);
@@ -226,23 +197,9 @@
} else if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
try {
if (exchange.getFault() != null) {
- SoapFault fault = new SoapFault(
- (QName) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_CODE),
- (QName) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_SUBCODE),
- (String) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_REASON),
- (URI) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_NODE),
- (URI) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_ROLE),
- exchange.getFault().getContent());
- sendFault(fault, request, response);
+ processFault(exchange, request, response);
} else {
- NormalizedMessage outMsg = exchange.getMessage("out");
- if (outMsg != null) {
- Context context = (Context) request.getAttribute(Context.class.getName());
- SoapMessage out = soapHelper.onReply(context, outMsg);
- SoapWriter writer = soapHelper.getSoapMarshaler().createWriter(out);
- response.setContentType(writer.getContentType());
- writer.write(response.getOutputStream());
- }
+ processResponse(exchange, request, response);
}
} finally {
exchange.setStatus(ExchangeStatus.DONE);
@@ -253,15 +210,67 @@
response.setStatus(HttpServletResponse.SC_ACCEPTED);
}
}
-
+
+ private void processResponse(MessageExchange exchange, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ NormalizedMessage outMsg = exchange.getMessage("out");
+ if (outMsg != null) {
+ Context ctx = (Context) request.getAttribute(Context.class.getName());
+ SoapMessage out = soapHelper.onReply(ctx, outMsg);
+ SoapWriter writer = soapHelper.getSoapMarshaler().createWriter(out);
+ response.setContentType(writer.getContentType());
+ writer.write(response.getOutputStream());
+ }
+ }
+
+ private void processFault(MessageExchange exchange, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ SoapFault fault = new SoapFault(
+ (QName) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_CODE),
+ (QName) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_SUBCODE),
+ (String) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_REASON),
+ (URI) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_NODE),
+ (URI) exchange.getFault().getProperty(JBIMarshaler.SOAP_FAULT_ROLE),
+ exchange.getFault().getContent());
+ sendFault(fault, request, response);
+ }
+
+ private void processGetRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ String query = request.getQueryString();
+ if (query != null && query.trim().equalsIgnoreCase("wsdl")) {
+ String uri = request.getRequestURI();
+ if (!uri.endsWith("/")) {
+ uri += "/";
+ }
+ uri += "main.wsdl";
+ response.sendRedirect(uri);
+ return;
+ }
+ String path = request.getPathInfo();
+ if (path.lastIndexOf('/') >= 0) {
+ path = path.substring(path.lastIndexOf('/') + 1);
+ }
+
+ // Set protocol, host, and port in the component
+ HttpComponent comp = (HttpComponent) endpoint.getServiceUnit().getComponent();
+ comp.setProtocol(request.getScheme());
+ comp.setHost(request.getServerName());
+ comp.setPort(request.getServerPort());
+ comp.setPath(request.getContextPath());
+
+ // Reload the wsdl
+ endpoint.reloadWsdl();
+
+ Node node = (Node) endpoint.getWsdls().get(path);
+ generateDocument(response, node);
+ }
+
protected void sendFault(SoapFault fault, HttpServletRequest request, HttpServletResponse response) throws Exception {
if (SoapFault.SENDER.equals(fault.getCode())) {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
} else {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
- Context context = (Context) request.getAttribute(Context.class.getName());
- SoapMessage soapFault = soapHelper.onFault(context, fault);
+ Context ctx = (Context) request.getAttribute(Context.class.getName());
+ SoapMessage soapFault = soapHelper.onFault(ctx, fault);
SoapWriter writer = soapHelper.getSoapMarshaler().createWriter(soapFault);
response.setContentType(writer.getContentType());
writer.write(response.getOutputStream());