SessionAwareMessageListener supports generic declaration of concrete JMS Message type
This commit is contained in:
parent
147709fa9e
commit
c82a66b59c
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -41,7 +41,7 @@ import javax.jms.Session;
|
||||||
* @see org.springframework.jms.listener.endpoint.JmsMessageEndpointManager
|
* @see org.springframework.jms.listener.endpoint.JmsMessageEndpointManager
|
||||||
* @see javax.jms.MessageListener
|
* @see javax.jms.MessageListener
|
||||||
*/
|
*/
|
||||||
public interface SessionAwareMessageListener {
|
public interface SessionAwareMessageListener<M extends Message> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for processing a received JMS message.
|
* Callback for processing a received JMS message.
|
||||||
|
|
@ -51,6 +51,6 @@ public interface SessionAwareMessageListener {
|
||||||
* @param session the underlying JMS Session (never <code>null</code>)
|
* @param session the underlying JMS Session (never <code>null</code>)
|
||||||
* @throws JMSException if thrown by JMS methods
|
* @throws JMSException if thrown by JMS methods
|
||||||
*/
|
*/
|
||||||
void onMessage(Message message, Session session) throws JMSException;
|
void onMessage(M message, Session session) throws JMSException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,8 @@ import org.springframework.util.ObjectUtils;
|
||||||
* @see org.springframework.jms.listener.SessionAwareMessageListener
|
* @see org.springframework.jms.listener.SessionAwareMessageListener
|
||||||
* @see org.springframework.jms.listener.AbstractMessageListenerContainer#setMessageListener
|
* @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".
|
* Out-of-the-box value for the default listener method: "handleMessage".
|
||||||
|
|
@ -318,6 +319,7 @@ public class MessageListenerAdapter implements MessageListener, SessionAwareMess
|
||||||
* @param session the JMS session to operate on
|
* @param session the JMS session to operate on
|
||||||
* @throws JMSException if thrown by JMS API methods
|
* @throws JMSException if thrown by JMS API methods
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void onMessage(Message message, Session session) throws JMSException {
|
public void onMessage(Message message, Session session) throws JMSException {
|
||||||
// Check whether the delegate is a MessageListener impl itself.
|
// Check whether the delegate is a MessageListener impl itself.
|
||||||
// In that case, the adapter will simply act as a pass-through.
|
// In that case, the adapter will simply act as a pass-through.
|
||||||
|
|
|
||||||
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -52,7 +52,7 @@ import org.springframework.remoting.support.RemoteInvocationResult;
|
||||||
* @see JmsInvokerProxyFactoryBean
|
* @see JmsInvokerProxyFactoryBean
|
||||||
*/
|
*/
|
||||||
public class JmsInvokerServiceExporter extends RemoteInvocationBasedExporter
|
public class JmsInvokerServiceExporter extends RemoteInvocationBasedExporter
|
||||||
implements SessionAwareMessageListener, InitializingBean {
|
implements SessionAwareMessageListener<Message>, InitializingBean {
|
||||||
|
|
||||||
private MessageConverter messageConverter = new SimpleMessageConverter();
|
private MessageConverter messageConverter = new SimpleMessageConverter();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue