Merge branch '1.5.x'
This commit is contained in:
@@ -21,8 +21,6 @@ import javax.management.MBeanServer;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
@@ -33,8 +31,11 @@ import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||
import org.springframework.context.EnvironmentAware;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.config.EnableIntegrationManagement;
|
||||
import org.springframework.integration.gateway.GatewayProxyFactoryBean;
|
||||
import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport;
|
||||
import org.springframework.integration.monitor.IntegrationMBeanExporter;
|
||||
import org.springframework.integration.support.management.IntegrationManagementConfigurer;
|
||||
@@ -54,12 +55,18 @@ import org.springframework.util.StringUtils;
|
||||
@AutoConfigureAfter(JmxAutoConfiguration.class)
|
||||
public class IntegrationAutoConfiguration {
|
||||
|
||||
/**
|
||||
* Basic Spring Integration configuration.
|
||||
*/
|
||||
@Configuration
|
||||
@EnableIntegration
|
||||
protected static class IntegrationConfiguration {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Spring Integration JMX configuration.
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(EnableIntegrationMBeanExport.class)
|
||||
@ConditionalOnMissingBean(value = IntegrationMBeanExporter.class, search = SearchStrategy.CURRENT)
|
||||
@@ -67,17 +74,10 @@ public class IntegrationAutoConfiguration {
|
||||
protected static class IntegrationJmxConfiguration
|
||||
implements EnvironmentAware, BeanFactoryAware {
|
||||
|
||||
private final IntegrationManagementConfigurer configurer;
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
private RelaxedPropertyResolver propertyResolver;
|
||||
|
||||
protected IntegrationJmxConfiguration(
|
||||
@Qualifier(IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME) ObjectProvider<IntegrationManagementConfigurer> configurerProvider) {
|
||||
this.configurer = configurerProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
@@ -100,17 +100,35 @@ public class IntegrationAutoConfiguration {
|
||||
if (StringUtils.hasLength(server)) {
|
||||
exporter.setServer(this.beanFactory.getBean(server, MBeanServer.class));
|
||||
}
|
||||
if (this.configurer != null) {
|
||||
if (this.configurer.getDefaultCountsEnabled() == null) {
|
||||
this.configurer.setDefaultCountsEnabled(true);
|
||||
}
|
||||
if (this.configurer.getDefaultStatsEnabled() == null) {
|
||||
this.configurer.setDefaultStatsEnabled(true);
|
||||
}
|
||||
}
|
||||
return exporter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Integration management configuration.
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ EnableIntegrationManagement.class,
|
||||
EnableIntegrationMBeanExport.class })
|
||||
@ConditionalOnMissingBean(value = IntegrationManagementConfigurer.class, name = IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME, search = SearchStrategy.CURRENT)
|
||||
@ConditionalOnProperty(prefix = "spring.jmx", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
protected static class IntegrationManagementConfiguration {
|
||||
|
||||
@Configuration
|
||||
@EnableIntegrationManagement(defaultCountsEnabled = "true", defaultStatsEnabled = "true")
|
||||
protected static class EnableIntegrationManagementConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Integration component scan configuration.
|
||||
*/
|
||||
@ConditionalOnMissingBean(GatewayProxyFactoryBean.class)
|
||||
@Import(IntegrationAutoConfigurationScanRegistrar.class)
|
||||
protected static class IntegrationComponentScanAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.boot.autoconfigure.integration;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.core.type.StandardAnnotationMetadata;
|
||||
import org.springframework.integration.annotation.IntegrationComponentScan;
|
||||
import org.springframework.integration.config.IntegrationComponentScanRegistrar;
|
||||
|
||||
/**
|
||||
* Variation of {@link IntegrationComponentScanRegistrar} the links
|
||||
* {@link AutoConfigurationPackages}.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class IntegrationAutoConfigurationScanRegistrar extends IntegrationComponentScanRegistrar
|
||||
implements BeanFactoryAware {
|
||||
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
|
||||
final BeanDefinitionRegistry registry) {
|
||||
super.registerBeanDefinitions(
|
||||
new IntegrationComponentScanConfigurationMetaData(this.beanFactory),
|
||||
registry);
|
||||
}
|
||||
|
||||
private static class IntegrationComponentScanConfigurationMetaData
|
||||
extends StandardAnnotationMetadata {
|
||||
|
||||
private final BeanFactory beanFactory;
|
||||
|
||||
IntegrationComponentScanConfigurationMetaData(BeanFactory beanFactory) {
|
||||
super(IntegrationComponentScanConfiguration.class, true);
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getAnnotationAttributes(String annotationName) {
|
||||
Map<String, Object> attributes = super.getAnnotationAttributes(
|
||||
annotationName);
|
||||
if (IntegrationComponentScan.class.getName().equals(annotationName)
|
||||
&& AutoConfigurationPackages.has(this.beanFactory)) {
|
||||
List<String> packages = AutoConfigurationPackages.get(this.beanFactory);
|
||||
attributes = new LinkedHashMap<String, Object>(attributes);
|
||||
attributes.put("value", packages.toArray(new String[packages.size()]));
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
}
|
||||
|
||||
@IntegrationComponentScan
|
||||
private static class IntegrationComponentScanConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import org.springframework.util.CollectionUtils;
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Stephane Nicoll
|
||||
* @author Artem Bilan
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.kafka")
|
||||
@@ -199,7 +200,7 @@ public class KafkaProperties {
|
||||
* Frequency in milliseconds that the consumer offsets are auto-committed to Kafka
|
||||
* if 'enable.auto.commit' true.
|
||||
*/
|
||||
private Long autoCommitInterval;
|
||||
private Integer autoCommitInterval;
|
||||
|
||||
/**
|
||||
* What to do when there is no initial offset in Kafka or if the current offset
|
||||
@@ -264,11 +265,11 @@ public class KafkaProperties {
|
||||
return this.ssl;
|
||||
}
|
||||
|
||||
public Long getAutoCommitInterval() {
|
||||
public Integer getAutoCommitInterval() {
|
||||
return this.autoCommitInterval;
|
||||
}
|
||||
|
||||
public void setAutoCommitInterval(Long autoCommitInterval) {
|
||||
public void setAutoCommitInterval(Integer autoCommitInterval) {
|
||||
this.autoCommitInterval = autoCommitInterval;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SecurityProperties implements SecurityPrerequisite {
|
||||
/**
|
||||
* Order applied to the WebSecurityConfigurerAdapter that is used to configure basic
|
||||
* authentication for application endpoints. If you want to add your own
|
||||
* authentication for all or some of those endpoints the best thing to do is add your
|
||||
* authentication for all or some of those endpoints the best thing to do is to add your
|
||||
* own WebSecurityConfigurerAdapter with lower order.
|
||||
*/
|
||||
public static final int BASIC_AUTH_ORDER = Ordered.LOWEST_PRECEDENCE - 5;
|
||||
|
||||
@@ -24,13 +24,18 @@ import javax.management.MBeanServer;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration.IntegrationComponentScanAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.integration.annotation.IntegrationComponentScan;
|
||||
import org.springframework.integration.annotation.MessagingGateway;
|
||||
import org.springframework.integration.gateway.RequestReplyExchanger;
|
||||
import org.springframework.integration.support.channel.HeaderChannelRegistry;
|
||||
import org.springframework.integration.support.management.IntegrationManagementConfigurer;
|
||||
import org.springframework.jmx.export.MBeanExporter;
|
||||
import org.springframework.test.context.support.TestPropertySourceUtils;
|
||||
|
||||
@@ -60,24 +65,35 @@ public class IntegrationAutoConfigurationTests {
|
||||
@Test
|
||||
public void integrationIsAvailable() {
|
||||
load();
|
||||
assertThat(this.context.getBean(HeaderChannelRegistry.class)).isNotNull();
|
||||
assertThat(this.context.getBean(TestGateway.class)).isNotNull();
|
||||
assertThat(this.context.getBean(IntegrationComponentScanAutoConfiguration.class))
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void explicitIntegrationComponentScan() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(IntegrationComponentScanConfiguration.class,
|
||||
JmxAutoConfiguration.class, IntegrationAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(TestGateway.class)).isNotNull();
|
||||
assertThat(this.context
|
||||
.getBeansOfType(IntegrationComponentScanAutoConfiguration.class))
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parentContext() {
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.register(JmxAutoConfiguration.class,
|
||||
IntegrationAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
load();
|
||||
AnnotationConfigApplicationContext parent = this.context;
|
||||
this.context = new AnnotationConfigApplicationContext();
|
||||
this.context.setParent(parent);
|
||||
this.context.register(JmxAutoConfiguration.class,
|
||||
IntegrationAutoConfiguration.class);
|
||||
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context,
|
||||
"SPRING_JMX_DEFAULT_DOMAIN=org.foo");
|
||||
this.context.refresh();
|
||||
assertThat(this.context.getBean(HeaderChannelRegistry.class)).isNotNull();
|
||||
((ConfigurableApplicationContext) this.context.getParent()).close();
|
||||
this.context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,12 +102,17 @@ public class IntegrationAutoConfigurationTests {
|
||||
MBeanServer mBeanServer = this.context.getBean(MBeanServer.class);
|
||||
assertDomains(mBeanServer, true, "org.springframework.integration",
|
||||
"org.springframework.integration.monitor");
|
||||
Object bean = this.context
|
||||
.getBean(IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME);
|
||||
assertThat(bean).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disableJmxIntegration() {
|
||||
load("spring.jmx.enabled=false");
|
||||
assertThat(this.context.getBeansOfType(MBeanServer.class)).hasSize(0);
|
||||
assertThat(this.context.getBeansOfType(IntegrationManagementConfigurer.class))
|
||||
.isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,4 +166,15 @@ public class IntegrationAutoConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@IntegrationComponentScan
|
||||
static class IntegrationComponentScanConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@MessagingGateway
|
||||
public interface TestGateway extends RequestReplyExchanger {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class KafkaAutoConfigurationTests {
|
||||
assertThat(configs.get(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG))
|
||||
.isEqualTo(Boolean.FALSE);
|
||||
assertThat(configs.get(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG))
|
||||
.isEqualTo(123L);
|
||||
.isEqualTo(123);
|
||||
assertThat(configs.get(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG))
|
||||
.isEqualTo("earliest");
|
||||
assertThat(configs.get(ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG)).isEqualTo(456);
|
||||
|
||||
Reference in New Issue
Block a user