Browse Source

SessionAwareMessageListener supports generic declaration of concrete JMS Message type

conversation
Juergen Hoeller 16 years ago
parent
commit
c82a66b59c
  1. 6
      org.springframework.jms/src/main/java/org/springframework/jms/listener/SessionAwareMessageListener.java
  2. 4
      org.springframework.jms/src/main/java/org/springframework/jms/listener/adapter/MessageListenerAdapter.java
  3. 4
      org.springframework.jms/src/main/java/org/springframework/jms/remoting/JmsInvokerServiceExporter.java

6
org.springframework.jms/src/main/java/org/springframework/jms/listener/SessionAwareMessageListener.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,7 +41,7 @@ import javax.jms.Session; @@ -41,7 +41,7 @@ import javax.jms.Session;
* @see org.springframework.jms.listener.endpoint.JmsMessageEndpointManager
* @see javax.jms.MessageListener
*/
public interface SessionAwareMessageListener {
public interface SessionAwareMessageListener<M extends Message> {
/**
* Callback for processing a received JMS message.
@ -51,6 +51,6 @@ public interface SessionAwareMessageListener { @@ -51,6 +51,6 @@ public interface SessionAwareMessageListener {
* @param session the underlying JMS Session (never <code>null</code>)
* @throws JMSException if thrown by JMS methods
*/
void onMessage(Message message, Session session) throws JMSException;
void onMessage(M message, Session session) throws JMSException;
}

4
org.springframework.jms/src/main/java/org/springframework/jms/listener/adapter/MessageListenerAdapter.java

@ -128,7 +128,8 @@ import org.springframework.util.ObjectUtils; @@ -128,7 +128,8 @@ import org.springframework.util.ObjectUtils;
* @see org.springframework.jms.listener.SessionAwareMessageListener
* @see org.springframework.jms.listener.AbstractMessageListenerContainer#setMessageListener
*/
public class MessageListenerAdapter implements MessageListener, SessionAwareMessageListener, SubscriptionNameProvider {
public class MessageListenerAdapter
implements MessageListener, SessionAwareMessageListener<Message>, SubscriptionNameProvider {
/**
* Out-of-the-box value for the default listener method: "handleMessage".
@ -318,6 +319,7 @@ public class MessageListenerAdapter implements MessageListener, SessionAwareMess @@ -318,6 +319,7 @@ public class MessageListenerAdapter implements MessageListener, SessionAwareMess
* @param session the JMS session to operate on
* @throws JMSException if thrown by JMS API methods
*/
@SuppressWarnings("unchecked")
public void onMessage(Message message, Session session) throws JMSException {
// Check whether the delegate is a MessageListener impl itself.
// In that case, the adapter will simply act as a pass-through.

4
org.springframework.jms/src/main/java/org/springframework/jms/remoting/JmsInvokerServiceExporter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -52,7 +52,7 @@ import org.springframework.remoting.support.RemoteInvocationResult; @@ -52,7 +52,7 @@ import org.springframework.remoting.support.RemoteInvocationResult;
* @see JmsInvokerProxyFactoryBean
*/
public class JmsInvokerServiceExporter extends RemoteInvocationBasedExporter
implements SessionAwareMessageListener, InitializingBean {
implements SessionAwareMessageListener<Message>, InitializingBean {
private MessageConverter messageConverter = new SimpleMessageConverter();

Loading…
Cancel
Save