INT-3292: Add support for Boot AutoConfiguration

JIRA: https://jira.springsource.org/browse/INT-3292

As far as Spring Boot reads `spring.factories` for key
`org.springframework.boot.autoconfigure.EnableAutoConfiguration`,
there is no difficulties to provide a hook to enable Spring Integration
via just Boot `@EnableAutoConfiguration`
This commit is contained in:
Artem Bilan
2014-02-07 18:31:18 +02:00
committed by Gary Russell
parent 2fd27e3a6c
commit 8cbaef7c6b
6 changed files with 103 additions and 1 deletions

View File

@@ -87,6 +87,7 @@ subprojects { subproject ->
springSocialTwitterVersion = '1.0.5.RELEASE'
springWsVersion = '2.1.1.RELEASE'
springRetryVersion = '1.0.3.RELEASE'
springBootVersion = '1.0.0.RC1'
}
eclipse {
@@ -205,7 +206,11 @@ project('spring-integration-core') {
compile("org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion", optional)
compile("com.fasterxml.jackson.core:jackson-databind:$jackson2Version", optional)
compile('com.jayway.jsonpath:json-path:0.9.0', optional)
testCompile ("org.aspectj:aspectjweaver:$aspectjVersion")
testCompile ("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion") {
exclude group: 'org.springframework'
}
}
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright 2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.config.boot;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.config.EnableIntegration;
/**
* @author Artem Bilan
* @since 4.0
*/
@Configuration
@EnableIntegration
interface IntegrationAutoConfiguration {
}

View File

@@ -0,0 +1,4 @@
/**
* Contains components for Spring Boot configuration.
*/
package org.springframework.integration.config.boot;

View File

@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.integration.config.boot.IntegrationAutoConfiguration

View File

@@ -0,0 +1,49 @@
/*
* Copyright 2014 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.configuration.boot;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.integration.context.IntegrationContextUtils;
/**
* @author Artem Bilan
* @since 4.0
*/
public class IntegrationAutoConfigurationTests {
@Test
public void testIntegrationAutoConfiguration() {
ConfigurableApplicationContext applicationContext = SpringApplication.run(Configuration.class);
assertTrue(applicationContext.containsBean(IntegrationContextUtils.CHANNEL_INITIALIZER_BEAN_NAME));
assertTrue(applicationContext.containsBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME));
assertTrue(applicationContext.containsBean(IntegrationContextUtils.MESSAGING_ANNOTATION_POSTPROCESSOR_NAME));
assertTrue(applicationContext.containsBean("jsonPath"));
assertFalse(applicationContext.containsBean("xpath"));
}
@EnableAutoConfiguration
public static class Configuration {
}
}

View File

@@ -36,7 +36,7 @@
</para>
</section>
<section id="4.0-enable-configuration">
<title>@EnableConfiguration</title>
<title>@EnableIntegration</title>
<para>
The <code>@EnableIntegration</code> annotation has been added, to permit declaration of
standard Spring Integration beans when using <code>@Configuration</code> classes. See
@@ -51,6 +51,18 @@
by a JMX MBean. For more information, see <xref linkend="message-history"/>.
</para>
</section>
<section id="4.0-boot">
<title>Spring Boot @EnableAutoConfiguration</title>
<para>
As well as the <code>@EnableIntegration</code> annotation mentioned above, a
a hook has been introduced to allow the
Spring Integration infrastructure beans to be configured using Spring Boot's
<code>@EnableAutoConfiguration</code>.
For more information see
<ulink url="http://projects.spring.io/spring-boot/docs/spring-boot-autoconfigure/README.html"
>Spring Boot - AutoConfigure</ulink>.
</para>
</section>
<section id="4.0-xpath-header-enricher-header-type">
<title>Header Type for XPath Header Enricher</title>
<para>