Author: thomas.diesler(a)jboss.com
Date: 2007-06-26 03:25:00 -0400 (Tue, 26 Jun 2007)
New Revision: 3722
Removed:
branches/jbossws-2.0/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/jms/
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/transport/jms/JMSMessageDispatcher.java
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/transport/jms/MessageDispatcher.java
Modified:
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/transport/jms/JMSTransportSupport.java
Log:
Restore JMS transport
Deleted:
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/transport/jms/JMSMessageDispatcher.java
===================================================================
---
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/transport/jms/JMSMessageDispatcher.java 2007-06-26
07:24:47 UTC (rev 3721)
+++
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/transport/jms/JMSMessageDispatcher.java 2007-06-26
07:25:00 UTC (rev 3722)
@@ -1,117 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.wsf.spi.transport.jms;
-
-// $Id:JMSMessageDispatcher.java 915 2006-09-08 08:40:45Z thomas.diesler(a)jboss.com $
-
-import java.io.InputStream;
-import java.rmi.RemoteException;
-
-import javax.management.ObjectName;
-import javax.xml.rpc.handler.soap.SOAPMessageContext;
-import javax.xml.soap.SOAPMessage;
-
-import org.jboss.logging.Logger;
-import org.jboss.util.NotImplementedException;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.invocation.BasicInvocationContext;
-import org.jboss.wsf.spi.invocation.InvocationContext;
-import org.jboss.wsf.spi.invocation.InvocationHandler;
-import org.jboss.wsf.spi.invocation.RequestHandler;
-import org.jboss.wsf.spi.management.EndpointRegistry;
-import org.jboss.wsf.spi.management.EndpointRegistryFactory;
-
-/**
- * A dispatcher for SOAPMessages
- *
- * @author Thomas.Diesler(a)jboss.org
- */
-public class JMSMessageDispatcher implements MessageDispatcher
-{
- // logging support
- protected Logger log = Logger.getLogger(JMSMessageDispatcher.class);
-
- /** Dispatch the message to the underlying SOAP engine
- */
- public SOAPMessage dipatchMessage(String fromName, Object targetBean, InputStream
inputStream) throws RemoteException
- {
- EndpointRegistry epRegistry = EndpointRegistryFactory.getEndpointRegistry();
- Endpoint endpoint = getEndpointForDestination(epRegistry, fromName);
-
- if (endpoint == null)
- throw new IllegalStateException("Cannot find endpoint for: " +
fromName);
-
- log.debug("dipatchMessage: " + endpoint.getName());
-
- RequestHandler reqHandler = endpoint.getRequestHandler();
-
- try
- {
- BasicInvocationContext invContext = new BasicInvocationContext();
- invContext.setTargetBean(targetBean);
-
- reqHandler.handleRequest(endpoint, inputStream, null, invContext);
- SOAPMessage resMessage = getResponseMessage(invContext);
- return resMessage;
- }
- catch (Exception ex)
- {
- throw new RemoteException("Cannot process SOAP request", ex);
- }
- }
-
- private SOAPMessage getResponseMessage(InvocationContext context)
- {
- SOAPMessage resMessage = null;
- if (context.getAttachment(javax.xml.rpc.handler.MessageContext.class) != null)
- {
- javax.xml.rpc.handler.MessageContext msgContext =
context.getAttachment(javax.xml.rpc.handler.MessageContext.class);
- SOAPMessageContext soapContext = (SOAPMessageContext)msgContext;
- resMessage = soapContext.getMessage();
- }
- return resMessage;
- }
-
- /** Dispatch the message to the underlying SOAP engine
- */
- public SOAPMessage delegateMessage(String serviceID, InputStream soapMessage) throws
RemoteException
- {
- throw new NotImplementedException();
- }
-
- // The destination jndiName is encoded in the service object name under key
'jms'
- private Endpoint getEndpointForDestination(EndpointRegistry epRegistry, String
fromName)
- {
- Endpoint endpoint = null;
- for (ObjectName oname : epRegistry.getEndpoints())
- {
- Endpoint aux = epRegistry.getEndpoint(oname);
- String jmsProp = aux.getName().getKeyProperty("jms");
- if (jmsProp != null && jmsProp.equals(fromName))
- {
- endpoint = aux;
- break;
- }
- }
- return endpoint;
- }
-}
Modified:
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/transport/jms/JMSTransportSupport.java
===================================================================
---
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/transport/jms/JMSTransportSupport.java 2007-06-26
07:24:47 UTC (rev 3721)
+++
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/transport/jms/JMSTransportSupport.java 2007-06-26
07:25:00 UTC (rev 3722)
@@ -27,6 +27,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.rmi.RemoteException;
import javax.ejb.EJBException;
@@ -45,12 +46,17 @@
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
+import javax.management.ObjectName;
import javax.naming.InitialContext;
import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
import org.jboss.logging.Logger;
import org.jboss.util.NestedRuntimeException;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.invocation.BasicInvocationContext;
+import org.jboss.wsf.spi.invocation.RequestHandler;
+import org.jboss.wsf.spi.management.EndpointRegistry;
+import org.jboss.wsf.spi.management.EndpointRegistryFactory;
/**
* The abstract base class for MDBs that want to act as web service endpoints.
@@ -98,16 +104,14 @@
fromName = "topic/" + ((Topic)destination).getTopicName();
InputStream inputStream = new ByteArrayInputStream(msgStr.getBytes());
- SOAPMessage resMessage = processSOAPMessage(fromName, inputStream);
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream(1024);
+ processSOAPMessage(fromName, inputStream, outputStream);
- if (resMessage != null)
+ msgStr = new String(outputStream.toByteArray());
+ log.debug("Outgoing SOAP message: " + msgStr);
+
+ if (msgStr.length() > 0)
{
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- resMessage.writeTo(outputStream);
-
- msgStr = new String(outputStream.toByteArray());
- log.debug("Outgoing SOAP message: " + msgStr);
-
Queue replyQueue = getReplyQueue(message);
if (replyQueue != null)
{
@@ -133,13 +137,48 @@
}
}
- protected SOAPMessage processSOAPMessage(String fromName, InputStream inputStream)
throws SOAPException, IOException, RemoteException
+ protected void processSOAPMessage(String fromName, InputStream inputStream,
OutputStream outStream) throws SOAPException, IOException, RemoteException
{
- MessageDispatcher msgDispatcher = new JMSMessageDispatcher();
- SOAPMessage resMessage = msgDispatcher.dipatchMessage(fromName, this,
inputStream);
- return resMessage;
+ EndpointRegistry epRegistry = EndpointRegistryFactory.getEndpointRegistry();
+ Endpoint endpoint = getEndpointForDestination(epRegistry, fromName);
+
+ if (endpoint == null)
+ throw new IllegalStateException("Cannot find endpoint for: " +
fromName);
+
+ log.debug("dipatchMessage: " + endpoint.getName());
+
+ RequestHandler reqHandler = endpoint.getRequestHandler();
+
+ try
+ {
+ BasicInvocationContext invContext = new BasicInvocationContext();
+ invContext.setTargetBean(this);
+
+ reqHandler.handleRequest(endpoint, inputStream, outStream, invContext);
+ }
+ catch (Exception ex)
+ {
+ throw new RemoteException("Cannot process SOAP request", ex);
+ }
}
-
+
+ // The destination jndiName is encoded in the service object name under key
'jms'
+ private Endpoint getEndpointForDestination(EndpointRegistry epRegistry, String
fromName)
+ {
+ Endpoint endpoint = null;
+ for (ObjectName oname : epRegistry.getEndpoints())
+ {
+ Endpoint aux = epRegistry.getEndpoint(oname);
+ String jmsProp = aux.getName().getKeyProperty("jms");
+ if (jmsProp != null && jmsProp.equals(fromName))
+ {
+ endpoint = aux;
+ break;
+ }
+ }
+ return endpoint;
+ }
+
private String getMessageStr(BytesMessage message) throws Exception
{
byte[] buffer = new byte[8 * 1024];
Deleted:
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/transport/jms/MessageDispatcher.java
===================================================================
---
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/transport/jms/MessageDispatcher.java 2007-06-26
07:24:47 UTC (rev 3721)
+++
branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/transport/jms/MessageDispatcher.java 2007-06-26
07:25:00 UTC (rev 3722)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY 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 along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.wsf.spi.transport.jms;
-
-// $Id:MessageDispatcher.java 898 2006-09-05 08:23:03Z thomas.diesler(a)jboss.com $
-
-import java.io.InputStream;
-import java.rmi.RemoteException;
-
-import javax.management.ObjectName;
-import javax.xml.soap.SOAPMessage;
-
-import org.jboss.wsf.spi.utils.ObjectNameFactory;
-
-/**
- * A dispatcher for SOAPMessages
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 19-Feb-2006
- */
-public interface MessageDispatcher
-{
- public static final ObjectName OBJECT_NAME =
ObjectNameFactory.create("jboss.ws:service=JMSTransportSupport");
-
- /** Dispatch the message to the underlying SOAP engine
- */
- SOAPMessage dipatchMessage(String fromName, Object targetImplBean, InputStream
reqMessage) throws RemoteException;
-
- /** Dispatch the message to the underlying SOAP engine
- */
- SOAPMessage delegateMessage(String serviceID, InputStream reqMessage) throws
RemoteException;
-}
\ No newline at end of file