INT-2755: Support 'id' For <chain> Child Elements

* Introduce XSD 'id' attribute for all `<chain>` sub-components
* Register `<chain>` sub-components as Beans with names based on `<chain>` 'id'
* Generate aliases for sub-components based on element 'id'
* Add `<chain>` parser test to check sub-components as Beans within `BeanFactory`
* Ignore `NestedChainParserTests` as abnormal and confused for SI-configs
* Now `<chain>` sub-components are trackable by `MessageHistory`
* Now `<chain>` sub-components are eligible for JMX export
* Polishing some failed tests

https://jira.springsource.org/browse/INT-2755
https://jira.springsource.org/browse/INT-2321

INT-2755: Register as Beans only if 'id' provided

INT-2755: Set 'componentName' for handlers with 'id'

When components within `<chain>` are configured with an 'id' attribute
the 'componentName' of the handler is  constructed as:
chainHandler.componentName + '.' + handler.componentName.
Otherwise it is as was before.

INT-2755: Polishing

INT-2755: changes according PR's comments

* Add INFO about preference of `id` attribute for `<chain>` in the `ChainParser`
* Change `<chain>`'s sub-components `id` generation algorithm
* Configure `<chain>`'s sub-component `componentName` in the `ChainParser` instead of in the `MessageHandlerChain`
* Add `componentName` property to the `JpaOutboundGatewayFactoryBean`
* Add a note to the Reference Manual

INT-2755: Localize duplicate 'id' within chain

INT-2755: remove child beans aliasing

* Polishing tests
* Polishing docs

INT-2755 Polishing: Handle Nested Chain Bean Names

Previously named beans within a nested chain did not get unique
bean names.

INT-2755: Polishing nested chains

Doc Polishing
This commit is contained in:
Artem Bilan
2013-02-20 23:52:54 +02:00
committed by Gary Russell
parent ccf7492097
commit ecf15a9834
30 changed files with 648 additions and 288 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -18,6 +18,7 @@ package org.springframework.integration.mail;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.DataInputStream;
@@ -30,7 +31,9 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.mapping.MessageMappingException;
import org.springframework.integration.message.GenericMessage;
@@ -48,6 +51,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
public class MailSendingMessageHandlerContextTests {
@Autowired
@Qualifier("mailSendingMessageConsumer")
private MailSendingMessageHandler handler;
@Autowired
@@ -56,6 +60,9 @@ public class MailSendingMessageHandlerContextTests {
@Autowired
private MessageChannel sendMailOutboundChainChannel;
@Autowired
private BeanFactory beanFactory;
@Before
public void reset() {
@@ -106,6 +113,7 @@ public class MailSendingMessageHandlerContextTests {
@Test //INT-2275
public void mailOutboundChannelAdapterWithinChain() {
assertNotNull(this.beanFactory.getBean("org.springframework.integration.handler.MessageHandlerChain#0$child.mail-outbound-channel-adapter-within-chain.handler"));
this.sendMailOutboundChainChannel.send(MailTestsHelper.createIntegrationMessage());
SimpleMailMessage mailMessage = MailTestsHelper.createSimpleMailMessage();
assertEquals("no mime message should have been sent", 0, this.mailSender.getSentMimeMessages().size());

View File

@@ -22,7 +22,7 @@
</bean>
<int:chain input-channel="sendMailOutboundChainChannel">
<int-mail:outbound-channel-adapter mail-sender="javaMailSender"/>
<int-mail:outbound-channel-adapter id="mail-outbound-channel-adapter-within-chain" mail-sender="javaMailSender"/>
</int:chain>
</beans>