Upgrade to Spring 2.5.5
This commit is contained in:
@@ -58,19 +58,19 @@ public class BatchMessageListenerContainer extends DefaultMessageListenerContain
|
||||
*
|
||||
*/
|
||||
public static interface ContainerDelegate {
|
||||
boolean receiveAndExecute(Session session, MessageConsumer consumer) throws JMSException;
|
||||
boolean receiveAndExecute(Object invoker, Session session, MessageConsumer consumer) throws JMSException;
|
||||
}
|
||||
|
||||
private Advice[] advices = new Advice[0];
|
||||
|
||||
private ContainerDelegate delegate = new ContainerDelegate() {
|
||||
public boolean receiveAndExecute(Session session, MessageConsumer consumer) throws JMSException {
|
||||
return BatchMessageListenerContainer.super.receiveAndExecute(session, consumer);
|
||||
public boolean receiveAndExecute(Object invoker, Session session, MessageConsumer consumer) throws JMSException {
|
||||
return BatchMessageListenerContainer.super.receiveAndExecute(invoker, session, consumer);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private ContainerDelegate proxy = delegate;
|
||||
|
||||
|
||||
/**
|
||||
* Public setter for the {@link Advice}.
|
||||
* @param advices the advice to set
|
||||
@@ -81,7 +81,7 @@ public class BatchMessageListenerContainer extends DefaultMessageListenerContain
|
||||
|
||||
/**
|
||||
* Set up interceptor with provided advice on the
|
||||
* {@link #receiveAndExecute(Session, MessageConsumer)} method.
|
||||
* {@link #receiveAndExecute(Object, Session, MessageConsumer)} method.
|
||||
*
|
||||
* @see org.springframework.jms.listener.AbstractJmsListeningContainer#afterPropertiesSet()
|
||||
*/
|
||||
@@ -117,11 +117,12 @@ public class BatchMessageListenerContainer extends DefaultMessageListenerContain
|
||||
|
||||
/**
|
||||
* Override base class method to wrap call in advice if provided.
|
||||
* @see org.springframework.jms.listener.AbstractPollingMessageListenerContainer#receiveAndExecute(javax.jms.Session,
|
||||
* javax.jms.MessageConsumer)
|
||||
* @see org.springframework.jms.listener.AbstractPollingMessageListenerContainer#receiveAndExecute(Object,
|
||||
* javax.jms.Session, javax.jms.MessageConsumer)
|
||||
*/
|
||||
protected boolean receiveAndExecute(final Session session, final MessageConsumer consumer) throws JMSException {
|
||||
return proxy.receiveAndExecute(session, consumer);
|
||||
protected boolean receiveAndExecute(final Object invoker, final Session session, final MessageConsumer consumer)
|
||||
throws JMSException {
|
||||
return proxy.receiveAndExecute(invoker, session, consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +140,7 @@ public class BatchMessageListenerContainer extends DefaultMessageListenerContain
|
||||
factory.setProxyTargetClass(false);
|
||||
factory.addInterface(ContainerDelegate.class);
|
||||
factory.setTarget(delegate);
|
||||
proxy = (ContainerDelegate) factory.getProxy();
|
||||
proxy = (ContainerDelegate) factory.getProxy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -139,7 +139,14 @@ public class BatchMessageListenerContainerTests extends TestCase {
|
||||
private BatchMessageListenerContainer getContainer(RepeatTemplate template) {
|
||||
MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory.class);
|
||||
ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
|
||||
BatchMessageListenerContainer container = new BatchMessageListenerContainer();
|
||||
// Yuck: we need to turn these method in base class to no-ops because the invoker is a private class
|
||||
// we can't create for test purposes...
|
||||
BatchMessageListenerContainer container = new BatchMessageListenerContainer() {
|
||||
protected void messageReceived(Object invoker, Session session) {
|
||||
}
|
||||
protected void noMessageReceived(Object invoker, Session session) {
|
||||
}
|
||||
};
|
||||
RepeatOperationsInterceptor interceptor = new RepeatOperationsInterceptor();
|
||||
interceptor.setRepeatOperations(template);
|
||||
container.setAdviceChain(new Advice[] {interceptor});
|
||||
@@ -193,11 +200,12 @@ public class BatchMessageListenerContainerTests extends TestCase {
|
||||
|
||||
private boolean doExecute(Session session, MessageConsumer consumer) throws IllegalAccessException {
|
||||
Method method = ReflectionUtils.findMethod(container.getClass(), "receiveAndExecute", new Class[] {
|
||||
Session.class, MessageConsumer.class });
|
||||
Object.class, Session.class, MessageConsumer.class });
|
||||
method.setAccessible(true);
|
||||
boolean received;
|
||||
try {
|
||||
received = ((Boolean) method.invoke(container, new Object[] { session, consumer })).booleanValue();
|
||||
// A null invoker is not normal, but we don't care about the invoker for a unit test
|
||||
received = ((Boolean) method.invoke(container, new Object[] { null, session, consumer })).booleanValue();
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
if (e.getCause() instanceof RuntimeException) {
|
||||
|
||||
Reference in New Issue
Block a user