@Test(expected = IllegalArgumentException.class) public void chainWithOutputChannelButLastHandlerDoesNotProduceReplies() { List<MessageHandler> handlers = new ArrayList<MessageHandler>(); handlers.add(producer1); handlers.add(producer2); handlers.add(handler3); MessageHandlerChain chain = new MessageHandlerChain(); chain.setBeanName("testChain"); chain.setHandlers(handlers); chain.setOutputChannel(outputChannel); chain.setBeanFactory(mock(BeanFactory.class)); chain.afterPropertiesSet(); }
@Override protected void onInit() { super.onInit(); synchronized (this.initializationMonitor) { if (!this.initialized) { Assert.notEmpty(this.handlers, "handler list must not be empty"); this.configureChain(); this.initialized = true; } } }
@Override public final void start() { this.lifecycleLock.lock(); try { if (!this.running) { this.doStart(); this.running = true; if (logger.isInfoEnabled()) { logger.info("started " + this); } } } finally { this.lifecycleLock.unlock(); } }
((MessageHandlerChain) handler).afterPropertiesSet(); Assert.isNull(getOutputChannel(), "An output channel was provided, but the final handler in " + "the chain does not implement the MessageProducer interface.");
public void handleMessage(Message<?> message) { if (!this.initialized) { this.afterPropertiesSet(); } this.handlers.get(0).handleMessage(message); }
@Override protected void handleMessageInternal(Message<?> message) throws Exception { if (!this.initialized) { this.onInit(); } this.handlers.get(0).handleMessage(message); }
public final void stop(Runnable callback) { this.lifecycleLock.lock(); try { this.stop(); callback.run(); } finally { this.lifecycleLock.unlock(); } }
@Override public boolean send(Message<?> message, long timeout) { produceOutput(message, message); return true; }
@Override public final void stop() { this.lifecycleLock.lock(); try { if (this.running) { this.doStop(); this.running = false; if (logger.isInfoEnabled()) { logger.info("stopped " + this); } } } finally { this.lifecycleLock.unlock(); } }
((MessageHandlerChain) handler).afterPropertiesSet(); Assert.isNull(getOutputChannel(), "An output channel was provided, but the final handler in " + "the chain does not implement the MessageProducer interface.");
@Override protected void handleMessageInternal(Message<?> message) throws Exception { if (!this.initialized) { this.onInit(); } this.handlers.get(0).handleMessage(message); }
public final void stop(Runnable callback) { this.lifecycleLock.lock(); try { this.stop(); callback.run(); } finally { this.lifecycleLock.unlock(); } }
@Override public boolean send(Message<?> message, long timeout) { produceOutput(message, message); return true; }
@Override public final void stop() { this.lifecycleLock.lock(); try { if (this.running) { this.doStop(); this.running = false; if (logger.isInfoEnabled()) { logger.info("stopped " + this); } } } finally { this.lifecycleLock.unlock(); } }
@Test(expected = IllegalArgumentException.class) // INT-1175 public void chainRejectsDuplicateHandlers() { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); beanFactory.registerSingleton("testChannel", outputChannel); List<MessageHandler> handlers = new ArrayList<MessageHandler>(); handlers.add(producer1); handlers.add(producer2); handlers.add(producer1); MessageHandlerChain chain = new MessageHandlerChain(); chain.setBeanName("testChain"); chain.setHandlers(handlers); chain.setBeanFactory(beanFactory); chain.afterPropertiesSet(); }
public final void afterPropertiesSet() { synchronized (this.initializationMonitor) { if (!this.initialized) { Assert.notEmpty(this.handlers, "handler list must not be empty"); this.configureChain(); this.initialized = true; } } }
@Override public final void start() { this.lifecycleLock.lock(); try { if (!this.running) { this.doStart(); this.running = true; if (logger.isInfoEnabled()) { logger.info("started " + this); } } } finally { this.lifecycleLock.unlock(); } }
@Override protected void onInit() { super.onInit(); synchronized (this.initializationMonitor) { if (!this.initialized) { Assert.notEmpty(this.handlers, "handler list must not be empty"); this.configureChain(); this.initialized = true; } } }