[jboss-svn-commits] JBL Code SVN: r29079 - in labs/jbossesb/workspace/tfennelly/httpg2/product: rosetta/src/org/jboss/soa/esb/http and 6 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 26 11:46:36 EDT 2009
Author: tfennelly
Date: 2009-08-26 11:46:35 -0400 (Wed, 26 Aug 2009)
New Revision: 29079
Added:
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpHeader.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/http/HttpHeader.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpMessageComposer.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpRequest.java
Removed:
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpHeader.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/LegacyHttpMessageComposer.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpRequestInfo.java
Modified:
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpResponse.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpRouter.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers120/XMLBeansModel.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpDispatchServlet.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayListener.java
labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpMessageComposer.java
labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/http_gateway/jboss-esb.xml
labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/http_gateway/src/org/jboss/soa/esb/samples/quickstart/httpgateway/MyAction.java
labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/webservice_proxy_basic/build.xml
labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/webservice_proxy_basic/jboss-esb.xml
Log:
Added use of HttpResponse and simplified use of HttpRequest and HttpResponse
Deleted: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpHeader.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpHeader.java 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpHeader.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.soa.esb.actions.routing.http;
-
-import org.jboss.internal.soa.esb.assertion.AssertArgument;
-
-import java.io.Serializable;
-
-/**
- * Http header.
- * <p/>
- * Simple name-value pair.
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class HttpHeader implements Serializable {
-
- private String name;
- private String value;
-
- public HttpHeader(String name, String value) {
- AssertArgument.isNotNullAndNotEmpty(name, "name");
- AssertArgument.isNotNullAndNotEmpty(value, "value");
- this.name = name;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public String getValue() {
- return value;
- }
-}
Added: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpHeader.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpHeader.java (rev 0)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpHeader.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.routing.http;
+
+/**
+ * Http Header.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ * @deprecated Use {@link org.jboss.soa.esb.http.HttpHeader}.
+ */
+public class HttpHeader extends org.jboss.soa.esb.http.HttpHeader {
+
+ public HttpHeader(String name, String value) {
+ super(name, value);
+ }
+}
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpResponse.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpResponse.java 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpResponse.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -20,6 +20,8 @@
package org.jboss.soa.esb.actions.routing.http;
import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.http.HttpHeader;
import java.io.Serializable;
import java.util.ArrayList;
@@ -32,27 +34,36 @@
public static final String RESPONSE_KEY = HttpResponse.class.getName() + "#response";
- private int responseCode;
- private long length;
+ private Integer responseCode;
+ private String contentType;
private String encoding;
- private List<HttpHeader> headers = new ArrayList<HttpHeader>();
+ private Long length;
+ private List<HttpHeader> headers = new ArrayList<org.jboss.soa.esb.http.HttpHeader>();
public HttpResponse(int responseCode) {
this.responseCode = responseCode;
}
- public int getResponseCode() {
+ public Integer getResponseCode() {
return responseCode;
}
- public long getLength() {
+ public Long getLength() {
return length;
}
- public void setLength(long length) {
+ public void setLength(Long length) {
this.length = length;
}
+ public String getContentType() {
+ return contentType;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
public String getEncoding() {
return encoding;
}
@@ -69,4 +80,14 @@
AssertArgument.isNotNull(header, "header");
headers.add(header);
}
+
+ public static HttpResponse getResponse(Message message) {
+ AssertArgument.isNotNull(message, "message");
+ return (HttpResponse) message.getBody().get(HttpResponse.RESPONSE_KEY);
+ }
+
+ public void setResponse(Message message) {
+ AssertArgument.isNotNull(message, "message");
+ message.getBody().add(HttpResponse.RESPONSE_KEY, this);
+ }
}
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpRouter.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpRouter.java 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpRouter.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -38,7 +38,7 @@
import org.jboss.soa.esb.actions.ActionProcessingException;
import org.jboss.soa.esb.actions.routing.AbstractRouter;
import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.http.HttpClientFactory;
+import org.jboss.soa.esb.http.*;
import org.jboss.soa.esb.listeners.ListenerTagNames;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
@@ -165,12 +165,12 @@
for(Header responseHeader : responseHeaders) {
String name = responseHeader.getName();
String value = responseHeader.getValue();
- response.addHeader(new HttpHeader(name, value));
+ response.addHeader(new org.jboss.soa.esb.http.HttpHeader(name, value));
// https://jira.jboss.org/jira/browse/JBESB-2511
new ResponseHeader(name, value).addToProperties(properties);
}
- message.getBody().add(HttpResponse.RESPONSE_KEY, response);
+ response.setResponse(message);
}
private void setRequestHeaders(HttpMethodBase method, Message message) {
Copied: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/http/HttpHeader.java (from rev 29039, labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/actions/routing/http/HttpHeader.java)
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/http/HttpHeader.java (rev 0)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/http/HttpHeader.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.http;
+
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+
+import java.io.Serializable;
+
+/**
+ * Http header.
+ * <p/>
+ * Simple name-value pair.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class HttpHeader implements Serializable {
+
+ private String name;
+ private String value;
+
+ public HttpHeader(String name, String value) {
+ AssertArgument.isNotNullAndNotEmpty(name, "name");
+ AssertArgument.isNotNullAndNotEmpty(value, "value");
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
Property changes on: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/http/HttpHeader.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers120/XMLBeansModel.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers120/XMLBeansModel.java 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers120/XMLBeansModel.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -150,20 +150,24 @@
* @return The Bus configuration instance.
*/
public Bus getOptionalBus(String busid) {
- List<Provider> providers = jbossesb.getProviders().getProviderList();
+ Providers providers = jbossesb.getProviders();
- for(Provider provider : providers) {
- if(provider instanceof BusProvider) {
- List<Bus> buses = ((BusProvider)provider).getBusList();
+ if(providers != null) {
+ List<Provider> providerList = providers.getProviderList();
- for(Bus bus : buses) {
- if(bus.getBusid().equals(busid)) {
- return bus;
+ for(Provider provider : providerList) {
+ if(provider instanceof BusProvider) {
+ List<Bus> buses = ((BusProvider)provider).getBusList();
+
+ for(Bus bus : buses) {
+ if(bus.getBusid().equals(busid)) {
+ return bus;
+ }
}
}
}
}
-
+
return null;
}
@@ -173,20 +177,24 @@
* @return The Provider configuration instance.
*/
public Provider getProvider(Bus bus) {
- List<Provider> providers = jbossesb.getProviders().getProviderList();
+ Providers providers = jbossesb.getProviders();
- for(Provider provider : providers) {
- if(provider instanceof BusProvider) {
- List<Bus> buses = ((BusProvider)provider).getBusList();
+ if(providers != null) {
+ List<Provider> providerList = providers.getProviderList();
- for(Bus installedBus : buses) {
- if(installedBus == bus) {
- return provider;
+ for(Provider provider : providerList) {
+ if(provider instanceof BusProvider) {
+ List<Bus> buses = ((BusProvider)provider).getBusList();
+
+ for(Bus installedBus : buses) {
+ if(installedBus == bus) {
+ return provider;
+ }
}
}
}
}
-
+
throw new IllegalStateException("No Provider instance found for the supplied Bus config instance. This should not be possible if the Bus instance was provided by this configuration. Where has this Bus instance come from?");
}
@@ -196,14 +204,18 @@
* @return The Provider configuration instance.
*/
public Provider getProvider(Class<? extends BusProvider> providerType) {
- List<Provider> providers = jbossesb.getProviders().getProviderList();
+ Providers providers = jbossesb.getProviders();
- for(Provider provider : providers) {
- if(providerType.isAssignableFrom(provider.getClass())) {
- return provider;
+ if(providers != null) {
+ List<Provider> providerList = providers.getProviderList();
+
+ for(Provider provider : providerList) {
+ if(providerType.isAssignableFrom(provider.getClass())) {
+ return provider;
+ }
}
}
-
+
return null;
}
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpDispatchServlet.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpDispatchServlet.java 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpDispatchServlet.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -86,7 +86,7 @@
try {
messageDeliveryAdapter = UncomposedMessageDeliveryAdapter
.getGatewayDeliveryAdapter(config,
- new LegacyHttpMessageComposer<HttpRequestWrapper>());
+ new HttpMessageComposer<HttpRequestWrapper>());
} catch (ConfigurationException e) {
throw new ServletException(e);
}
@@ -133,7 +133,7 @@
} catch (FaultMessageException fme) {
Message faultMessage = fme.getReturnedMessage();
if (faultMessage != null) {
- Object obj = faultMessage.getProperties().getProperty(LegacyHttpMessageComposer.HTTP_RESPONSE_STATUS);
+ Object obj = faultMessage.getProperties().getProperty(HttpMessageComposer.HTTP_RESPONSE_STATUS);
if (obj != null && obj instanceof Integer) {
response.setStatus((Integer)obj);
} else {
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayListener.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayListener.java 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpGatewayListener.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -51,6 +51,7 @@
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.helpers.KeyValuePair;
import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.listeners.gateway.http.HttpRequestWrapper;
import org.jboss.soa.esb.listeners.lifecycle.AbstractManagedLifecycle;
import org.jboss.soa.esb.listeners.lifecycle.ManagedLifecycleException;
import org.jboss.soa.esb.listeners.message.UncomposedMessageDeliveryAdapter;
@@ -71,9 +72,9 @@
* <p>The different tomcat listner can be started in same port with different context.for example:
* <code> http://localhost:8765/jbossesb/servicecategory/servicename </code>
*
- * <p>This class uses the {@link org.jboss.soa.esb.listeners.gateway.LegacyHttpMessageComposer}
+ * <p>This class uses the {@link HttpMessageComposer}
* by default.
- * @see org.jboss.soa.esb.listeners.gateway.LegacyHttpMessageComposer
+ * @see HttpMessageComposer
* @see org.jboss.soa.esb.listeners.gateway.HttpDispatchServlet
* @author <a href="mailto:ema at redhat.com">Jim Ma</a>
* @deprecated
@@ -412,7 +413,7 @@
throws ConfigurationException {
return UncomposedMessageDeliveryAdapter.getGatewayDeliveryAdapter(
getConfig(),
- new LegacyHttpMessageComposer<org.jboss.soa.esb.listeners.gateway.http.HttpRequestWrapper>());
+ new HttpMessageComposer<HttpRequestWrapper>());
}
/**Initialize the StandardContext.By default it will uses
Copied: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpMessageComposer.java (from rev 29056, labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/LegacyHttpMessageComposer.java)
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpMessageComposer.java (rev 0)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/HttpMessageComposer.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -0,0 +1,246 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.gateway;
+
+import java.io.IOException;
+import java.util.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.jboss.soa.esb.actions.ActionUtils;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.message.AbstractMessageComposer;
+import org.jboss.soa.esb.listeners.message.MessageDeliverException;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.MessagePayloadProxy;
+import org.jboss.soa.esb.message.MessagePayloadProxy.NullPayloadHandling;
+import org.jboss.soa.esb.message.body.content.BytesBody;
+
+/**
+ * Http Message Composer.
+ * <p/>
+ * This class is used to compose the HttpServletRquest
+ * to ESB aware message and decompse the ESB aware message to HttpServletRespones
+ * <p>
+ * This class will put the http request header and other requst information in ESB message properties with the key "RequestInfoMap".
+ * <p>
+ * If the request is the submitted from html form(with the <code>Content-Type: application/x-www-form-urlencoded</code>), HttpServletRequest.getParameterMap() result)
+ * will be put in ESB message properties. The key for it is "RequestParamterMap". It put the the byte array read from request inputstream in message payload.
+ * <p>
+ * In decompose process, the header map in message properties will be added
+ * in HttpServletResponse. The value for "ReponseStatus" store in ESB message properties will
+ * put in the http response. The message payload byte[] or String object will be wrote to HttpServletResponse.
+ * If the object in message payload is not byte[],it will throw exception when the ESB message
+ * is decomposed
+ *
+ * @author <a href="mailto:ema at redhat.com">Jim Ma</a>
+ * @deprecated
+ */
+public class HttpMessageComposer<T extends org.jboss.soa.esb.listeners.gateway.http.HttpRequestWrapper> extends AbstractMessageComposer<T> {
+
+ private static final Logger logger = Logger.getLogger(HttpMessageComposer.class);
+
+ /** Request parameter map key in esb message properties */
+ public static final String HTTP_REQUEST_PARAMETER_MAP = "RequestParameterMap";
+
+ /** Request information map key in esb message properties */
+ public static final String HTTP_REQUEST_INFO_MAP = "RequestInfoMap";
+
+ /** Reponse header map key in esb message properties */
+ public static final String HTTP_RESPONSE_HEADER_MAP = "ResponseHeaderMap";
+
+ /** Response status key in esb message properties */
+ public static final String HTTP_RESPONSE_STATUS = "ReponseStatus";
+
+ /** Message payload proxy */
+ private MessagePayloadProxy payloadProxy;
+
+ /*
+ * Method for configue the payload proxy
+ */
+ public void setConfiguration(ConfigTree config) {
+ super.setConfiguration(config);
+ payloadProxy = new MessagePayloadProxy(config, new String[] {
+ ActionUtils.POST_ACTION_DATA, Body.DEFAULT_LOCATION,
+ BytesBody.BYTES_LOCATION },
+ new String[] { ActionUtils.POST_ACTION_DATA });
+ payloadProxy.setNullSetPayloadHandling(NullPayloadHandling.LOG);
+ }
+
+ protected MessagePayloadProxy getPayloadProxy() {
+ return payloadProxy;
+ }
+
+ /*
+ *Method for populating the ESB aware message from a HttpServletRequest
+ */
+ @SuppressWarnings("unchecked")
+ protected void populateMessage(Message message, T requestWrapper)
+ throws MessageDeliverException {
+ HttpServletRequest request = requestWrapper.getRequest();
+ Map paraMap = request.getParameterMap();
+ byte[] bodyBytes = null;
+
+ try {
+ bodyBytes = StreamUtils.readStream(request.getInputStream());
+ } catch (IOException e) {
+ throw new MessageDeliverException("Failed to read body data from http request", e);
+ }
+
+ //Set http request info
+ message.getProperties().setProperty(HTTP_REQUEST_INFO_MAP, getRequestInfo(request));
+ if (paraMap != null && !paraMap.isEmpty()) {
+ message.getProperties().setProperty(this.HTTP_REQUEST_PARAMETER_MAP, paraMap);
+ }
+
+ payloadProxy.setPayload(message, bodyBytes);
+ }
+
+ /*
+ * Method for decompsing a esb message to a HttpServletResponse
+ */
+ @SuppressWarnings("unchecked")
+ public Object decompose(Message message, T requestWrapper) throws MessageDeliverException {
+ HttpServletRequest request = requestWrapper.getRequest();
+ HttpServletResponse response = requestWrapper.getResponse();
+ Map<String, String> headers;
+ Integer status;
+
+ try {
+ headers = (Map<String, String>) message.getProperties().getProperty(HTTP_RESPONSE_HEADER_MAP);
+ } catch(ClassCastException e) {
+ response.setStatus(HttpServletResponse.SC_BAD_GATEWAY);
+ logger.debug("'" + HTTP_RESPONSE_HEADER_MAP + "' must be of type " + Map.class.getName());
+ return null;
+ }
+
+ try {
+ status = (Integer) message.getProperties().getProperty(HTTP_RESPONSE_STATUS);
+ } catch(ClassCastException e) {
+ response.setStatus(HttpServletResponse.SC_BAD_GATEWAY);
+ logger.debug("'" + HTTP_RESPONSE_STATUS + "' must be of type Integer.");
+ return null;
+ }
+
+ if (headers != null) {
+ Set<Map.Entry<String, String>> entries = headers.entrySet();
+ for(Map.Entry<String, String> entry : entries) {
+ String headerName = entry.getKey();
+ if(headerName.equals("Content-Type")) {
+ response.setContentType(entry.getValue());
+ } else {
+ response.setHeader(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ Object obj = payloadProxy.getPayload(message);
+ try {
+ byte[] outBytes;
+
+ if (obj instanceof String) {
+ String encoding = request.getCharacterEncoding();
+ if(encoding == null) {
+ encoding = "UTF-8";
+ }
+ outBytes = ((String) obj).getBytes(encoding);
+ } else if (obj instanceof byte[]) {
+ outBytes = (byte[]) obj;
+ } else if (obj == null) {
+ response.setContentLength(0);
+ response.setStatus(HttpServletResponse.SC_NO_CONTENT);
+ logger.debug("Expected a response payload from '" + ListenerTagNames.MEP_REQUEST_RESPONSE + "' service '" + requestWrapper.getService() + "', but received none.");
+ return null;
+ } else {
+ response.setContentLength(0);
+ response.setStatus(HttpServletResponse.SC_BAD_GATEWAY);
+ logger.debug("Unsupport HTTP response payload type " + obj.getClass().getName() + " from service '" + requestWrapper.getService() + "'. Only supports java.lang.String or byte[] payloads.");
+ return null;
+ }
+
+ if(outBytes.length > 0) {
+ response.getOutputStream().write(outBytes);
+ }
+ response.setContentLength(outBytes.length);
+
+ if (status != null) {
+ response.setStatus(status);
+ } else {
+ response.setStatus(HttpServletResponse.SC_OK);
+ }
+ } catch (IOException e) {
+ throw new MessageDeliverException("Unexpected error when write the message to http response", e);
+ }
+
+ return null;
+ }
+
+ /**
+ * Method for get request information from a servlet request
+ * The result includes the http header and other servlet request information
+ * @param request ServletRequest
+ * @return Request information includes the http header and other information parsed by
+ * servlet container from a servlet request
+ */
+ public Map<String, Object> getRequestInfo(HttpServletRequest request) {
+ Map<String, Object> requestInfoMap = new HashMap<String, Object>();
+
+ requestInfoMap.put("authType", request.getAuthType());
+ requestInfoMap.put("characterEncoding", request.getCharacterEncoding());
+ requestInfoMap.put("contentType", request.getContentType());
+ requestInfoMap.put("contextPath", request.getContextPath());
+ requestInfoMap.put("localAddr", request.getLocalAddr());
+ requestInfoMap.put("localName", request.getLocalName());
+ requestInfoMap.put("method", request.getMethod());
+ requestInfoMap.put("pathInfo", request.getPathInfo());
+ requestInfoMap.put("protocol", request.getProtocol());
+ requestInfoMap.put("queryString", request.getQueryString());
+ requestInfoMap.put("remoteAddr", request.getRemoteAddr());
+ requestInfoMap.put("remoteHost", request.getRemoteHost());
+ requestInfoMap.put("remoteUser", request.getRemoteUser());
+ requestInfoMap.put("contentLength", Integer.toString(request.getContentLength()));
+ requestInfoMap.put("requestSessionId", request.getRequestedSessionId());
+ requestInfoMap.put("requestURI", request.getRequestURI());
+ requestInfoMap.put("scheme", request.getScheme());
+ requestInfoMap.put("serverName", request.getServerName());
+ requestInfoMap.put("requestPath", request.getServletPath());
+ requestInfoMap.put("pathInfo", request.getPathInfo());
+ if(request.getPathInfo() != null) {
+ requestInfoMap.put("pathInfoTokens", request.getPathInfo().split("/"));
+ } else {
+ requestInfoMap.put("pathInfoTokens", new String[0]);
+ }
+
+ //Add http header
+ Enumeration enumeration = request.getHeaderNames();
+ while (enumeration.hasMoreElements()) {
+ String name = (String) enumeration.nextElement();
+ String value = request.getHeader(name);
+ requestInfoMap.put(name, value);
+ }
+
+ return requestInfoMap;
+ }
+}
\ No newline at end of file
Deleted: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/LegacyHttpMessageComposer.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/LegacyHttpMessageComposer.java 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/LegacyHttpMessageComposer.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -1,246 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.soa.esb.listeners.gateway;
-
-import java.io.IOException;
-import java.util.*;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.log4j.Logger;
-import org.jboss.internal.soa.esb.util.StreamUtils;
-import org.jboss.soa.esb.actions.ActionUtils;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.message.AbstractMessageComposer;
-import org.jboss.soa.esb.listeners.message.MessageDeliverException;
-import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.message.Body;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.MessagePayloadProxy;
-import org.jboss.soa.esb.message.MessagePayloadProxy.NullPayloadHandling;
-import org.jboss.soa.esb.message.body.content.BytesBody;
-
-/**
- * Http Message Composer.
- * <p/>
- * This class is used to compose the HttpServletRquest
- * to ESB aware message and decompse the ESB aware message to HttpServletRespones
- * <p>
- * This class will put the http request header and other requst information in ESB message properties with the key "RequestInfoMap".
- * <p>
- * If the request is the submitted from html form(with the <code>Content-Type: application/x-www-form-urlencoded</code>), HttpServletRequest.getParameterMap() result)
- * will be put in ESB message properties. The key for it is "RequestParamterMap". It put the the byte array read from request inputstream in message payload.
- * <p>
- * In decompose process, the header map in message properties will be added
- * in HttpServletResponse. The value for "ReponseStatus" store in ESB message properties will
- * put in the http response. The message payload byte[] or String object will be wrote to HttpServletResponse.
- * If the object in message payload is not byte[],it will throw exception when the ESB message
- * is decomposed
- *
- * @author <a href="mailto:ema at redhat.com">Jim Ma</a>
- * @deprecated
- */
-public class LegacyHttpMessageComposer<T extends org.jboss.soa.esb.listeners.gateway.http.HttpRequestWrapper> extends AbstractMessageComposer<T> {
-
- private static final Logger logger = Logger.getLogger(LegacyHttpMessageComposer.class);
-
- /** Request parameter map key in esb message properties */
- public static final String HTTP_REQUEST_PARAMETER_MAP = "RequestParameterMap";
-
- /** Request information map key in esb message properties */
- public static final String HTTP_REQUEST_INFO_MAP = "RequestInfoMap";
-
- /** Reponse header map key in esb message properties */
- public static final String HTTP_RESPONSE_HEADER_MAP = "ResponseHeaderMap";
-
- /** Response status key in esb message properties */
- public static final String HTTP_RESPONSE_STATUS = "ReponseStatus";
-
- /** Message payload proxy */
- private MessagePayloadProxy payloadProxy;
-
- /*
- * Method for configue the payload proxy
- */
- public void setConfiguration(ConfigTree config) {
- super.setConfiguration(config);
- payloadProxy = new MessagePayloadProxy(config, new String[] {
- ActionUtils.POST_ACTION_DATA, Body.DEFAULT_LOCATION,
- BytesBody.BYTES_LOCATION },
- new String[] { ActionUtils.POST_ACTION_DATA });
- payloadProxy.setNullSetPayloadHandling(NullPayloadHandling.LOG);
- }
-
- protected MessagePayloadProxy getPayloadProxy() {
- return payloadProxy;
- }
-
- /*
- *Method for populating the ESB aware message from a HttpServletRequest
- */
- @SuppressWarnings("unchecked")
- protected void populateMessage(Message message, T requestWrapper)
- throws MessageDeliverException {
- HttpServletRequest request = requestWrapper.getRequest();
- Map paraMap = request.getParameterMap();
- byte[] bodyBytes = null;
-
- try {
- bodyBytes = StreamUtils.readStream(request.getInputStream());
- } catch (IOException e) {
- throw new MessageDeliverException("Failed to read body data from http request", e);
- }
-
- //Set http request info
- message.getProperties().setProperty(HTTP_REQUEST_INFO_MAP, getRequestInfo(request));
- if (paraMap != null && !paraMap.isEmpty()) {
- message.getProperties().setProperty(this.HTTP_REQUEST_PARAMETER_MAP, paraMap);
- }
-
- payloadProxy.setPayload(message, bodyBytes);
- }
-
- /*
- * Method for decompsing a esb message to a HttpServletResponse
- */
- @SuppressWarnings("unchecked")
- public Object decompose(Message message, T requestWrapper) throws MessageDeliverException {
- HttpServletRequest request = requestWrapper.getRequest();
- HttpServletResponse response = requestWrapper.getResponse();
- Map<String, String> headers;
- Integer status;
-
- try {
- headers = (Map<String, String>) message.getProperties().getProperty(HTTP_RESPONSE_HEADER_MAP);
- } catch(ClassCastException e) {
- response.setStatus(HttpServletResponse.SC_BAD_GATEWAY);
- logger.debug("'" + HTTP_RESPONSE_HEADER_MAP + "' must be of type " + Map.class.getName());
- return null;
- }
-
- try {
- status = (Integer) message.getProperties().getProperty(HTTP_RESPONSE_STATUS);
- } catch(ClassCastException e) {
- response.setStatus(HttpServletResponse.SC_BAD_GATEWAY);
- logger.debug("'" + HTTP_RESPONSE_STATUS + "' must be of type Integer.");
- return null;
- }
-
- if (headers != null) {
- Set<Map.Entry<String, String>> entries = headers.entrySet();
- for(Map.Entry<String, String> entry : entries) {
- String headerName = entry.getKey();
- if(headerName.equals("Content-Type")) {
- response.setContentType(entry.getValue());
- } else {
- response.setHeader(entry.getKey(), entry.getValue());
- }
- }
- }
-
- Object obj = payloadProxy.getPayload(message);
- try {
- byte[] outBytes;
-
- if (obj instanceof String) {
- String encoding = request.getCharacterEncoding();
- if(encoding == null) {
- encoding = "UTF-8";
- }
- outBytes = ((String) obj).getBytes(encoding);
- } else if (obj instanceof byte[]) {
- outBytes = (byte[]) obj;
- } else if (obj == null) {
- response.setContentLength(0);
- response.setStatus(HttpServletResponse.SC_NO_CONTENT);
- logger.debug("Expected a response payload from '" + ListenerTagNames.MEP_REQUEST_RESPONSE + "' service '" + requestWrapper.getService() + "', but received none.");
- return null;
- } else {
- response.setContentLength(0);
- response.setStatus(HttpServletResponse.SC_BAD_GATEWAY);
- logger.debug("Unsupport HTTP response payload type " + obj.getClass().getName() + " from service '" + requestWrapper.getService() + "'. Only supports java.lang.String or byte[] payloads.");
- return null;
- }
-
- if(outBytes.length > 0) {
- response.getOutputStream().write(outBytes);
- }
- response.setContentLength(outBytes.length);
-
- if (status != null) {
- response.setStatus(status);
- } else {
- response.setStatus(HttpServletResponse.SC_OK);
- }
- } catch (IOException e) {
- throw new MessageDeliverException("Unexpected error when write the message to http response", e);
- }
-
- return null;
- }
-
- /**
- * Method for get request information from a servlet request
- * The result includes the http header and other servlet request information
- * @param request ServletRequest
- * @return Request information includes the http header and other information parsed by
- * servlet container from a servlet request
- */
- public Map<String, Object> getRequestInfo(HttpServletRequest request) {
- Map<String, Object> requestInfoMap = new HashMap<String, Object>();
-
- requestInfoMap.put("authType", request.getAuthType());
- requestInfoMap.put("characterEncoding", request.getCharacterEncoding());
- requestInfoMap.put("contentType", request.getContentType());
- requestInfoMap.put("contextPath", request.getContextPath());
- requestInfoMap.put("localAddr", request.getLocalAddr());
- requestInfoMap.put("localName", request.getLocalName());
- requestInfoMap.put("method", request.getMethod());
- requestInfoMap.put("pathInfo", request.getPathInfo());
- requestInfoMap.put("protocol", request.getProtocol());
- requestInfoMap.put("queryString", request.getQueryString());
- requestInfoMap.put("remoteAddr", request.getRemoteAddr());
- requestInfoMap.put("remoteHost", request.getRemoteHost());
- requestInfoMap.put("remoteUser", request.getRemoteUser());
- requestInfoMap.put("contentLength", Integer.toString(request.getContentLength()));
- requestInfoMap.put("requestSessionId", request.getRequestedSessionId());
- requestInfoMap.put("requestURI", request.getRequestURI());
- requestInfoMap.put("scheme", request.getScheme());
- requestInfoMap.put("serverName", request.getServerName());
- requestInfoMap.put("requestPath", request.getServletPath());
- requestInfoMap.put("pathInfo", request.getPathInfo());
- if(request.getPathInfo() != null) {
- requestInfoMap.put("pathInfoTokens", request.getPathInfo().split("/"));
- } else {
- requestInfoMap.put("pathInfoTokens", new String[0]);
- }
-
- //Add http header
- Enumeration enumeration = request.getHeaderNames();
- while (enumeration.hasMoreElements()) {
- String name = (String) enumeration.nextElement();
- String value = request.getHeader(name);
- requestInfoMap.put(name, value);
- }
-
- return requestInfoMap;
- }
-}
\ No newline at end of file
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpMessageComposer.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpMessageComposer.java 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpMessageComposer.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -30,16 +30,15 @@
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.util.StreamUtils;
-import org.jboss.soa.esb.actions.ActionUtils;
+import org.jboss.soa.esb.actions.routing.http.HttpResponse;
+import org.jboss.soa.esb.http.HttpHeader;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.message.AbstractMessageComposer;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.MessagePayloadProxy;
import org.jboss.soa.esb.message.MessagePayloadProxy.NullPayloadHandling;
-import org.jboss.soa.esb.message.body.content.BytesBody;
import org.jboss.soa.esb.common.ModulePropertyManager;
/**
@@ -65,15 +64,6 @@
private static final Logger logger = Logger.getLogger(HttpMessageComposer.class);
- /** Request information key in esb message properties */
- public static final String HTTP_REQUEST_INFO = "RequestInfo";
-
- /** Reponse header map key in esb message properties */
- public static final String HTTP_RESPONSE_HEADER_MAP = "ResponseHeaderMap";
-
- /** Response status key in esb message properties */
- public static final String HTTP_RESPONSE_STATUS = "ReponseStatus";
-
/** Message payload proxy */
private MessagePayloadProxy payloadProxy;
@@ -85,10 +75,7 @@
*/
public void setConfiguration(ConfigTree config) {
super.setConfiguration(config);
- payloadProxy = new MessagePayloadProxy(config, new String[] {
- ActionUtils.POST_ACTION_DATA, Body.DEFAULT_LOCATION,
- BytesBody.BYTES_LOCATION },
- new String[] { ActionUtils.POST_ACTION_DATA });
+ payloadProxy = new MessagePayloadProxy(config);
payloadProxy.setNullSetPayloadHandling(NullPayloadHandling.LOG);
payloadAs = config.getAttribute("payloadAs");
@@ -150,9 +137,10 @@
payloadProxy.setPayload(message, bodyBytes);
}
- //Set http request info
- message.getProperties().setProperty(HTTP_REQUEST_INFO, getRequestInfo(request));
- }
+ //Get the http request info and set it on the message...
+ HttpRequest requestInfo = getRequestInfo(request);
+ requestInfo.setRequest(message);
+ }
private boolean isTextMimetype(String contentType) {
for(int i = 0; i < textMimePatterns.length; i++) {
@@ -173,45 +161,40 @@
HttpServletRequest request = requestWrapper.getRequest();
HttpServletResponse response = requestWrapper.getResponse();
Map<String, String> headers;
- Integer status;
+ Integer status = HttpServletResponse.SC_OK;
+ String encoding = null;
+ HttpResponse responseInfo = HttpResponse.getResponse(message);
- try {
- headers = (Map<String, String>) message.getProperties().getProperty(HTTP_RESPONSE_HEADER_MAP);
- } catch(ClassCastException e) {
- response.setStatus(HttpServletResponse.SC_BAD_GATEWAY);
- logger.debug("'" + HTTP_RESPONSE_HEADER_MAP + "' must be of type " + Map.class.getName());
- return null;
- }
+ if(responseInfo != null) {
+ for(org.jboss.soa.esb.http.HttpHeader header : responseInfo.getHeaders()) {
+ if(header.getName().equals("Content-Type")) {
+ response.setContentType(header.getValue());
+ } else if(header.getName().equals("Transfer-Encoding")) {
+ // Filter out!!
+ } else {
+ response.setHeader(header.getName(), header.getValue());
+ }
+ }
- try {
- status = (Integer) message.getProperties().getProperty(HTTP_RESPONSE_STATUS);
- } catch(ClassCastException e) {
- response.setStatus(HttpServletResponse.SC_BAD_GATEWAY);
- logger.debug("'" + HTTP_RESPONSE_STATUS + "' must be of type Integer.");
- return null;
+ if(responseInfo.getContentType() != null) {
+ response.setContentType(responseInfo.getContentType());
+ }
+ encoding = responseInfo.getEncoding();
+ status = responseInfo.getResponseCode();
}
- if (headers != null) {
- Set<Map.Entry<String, String>> entries = headers.entrySet();
- for(Map.Entry<String, String> entry : entries) {
- String headerName = entry.getKey();
- if(headerName.equals("Content-Type")) {
- response.setContentType(entry.getValue());
- } else {
- response.setHeader(entry.getKey(), entry.getValue());
- }
+ if(encoding == null) {
+ encoding = request.getCharacterEncoding();
+ if(encoding == null) {
+ encoding = "UTF-8";
}
}
- Object obj = payloadProxy.getPayload(message);
+ Object obj = payloadProxy.getPayload(message);
try {
byte[] outBytes;
if (obj instanceof String) {
- String encoding = request.getCharacterEncoding();
- if(encoding == null) {
- encoding = "UTF-8";
- }
outBytes = ((String) obj).getBytes(encoding);
} else if (obj instanceof byte[]) {
outBytes = (byte[]) obj;
@@ -230,13 +213,10 @@
if(outBytes.length > 0) {
response.getOutputStream().write(outBytes);
}
- response.setContentLength(outBytes.length);
- if (status != null) {
- response.setStatus(status);
- } else {
- response.setStatus(HttpServletResponse.SC_OK);
- }
+ response.setCharacterEncoding(encoding);
+ response.setContentLength(outBytes.length);
+ response.setStatus(status);
} catch (IOException e) {
throw new MessageDeliverException("Unexpected error when write the message to http response", e);
}
@@ -251,8 +231,8 @@
* @return Request information includes the http header and other information parsed by
* servlet container from a servlet request
*/
- public HttpRequestInfo getRequestInfo(HttpServletRequest request) {
- HttpRequestInfo requestInfo = new HttpRequestInfo();
+ public HttpRequest getRequestInfo(HttpServletRequest request) {
+ HttpRequest requestInfo = new HttpRequest();
requestInfo.setAuthType(request.getAuthType());
requestInfo.setCharacterEncoding(request.getCharacterEncoding());
@@ -301,7 +281,7 @@
while (enumeration.hasMoreElements()) {
String name = (String) enumeration.nextElement();
String value = request.getHeader(name);
- requestInfo.getHeaders().put(name, value);
+ requestInfo.getHeaders().add(new HttpHeader(name, value));
}
return requestInfo;
Copied: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpRequest.java (from rev 29056, labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpRequestInfo.java)
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpRequest.java (rev 0)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpRequest.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -0,0 +1,237 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.listeners.gateway.http;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.http.HttpHeader;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+import java.io.Serializable;
+
+/**
+ * HTTP Request Information.
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class HttpRequest implements Serializable {
+
+ /** Request information key in esb message properties */
+ private static final String REQUEST_KEY = HttpRequest.class.getName() + "#request";
+
+ private String authType;
+ private String characterEncoding;
+ private String contentType;
+ private String contextPath;
+ private String localAddr;
+ private String localName;
+ private String method;
+ private String pathInfo;
+ private String protocol;
+ private String queryString;
+ private String remoteAddr;
+ private String remoteHost;
+ private String remoteUser;
+ private int contentLength;
+ private String requestSessionId;
+ private String requestURI;
+ private String scheme;
+ private String serverName;
+ private String requestPath;
+ private List<String> pathInfoTokens = new ArrayList<String>();
+ private Map<String, String[]> queryParams = new HashMap<String, String[]>();
+ private List<HttpHeader> headers = new ArrayList<org.jboss.soa.esb.http.HttpHeader>();
+
+ public String getAuthType() {
+ return authType;
+ }
+
+ public void setAuthType(String authType) {
+ this.authType = authType;
+ }
+
+ public String getCharacterEncoding() {
+ return characterEncoding;
+ }
+
+ public void setCharacterEncoding(String characterEncoding) {
+ this.characterEncoding = characterEncoding;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ public String getContextPath() {
+ return contextPath;
+ }
+
+ public void setContextPath(String contextPath) {
+ this.contextPath = contextPath;
+ }
+
+ public String getLocalAddr() {
+ return localAddr;
+ }
+
+ public void setLocalAddr(String localAddr) {
+ this.localAddr = localAddr;
+ }
+
+ public String getLocalName() {
+ return localName;
+ }
+
+ public void setLocalName(String localName) {
+ this.localName = localName;
+ }
+
+ public String getMethod() {
+ return method;
+ }
+
+ public void setMethod(String method) {
+ this.method = method;
+ }
+
+ public String getPathInfo() {
+ return pathInfo;
+ }
+
+ public void setPathInfo(String pathInfo) {
+ this.pathInfo = pathInfo;
+ }
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ public String getQueryString() {
+ return queryString;
+ }
+
+ public void setQueryString(String queryString) {
+ this.queryString = queryString;
+ }
+
+ public String getRemoteAddr() {
+ return remoteAddr;
+ }
+
+ public void setRemoteAddr(String remoteAddr) {
+ this.remoteAddr = remoteAddr;
+ }
+
+ public String getRemoteHost() {
+ return remoteHost;
+ }
+
+ public void setRemoteHost(String remoteHost) {
+ this.remoteHost = remoteHost;
+ }
+
+ public String getRemoteUser() {
+ return remoteUser;
+ }
+
+ public void setRemoteUser(String remoteUser) {
+ this.remoteUser = remoteUser;
+ }
+
+ public int getContentLength() {
+ return contentLength;
+ }
+
+ public void setContentLength(int contentLength) {
+ this.contentLength = contentLength;
+ }
+
+ public String getRequestSessionId() {
+ return requestSessionId;
+ }
+
+ public void setRequestSessionId(String requestSessionId) {
+ this.requestSessionId = requestSessionId;
+ }
+
+ public String getRequestURI() {
+ return requestURI;
+ }
+
+ public void setRequestURI(String requestURI) {
+ this.requestURI = requestURI;
+ }
+
+ public String getScheme() {
+ return scheme;
+ }
+
+ public void setScheme(String scheme) {
+ this.scheme = scheme;
+ }
+
+ public String getServerName() {
+ return serverName;
+ }
+
+ public void setServerName(String serverName) {
+ this.serverName = serverName;
+ }
+
+ public String getRequestPath() {
+ return requestPath;
+ }
+
+ public void setRequestPath(String requestPath) {
+ this.requestPath = requestPath;
+ }
+
+ public List<String> getPathInfoTokens() {
+ return pathInfoTokens;
+ }
+
+ public Map<String, String[]> getQueryParams() {
+ return queryParams;
+ }
+
+ public List<HttpHeader> getHeaders() {
+ return headers;
+ }
+
+ public static HttpRequest getRequest(Message message) {
+ AssertArgument.isNotNull(message, "message");
+ return (HttpRequest) message.getProperties().getProperty(HttpRequest.REQUEST_KEY);
+ }
+
+ public void setRequest(Message message) {
+ AssertArgument.isNotNull(message, "message");
+ message.getProperties().setProperty(HttpRequest.REQUEST_KEY, this);
+ }
+}
Deleted: labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpRequestInfo.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpRequestInfo.java 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/rosetta/src/org/jboss/soa/esb/listeners/gateway/http/HttpRequestInfo.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -1,220 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.soa.esb.listeners.gateway.http;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ArrayList;
-import java.io.Serializable;
-
-/**
- * HTTP Request Information.
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class HttpRequestInfo implements Serializable {
-
- private String authType;
- private String characterEncoding;
- private String contentType;
- private String contextPath;
- private String localAddr;
- private String localName;
- private String method;
- private String pathInfo;
- private String protocol;
- private String queryString;
- private String remoteAddr;
- private String remoteHost;
- private String remoteUser;
- private int contentLength;
- private String requestSessionId;
- private String requestURI;
- private String scheme;
- private String serverName;
- private String requestPath;
- private List<String> pathInfoTokens = new ArrayList<String>();
- private Map<String, String[]> queryParams = new HashMap<String, String[]>();
- private Map<String, String> headers = new HashMap<String, String>();
-
- public String getAuthType() {
- return authType;
- }
-
- public void setAuthType(String authType) {
- this.authType = authType;
- }
-
- public String getCharacterEncoding() {
- return characterEncoding;
- }
-
- public void setCharacterEncoding(String characterEncoding) {
- this.characterEncoding = characterEncoding;
- }
-
- public String getContentType() {
- return contentType;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
- public String getContextPath() {
- return contextPath;
- }
-
- public void setContextPath(String contextPath) {
- this.contextPath = contextPath;
- }
-
- public String getLocalAddr() {
- return localAddr;
- }
-
- public void setLocalAddr(String localAddr) {
- this.localAddr = localAddr;
- }
-
- public String getLocalName() {
- return localName;
- }
-
- public void setLocalName(String localName) {
- this.localName = localName;
- }
-
- public String getMethod() {
- return method;
- }
-
- public void setMethod(String method) {
- this.method = method;
- }
-
- public String getPathInfo() {
- return pathInfo;
- }
-
- public void setPathInfo(String pathInfo) {
- this.pathInfo = pathInfo;
- }
-
- public String getProtocol() {
- return protocol;
- }
-
- public void setProtocol(String protocol) {
- this.protocol = protocol;
- }
-
- public String getQueryString() {
- return queryString;
- }
-
- public void setQueryString(String queryString) {
- this.queryString = queryString;
- }
-
- public String getRemoteAddr() {
- return remoteAddr;
- }
-
- public void setRemoteAddr(String remoteAddr) {
- this.remoteAddr = remoteAddr;
- }
-
- public String getRemoteHost() {
- return remoteHost;
- }
-
- public void setRemoteHost(String remoteHost) {
- this.remoteHost = remoteHost;
- }
-
- public String getRemoteUser() {
- return remoteUser;
- }
-
- public void setRemoteUser(String remoteUser) {
- this.remoteUser = remoteUser;
- }
-
- public int getContentLength() {
- return contentLength;
- }
-
- public void setContentLength(int contentLength) {
- this.contentLength = contentLength;
- }
-
- public String getRequestSessionId() {
- return requestSessionId;
- }
-
- public void setRequestSessionId(String requestSessionId) {
- this.requestSessionId = requestSessionId;
- }
-
- public String getRequestURI() {
- return requestURI;
- }
-
- public void setRequestURI(String requestURI) {
- this.requestURI = requestURI;
- }
-
- public String getScheme() {
- return scheme;
- }
-
- public void setScheme(String scheme) {
- this.scheme = scheme;
- }
-
- public String getServerName() {
- return serverName;
- }
-
- public void setServerName(String serverName) {
- this.serverName = serverName;
- }
-
- public String getRequestPath() {
- return requestPath;
- }
-
- public void setRequestPath(String requestPath) {
- this.requestPath = requestPath;
- }
-
- public List<String> getPathInfoTokens() {
- return pathInfoTokens;
- }
-
- public Map<String, String[]> getQueryParams() {
- return queryParams;
- }
-
- public Map<String, String> getHeaders() {
- return headers;
- }
-}
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/http_gateway/jboss-esb.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/http_gateway/jboss-esb.xml 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/http_gateway/jboss-esb.xml 2009-08-26 15:46:35 UTC (rev 29079)
@@ -61,7 +61,7 @@
<listeners>
<http-gateway name="Exception1">
<!-- Override the exception mappings defined on the <http-provider>... -->
- <exception mappingsFile="">
+ <exception>
<mapping class="org.jboss.soa.esb.samples.quickstart.httpgateway.MyActionException" status="503" />
</exception>
</http-gateway>
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/http_gateway/src/org/jboss/soa/esb/samples/quickstart/httpgateway/MyAction.java
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/http_gateway/src/org/jboss/soa/esb/samples/quickstart/httpgateway/MyAction.java 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/http_gateway/src/org/jboss/soa/esb/samples/quickstart/httpgateway/MyAction.java 2009-08-26 15:46:35 UTC (rev 29079)
@@ -20,16 +20,12 @@
*/
package org.jboss.soa.esb.samples.quickstart.httpgateway;
-import java.beans.XMLEncoder;
-import java.io.ByteArrayOutputStream;
-
import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
import org.jboss.soa.esb.actions.ActionProcessingException;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.listeners.ListenerTagNames;
-import org.jboss.soa.esb.listeners.gateway.http.HttpMessageComposer;
-import org.jboss.soa.esb.listeners.gateway.http.HttpRequestInfo;
+import org.jboss.soa.esb.listeners.gateway.http.HttpRequest;
import org.jboss.soa.esb.Service;
import com.thoughtworks.xstream.XStream;
@@ -51,7 +47,7 @@
System.out.println("Service: " + service);
System.out.println("");
System.out.println("------------Http Request Info (XStream Encoded)-------------------");
- HttpRequestInfo requestInfo = (HttpRequestInfo) message.getProperties().getProperty(HttpMessageComposer.HTTP_REQUEST_INFO);
+ HttpRequest requestInfo = HttpRequest.getRequest(message);
String requestInfoXML;
XStream xstream = new XStream();
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/webservice_proxy_basic/build.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/webservice_proxy_basic/build.xml 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/webservice_proxy_basic/build.xml 2009-08-26 15:46:35 UTC (rev 29079)
@@ -16,12 +16,12 @@
<target name="quickstart-specific-predeploys">
<copy todir="${org.jboss.esb.server.deploy.dir}"
- file="build/predeploy/${ant.project.name}.war"/>
+ file="build/predeploy/${ant.project.name}_ws.war"/>
<sleep seconds="3"/>
</target>
<target name="quickstart-specific-undeploys">
- <delete file="${org.jboss.esb.server.deploy.dir}/${ant.project.name}.war"/>
+ <delete file="${org.jboss.esb.server.deploy.dir}/${ant.project.name}_ws.war"/>
</target>
<target name="makewar" description="make war">
@@ -36,7 +36,7 @@
<!-- War... -->
<mkdir dir="build/predeploy"/>
- <war warfile="build/predeploy/${ant.project.name}.war"
+ <war warfile="build/predeploy/${ant.project.name}_ws.war"
webxml="${basedir}/war/resources/WEB-INF/web.xml">
<webinf dir="${basedir}/war/resources/WEB-INF">
<include name="jboss-web.xml"/>
@@ -69,13 +69,13 @@
<target name="runws">
<echo>Calling JBossWS webservice directly.</echo>
- <property name="runtest.arg.url" value="http://localhost:8080/Quickstart_webservice_proxy_basic/HelloWorldWS"/>
+ <property name="runtest.arg.url" value="http://localhost:8080/Quickstart_webservice_proxy_basic_ws/HelloWorldWS"/>
<antcall target="runinternal"/>
</target>
<target name="runjbr">
<echo>Calling JBossWS webservice via JBossRemotingGatewayListener and SOAPProxy.</echo>
- <property name="runtest.arg.url" value="http://localhost:9090"/>
+ <property name="runtest.arg.url" value="http://localhost:8080/Quickstart_webservice_proxy_basic/http/Proxy_Basic/Proxy"/>
<antcall target="runinternal"/>
</target>
<target name="runtest" depends="runjbr"/>
Modified: labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/webservice_proxy_basic/jboss-esb.xml
===================================================================
--- labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/webservice_proxy_basic/jboss-esb.xml 2009-08-26 14:59:56 UTC (rev 29078)
+++ labs/jbossesb/workspace/tfennelly/httpg2/product/samples/quickstarts/webservice_proxy_basic/jboss-esb.xml 2009-08-26 15:46:35 UTC (rev 29079)
@@ -1,21 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.1.0.xsd" parameterReloadSecs="5">
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.2.0.xsd" parameterReloadSecs="5">
- <providers>
- <jbr-provider name="JBR-PROVIDER" protocol="http" host="localhost">
- <jbr-bus busid="JBR-BUS" port="9090"/>
- </jbr-provider>
- </providers>
-
- <services>
+ <services>
<service category="Proxy_Basic" name="Proxy"
description="Basic WebService Proxy"
invmScope="GLOBAL" >
- <listeners>
- <jbr-listener name="JBR-GATEWAY"
- busidref="JBR-BUS"
- is-gateway="true"
- />
+ <listeners>
+ <http-gateway name="basicProxy" />
</listeners>
<actions mep="RequestResponse">
<action name="echo-request"
@@ -24,7 +15,7 @@
</action>
<action name="proxy"
class="org.jboss.soa.esb.actions.soap.proxy.SOAPProxy">
- <property name="wsdl" value="http://localhost:8080/Quickstart_webservice_proxy_basic/HelloWorldWS?wsdl"/>
+ <property name="wsdl" value="http://localhost:8080/Quickstart_webservice_proxy_basic_ws/HelloWorldWS?wsdl"/>
</action>
<action name="echo-response"
class="org.jboss.soa.esb.actions.SystemPrintln">
More information about the jboss-svn-commits
mailing list