Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
6e02fe59
Commit
6e02fe59
authored
Dec 22, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
ae389d27
78ee8637
Changes
33
Show whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
537 additions
and
127 deletions
+537
-127
pom.xml
spring-boot-actuator/pom.xml
+5
-5
ManagementServerProperties.java
...oot/actuate/autoconfigure/ManagementServerProperties.java
+1
-1
PublicMetricsAutoConfiguration.java
...actuate/autoconfigure/PublicMetricsAutoConfiguration.java
+14
-3
SpringIntegrationMetricReader.java
...te/metrics/integration/SpringIntegrationMetricReader.java
+74
-40
PublicMetricsAutoConfigurationTests.java
...te/autoconfigure/PublicMetricsAutoConfigurationTests.java
+1
-1
JolokiaMvcEndpointIntegrationTests.java
...uate/endpoint/mvc/JolokiaMvcEndpointIntegrationTests.java
+1
-1
SpringIntegrationMetricReaderNoJmxTests.java
.../integration/SpringIntegrationMetricReaderNoJmxTests.java
+60
-0
SpringIntegrationMetricReaderTests.java
...trics/integration/SpringIntegrationMetricReaderTests.java
+5
-3
IntegrationAutoConfiguration.java
...toconfigure/integration/IntegrationAutoConfiguration.java
+35
-17
IntegrationAutoConfigurationScanRegistrar.java
...ntegration/IntegrationAutoConfigurationScanRegistrar.java
+87
-0
KafkaProperties.java
...ngframework/boot/autoconfigure/kafka/KafkaProperties.java
+4
-3
SecurityProperties.java
...ework/boot/autoconfigure/security/SecurityProperties.java
+1
-1
IntegrationAutoConfigurationTests.java
...figure/integration/IntegrationAutoConfigurationTests.java
+38
-6
KafkaAutoConfigurationTests.java
...boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java
+1
-1
KafkaSpecialProducerConsumerConfigExample.java
...boot/kafka/KafkaSpecialProducerConsumerConfigExample.java
+3
-4
SampleCommandLineRunner.java
...main/java/sample/integration/SampleCommandLineRunner.java
+38
-0
SampleMessageGateway.java
...rc/main/java/sample/integration/SampleMessageGateway.java
+26
-0
SampleIntegrationApplicationTests.java
...tegration/consumer/SampleIntegrationApplicationTests.java
+19
-15
pom.xml
spring-boot-starters/spring-boot-starter-integration/pom.xml
+0
-4
spring.provides
...r-integration/src/main/resources/META-INF/spring.provides
+1
-1
SpringBootTestContextCustomizer.java
...rk/boot/test/context/SpringBootTestContextCustomizer.java
+1
-1
AbstractSpringBootTestEmbeddedWebEnvironmentTests.java
...xt/AbstractSpringBootTestEmbeddedWebEnvironmentTests.java
+4
-0
SpringBootTestTestRestTemplateDefinedByUser.java
.../context/SpringBootTestTestRestTemplateDefinedByUser.java
+65
-0
MainClassFinder.java
...rg/springframework/boot/loader/tools/MainClassFinder.java
+1
-1
AbstractExecutableArchiveLauncherTests.java
...k/boot/loader/AbstractExecutableArchiveLauncherTests.java
+5
-5
custom-layout.apt
...boot-maven-plugin/src/site/apt/examples/custom-layout.apt
+1
-1
RelaxedPropertyResolver.java
...rg/springframework/boot/bind/RelaxedPropertyResolver.java
+23
-0
LoggingSystemProperties.java
...springframework/boot/logging/LoggingSystemProperties.java
+2
-2
DefaultLogbackConfiguration.java
...ork/boot/logging/logback/DefaultLogbackConfiguration.java
+6
-5
SpringPhysicalNamingStrategy.java
.../boot/orm/jpa/hibernate/SpringPhysicalNamingStrategy.java
+2
-2
SpringBootServletInitializer.java
...mework/boot/web/support/SpringBootServletInitializer.java
+1
-1
LoggingApplicationListenerTests.java
...amework/boot/logging/LoggingApplicationListenerTests.java
+11
-1
SpringProfileDocumentMatcherTests.java
...ramework/boot/yaml/SpringProfileDocumentMatcherTests.java
+1
-2
No files found.
spring-boot-actuator/pom.xml
View file @
6e02fe59
...
...
@@ -199,11 +199,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-jmx
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-core
</artifactId>
...
...
@@ -349,6 +344,11 @@
<artifactId>
spring-data-rest-webmvc
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-jmx
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.security
</groupId>
<artifactId>
spring-security-test
</artifactId>
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java
View file @
6e02fe59
...
...
@@ -45,7 +45,7 @@ public class ManagementServerProperties implements SecurityPrerequisite {
/**
* Order applied to the WebSecurityConfigurerAdapter that is used to configure basic
* authentication for management endpoints. If you want to add your own authentication
* for all or some of those endpoints the best thing to do is add your own
* for all or some of those endpoints the best thing to do is
to
add your own
* WebSecurityConfigurerAdapter with lower order, for instance by using
* {@code ACCESS_OVERRIDE_ORDER}.
*/
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfiguration.java
View file @
6e02fe59
...
...
@@ -44,6 +44,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication
;
import
org.springframework.boot.autoconfigure.condition.SearchStrategy
;
import
org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProvider
;
...
...
@@ -51,6 +52,7 @@ import org.springframework.cache.CacheManager;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.integration.monitor.IntegrationMBeanExporter
;
import
org.springframework.integration.support.management.IntegrationManagementConfigurer
;
/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link PublicMetrics}.
...
...
@@ -58,6 +60,7 @@ import org.springframework.integration.monitor.IntegrationMBeanExporter;
* @author Stephane Nicoll
* @author Phillip Webb
* @author Johannes Edmeier
* @author Artem Bilan
* @since 1.2.0
*/
@Configuration
...
...
@@ -137,15 +140,23 @@ public class PublicMetricsAutoConfiguration {
@Configuration
@ConditionalOnClass
(
IntegrationMBeanExporter
.
class
)
@ConditionalOnBean
(
IntegrationMBeanExporter
.
class
)
static
class
IntegrationMetricsConfiguration
{
@Bean
(
name
=
IntegrationManagementConfigurer
.
MANAGEMENT_CONFIGURER_NAME
)
@ConditionalOnMissingBean
(
value
=
IntegrationManagementConfigurer
.
class
,
name
=
IntegrationManagementConfigurer
.
MANAGEMENT_CONFIGURER_NAME
,
search
=
SearchStrategy
.
CURRENT
)
public
IntegrationManagementConfigurer
managementConfigurer
()
{
IntegrationManagementConfigurer
configurer
=
new
IntegrationManagementConfigurer
();
configurer
.
setDefaultCountsEnabled
(
true
);
configurer
.
setDefaultStatsEnabled
(
true
);
return
configurer
;
}
@Bean
@ConditionalOnMissingBean
(
name
=
"springIntegrationPublicMetrics"
)
public
MetricReaderPublicMetrics
springIntegrationPublicMetrics
(
IntegrationM
BeanExporter
export
er
)
{
IntegrationM
anagementConfigurer
managementConfigur
er
)
{
return
new
MetricReaderPublicMetrics
(
new
SpringIntegrationMetricReader
(
export
er
));
new
SpringIntegrationMetricReader
(
managementConfigur
er
));
}
}
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/integration/SpringIntegrationMetricReader.java
View file @
6e02fe59
...
...
@@ -22,22 +22,27 @@ import java.util.List;
import
org.springframework.boot.actuate.metrics.Metric
;
import
org.springframework.boot.actuate.metrics.reader.MetricReader
;
import
org.springframework.integration.monitor.IntegrationMBeanExporter
;
import
org.springframework.integration.support.management.IntegrationManagementConfigurer
;
import
org.springframework.integration.support.management.MessageChannelMetrics
;
import
org.springframework.integration.support.management.MessageHandlerMetrics
;
import
org.springframework.integration.support.management.MessageSourceMetrics
;
import
org.springframework.integration.support.management.PollableChannelManagement
;
import
org.springframework.integration.support.management.Statistics
;
/**
* A {@link MetricReader} for Spring Integration metrics (as provided by
*
spring-integration-jmx
).
*
{@link IntegrationManagementConfigurer}
).
*
* @author Dave Syer
* @author Artem Bilan
* @since 1.3.0
*/
public
class
SpringIntegrationMetricReader
implements
MetricReader
{
private
final
IntegrationM
BeanExporter
export
er
;
private
final
IntegrationM
anagementConfigurer
configur
er
;
public
SpringIntegrationMetricReader
(
IntegrationM
BeanExporter
export
er
)
{
this
.
exporter
=
export
er
;
public
SpringIntegrationMetricReader
(
IntegrationM
anagementConfigurer
configur
er
)
{
this
.
configurer
=
configur
er
;
}
@Override
...
...
@@ -47,51 +52,80 @@ public class SpringIntegrationMetricReader implements MetricReader {
@Override
public
Iterable
<
Metric
<?>>
findAll
()
{
IntegrationMBeanExporter
exporter
=
this
.
exporter
;
List
<
Metric
<?>>
metrics
=
new
ArrayList
<
Metric
<?>>();
for
(
String
name
:
exporter
.
getChannelNames
())
{
List
<
Metric
<?>>
result
=
new
ArrayList
<
Metric
<?>>();
String
[]
channelNames
=
this
.
configurer
.
getChannelNames
();
String
[]
handlerNames
=
this
.
configurer
.
getHandlerNames
();
String
[]
sourceNames
=
this
.
configurer
.
getSourceNames
();
addChannelMetrics
(
result
,
channelNames
);
addHandlerMetrics
(
result
,
handlerNames
);
addSourceMetrics
(
result
,
sourceNames
);
result
.
add
(
new
Metric
<
Integer
>(
"integration.handlerCount"
,
handlerNames
.
length
));
result
.
add
(
new
Metric
<
Integer
>(
"integration.channelCount"
,
channelNames
.
length
));
result
.
add
(
new
Metric
<
Integer
>(
"integration.sourceCount"
,
sourceNames
.
length
));
return
result
;
}
private
void
addChannelMetrics
(
List
<
Metric
<?>>
result
,
String
[]
names
)
{
for
(
String
name
:
names
)
{
addChannelMetrics
(
result
,
name
,
this
.
configurer
.
getChannelMetrics
(
name
));
}
}
private
void
addChannelMetrics
(
List
<
Metric
<?>>
result
,
String
name
,
MessageChannelMetrics
metrics
)
{
String
prefix
=
"integration.channel."
+
name
;
metrics
.
addAll
(
getStatistics
(
prefix
+
".errorRate"
,
exporter
.
getChannelErrorRate
(
name
)));
metrics
.
add
(
new
Metric
<
Long
>(
prefix
+
".sendCount"
,
exporter
.
getChannelSendCountLong
(
name
)));
metrics
.
addAll
(
getStatistics
(
prefix
+
".sendRate"
,
exporter
.
getChannelSendRate
(
name
)));
metrics
.
add
(
new
Metric
<
Long
>(
prefix
+
".receiveCount"
,
exporter
.
getChannelReceiveCountLong
(
name
)));
result
.
addAll
(
getStatistics
(
prefix
+
".errorRate"
,
metrics
.
getErrorRate
()));
result
.
add
(
new
Metric
<
Long
>(
prefix
+
".sendCount"
,
metrics
.
getSendCountLong
()));
result
.
addAll
(
getStatistics
(
prefix
+
".sendRate"
,
metrics
.
getSendRate
()));
if
(
metrics
instanceof
PollableChannelManagement
)
{
result
.
add
(
new
Metric
<
Long
>(
prefix
+
".receiveCount"
,
((
PollableChannelManagement
)
metrics
).
getReceiveCountLong
()));
}
for
(
String
name
:
exporter
.
getHandlerNames
())
{
metrics
.
addAll
(
getStatistics
(
"integration.handler."
+
name
+
".duration"
,
exporter
.
getHandlerDuration
(
name
)));
}
metrics
.
add
(
new
Metric
<
Integer
>(
"integration.activeHandlerCount"
,
exporter
.
getActiveHandlerCount
()));
metrics
.
add
(
new
Metric
<
Integer
>(
"integration.handlerCount"
,
exporter
.
getHandlerCount
()));
metrics
.
add
(
new
Metric
<
Integer
>(
"integration.channelCount"
,
exporter
.
getChannelCount
()));
metrics
.
add
(
new
Metric
<
Integer
>(
"integration.queuedMessageCount"
,
exporter
.
getQueuedMessageCount
()));
return
metrics
;
private
void
addHandlerMetrics
(
List
<
Metric
<?>>
result
,
String
[]
names
)
{
for
(
String
name
:
names
)
{
addHandlerMetrics
(
result
,
name
,
this
.
configurer
.
getHandlerMetrics
(
name
));
}
}
private
void
addHandlerMetrics
(
List
<
Metric
<?>>
result
,
String
name
,
MessageHandlerMetrics
metrics
)
{
String
prefix
=
"integration.handler."
+
name
;
result
.
addAll
(
getStatistics
(
prefix
+
".duration"
,
metrics
.
getDuration
()));
long
activeCount
=
metrics
.
getActiveCountLong
();
result
.
add
(
new
Metric
<
Long
>(
prefix
+
".activeCount"
,
activeCount
));
}
private
void
addSourceMetrics
(
List
<
Metric
<?>>
result
,
String
[]
names
)
{
for
(
String
name
:
names
)
{
addSourceMetrics
(
result
,
name
,
this
.
configurer
.
getSourceMetrics
(
name
));
}
}
private
void
addSourceMetrics
(
List
<
Metric
<?>>
result
,
String
name
,
MessageSourceMetrics
sourceMetrics
)
{
String
prefix
=
"integration.source."
+
name
;
result
.
add
(
new
Metric
<
Long
>(
prefix
+
".messageCount"
,
sourceMetrics
.
getMessageCountLong
()));
}
private
Collection
<?
extends
Metric
<?>>
getStatistics
(
String
name
,
Statistics
statistic
)
{
private
Collection
<?
extends
Metric
<?>>
getStatistics
(
String
name
,
Statistics
stats
)
{
List
<
Metric
<?>>
metrics
=
new
ArrayList
<
Metric
<?>>();
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".mean"
,
statistic
.
getMean
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".max"
,
statistic
.
getMax
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".min"
,
statistic
.
getMin
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".stdev"
,
statistic
.
getStandardDeviation
()));
metrics
.
add
(
new
Metric
<
Long
>(
name
+
".count"
,
statistic
.
getCountLong
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".mean"
,
stats
.
getMean
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".max"
,
stats
.
getMax
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".min"
,
stats
.
getMin
()));
metrics
.
add
(
new
Metric
<
Double
>(
name
+
".stdev"
,
stats
.
getStandardDeviation
()));
metrics
.
add
(
new
Metric
<
Long
>(
name
+
".count"
,
stats
.
getCountLong
()));
return
metrics
;
}
@Override
public
long
count
()
{
int
totalChannelCount
=
this
.
exporter
.
getChannelCount
()
*
11
;
int
totalHandlerCount
=
this
.
exporter
.
getHandlerCount
()
*
5
;
return
totalChannelCount
+
totalHandlerCount
+
4
;
int
totalChannelCount
=
this
.
configurer
.
getChannelNames
().
length
;
int
totalHandlerCount
=
this
.
configurer
.
getHandlerNames
().
length
;
int
totalSourceCount
=
this
.
configurer
.
getSourceNames
().
length
;
return
totalChannelCount
+
totalHandlerCount
+
totalSourceCount
;
}
}
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java
View file @
6e02fe59
...
...
@@ -92,7 +92,7 @@ public class PublicMetricsAutoConfigurationTests {
public
void
metricReaderPublicMetrics
()
throws
Exception
{
load
();
assertThat
(
this
.
context
.
getBeansOfType
(
MetricReaderPublicMetrics
.
class
))
.
hasSize
(
1
);
.
hasSize
(
2
);
}
@Test
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaMvcEndpointIntegrationTests.java
View file @
6e02fe59
...
...
@@ -47,7 +47,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
/**
* Integration tests for {@link JolokiaMvcEndpoint}
* Integration tests for {@link JolokiaMvcEndpoint}
.
*
* @author Christian Dupuis
* @author Dave Syer
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/integration/SpringIntegrationMetricReaderNoJmxTests.java
0 → 100644
View file @
6e02fe59
/*
* 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
.
actuate
.
metrics
.
integration
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.actuate.autoconfigure.PublicMetricsAutoConfiguration
;
import
org.springframework.boot.actuate.endpoint.MetricReaderPublicMetrics
;
import
org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Tests for {@link SpringIntegrationMetricReader}.
*
* @author Artem Bilan
*/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
"spring.jmx.enabled=false"
)
@DirtiesContext
public
class
SpringIntegrationMetricReaderNoJmxTests
{
@Autowired
@Qualifier
(
"springIntegrationPublicMetrics"
)
private
MetricReaderPublicMetrics
integrationMetricReader
;
@Test
public
void
test
()
{
assertThat
(
this
.
integrationMetricReader
.
metrics
().
size
()
>
0
).
isTrue
();
}
@Configuration
@Import
({
IntegrationAutoConfiguration
.
class
,
PublicMetricsAutoConfiguration
.
class
})
protected
static
class
TestConfiguration
{
}
}
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/integration/SpringIntegrationMetricReaderTests.java
View file @
6e02fe59
...
...
@@ -26,7 +26,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.integration.
monitor.IntegrationMBeanExport
er
;
import
org.springframework.integration.
support.management.IntegrationManagementConfigur
er
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.junit4.SpringRunner
;
...
...
@@ -36,6 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Tests for {@link SpringIntegrationMetricReader}.
*
* @author Dave Syer
* @author Artem Bilan
*/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
"spring.jmx.enabled=true"
)
...
...
@@ -55,8 +56,9 @@ public class SpringIntegrationMetricReaderTests {
protected
static
class
TestConfiguration
{
@Bean
public
SpringIntegrationMetricReader
reader
(
IntegrationMBeanExporter
exporter
)
{
return
new
SpringIntegrationMetricReader
(
exporter
);
public
SpringIntegrationMetricReader
reader
(
IntegrationManagementConfigurer
managementConfigurer
)
{
return
new
SpringIntegrationMetricReader
(
managementConfigurer
);
}
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java
View file @
6e02fe59
...
...
@@ -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
);
return
exporter
;
}
if
(
this
.
configurer
.
getDefaultStatsEnabled
()
==
null
)
{
this
.
configurer
.
setDefaultStatsEnabled
(
true
);
}
/**
* 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
{
}
return
exporter
;
}
/**
* Integration component scan configuration.
*/
@ConditionalOnMissingBean
(
GatewayProxyFactoryBean
.
class
)
@Import
(
IntegrationAutoConfigurationScanRegistrar
.
class
)
protected
static
class
IntegrationComponentScanAutoConfiguration
{
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationScanRegistrar.java
0 → 100644
View file @
6e02fe59
/*
* 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
{
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java
View file @
6e02fe59
...
...
@@ -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
;
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java
View file @
6e02fe59
...
...
@@ -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
;
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfigurationTests.java
View file @
6e02fe59
...
...
@@ -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
parentContext
()
{
public
void
explicitIntegrationComponentScan
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
JmxAuto
Configuration
.
class
,
IntegrationAutoConfiguration
.
class
);
this
.
context
.
register
(
IntegrationComponentScan
Configuration
.
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
()
{
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
{
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java
View file @
6e02fe59
...
...
@@ -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
(
123
L
);
.
isEqualTo
(
123
);
assertThat
(
configs
.
get
(
ConsumerConfig
.
AUTO_OFFSET_RESET_CONFIG
))
.
isEqualTo
(
"earliest"
);
assertThat
(
configs
.
get
(
ConsumerConfig
.
FETCH_MAX_WAIT_MS_CONFIG
)).
isEqualTo
(
456
);
...
...
spring-boot-docs/src/main/java/org/springframework/boot/kafka/KafkaSpecialProducerConsumerConfigExample.java
View file @
6e02fe59
...
...
@@ -64,11 +64,10 @@ public class KafkaSpecialProducerConsumerConfigExample {
*/
@Bean
public
ConsumerFactory
<?,
?>
kafkaConsumerFactory
(
KafkaProperties
properties
)
{
Map
<
String
,
Object
>
consumererProperties
=
properties
.
buildConsumerProperties
();
consumererProperties
.
put
(
CommonClientConfigs
.
METRIC_REPORTER_CLASSES_CONFIG
,
Map
<
String
,
Object
>
consumerProperties
=
properties
.
buildConsumerProperties
();
consumerProperties
.
put
(
CommonClientConfigs
.
METRIC_REPORTER_CLASSES_CONFIG
,
MyConsumerMetricsReporter
.
class
);
return
new
DefaultKafkaConsumerFactory
<
Object
,
Object
>(
consumer
er
Properties
);
return
new
DefaultKafkaConsumerFactory
<
Object
,
Object
>(
consumerProperties
);
}
}
...
...
spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/SampleCommandLineRunner.java
0 → 100644
View file @
6e02fe59
/*
* 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
sample
.
integration
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.stereotype.Component
;
@Component
public
class
SampleCommandLineRunner
implements
CommandLineRunner
{
private
final
SampleMessageGateway
gateway
;
public
SampleCommandLineRunner
(
SampleMessageGateway
gateway
)
{
this
.
gateway
=
gateway
;
}
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
for
(
String
arg
:
args
)
{
this
.
gateway
.
echo
(
arg
);
}
}
}
spring-boot-samples/spring-boot-sample-integration/src/main/java/sample/integration/SampleMessageGateway.java
0 → 100644
View file @
6e02fe59
/*
* 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
sample
.
integration
;
import
org.springframework.integration.annotation.MessagingGateway
;
@MessagingGateway
(
defaultRequestChannel
=
"outputChannel"
)
public
interface
SampleMessageGateway
{
void
echo
(
String
message
);
}
spring-boot-samples/spring-boot-sample-integration/src/test/java/sample/integration/consumer/SampleIntegrationApplicationTests.java
View file @
6e02fe59
...
...
@@ -23,9 +23,8 @@ import java.util.concurrent.Executors;
import
java.util.concurrent.Future
;
import
java.util.concurrent.TimeUnit
;
import
org.junit.After
Class
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
sample.integration.SampleIntegrationApplication
;
import
sample.integration.producer.ProducerApplication
;
...
...
@@ -48,32 +47,37 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
public
class
SampleIntegrationApplicationTests
{
private
static
ConfigurableApplicationContext
context
;
@BeforeClass
public
static
void
start
()
throws
Exception
{
context
=
SpringApplication
.
run
(
SampleIntegrationApplication
.
class
);
}
@AfterClass
public
static
void
stop
()
{
if
(
context
!=
null
)
{
context
.
close
();
}
}
private
ConfigurableApplicationContext
context
;
@Before
public
void
deleteOutput
()
{
FileSystemUtils
.
deleteRecursively
(
new
File
(
"target/input"
));
FileSystemUtils
.
deleteRecursively
(
new
File
(
"target/output"
));
}
@After
public
void
stop
()
{
if
(
this
.
context
!=
null
)
{
this
.
context
.
close
();
}
}
@Test
public
void
testVanillaExchange
()
throws
Exception
{
this
.
context
=
SpringApplication
.
run
(
SampleIntegrationApplication
.
class
);
SpringApplication
.
run
(
ProducerApplication
.
class
,
"World"
);
String
output
=
getOutput
();
assertThat
(
output
).
contains
(
"Hello World"
);
}
@Test
public
void
testMessageGateway
()
throws
Exception
{
this
.
context
=
SpringApplication
.
run
(
SampleIntegrationApplication
.
class
,
"testviamg"
);
String
output
=
getOutput
();
assertThat
(
output
).
contains
(
"testviamg"
);
}
private
String
getOutput
()
throws
Exception
{
Future
<
String
>
future
=
Executors
.
newSingleThreadExecutor
()
.
submit
(
new
Callable
<
String
>()
{
...
...
spring-boot-starters/spring-boot-starter-integration/pom.xml
View file @
6e02fe59
...
...
@@ -30,9 +30,5 @@
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.integration
</groupId>
<artifactId>
spring-integration-jmx
</artifactId>
</dependency>
</dependencies>
</project>
spring-boot-starters/spring-boot-starter-integration/src/main/resources/META-INF/spring.provides
View file @
6e02fe59
provides: spring-integration-core,spring-integration-java-dsl,spring-integration-jmx
\ No newline at end of file
provides: spring-integration-core,spring-integration-java-dsl
spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextCustomizer.java
View file @
6e02fe59
...
...
@@ -62,7 +62,7 @@ class SpringBootTestContextCustomizer implements ContextCustomizer {
private
void
registerTestRestTemplate
(
ConfigurableApplicationContext
context
,
BeanDefinitionRegistry
registry
)
{
registry
.
registerBeanDefinition
(
"testRestTemplate"
,
registry
.
registerBeanDefinition
(
TestRestTemplate
.
class
.
getName
()
,
new
RootBeanDefinition
(
TestRestTemplateFactory
.
class
));
}
...
...
spring-boot-test/src/test/java/org/springframework/boot/test/context/AbstractSpringBootTestEmbeddedWebEnvironmentTests.java
View file @
6e02fe59
...
...
@@ -60,6 +60,10 @@ public abstract class AbstractSpringBootTestEmbeddedWebEnvironmentTests {
@Autowired
private
TestRestTemplate
restTemplate
;
public
WebApplicationContext
getContext
()
{
return
this
.
context
;
}
public
TestRestTemplate
getRestTemplate
()
{
return
this
.
restTemplate
;
}
...
...
spring-boot-test/src/test/java/org/springframework/boot/test/context/SpringBootTestTestRestTemplateDefinedByUser.java
0 → 100644
View file @
6e02fe59
/*
* 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
.
test
.
context
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest.WebEnvironment
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.servlet.config.annotation.EnableWebMvc
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Tests for {@link SpringBootTest} configured with {@link WebEnvironment#RANDOM_PORT}.
*
* @author Phillip Webb
* @author Andy Wilkinson
*/
@RunWith
(
SpringRunner
.
class
)
@DirtiesContext
@SpringBootTest
(
webEnvironment
=
WebEnvironment
.
RANDOM_PORT
,
properties
=
{
"value=123"
})
public
class
SpringBootTestTestRestTemplateDefinedByUser
extends
AbstractSpringBootTestEmbeddedWebEnvironmentTests
{
@Test
public
void
restTemplateIsUserDefined
()
throws
Exception
{
assertThat
(
getContext
().
getBean
(
"testRestTemplate"
))
.
isInstanceOf
(
RestTemplate
.
class
);
}
// gh-7711
@Configuration
@EnableWebMvc
@RestController
protected
static
class
Config
extends
AbstractConfig
{
@Bean
public
RestTemplate
testRestTemplate
()
{
return
new
RestTemplate
();
}
}
}
spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java
View file @
6e02fe59
...
...
@@ -372,7 +372,7 @@ public abstract class MainClassFinder {
/**
* Handle the specified main class.
* @param mainClass the main
C
lass
* @param mainClass the main
c
lass
* @return a non-null value if processing should end or {@code null} to continue
*/
T
doWith
(
MainClass
mainClass
);
...
...
spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/AbstractExecutableArchiveLauncherTests.java
View file @
6e02fe59
...
...
@@ -55,15 +55,15 @@ public class AbstractExecutableArchiveLauncherTests {
jarOutputStream
.
putNextEntry
(
new
JarEntry
(
entryPrefix
+
"/"
));
jarOutputStream
.
putNextEntry
(
new
JarEntry
(
entryPrefix
+
"/classes/"
));
jarOutputStream
.
putNextEntry
(
new
JarEntry
(
entryPrefix
+
"/lib/"
));
JarEntry
webInfL
ibFoo
=
new
JarEntry
(
entryPrefix
+
"/lib/foo.jar"
);
webInfL
ibFoo
.
setMethod
(
ZipEntry
.
STORED
);
JarEntry
l
ibFoo
=
new
JarEntry
(
entryPrefix
+
"/lib/foo.jar"
);
l
ibFoo
.
setMethod
(
ZipEntry
.
STORED
);
ByteArrayOutputStream
fooJarStream
=
new
ByteArrayOutputStream
();
new
JarOutputStream
(
fooJarStream
).
close
();
webInfL
ibFoo
.
setSize
(
fooJarStream
.
size
());
l
ibFoo
.
setSize
(
fooJarStream
.
size
());
CRC32
crc32
=
new
CRC32
();
crc32
.
update
(
fooJarStream
.
toByteArray
());
webInfL
ibFoo
.
setCrc
(
crc32
.
getValue
());
jarOutputStream
.
putNextEntry
(
webInfL
ibFoo
);
l
ibFoo
.
setCrc
(
crc32
.
getValue
());
jarOutputStream
.
putNextEntry
(
l
ibFoo
);
jarOutputStream
.
write
(
fooJarStream
.
toByteArray
());
jarOutputStream
.
close
();
return
archive
;
...
...
spring-boot-tools/spring-boot-maven-plugin/src/site/apt/examples/custom-layout.apt
View file @
6e02fe59
...
...
@@ -47,7 +47,7 @@
</build>
...
</project>
+
---
---
The layout factory is provided as an implementation of <<<LayoutFactory>>> (from
spring-boot-loader-tools) explicitly specified in the pom. If there is only one custom
...
...
spring-boot/src/main/java/org/springframework/boot/bind/RelaxedPropertyResolver.java
View file @
6e02fe59
...
...
@@ -19,7 +19,9 @@ package org.springframework.boot.bind;
import
java.util.Map
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.PropertyResolver
;
import
org.springframework.core.env.PropertySourcesPropertyResolver
;
import
org.springframework.util.Assert
;
/**
...
...
@@ -129,4 +131,25 @@ public class RelaxedPropertyResolver implements PropertyResolver {
keyPrefix
);
}
/**
* Return a property resolver for the environment, preferring one that ignores
* unresolvable nested placeholders.
* @param environment the source environment
* @param prefix the prefix
* @return a property resolver for the environment
* @since 1.4.3
*/
public
static
RelaxedPropertyResolver
ignoringUnresolvableNestedPlaceholders
(
Environment
environment
,
String
prefix
)
{
Assert
.
notNull
(
environment
,
"Environment must not be null"
);
PropertyResolver
resolver
=
environment
;
if
(
environment
instanceof
ConfigurableEnvironment
)
{
resolver
=
new
PropertySourcesPropertyResolver
(
((
ConfigurableEnvironment
)
environment
).
getPropertySources
());
((
PropertySourcesPropertyResolver
)
resolver
)
.
setIgnoreUnresolvableNestedPlaceholders
(
true
);
}
return
new
RelaxedPropertyResolver
(
resolver
,
prefix
);
}
}
spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystemProperties.java
View file @
6e02fe59
...
...
@@ -49,8 +49,8 @@ class LoggingSystemProperties {
}
public
void
apply
(
LogFile
logFile
)
{
RelaxedPropertyResolver
propertyResolver
=
new
RelaxedPropertyResolver
(
this
.
environment
,
"logging."
);
RelaxedPropertyResolver
propertyResolver
=
RelaxedPropertyResolver
.
ignoringUnresolvableNestedPlaceholders
(
this
.
environment
,
"logging."
);
setSystemProperty
(
propertyResolver
,
EXCEPTION_CONVERSION_WORD
,
"exception-conversion-word"
);
setSystemProperty
(
propertyResolver
,
CONSOLE_LOG_PATTERN
,
"pattern.console"
);
...
...
spring-boot/src/main/java/org/springframework/boot/logging/logback/DefaultLogbackConfiguration.java
View file @
6e02fe59
...
...
@@ -72,7 +72,8 @@ class DefaultLogbackConfiguration {
if
(
environment
==
null
)
{
return
new
PropertySourcesPropertyResolver
(
null
);
}
return
new
RelaxedPropertyResolver
(
environment
,
"logging.pattern."
);
return
RelaxedPropertyResolver
.
ignoringUnresolvableNestedPlaceholders
(
environment
,
"logging.pattern."
);
}
public
void
apply
(
LogbackConfigurator
config
)
{
...
...
@@ -131,13 +132,13 @@ class DefaultLogbackConfiguration {
appender
.
setEncoder
(
encoder
);
config
.
start
(
encoder
);
appender
.
setFile
(
logFile
);
g
etRollingPolicy
(
appender
,
config
,
logFile
);
g
etMaxFileSize
(
appender
,
config
);
s
etRollingPolicy
(
appender
,
config
,
logFile
);
s
etMaxFileSize
(
appender
,
config
);
config
.
appender
(
"FILE"
,
appender
);
return
appender
;
}
private
void
g
etRollingPolicy
(
RollingFileAppender
<
ILoggingEvent
>
appender
,
private
void
s
etRollingPolicy
(
RollingFileAppender
<
ILoggingEvent
>
appender
,
LogbackConfigurator
config
,
String
logFile
)
{
FixedWindowRollingPolicy
rollingPolicy
=
new
FixedWindowRollingPolicy
();
rollingPolicy
.
setFileNamePattern
(
logFile
+
".%i"
);
...
...
@@ -146,7 +147,7 @@ class DefaultLogbackConfiguration {
config
.
start
(
rollingPolicy
);
}
private
void
g
etMaxFileSize
(
RollingFileAppender
<
ILoggingEvent
>
appender
,
private
void
s
etMaxFileSize
(
RollingFileAppender
<
ILoggingEvent
>
appender
,
LogbackConfigurator
config
)
{
SizeBasedTriggeringPolicy
<
ILoggingEvent
>
triggeringPolicy
=
new
SizeBasedTriggeringPolicy
<
ILoggingEvent
>();
try
{
...
...
spring-boot/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringPhysicalNamingStrategy.java
View file @
6e02fe59
...
...
@@ -77,7 +77,7 @@ public class SpringPhysicalNamingStrategy implements PhysicalNamingStrategy {
}
/**
* Get an the identifier for the specified details. By default his method will return
* Get an the identifier for the specified details. By default
t
his method will return
* an identifier with the name adapted based on the result of
* {@link #isCaseInsensitive(JdbcEnvironment)}
* @param name the name of the identifier
...
...
@@ -95,7 +95,7 @@ public class SpringPhysicalNamingStrategy implements PhysicalNamingStrategy {
/**
* Specify whether the database is case sensitive.
* @param jdbcEnvironment
T
he JDBC environment which can be used to determine case
* @param jdbcEnvironment
t
he JDBC environment which can be used to determine case
* @return true if the database is case insensitive sensitivity
*/
protected
boolean
isCaseInsensitive
(
JdbcEnvironment
jdbcEnvironment
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/web/support/SpringBootServletInitializer.java
View file @
6e02fe59
...
...
@@ -163,7 +163,7 @@ public abstract class SpringBootServletInitializer implements WebApplicationInit
}
/**
* Configure the application. Normally all you would need to do is add sources (e.g.
* Configure the application. Normally all you would need to do is
to
add sources (e.g.
* config classes) because other settings have sensible defaults. You might choose
* (for instance) to add default command line arguments, or set an active Spring
* profile.
...
...
spring-boot/src/test/java/org/springframework/boot/logging/LoggingApplicationListenerTests.java
View file @
6e02fe59
...
...
@@ -167,7 +167,7 @@ public class LoggingApplicationListenerTests {
@Test
public
void
tomcatNopLoggingConfigDoesNotCauseAFailure
()
throws
Exception
{
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
context
,
"
logging.config
: -Dnop"
);
"
LOGGING_CONFIG
: -Dnop"
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
this
.
logger
.
info
(
"Hello world"
);
...
...
@@ -469,6 +469,16 @@ public class LoggingApplicationListenerTests {
assertThat
(
System
.
getProperty
(
"PID"
)).
isNotNull
();
}
@Test
public
void
environmentPropertiesIgnoreUnresolvablePlaceholders
()
{
// gh-7719
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
context
,
"logging.pattern.console=console ${pid}"
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
assertThat
(
System
.
getProperty
(
"CONSOLE_LOG_PATTERN"
)).
isEqualTo
(
"console ${pid}"
);
}
@Test
public
void
logFilePropertiesCanReferenceSystemProperties
()
{
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
context
,
...
...
spring-boot/src/test/java/org/springframework/boot/yaml/SpringProfileDocumentMatcherTests.java
View file @
6e02fe59
...
...
@@ -67,8 +67,7 @@ public class SpringProfileDocumentMatcherTests {
@Test
public
void
matchesCommaSeparatedArray
()
throws
IOException
{
DocumentMatcher
matcher
=
new
SpringProfileDocumentMatcher
(
"foo"
,
"bar"
);
Properties
properties
=
getProperties
(
String
.
format
(
"spring.profiles: [bar, spam]"
));
Properties
properties
=
getProperties
(
"spring.profiles: [bar, spam]"
);
assertThat
(
matcher
.
matches
(
properties
)).
isEqualTo
(
MatchStatus
.
FOUND
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment