Author: alessio.soldano(a)jboss.com
Date: 2010-05-21 05:32:08 -0400 (Fri, 21 May 2010)
New Revision: 12300
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/transport/jms/AbstractJMSTransportSupport.java
stack/native/branches/jbossws-native-3.1.2/modules/testsuite/pom.xml
Log:
[JBPAPP-4359] Using JMSResolver in native stack
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/transport/jms/AbstractJMSTransportSupport.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/transport/jms/AbstractJMSTransportSupport.java 2010-05-21
06:52:24 UTC (rev 12299)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/transport/jms/AbstractJMSTransportSupport.java 2010-05-21
09:32:08 UTC (rev 12300)
@@ -41,7 +41,6 @@
import javax.jms.QueueSession;
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;
@@ -57,17 +56,19 @@
import org.jboss.wsf.spi.invocation.RequestHandler;
import org.jboss.wsf.spi.management.EndpointRegistry;
import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+import org.jboss.wsf.spi.management.JMSEndpointResolver;
/**
* The abstract base class for MDBs that want to act as web service endpoints.
* A subclass should only need to implement the service endpoint interface.
*
* @author Thomas.Diesler(a)jboss.org
+ * @author alessio.soldano(a)jboss.com
*/
public abstract class AbstractJMSTransportSupport implements MessageListener
{
// logging support
- protected Logger log = Logger.getLogger(AbstractJMSTransportSupport.class);
+ protected static Logger log = Logger.getLogger(AbstractJMSTransportSupport.class);
private QueueConnectionFactory conFactory;
@@ -93,21 +94,16 @@
return;
}
- log.debug("Incomming SOAP message: " + msgStr);
+ if (log.isDebugEnabled())
+ log.debug("Incomming SOAP message: " + msgStr);
- String fromName = null;
- Destination destination = message.getJMSDestination();
- if (destination instanceof Queue)
- fromName = "queue/" + ((Queue)destination).getQueueName();
- if (destination instanceof Topic)
- fromName = "topic/" + ((Topic)destination).getTopicName();
-
InputStream inputStream = new ByteArrayInputStream(msgStr.getBytes());
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(1024);
- processSOAPMessage(fromName, inputStream, outputStream);
+ processSOAPMessage(message.getJMSDestination(), inputStream, outputStream);
msgStr = new String(outputStream.toByteArray());
- log.debug("Outgoing SOAP message: " + msgStr);
+ if (log.isDebugEnabled())
+ log.debug("Outgoing SOAP message: " + msgStr);
if (msgStr.length() > 0)
{
@@ -135,34 +131,40 @@
throw new EJBException(e);
}
}
-
- protected void processSOAPMessage(String fromName, InputStream inputStream,
OutputStream outStream) throws SOAPException, IOException, RemoteException
+
+ protected void processSOAPMessage(Destination destination, InputStream inputStream,
OutputStream outStream) throws SOAPException, IOException, RemoteException
{
SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
EndpointRegistry epRegistry =
spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
- Endpoint endpoint = getEndpointForDestination(epRegistry, fromName);
+ JMSEndpointResolver resolver = spiProvider.getSPI(JMSEndpointResolver.class);
+ resolver.setDestination(destination);
+ Endpoint endpoint = epRegistry.resolve(resolver);
if (endpoint == null)
- throw new IllegalStateException("Cannot find endpoint for: " +
fromName);
+ throw new IllegalStateException("Cannot find endpoint for destination:
" + destination);
EndpointAssociation.setEndpoint(endpoint);
try
{
- log.debug("dipatchMessage: " + endpoint.getName());
+ boolean debugEnabled = log.isDebugEnabled();
+ if (debugEnabled)
+ log.debug("dipatchMessage: " + endpoint.getName());
// [JBWS-1324]: workaround to prevent message processing before endpoint is
started
EndpointState state = endpoint.getState();
ObjectName name = endpoint.getName();
long startTime = System.currentTimeMillis();
- log.debug(name + " is in state: " + state);
+ if (debugEnabled)
+ log.debug(name + " is in state: " + state);
while (state != EndpointState.STARTED && (System.currentTimeMillis() -
startTime < 60000))
{
try
{
Thread.sleep(1000);
state = endpoint.getState();
- log.debug(name + " is now in state: " + state);
+ if (debugEnabled)
+ log.debug(name + " is now in state: " + state);
}
catch (InterruptedException e)
{
@@ -190,23 +192,6 @@
}
}
- // 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];
Modified: stack/native/branches/jbossws-native-3.1.2/modules/testsuite/pom.xml
===================================================================
--- stack/native/branches/jbossws-native-3.1.2/modules/testsuite/pom.xml 2010-05-21
06:52:24 UTC (rev 12299)
+++ stack/native/branches/jbossws-native-3.1.2/modules/testsuite/pom.xml 2010-05-21
09:32:08 UTC (rev 12300)
@@ -25,6 +25,7 @@
<hibernate.version>3.2.4.sp1</hibernate.version>
<endpoint.servlet>org.jboss.wsf.stack.jbws.EndpointServlet</endpoint.servlet>
<jboss.javaee.version>5.0.1.GA</jboss.javaee.version>
+ <hornetq.version>2.1.0.BETA3</hornetq.version>
</properties>
<!-- Modules -->
@@ -330,6 +331,11 @@
<artifactId>jboss-as-security</artifactId>
<version>${jboss.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.hornetq</groupId>
+ <artifactId>hornetq-jms-client</artifactId>
+ <version>${hornetq.version}</version>
+ </dependency>
</dependencies>
<build>
<plugins>