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
ac54d7fe
Commit
ac54d7fe
authored
Jan 21, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final polish before 1.0.0.RC1
parent
853b0a80
Changes
67
Show whitespace changes
Inline
Side-by-side
Showing
67 changed files
with
390 additions
and
218 deletions
+390
-218
EndpointWebMvcChildContextConfiguration.java
...utoconfigure/EndpointWebMvcChildContextConfiguration.java
+2
-1
MetricRepositoryAutoConfiguration.java
...uate/autoconfigure/MetricRepositoryAutoConfiguration.java
+2
-4
AbstractEndpoint.java
...ringframework/boot/actuate/endpoint/AbstractEndpoint.java
+1
-2
TraceEndpoint.java
.../springframework/boot/actuate/endpoint/TraceEndpoint.java
+1
-2
EndpointMBeanExporter.java
...work/boot/actuate/endpoint/jmx/EndpointMBeanExporter.java
+1
-3
EndpointHandlerMapping.java
...ork/boot/actuate/endpoint/mvc/EndpointHandlerMapping.java
+1
-2
EndpointMvcAdapter.java
...amework/boot/actuate/endpoint/mvc/EndpointMvcAdapter.java
+15
-9
EnvironmentMvcEndpoint.java
...ork/boot/actuate/endpoint/mvc/EnvironmentMvcEndpoint.java
+4
-2
JolokiaMvcEndpoint.java
...amework/boot/actuate/endpoint/mvc/JolokiaMvcEndpoint.java
+4
-4
ManagementErrorEndpoint.java
...rk/boot/actuate/endpoint/mvc/ManagementErrorEndpoint.java
+12
-7
MetricsMvcEndpoint.java
...amework/boot/actuate/endpoint/mvc/MetricsMvcEndpoint.java
+5
-3
MvcEndpoint.java
...pringframework/boot/actuate/endpoint/mvc/MvcEndpoint.java
+15
-3
MvcEndpoints.java
...ringframework/boot/actuate/endpoint/mvc/MvcEndpoints.java
+3
-3
ShutdownMvcEndpoint.java
...mework/boot/actuate/endpoint/mvc/ShutdownMvcEndpoint.java
+4
-2
VanillaHealthIndicator.java
...framework/boot/actuate/health/VanillaHealthIndicator.java
+2
-2
AbstractMetricExporter.java
...k/boot/actuate/metrics/export/AbstractMetricExporter.java
+2
-7
InMemoryMetricRepository.java
.../actuate/metrics/repository/InMemoryMetricRepository.java
+2
-1
RedisMultiMetricRepository.java
.../metrics/repository/redis/RedisMultiMetricRepository.java
+1
-1
RedisUtils.java
...ork/boot/actuate/metrics/repository/redis/RedisUtils.java
+18
-0
RichGauge.java
.../springframework/boot/actuate/metrics/rich/RichGauge.java
+16
-0
CodahaleMetricWriter.java
...ork/boot/actuate/metrics/writer/CodahaleMetricWriter.java
+11
-6
DefaultCounterService.java
...rk/boot/actuate/metrics/writer/DefaultCounterService.java
+2
-4
DefaultGaugeService.java
...work/boot/actuate/metrics/writer/DefaultGaugeService.java
+2
-4
ManagementServerProperties.java
...k/boot/actuate/properties/ManagementServerProperties.java
+6
-6
ErrorController.java
...org/springframework/boot/actuate/web/ErrorController.java
+1
-2
EndpointWebMvcAutoConfigurationTests.java
...e/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
+2
-1
EndpointHandlerMappingTests.java
...oot/actuate/endpoint/mvc/EndpointHandlerMappingTests.java
+3
-3
RedisServer.java
...rk/boot/actuate/metrics/repository/redis/RedisServer.java
+7
-7
AutoConfigurationReportLoggingInitializer.java
...oconfigure/AutoConfigurationReportLoggingInitializer.java
+0
-1
EnableAutoConfiguration.java
...framework/boot/autoconfigure/EnableAutoConfiguration.java
+0
-3
BasicBatchConfigurer.java
...mework/boot/autoconfigure/batch/BasicBatchConfigurer.java
+15
-0
BatchDatabaseInitializer.java
...rk/boot/autoconfigure/batch/BatchDatabaseInitializer.java
+3
-2
OnBeanCondition.java
...amework/boot/autoconfigure/condition/OnBeanCondition.java
+17
-7
OnWebApplicationCondition.java
...ot/autoconfigure/condition/OnWebApplicationCondition.java
+3
-2
DataSourceAutoConfiguration.java
.../boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java
+19
-3
JmsTemplateAutoConfiguration.java
.../boot/autoconfigure/jms/JmsTemplateAutoConfiguration.java
+3
-7
JmxAutoConfiguration.java
...ramework/boot/autoconfigure/jmx/JmxAutoConfiguration.java
+1
-2
ReactorAutoConfiguration.java
.../boot/autoconfigure/reactor/ReactorAutoConfiguration.java
+1
-2
AuthenticationManagerConfiguration.java
...onfigure/security/AuthenticationManagerConfiguration.java
+6
-1
SecurityAutoConfiguration.java
...oot/autoconfigure/security/SecurityAutoConfiguration.java
+7
-1
SpringBootWebSecurityConfiguration.java
...onfigure/security/SpringBootWebSecurityConfiguration.java
+35
-34
CommandLineInvoker.java
...framework/boot/cli/infrastructure/CommandLineInvoker.java
+1
-1
CommandCompleter.java
...ingframework/boot/cli/command/shell/CommandCompleter.java
+5
-2
EscapeAwareWhiteSpaceArgumentDelimiter.java
...command/shell/EscapeAwareWhiteSpaceArgumentDelimiter.java
+1
-1
RunProcessCommand.java
...ngframework/boot/cli/command/shell/RunProcessCommand.java
+2
-2
GroovyCompiler.java
...org/springframework/boot/cli/compiler/GroovyCompiler.java
+1
-2
RepositoryConfigurationFactory.java
...ork/boot/cli/compiler/RepositoryConfigurationFactory.java
+1
-2
JreProxySelector.java
...ngframework/boot/cli/compiler/grape/JreProxySelector.java
+4
-4
ManagedDependenciesFactory.java
...k/boot/cli/compiler/grape/ManagedDependenciesFactory.java
+4
-0
RepositoryConfiguration.java
...work/boot/cli/compiler/grape/RepositoryConfiguration.java
+1
-2
GroovyBeansTransformation.java
...li/compiler/transformation/GroovyBeansTransformation.java
+1
-4
EnableDeviceResolver.java
...org/springframework/boot/groovy/EnableDeviceResolver.java
+7
-2
EnableIntegrationPatterns.java
...pringframework/boot/groovy/EnableIntegrationPatterns.java
+6
-2
EnableJmsMessaging.java
...a/org/springframework/boot/groovy/EnableJmsMessaging.java
+7
-2
GroovyTemplate.java
.../java/org/springframework/boot/groovy/GroovyTemplate.java
+3
-1
SampleMongoApplicationTests.java
...t/java/sample/data/mongo/SampleMongoApplicationTests.java
+2
-2
SpringBootPluginExtension.groovy
...ingframework/boot/gradle/SpringBootPluginExtension.groovy
+6
-6
ProjectLibraries.java
...rg/springframework/boot/gradle/task/ProjectLibraries.java
+16
-3
RunApp.java
...n/groovy/org/springframework/boot/gradle/task/RunApp.java
+2
-2
PropertiesLauncher.java
...a/org/springframework/boot/loader/PropertiesLauncher.java
+1
-3
FilteredArchive.java
.../springframework/boot/loader/archive/FilteredArchive.java
+4
-1
SystemPropertyUtils.java
...springframework/boot/loader/util/SystemPropertyUtils.java
+10
-8
SimpleJsonParser.java
...ava/org/springframework/boot/config/SimpleJsonParser.java
+3
-3
JettyEmbeddedServletContainer.java
...context/embedded/jetty/JettyEmbeddedServletContainer.java
+2
-2
TomcatEmbeddedWebappClassLoader.java
...text/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java
+3
-3
package-info.java
...main/java/org/springframework/boot/test/package-info.java
+23
-0
EnableConfigurationPropertiesTests.java
...ontext/properties/EnableConfigurationPropertiesTests.java
+19
-2
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcChildContextConfiguration.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -53,6 +53,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
...
@@ -53,6 +53,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
* Configuration triggered from {@link EndpointWebMvcAutoConfiguration} when a new
* Configuration triggered from {@link EndpointWebMvcAutoConfiguration} when a new
* {@link EmbeddedServletContainer} running on a different port is required.
* {@link EmbeddedServletContainer} running on a different port is required.
*
*
* @author Dave Syer
* @see EndpointWebMvcAutoConfiguration
* @see EndpointWebMvcAutoConfiguration
*/
*/
@Configuration
@Configuration
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricRepositoryAutoConfiguration.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -48,11 +48,9 @@ import org.springframework.messaging.support.ExecutorSubscribableChannel;
...
@@ -48,11 +48,9 @@ import org.springframework.messaging.support.ExecutorSubscribableChannel;
import
com.codahale.metrics.MetricRegistry
;
import
com.codahale.metrics.MetricRegistry
;
/**
/**
* <p>
* {@link EnableAutoConfiguration Auto-configuration} for metrics services. Creates
* {@link EnableAutoConfiguration Auto-configuration} for metrics services. Creates
* user-facing {@link GaugeService} and {@link CounterService} instances, and also back
* user-facing {@link GaugeService} and {@link CounterService} instances, and also back
* end repositories to catch the data pumped into them.
* end repositories to catch the data pumped into them. </p>
* </p>
* <p>
* <p>
* An {@link InMemoryMetricRepository} is always created unless another
* An {@link InMemoryMetricRepository} is always created unless another
* {@link MetricRepository} is already provided by the user. In general, even if metric
* {@link MetricRepository} is already provided by the user. In general, even if metric
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AbstractEndpoint.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -21,7 +21,6 @@ import javax.validation.constraints.Pattern;
...
@@ -21,7 +21,6 @@ import javax.validation.constraints.Pattern;
/**
/**
* Abstract base for {@link Endpoint} implementations.
* Abstract base for {@link Endpoint} implementations.
* <p>
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Christian Dupuis
* @author Christian Dupuis
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/TraceEndpoint.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -35,7 +35,6 @@ public class TraceEndpoint extends AbstractEndpoint<List<Trace>> {
...
@@ -35,7 +35,6 @@ public class TraceEndpoint extends AbstractEndpoint<List<Trace>> {
/**
/**
* Create a new {@link TraceEndpoint} instance.
* Create a new {@link TraceEndpoint} instance.
*
* @param repository the trace repository
* @param repository the trace repository
*/
*/
public
TraceEndpoint
(
TraceRepository
repository
)
{
public
TraceEndpoint
(
TraceRepository
repository
)
{
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanExporter.java
View file @
ac54d7fe
/*
/*
* Copyright 2013 the original author or authors.
* Copyright 2013
-2014
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -184,8 +184,6 @@ public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecyc
...
@@ -184,8 +184,6 @@ public class EndpointMBeanExporter extends MBeanExporter implements SmartLifecyc
return
builder
.
toString
();
return
builder
.
toString
();
}
}
// SmartLifeCycle implementation
@Override
@Override
public
final
int
getPhase
()
{
public
final
int
getPhase
()
{
return
this
.
phase
;
return
this
.
phase
;
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMapping.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -46,7 +46,6 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
...
@@ -46,7 +46,6 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
* @author Phillip Webb
* @author Phillip Webb
* @author Christian Dupuis
* @author Christian Dupuis
* @author Dave Syer
* @author Dave Syer
*
*/
*/
public
class
EndpointHandlerMapping
extends
RequestMappingHandlerMapping
implements
public
class
EndpointHandlerMapping
extends
RequestMappingHandlerMapping
implements
ApplicationContextAware
{
ApplicationContextAware
{
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/
GenericMvcEndpoint
.java
→
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/
EndpointMvcAdapter
.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -17,18 +17,26 @@
...
@@ -17,18 +17,26 @@
package
org
.
springframework
.
boot
.
actuate
.
endpoint
.
mvc
;
package
org
.
springframework
.
boot
.
actuate
.
endpoint
.
mvc
;
import
org.springframework.boot.actuate.endpoint.Endpoint
;
import
org.springframework.boot.actuate.endpoint.Endpoint
;
import
org.springframework.util.Assert
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
/**
/**
* Adapter class to expose {@link Endpoint}s as {@link MvcEndpoint}s.
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
class
GenericMvcEndpoint
implements
MvcEndpoint
{
public
class
EndpointMvcAdapter
implements
MvcEndpoint
{
private
Endpoint
<?>
delegate
;
private
final
Endpoint
<?>
delegate
;
public
GenericMvcEndpoint
(
Endpoint
<?>
delegate
)
{
/**
* Create a new {@link EndpointMvcAdapter}.
* @param delegate the underlying {@link Endpoint} to adapt.
*/
public
EndpointMvcAdapter
(
Endpoint
<?>
delegate
)
{
Assert
.
notNull
(
delegate
,
"Delegate must not be null"
);
this
.
delegate
=
delegate
;
this
.
delegate
=
delegate
;
}
}
...
@@ -49,11 +57,9 @@ public class GenericMvcEndpoint implements MvcEndpoint {
...
@@ -49,11 +57,9 @@ public class GenericMvcEndpoint implements MvcEndpoint {
}
}
@Override
@Override
public
Class
<?>
getEndpointType
()
{
@SuppressWarnings
(
"rawtypes"
)
@SuppressWarnings
(
"unchecked"
)
public
Class
<?
extends
Endpoint
>
getEndpointType
()
{
Class
<?
extends
Endpoint
<?>>
type
=
(
Class
<?
extends
Endpoint
<?>>)
this
.
delegate
return
this
.
delegate
.
getClass
();
.
getClass
();
return
type
;
}
}
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpoint.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -27,9 +27,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
...
@@ -27,9 +27,11 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
/**
/**
* Adapter to expose {@link EnvironmentEndpoint} as an {@link MvcEndpoint}.
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
class
EnvironmentMvcEndpoint
extends
GenericMvcEndpoint
implements
public
class
EnvironmentMvcEndpoint
extends
EndpointMvcAdapter
implements
EnvironmentAware
{
EnvironmentAware
{
private
Environment
environment
;
private
Environment
environment
;
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaMvcEndpoint.java
View file @
ac54d7fe
/*
/*
* Copyright 2013 the original author or authors.
* Copyright 2013
-2014
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -38,8 +38,7 @@ import org.springframework.web.servlet.ModelAndView;
...
@@ -38,8 +38,7 @@ import org.springframework.web.servlet.ModelAndView;
import
org.springframework.web.servlet.mvc.ServletWrappingController
;
import
org.springframework.web.servlet.mvc.ServletWrappingController
;
/**
/**
* {@link Endpoint} implementation to register the Jolokia infrastructure with the Boot
* {@link MvcEndpoint} to expose Jolokia.
* management subsystem.
*
*
* @author Christian Dupuis
* @author Christian Dupuis
*/
*/
...
@@ -110,7 +109,8 @@ public class JolokiaMvcEndpoint implements MvcEndpoint, InitializingBean,
...
@@ -110,7 +109,8 @@ public class JolokiaMvcEndpoint implements MvcEndpoint, InitializingBean,
}
}
@Override
@Override
public
Class
<?>
getEndpointType
()
{
@SuppressWarnings
(
"rawtypes"
)
public
Class
<?
extends
Endpoint
>
getEndpointType
()
{
return
null
;
return
null
;
}
}
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ManagementErrorEndpoint.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -18,17 +18,19 @@ package org.springframework.boot.actuate.endpoint.mvc;
...
@@ -18,17 +18,19 @@ package org.springframework.boot.actuate.endpoint.mvc;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.boot.actuate.endpoint.Endpoint
;
import
org.springframework.boot.actuate.web.ErrorController
;
import
org.springframework.boot.actuate.web.ErrorController
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.util.Assert
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.context.request.RequestAttributes
;
import
org.springframework.web.context.request.RequestAttributes
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.RequestContextHolder
;
/**
/**
* Special
endpoint for handling "/error" path when the management servlet is in a child
* Special
{@link MvcEndpoint} for handling "/error" path when the management servlet is
*
context. The regular {@link ErrorController} should be available there but because of
*
in a child context. The regular {@link ErrorController} should be available there but
* the way the handler mappings are set up it will not be detected.
*
because of
the way the handler mappings are set up it will not be detected.
*
*
* @author Dave Syer
* @author Dave Syer
*/
*/
...
@@ -36,9 +38,11 @@ import org.springframework.web.context.request.RequestContextHolder;
...
@@ -36,9 +38,11 @@ import org.springframework.web.context.request.RequestContextHolder;
public
class
ManagementErrorEndpoint
implements
MvcEndpoint
{
public
class
ManagementErrorEndpoint
implements
MvcEndpoint
{
private
final
ErrorController
controller
;
private
final
ErrorController
controller
;
private
String
path
;
private
final
String
path
;
public
ManagementErrorEndpoint
(
String
path
,
ErrorController
controller
)
{
public
ManagementErrorEndpoint
(
String
path
,
ErrorController
controller
)
{
Assert
.
notNull
(
controller
,
"Controller must not be null"
);
this
.
path
=
path
;
this
.
path
=
path
;
this
.
controller
=
controller
;
this
.
controller
=
controller
;
}
}
...
@@ -61,7 +65,8 @@ public class ManagementErrorEndpoint implements MvcEndpoint {
...
@@ -61,7 +65,8 @@ public class ManagementErrorEndpoint implements MvcEndpoint {
}
}
@Override
@Override
public
Class
<?>
getEndpointType
()
{
@SuppressWarnings
(
"rawtypes"
)
public
Class
<?
extends
Endpoint
>
getEndpointType
()
{
return
null
;
return
null
;
}
}
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/MetricsMvcEndpoint.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -25,11 +25,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
...
@@ -25,11 +25,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
/**
/**
* Adapter to expose {@link MetricsEndpoint} as an {@link MvcEndpoint}.
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
class
MetricsMvcEndpoint
extends
GenericMvcEndpoint
{
public
class
MetricsMvcEndpoint
extends
EndpointMvcAdapter
{
private
MetricsEndpoint
delegate
;
private
final
MetricsEndpoint
delegate
;
public
MetricsMvcEndpoint
(
MetricsEndpoint
delegate
)
{
public
MetricsMvcEndpoint
(
MetricsEndpoint
delegate
)
{
super
(
delegate
);
super
(
delegate
);
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpoint.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -29,10 +29,22 @@ import org.springframework.boot.actuate.endpoint.Endpoint;
...
@@ -29,10 +29,22 @@ import org.springframework.boot.actuate.endpoint.Endpoint;
*/
*/
public
interface
MvcEndpoint
{
public
interface
MvcEndpoint
{
/**
* Return the MVC path of the endpoint.
*/
String
getPath
();
String
getPath
();
/**
* Return if the endpoint exposes sensitive information.
*/
boolean
isSensitive
();
boolean
isSensitive
();
Class
<?>
getEndpointType
();
/**
* Return the type of {@link Endpoint} exposed, or {@code null} if this
* {@link MvcEndpoint} exposes information that cannot be represented as a traditional
* {@link Endpoint}.
*/
@SuppressWarnings
(
"rawtypes"
)
Class
<?
extends
Endpoint
>
getEndpointType
();
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpoints.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -60,7 +60,7 @@ public class MvcEndpoints implements ApplicationContextAware, InitializingBean {
...
@@ -60,7 +60,7 @@ public class MvcEndpoints implements ApplicationContextAware, InitializingBean {
Endpoint
.
class
).
values
();
Endpoint
.
class
).
values
();
for
(
Endpoint
<?>
endpoint
:
delegates
)
{
for
(
Endpoint
<?>
endpoint
:
delegates
)
{
if
(
isGenericEndpoint
(
endpoint
.
getClass
()))
{
if
(
isGenericEndpoint
(
endpoint
.
getClass
()))
{
this
.
endpoints
.
add
(
new
GenericMvcEndpoint
(
endpoint
));
this
.
endpoints
.
add
(
new
EndpointMvcAdapter
(
endpoint
));
}
}
}
}
}
}
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpoint.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -22,9 +22,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
...
@@ -22,9 +22,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
/**
/**
* Adapter to expose {@link ShutdownEndpoint} as an {@link MvcEndpoint}.
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
class
ShutdownMvcEndpoint
extends
GenericMvcEndpoint
{
public
class
ShutdownMvcEndpoint
extends
EndpointMvcAdapter
{
public
ShutdownMvcEndpoint
(
ShutdownEndpoint
delegate
)
{
public
ShutdownMvcEndpoint
(
ShutdownEndpoint
delegate
)
{
super
(
delegate
);
super
(
delegate
);
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/VanillaHealthIndicator.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
package
org
.
springframework
.
boot
.
actuate
.
health
;
package
org
.
springframework
.
boot
.
actuate
.
health
;
/**
/**
* Default implementation of {@link HealthIndicator} that simply returns
"ok"
.
* Default implementation of {@link HealthIndicator} that simply returns
{@literal "ok"}
.
*
*
* @author Dave Syer
* @author Dave Syer
*/
*/
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/export/AbstractMetricExporter.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -49,7 +49,6 @@ public abstract class AbstractMetricExporter implements Exporter {
...
@@ -49,7 +49,6 @@ public abstract class AbstractMetricExporter implements Exporter {
/**
/**
* The earliest time for which data will be exported.
* The earliest time for which data will be exported.
*
* @param earliestTimestamp the timestamp to set
* @param earliestTimestamp the timestamp to set
*/
*/
public
void
setEarliestTimestamp
(
Date
earliestTimestamp
)
{
public
void
setEarliestTimestamp
(
Date
earliestTimestamp
)
{
...
@@ -58,7 +57,6 @@ public abstract class AbstractMetricExporter implements Exporter {
...
@@ -58,7 +57,6 @@ public abstract class AbstractMetricExporter implements Exporter {
/**
/**
* Ignore timestamps (export all metrics).
* Ignore timestamps (export all metrics).
*
* @param ignoreTimestamps the flag to set
* @param ignoreTimestamps the flag to set
*/
*/
public
void
setIgnoreTimestamps
(
boolean
ignoreTimestamps
)
{
public
void
setIgnoreTimestamps
(
boolean
ignoreTimestamps
)
{
...
@@ -96,7 +94,6 @@ public abstract class AbstractMetricExporter implements Exporter {
...
@@ -96,7 +94,6 @@ public abstract class AbstractMetricExporter implements Exporter {
* prefixes). If the metrics to be exported partition into groups identified by a
* prefixes). If the metrics to be exported partition into groups identified by a
* String, subclasses should override this method. Otherwise the default should be
* String, subclasses should override this method. Otherwise the default should be
* fine (iteration over all metrics).
* fine (iteration over all metrics).
*
* @return groups of metrics to iterate over (default singleton empty string)
* @return groups of metrics to iterate over (default singleton empty string)
*/
*/
protected
Iterable
<
String
>
groups
()
{
protected
Iterable
<
String
>
groups
()
{
...
@@ -105,7 +102,6 @@ public abstract class AbstractMetricExporter implements Exporter {
...
@@ -105,7 +102,6 @@ public abstract class AbstractMetricExporter implements Exporter {
/**
/**
* Write the values associated with a group.
* Write the values associated with a group.
*
* @param group the group to write
* @param group the group to write
* @param values the values to write
* @param values the values to write
*/
*/
...
@@ -113,7 +109,6 @@ public abstract class AbstractMetricExporter implements Exporter {
...
@@ -113,7 +109,6 @@ public abstract class AbstractMetricExporter implements Exporter {
/**
/**
* Get the next group of metrics to write.
* Get the next group of metrics to write.
*
* @param group the group name to write
* @param group the group name to write
* @return some metrics to write
* @return some metrics to write
*/
*/
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/InMemoryMetricRepository.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -37,6 +37,7 @@ public class InMemoryMetricRepository implements MetricRepository, MultiMetricRe
...
@@ -37,6 +37,7 @@ public class InMemoryMetricRepository implements MetricRepository, MultiMetricRe
PrefixMetricReader
{
PrefixMetricReader
{
private
SimpleInMemoryRepository
<
Metric
<?>>
metrics
=
new
SimpleInMemoryRepository
<
Metric
<?>>();
private
SimpleInMemoryRepository
<
Metric
<?>>
metrics
=
new
SimpleInMemoryRepository
<
Metric
<?>>();
private
Collection
<
String
>
groups
=
new
HashSet
<
String
>();
private
Collection
<
String
>
groups
=
new
HashSet
<
String
>();
@Override
@Override
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/redis/RedisMultiMetricRepository.java
View file @
ac54d7fe
...
@@ -43,6 +43,7 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
...
@@ -43,6 +43,7 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
private
static
final
String
DEFAULT_METRICS_PREFIX
=
"spring.groups."
;
private
static
final
String
DEFAULT_METRICS_PREFIX
=
"spring.groups."
;
private
String
prefix
=
DEFAULT_METRICS_PREFIX
;
private
String
prefix
=
DEFAULT_METRICS_PREFIX
;
private
String
keys
=
this
.
prefix
+
"keys"
;
private
String
keys
=
this
.
prefix
+
"keys"
;
private
BoundZSetOperations
<
String
,
String
>
zSetOperations
;
private
BoundZSetOperations
<
String
,
String
>
zSetOperations
;
...
@@ -57,7 +58,6 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
...
@@ -57,7 +58,6 @@ public class RedisMultiMetricRepository implements MultiMetricRepository {
/**
/**
* The prefix for all metrics keys.
* The prefix for all metrics keys.
*
* @param prefix the prefix to set for all metrics keys
* @param prefix the prefix to set for all metrics keys
*/
*/
public
void
setPrefix
(
String
prefix
)
{
public
void
setPrefix
(
String
prefix
)
{
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/redis/RedisUtils.java
View file @
ac54d7fe
/*
* Copyright 2012-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
.
boot
.
actuate
.
metrics
.
repository
.
redis
;
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
repository
.
redis
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
import
org.springframework.data.redis.connection.RedisConnectionFactory
;
...
@@ -8,6 +24,8 @@ import org.springframework.data.redis.serializer.GenericToStringSerializer;
...
@@ -8,6 +24,8 @@ import org.springframework.data.redis.serializer.GenericToStringSerializer;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
import
org.springframework.data.redis.serializer.StringRedisSerializer
;
/**
/**
* General Utils for working with Redis.
*
* @author Luke Taylor
* @author Luke Taylor
*/
*/
class
RedisUtils
{
class
RedisUtils
{
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/rich/RichGauge.java
View file @
ac54d7fe
/*
* Copyright 2012-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
.
boot
.
actuate
.
metrics
.
rich
;
package
org
.
springframework
.
boot
.
actuate
.
metrics
.
rich
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/CodahaleMetricWriter.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -30,6 +30,7 @@ import com.codahale.metrics.Timer;
...
@@ -30,6 +30,7 @@ import com.codahale.metrics.Timer;
/**
/**
* A {@link MetricWriter} that send data to a Codahale {@link MetricRegistry} based on a
* A {@link MetricWriter} that send data to a Codahale {@link MetricRegistry} based on a
* naming convention:
* naming convention:
*
* <ul>
* <ul>
* <li>Updates to {@link #increment(Delta)} with names in "meter.*" are treated as
* <li>Updates to {@link #increment(Delta)} with names in "meter.*" are treated as
* {@link Meter} events</li>
* {@link Meter} events</li>
...
@@ -49,7 +50,8 @@ public class CodahaleMetricWriter implements MetricWriter {
...
@@ -49,7 +50,8 @@ public class CodahaleMetricWriter implements MetricWriter {
private
final
MetricRegistry
registry
;
private
final
MetricRegistry
registry
;
/**
/**
* @param registry
* Create a new {@link CodahaleMetricWriter} instance.
* @param registry the underlying metric registry
*/
*/
public
CodahaleMetricWriter
(
MetricRegistry
registry
)
{
public
CodahaleMetricWriter
(
MetricRegistry
registry
)
{
this
.
registry
=
registry
;
this
.
registry
=
registry
;
...
@@ -94,17 +96,20 @@ public class CodahaleMetricWriter implements MetricWriter {
...
@@ -94,17 +96,20 @@ public class CodahaleMetricWriter implements MetricWriter {
this
.
registry
.
remove
(
metricName
);
this
.
registry
.
remove
(
metricName
);
}
}
/**
* Simple {@link Gauge} implementation to {@literal double} value.
*/
private
static
class
SimpleGauge
implements
Gauge
<
Double
>
{
private
static
class
SimpleGauge
implements
Gauge
<
Double
>
{
private
final
double
gaug
e
;
private
final
double
valu
e
;
private
SimpleGauge
(
double
gaug
e
)
{
private
SimpleGauge
(
double
valu
e
)
{
this
.
gauge
=
gaug
e
;
this
.
value
=
valu
e
;
}
}
@Override
@Override
public
Double
getValue
()
{
public
Double
getValue
()
{
return
this
.
gaug
e
;
return
this
.
valu
e
;
}
}
}
}
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterService.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -54,9 +54,7 @@ public class DefaultCounterService implements CounterService {
...
@@ -54,9 +54,7 @@ public class DefaultCounterService implements CounterService {
if
(
metricName
.
startsWith
(
"counter"
)
||
metricName
.
startsWith
(
"meter"
))
{
if
(
metricName
.
startsWith
(
"counter"
)
||
metricName
.
startsWith
(
"meter"
))
{
return
metricName
;
return
metricName
;
}
}
else
{
return
"counter."
+
metricName
;
return
"counter."
+
metricName
;
}
}
}
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DefaultGaugeService.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -46,9 +46,7 @@ public class DefaultGaugeService implements GaugeService {
...
@@ -46,9 +46,7 @@ public class DefaultGaugeService implements GaugeService {
||
metricName
.
startsWith
(
"timer"
))
{
||
metricName
.
startsWith
(
"timer"
))
{
return
metricName
;
return
metricName
;
}
}
else
{
return
"gauge."
+
metricName
;
return
"gauge."
+
metricName
;
}
}
}
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/properties/ManagementServerProperties.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -81,6 +81,9 @@ public class ManagementServerProperties implements SecurityPrequisite {
...
@@ -81,6 +81,9 @@ public class ManagementServerProperties implements SecurityPrequisite {
return
this
.
security
;
return
this
.
security
;
}
}
/**
* Security configuration.
*/
public
static
class
Security
{
public
static
class
Security
{
private
boolean
enabled
=
true
;
private
boolean
enabled
=
true
;
...
@@ -116,11 +119,8 @@ public class ManagementServerProperties implements SecurityPrequisite {
...
@@ -116,11 +119,8 @@ public class ManagementServerProperties implements SecurityPrequisite {
}
}
private
static
Security
maybeCreateSecurity
()
{
private
static
Security
maybeCreateSecurity
()
{
if
(
ClassUtils
return
(
ClassUtils
.
isPresent
(
"org.springframework.security.core.Authentication"
,
.
isPresent
(
"org.springframework.security.core.Authentication"
,
null
))
{
null
)
?
new
Security
()
:
null
);
return
new
Security
();
}
return
null
;
}
}
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/ErrorController.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -36,7 +36,6 @@ public interface ErrorController {
...
@@ -36,7 +36,6 @@ public interface ErrorController {
/**
/**
* Extract a useful model of the error from the request attributes.
* Extract a useful model of the error from the request attributes.
*
* @param attributes the request attributes
* @param attributes the request attributes
* @param trace flag to indicate that stack trace information should be included
* @param trace flag to indicate that stack trace information should be included
* @return a model containing error messages and codes etc.
* @return a model containing error messages and codes etc.
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
View file @
ac54d7fe
...
@@ -260,7 +260,8 @@ public class EndpointWebMvcAutoConfigurationTests {
...
@@ -260,7 +260,8 @@ public class EndpointWebMvcAutoConfigurationTests {
}
}
@Override
@Override
public
Class
<?>
getEndpointType
()
{
@SuppressWarnings
(
"rawtypes"
)
public
Class
<?
extends
Endpoint
>
getEndpointType
()
{
return
Endpoint
.
class
;
return
Endpoint
.
class
;
}
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMappingTests.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -146,7 +146,7 @@ public class EndpointHandlerMappingTests {
...
@@ -146,7 +146,7 @@ public class EndpointHandlerMappingTests {
}
}
private
static
class
TestMvcEndpoint
extends
GenericMvcEndpoint
{
private
static
class
TestMvcEndpoint
extends
EndpointMvcAdapter
{
public
TestMvcEndpoint
(
TestEndpoint
delegate
)
{
public
TestMvcEndpoint
(
TestEndpoint
delegate
)
{
super
(
delegate
);
super
(
delegate
);
...
@@ -154,7 +154,7 @@ public class EndpointHandlerMappingTests {
...
@@ -154,7 +154,7 @@ public class EndpointHandlerMappingTests {
}
}
private
static
class
TestActionEndpoint
extends
GenericMvcEndpoint
{
private
static
class
TestActionEndpoint
extends
EndpointMvcAdapter
{
public
TestActionEndpoint
(
TestEndpoint
delegate
)
{
public
TestActionEndpoint
(
TestEndpoint
delegate
)
{
super
(
delegate
);
super
(
delegate
);
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/repository/redis/RedisServer.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -54,10 +54,9 @@ public class RedisServer implements TestRule {
...
@@ -54,10 +54,9 @@ public class RedisServer implements TestRule {
try
{
try
{
this
.
resource
=
obtainResource
();
this
.
resource
=
obtainResource
();
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
x
)
{
maybeCleanup
();
maybeCleanup
();
return
failOrSkip
(
ex
);
return
failOrSkip
(
e
);
}
}
return
new
Statement
()
{
return
new
Statement
()
{
...
@@ -82,17 +81,18 @@ public class RedisServer implements TestRule {
...
@@ -82,17 +81,18 @@ public class RedisServer implements TestRule {
};
};
}
}
private
Statement
failOrSkip
(
Exception
e
)
{
private
Statement
failOrSkip
(
Exception
e
xception
)
{
String
serversRequired
=
System
.
getenv
(
EXTERNAL_SERVERS_REQUIRED
);
String
serversRequired
=
System
.
getenv
(
EXTERNAL_SERVERS_REQUIRED
);
if
(
"true"
.
equalsIgnoreCase
(
serversRequired
))
{
if
(
"true"
.
equalsIgnoreCase
(
serversRequired
))
{
logger
.
error
(
this
.
resourceDescription
+
" IS REQUIRED BUT NOT AVAILABLE"
,
e
);
logger
.
error
(
this
.
resourceDescription
+
" IS REQUIRED BUT NOT AVAILABLE"
,
exception
);
fail
(
this
.
resourceDescription
+
" IS NOT AVAILABLE"
);
fail
(
this
.
resourceDescription
+
" IS NOT AVAILABLE"
);
// Never reached, here to satisfy method signature
// Never reached, here to satisfy method signature
return
null
;
return
null
;
}
}
else
{
else
{
logger
.
error
(
this
.
resourceDescription
+
" IS NOT AVAILABLE, SKIPPING TESTS"
,
logger
.
error
(
this
.
resourceDescription
+
" IS NOT AVAILABLE, SKIPPING TESTS"
,
e
);
e
xception
);
return
new
Statement
()
{
return
new
Statement
()
{
@Override
@Override
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationReportLoggingInitializer.java
View file @
ac54d7fe
...
@@ -40,7 +40,6 @@ import org.springframework.util.StringUtils;
...
@@ -40,7 +40,6 @@ import org.springframework.util.StringUtils;
* the {@link AutoConfigurationReport} to the log. Reports are logged at the
* the {@link AutoConfigurationReport} to the log. Reports are logged at the
* {@link LogLevel#DEBUG DEBUG} level unless there was a problem, in which case they are
* {@link LogLevel#DEBUG DEBUG} level unless there was a problem, in which case they are
* the {@link LogLevel#INFO INFO} level is used.
* the {@link LogLevel#INFO INFO} level is used.
*
* <p>
* <p>
* This initializer is not intended to be shared across multiple application context
* This initializer is not intended to be shared across multiple application context
* instances.
* instances.
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfiguration.java
View file @
ac54d7fe
...
@@ -39,20 +39,17 @@ import org.springframework.core.io.support.SpringFactoriesLoader;
...
@@ -39,20 +39,17 @@ import org.springframework.core.io.support.SpringFactoriesLoader;
* have {@code tomat-embedded.jar} on your classpath you are likely to want a
* have {@code tomat-embedded.jar} on your classpath you are likely to want a
* {@link TomcatEmbeddedServletContainerFactory} (unless you have defined your own
* {@link TomcatEmbeddedServletContainerFactory} (unless you have defined your own
* {@link EmbeddedServletContainerFactory} bean).
* {@link EmbeddedServletContainerFactory} bean).
*
* <p>
* <p>
* Auto-configuration tries to be as intelligent as possible and will back-away as you
* Auto-configuration tries to be as intelligent as possible and will back-away as you
* define more of your own configuration. You can always manually {@link #exclude()} any
* define more of your own configuration. You can always manually {@link #exclude()} any
* configuration that you never want to apply. Auto-configuration is always applied after
* configuration that you never want to apply. Auto-configuration is always applied after
* user-defined beans have been registered.
* user-defined beans have been registered.
*
* <p>
* <p>
* The package of the class that is annotated with {@code @EnableAutoConfiguration} has
* The package of the class that is annotated with {@code @EnableAutoConfiguration} has
* specific significance and is often used as a 'default'. For example, it will be used
* specific significance and is often used as a 'default'. For example, it will be used
* when scanning for {@code @Entity} classes. It is generally recommended that you place
* when scanning for {@code @Entity} classes. It is generally recommended that you place
* {@code @EnableAutoConfiguration} in a root package so that all sub-packages and classes
* {@code @EnableAutoConfiguration} in a root package so that all sub-packages and classes
* can be searched.
* can be searched.
*
* <p>
* <p>
* Auto-configuration classes are regular Spring {@link Configuration} beans. They are
* Auto-configuration classes are regular Spring {@link Configuration} beans. They are
* located using the {@link SpringFactoriesLoader} mechanism (keyed against this class).
* located using the {@link SpringFactoriesLoader} mechanism (keyed against this class).
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java
View file @
ac54d7fe
...
@@ -33,6 +33,8 @@ import org.springframework.stereotype.Component;
...
@@ -33,6 +33,8 @@ import org.springframework.stereotype.Component;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
/**
/**
* Basic {@link BatchConfigurer} implementation.
*
* @author Dave Syer
* @author Dave Syer
*/
*/
@Component
@Component
...
@@ -41,15 +43,28 @@ public class BasicBatchConfigurer implements BatchConfigurer {
...
@@ -41,15 +43,28 @@ public class BasicBatchConfigurer implements BatchConfigurer {
private
static
Log
logger
=
LogFactory
.
getLog
(
BasicBatchConfigurer
.
class
);
private
static
Log
logger
=
LogFactory
.
getLog
(
BasicBatchConfigurer
.
class
);
private
DataSource
dataSource
;
private
DataSource
dataSource
;
private
EntityManagerFactory
entityManagerFactory
;
private
EntityManagerFactory
entityManagerFactory
;
private
PlatformTransactionManager
transactionManager
;
private
PlatformTransactionManager
transactionManager
;
private
JobRepository
jobRepository
;
private
JobRepository
jobRepository
;
private
JobLauncher
jobLauncher
;
private
JobLauncher
jobLauncher
;
/**
* Create a new {@link BasicBatchConfigurer} instance.
* @param dataSource the underlying data source
*/
public
BasicBatchConfigurer
(
DataSource
dataSource
)
{
public
BasicBatchConfigurer
(
DataSource
dataSource
)
{
this
(
dataSource
,
null
);
this
(
dataSource
,
null
);
}
}
/**
* Create a new {@link BasicBatchConfigurer} instance.
* @param dataSource the underlying data source
* @param entityManagerFactory the entity manager factory (or {@code null})
*/
public
BasicBatchConfigurer
(
DataSource
dataSource
,
public
BasicBatchConfigurer
(
DataSource
dataSource
,
EntityManagerFactory
entityManagerFactory
)
{
EntityManagerFactory
entityManagerFactory
)
{
this
.
entityManagerFactory
=
entityManagerFactory
;
this
.
entityManagerFactory
=
entityManagerFactory
;
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchDatabaseInitializer.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -38,7 +38,8 @@ import org.springframework.stereotype.Component;
...
@@ -38,7 +38,8 @@ import org.springframework.stereotype.Component;
@Component
@Component
public
class
BatchDatabaseInitializer
implements
EnvironmentAware
{
public
class
BatchDatabaseInitializer
implements
EnvironmentAware
{
private
static
final
String
DEFAULT_SCHEMA_LOCATION
=
"classpath:org/springframework/batch/core/schema-@@platform@@.sql"
;
private
static
final
String
DEFAULT_SCHEMA_LOCATION
=
"classpath:org/springframework/"
+
"batch/core/schema-@@platform@@.sql"
;
@Autowired
@Autowired
private
DataSource
dataSource
;
private
DataSource
dataSource
;
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -198,16 +198,26 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
...
@@ -198,16 +198,26 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
if
(
this
.
types
.
isEmpty
()
&&
this
.
names
.
isEmpty
())
{
if
(
this
.
types
.
isEmpty
()
&&
this
.
names
.
isEmpty
())
{
addDeducedBeanType
(
context
,
metadata
,
this
.
types
);
addDeducedBeanType
(
context
,
metadata
,
this
.
types
);
}
}
Assert
.
isTrue
(
Assert
.
isTrue
(
hasAtLeastOne
(
this
.
types
,
this
.
names
,
this
.
annotations
),
!
this
.
types
.
isEmpty
()
||
!
this
.
names
.
isEmpty
()
annotationName
(
annotationType
)
+
" annotations must "
||
!
this
.
annotations
.
isEmpty
(),
+
"specify at least one bean (type, name or annotation)"
);
"@"
+
ClassUtils
.
getShortName
(
annotationType
)
+
" annotations must specify at least one bean (type, name or annotation)"
);
this
.
strategy
=
(
SearchStrategy
)
metadata
.
getAnnotationAttributes
(
this
.
strategy
=
(
SearchStrategy
)
metadata
.
getAnnotationAttributes
(
annotationType
.
getName
()).
get
(
"search"
);
annotationType
.
getName
()).
get
(
"search"
);
}
}
private
boolean
hasAtLeastOne
(
List
<?>...
lists
)
{
for
(
List
<?>
list
:
lists
)
{
if
(!
list
.
isEmpty
())
{
return
true
;
}
}
return
false
;
}
private
String
annotationName
(
Class
<?>
annotationType
)
{
return
"@"
+
ClassUtils
.
getShortName
(
annotationType
);
}
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
private
void
collect
(
MultiValueMap
<
String
,
Object
>
attributes
,
String
key
,
private
void
collect
(
MultiValueMap
<
String
,
Object
>
attributes
,
String
key
,
List
<
String
>
destination
)
{
List
<
String
>
destination
)
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnWebApplicationCondition.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -34,7 +34,8 @@ import org.springframework.web.context.support.StandardServletEnvironment;
...
@@ -34,7 +34,8 @@ import org.springframework.web.context.support.StandardServletEnvironment;
*/
*/
class
OnWebApplicationCondition
extends
SpringBootCondition
{
class
OnWebApplicationCondition
extends
SpringBootCondition
{
private
static
final
String
WEB_CONTEXT_CLASS
=
"org.springframework.web.context.support.GenericWebApplicationContext"
;
private
static
final
String
WEB_CONTEXT_CLASS
=
"org.springframework.web.context."
+
"support.GenericWebApplicationContext"
;
@Override
@Override
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -31,9 +31,9 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -31,9 +31,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.config.BeanDefinition
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.beans.factory.config.ConfigurableListableBeanFactory
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionOutcome
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionOutcome
;
import
org.springframework.boot.autoconfigure.condition.SpringBootCondition
;
import
org.springframework.boot.autoconfigure.condition.SpringBootCondition
;
import
org.springframework.boot.bind.RelaxedPropertyResolver
;
import
org.springframework.boot.bind.RelaxedPropertyResolver
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
...
@@ -177,6 +177,9 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
...
@@ -177,6 +177,9 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
}
}
/**
* Base {@link Condition} for non-embedded database checks.
*/
static
abstract
class
NonEmbeddedDatabaseCondition
extends
SpringBootCondition
{
static
abstract
class
NonEmbeddedDatabaseCondition
extends
SpringBootCondition
{
protected
abstract
String
getDataSourceClassName
();
protected
abstract
String
getDataSourceClassName
();
...
@@ -243,6 +246,10 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
...
@@ -243,6 +246,10 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
}
}
}
}
/**
* {@link Condition} to detect when a commons-dbcp {@code BasicDataSource} backed
* database is used.
*/
static
class
BasicDatabaseCondition
extends
NonEmbeddedDatabaseCondition
{
static
class
BasicDatabaseCondition
extends
NonEmbeddedDatabaseCondition
{
private
Condition
tomcatCondition
=
new
TomcatDatabaseCondition
();
private
Condition
tomcatCondition
=
new
TomcatDatabaseCondition
();
...
@@ -256,12 +263,15 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
...
@@ -256,12 +263,15 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
AnnotatedTypeMetadata
metadata
)
{
if
(
matches
(
context
,
metadata
,
this
.
tomcatCondition
))
{
if
(
matches
(
context
,
metadata
,
this
.
tomcatCondition
))
{
return
ConditionOutcome
.
noMatch
(
"
t
omcat DataSource"
);
return
ConditionOutcome
.
noMatch
(
"
T
omcat DataSource"
);
}
}
return
super
.
getMatchOutcome
(
context
,
metadata
);
return
super
.
getMatchOutcome
(
context
,
metadata
);
}
}
}
}
/**
* {@link Condition} to detect when a Tomcat DataSource backed database is used.
*/
static
class
TomcatDatabaseCondition
extends
NonEmbeddedDatabaseCondition
{
static
class
TomcatDatabaseCondition
extends
NonEmbeddedDatabaseCondition
{
@Override
@Override
...
@@ -271,6 +281,9 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
...
@@ -271,6 +281,9 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
}
}
/**
* {@link Condition} to detect when an embedded database is used.
*/
static
class
EmbeddedDatabaseCondition
extends
SpringBootCondition
{
static
class
EmbeddedDatabaseCondition
extends
SpringBootCondition
{
private
SpringBootCondition
tomcatCondition
=
new
TomcatDatabaseCondition
();
private
SpringBootCondition
tomcatCondition
=
new
TomcatDatabaseCondition
();
...
@@ -293,6 +306,9 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
...
@@ -293,6 +306,9 @@ public class DataSourceAutoConfiguration implements EnvironmentAware {
}
}
}
}
/**
* {@link Condition} to detect when a database is configured.
*/
static
class
DatabaseCondition
extends
SpringBootCondition
{
static
class
DatabaseCondition
extends
SpringBootCondition
{
private
SpringBootCondition
tomcatCondition
=
new
TomcatDatabaseCondition
();
private
SpringBootCondition
tomcatCondition
=
new
TomcatDatabaseCondition
();
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsTemplateAutoConfiguration.java
View file @
ac54d7fe
...
@@ -80,17 +80,15 @@ public class JmsTemplateAutoConfiguration {
...
@@ -80,17 +80,15 @@ public class JmsTemplateAutoConfiguration {
private
ActiveMQConnectionFactoryProperties
config
;
private
ActiveMQConnectionFactoryProperties
config
;
@Bean
@Bean
ConnectionFactory
jmsConnectionFactory
()
{
public
ConnectionFactory
jmsConnectionFactory
()
{
if
(
this
.
config
.
isPooled
())
{
if
(
this
.
config
.
isPooled
())
{
PooledConnectionFactory
pool
=
new
PooledConnectionFactory
();
PooledConnectionFactory
pool
=
new
PooledConnectionFactory
();
pool
.
setConnectionFactory
(
new
ActiveMQConnectionFactory
(
this
.
config
pool
.
setConnectionFactory
(
new
ActiveMQConnectionFactory
(
this
.
config
.
getBrokerURL
()));
.
getBrokerURL
()));
return
pool
;
return
pool
;
}
}
else
{
return
new
ActiveMQConnectionFactory
(
this
.
config
.
getBrokerURL
());
return
new
ActiveMQConnectionFactory
(
this
.
config
.
getBrokerURL
());
}
}
}
}
}
...
@@ -108,10 +106,8 @@ public class JmsTemplateAutoConfiguration {
...
@@ -108,10 +106,8 @@ public class JmsTemplateAutoConfiguration {
if
(
this
.
inMemory
)
{
if
(
this
.
inMemory
)
{
return
"vm://localhost"
;
return
"vm://localhost"
;
}
}
else
{
return
this
.
brokerURL
;
return
this
.
brokerURL
;
}
}
}
public
void
setBrokerURL
(
String
brokerURL
)
{
public
void
setBrokerURL
(
String
brokerURL
)
{
this
.
brokerURL
=
brokerURL
;
this
.
brokerURL
=
brokerURL
;
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java
View file @
ac54d7fe
/*
/*
* Copyright 201
3
the original author or authors.
* Copyright 201
2-2014
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -27,7 +27,6 @@ import org.springframework.jmx.export.MBeanExporter;
...
@@ -27,7 +27,6 @@ import org.springframework.jmx.export.MBeanExporter;
/**
/**
* {@link EnableAutoConfiguration Auto-configuration} to enable/disable Spring's
* {@link EnableAutoConfiguration Auto-configuration} to enable/disable Spring's
* {@link EnableMBeanExport} mechanism based on configuration properties.
* {@link EnableMBeanExport} mechanism based on configuration properties.
*
* <p>
* <p>
* To disable auto export of annotation beans set <code>spring.jmx.enabled: false</code>.
* To disable auto export of annotation beans set <code>spring.jmx.enabled: false</code>.
*
*
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/reactor/ReactorAutoConfiguration.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -48,7 +48,6 @@ public class ReactorAutoConfiguration {
...
@@ -48,7 +48,6 @@ public class ReactorAutoConfiguration {
@ConditionalOnMissingBean
(
Environment
.
class
)
@ConditionalOnMissingBean
(
Environment
.
class
)
@EnableReactor
@EnableReactor
protected
static
class
ReactorConfiguration
{
protected
static
class
ReactorConfiguration
{
}
}
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/AuthenticationManagerConfiguration.java
View file @
ac54d7fe
...
@@ -33,6 +33,11 @@ import org.springframework.security.config.annotation.ObjectPostProcessor;
...
@@ -33,6 +33,11 @@ import org.springframework.security.config.annotation.ObjectPostProcessor;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.authentication.configurers.provisioning.InMemoryUserDetailsManagerConfigurer
;
import
org.springframework.security.config.annotation.authentication.configurers.provisioning.InMemoryUserDetailsManagerConfigurer
;
/**
* Configuration for a Spring Security in-memory {@link AuthenticationManager}.
*
* @author Dave Syer
*/
@Configuration
@Configuration
@ConditionalOnBean
(
ObjectPostProcessor
.
class
)
@ConditionalOnBean
(
ObjectPostProcessor
.
class
)
@ConditionalOnMissingBean
(
AuthenticationManager
.
class
)
@ConditionalOnMissingBean
(
AuthenticationManager
.
class
)
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfiguration.java
View file @
ac54d7fe
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
security
;
package
org
.
springframework
.
boot
.
autoconfigure
.
security
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
...
@@ -24,6 +25,11 @@ import org.springframework.context.annotation.Configuration;
...
@@ -24,6 +25,11 @@ import org.springframework.context.annotation.Configuration;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.security.authentication.AuthenticationManager
;
import
org.springframework.security.authentication.AuthenticationManager
;
/**
* {@link EnableAutoConfiguration Auto-configuration} for Spring Security.
*
* @author Dave Syer
*/
@Configuration
@Configuration
@ConditionalOnClass
(
AuthenticationManager
.
class
)
@ConditionalOnClass
(
AuthenticationManager
.
class
)
@EnableConfigurationProperties
@EnableConfigurationProperties
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SpringBootWebSecurityConfiguration.java
View file @
ac54d7fe
...
@@ -87,7 +87,6 @@ import org.springframework.web.servlet.support.RequestDataValueProcessor;
...
@@ -87,7 +87,6 @@ import org.springframework.web.servlet.support.RequestDataValueProcessor;
@ConditionalOnClass
({
EnableWebSecurity
.
class
})
@ConditionalOnClass
({
EnableWebSecurity
.
class
})
@ConditionalOnMissingBean
(
WebSecurityConfiguration
.
class
)
@ConditionalOnMissingBean
(
WebSecurityConfiguration
.
class
)
@ConditionalOnWebApplication
@ConditionalOnWebApplication
// @ConditionalOnMissingBean(annotation = EnableWebSecurity.class)
public
class
SpringBootWebSecurityConfiguration
{
public
class
SpringBootWebSecurityConfiguration
{
private
static
List
<
String
>
DEFAULT_IGNORED
=
Arrays
.
asList
(
"/css/**"
,
"/js/**"
,
private
static
List
<
String
>
DEFAULT_IGNORED
=
Arrays
.
asList
(
"/css/**"
,
"/js/**"
,
...
@@ -107,6 +106,39 @@ public class SpringBootWebSecurityConfiguration {
...
@@ -107,6 +106,39 @@ public class SpringBootWebSecurityConfiguration {
return
new
IgnoredPathsWebSecurityConfigurerAdapter
();
return
new
IgnoredPathsWebSecurityConfigurerAdapter
();
}
}
public
static
void
configureHeaders
(
HeadersConfigurer
<?>
configurer
,
SecurityProperties
.
Headers
headers
)
throws
Exception
{
if
(
headers
.
getHsts
()
!=
Headers
.
HSTS
.
none
)
{
boolean
includeSubdomains
=
headers
.
getHsts
()
==
Headers
.
HSTS
.
all
;
HstsHeaderWriter
writer
=
new
HstsHeaderWriter
(
includeSubdomains
);
writer
.
setRequestMatcher
(
AnyRequestMatcher
.
INSTANCE
);
configurer
.
addHeaderWriter
(
writer
);
}
if
(
headers
.
isContentType
())
{
configurer
.
contentTypeOptions
();
}
if
(
headers
.
isXss
())
{
configurer
.
xssProtection
();
}
if
(
headers
.
isCache
())
{
configurer
.
cacheControl
();
}
if
(
headers
.
isFrame
())
{
configurer
.
frameOptions
();
}
}
public
static
List
<
String
>
getIgnored
(
SecurityProperties
security
)
{
List
<
String
>
ignored
=
new
ArrayList
<
String
>(
security
.
getIgnored
());
if
(
ignored
.
isEmpty
())
{
ignored
.
addAll
(
DEFAULT_IGNORED
);
}
else
if
(
ignored
.
contains
(
"none"
))
{
ignored
.
remove
(
"none"
);
}
return
ignored
;
}
// Get the ignored paths in early
// Get the ignored paths in early
@Order
(
Ordered
.
HIGHEST_PRECEDENCE
)
@Order
(
Ordered
.
HIGHEST_PRECEDENCE
)
private
static
class
IgnoredPathsWebSecurityConfigurerAdapter
implements
private
static
class
IgnoredPathsWebSecurityConfigurerAdapter
implements
...
@@ -135,10 +167,12 @@ public class SpringBootWebSecurityConfiguration {
...
@@ -135,10 +167,12 @@ public class SpringBootWebSecurityConfiguration {
@ConditionalOnExpression
(
"${security.basic.enabled:true}"
)
@ConditionalOnExpression
(
"${security.basic.enabled:true}"
)
@Configuration
@Configuration
protected
static
class
WebMvcSecurityConfigurationConditions
{
protected
static
class
WebMvcSecurityConfigurationConditions
{
@Configuration
@Configuration
@EnableWebMvcSecurity
@EnableWebMvcSecurity
protected
static
class
DefaultWebMvcSecurityConfiguration
{
protected
static
class
DefaultWebMvcSecurityConfiguration
{
}
}
}
}
// Pull in a plain @EnableWebSecurity if Spring MVC is not available
// Pull in a plain @EnableWebSecurity if Spring MVC is not available
...
@@ -223,37 +257,4 @@ public class SpringBootWebSecurityConfiguration {
...
@@ -223,37 +257,4 @@ public class SpringBootWebSecurityConfiguration {
}
}
public
static
void
configureHeaders
(
HeadersConfigurer
<?>
configurer
,
SecurityProperties
.
Headers
headers
)
throws
Exception
{
if
(
headers
.
getHsts
()
!=
Headers
.
HSTS
.
none
)
{
boolean
includeSubdomains
=
headers
.
getHsts
()
==
Headers
.
HSTS
.
all
;
HstsHeaderWriter
writer
=
new
HstsHeaderWriter
(
includeSubdomains
);
writer
.
setRequestMatcher
(
AnyRequestMatcher
.
INSTANCE
);
configurer
.
addHeaderWriter
(
writer
);
}
if
(
headers
.
isContentType
())
{
configurer
.
contentTypeOptions
();
}
if
(
headers
.
isXss
())
{
configurer
.
xssProtection
();
}
if
(
headers
.
isCache
())
{
configurer
.
cacheControl
();
}
if
(
headers
.
isFrame
())
{
configurer
.
frameOptions
();
}
}
public
static
List
<
String
>
getIgnored
(
SecurityProperties
security
)
{
List
<
String
>
ignored
=
new
ArrayList
<
String
>(
security
.
getIgnored
());
if
(
ignored
.
isEmpty
())
{
ignored
.
addAll
(
DEFAULT_IGNORED
);
}
else
if
(
ignored
.
contains
(
"none"
))
{
ignored
.
remove
(
"none"
);
}
return
ignored
;
}
}
}
spring-boot-cli/src/it/java/org/springframework/boot/cli/infrastructure/CommandLineInvoker.java
View file @
ac54d7fe
...
@@ -106,7 +106,7 @@ public final class CommandLineInvoker {
...
@@ -106,7 +106,7 @@ public final class CommandLineInvoker {
lines
.
add
(
line
);
lines
.
add
(
line
);
}
}
}
}
catch
(
IOException
e
)
{
catch
(
IOException
e
x
)
{
throw
new
RuntimeException
(
"Failed to read standard output"
);
throw
new
RuntimeException
(
"Failed to read standard output"
);
}
}
return
lines
;
return
lines
;
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java
View file @
ac54d7fe
...
@@ -112,11 +112,14 @@ public class CommandCompleter extends StringsCompleter {
...
@@ -112,11 +112,14 @@ public class CommandCompleter extends StringsCompleter {
}
}
this
.
console
.
drawLine
();
this
.
console
.
drawLine
();
}
}
catch
(
IOException
e
)
{
catch
(
IOException
e
x
)
{
Log
.
error
(
e
.
getMessage
()
+
" ("
+
e
.
getClass
().
getName
()
+
")"
);
Log
.
error
(
e
x
.
getMessage
()
+
" ("
+
ex
.
getClass
().
getName
()
+
")"
);
}
}
}
}
/**
* Encapsulated options and usage help.
*/
private
static
class
OptionHelpLine
{
private
static
class
OptionHelpLine
{
private
final
String
options
;
private
final
String
options
;
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/EscapeAwareWhiteSpaceArgumentDelimiter.java
View file @
ac54d7fe
...
@@ -20,7 +20,7 @@ import jline.console.completer.ArgumentCompleter.ArgumentList;
...
@@ -20,7 +20,7 @@ import jline.console.completer.ArgumentCompleter.ArgumentList;
import
jline.console.completer.ArgumentCompleter.WhitespaceArgumentDelimiter
;
import
jline.console.completer.ArgumentCompleter.WhitespaceArgumentDelimiter
;
/**
/**
* Escape ware variant of {@link WhitespaceArgumentDelimiter}.
* Escape
a
ware variant of {@link WhitespaceArgumentDelimiter}.
*
*
* @author Phillip Webb
* @author Phillip Webb
*/
*/
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/RunProcessCommand.java
View file @
ac54d7fe
...
@@ -103,7 +103,7 @@ class RunProcessCommand extends AbstractCommand {
...
@@ -103,7 +103,7 @@ class RunProcessCommand extends AbstractCommand {
}
}
reader
.
close
();
reader
.
close
();
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
x
)
{
}
}
};
};
}.
start
();
}.
start
();
...
@@ -135,7 +135,7 @@ class RunProcessCommand extends AbstractCommand {
...
@@ -135,7 +135,7 @@ class RunProcessCommand extends AbstractCommand {
this
.
process
=
null
;
this
.
process
=
null
;
return
true
;
return
true
;
}
}
catch
(
InterruptedException
e
)
{
catch
(
InterruptedException
e
x
)
{
Thread
.
currentThread
().
interrupt
();
Thread
.
currentThread
().
interrupt
();
}
}
}
}
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java
View file @
ac54d7fe
...
@@ -64,8 +64,7 @@ import org.springframework.boot.cli.util.ResourceUtils;
...
@@ -64,8 +64,7 @@ import org.springframework.boot.cli.util.ResourceUtils;
*
*
* <li>Generated class files can also be loaded using
* <li>Generated class files can also be loaded using
* {@link ClassLoader#getResource(String)}</li>
* {@link ClassLoader#getResource(String)}</li>
*
* </ul>
* <ul>
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Dave Syer
* @author Dave Syer
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/RepositoryConfigurationFactory.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -61,7 +61,6 @@ public final class RepositoryConfigurationFactory {
...
@@ -61,7 +61,6 @@ public final class RepositoryConfigurationFactory {
/**
/**
* Add the default local M2 cache directory as a remote repository. Only do this if
* Add the default local M2 cache directory as a remote repository. Only do this if
* the local cache location has been changed from the default.
* the local cache location has been changed from the default.
*
* @param repositoryConfiguration
* @param repositoryConfiguration
*/
*/
public
static
void
addDefaultCacheAsRespository
(
public
static
void
addDefaultCacheAsRespository
(
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/JreProxySelector.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -54,7 +54,7 @@ public final class JreProxySelector implements ProxySelector {
...
@@ -54,7 +54,7 @@ public final class JreProxySelector implements ProxySelector {
URI
uri
=
new
URI
(
repository
.
getUrl
()).
parseServerAuthority
();
URI
uri
=
new
URI
(
repository
.
getUrl
()).
parseServerAuthority
();
proxies
=
java
.
net
.
ProxySelector
.
getDefault
().
select
(
uri
);
proxies
=
java
.
net
.
ProxySelector
.
getDefault
().
select
(
uri
);
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
x
)
{
// URL invalid or not accepted by selector or no selector at all, simply use
// URL invalid or not accepted by selector or no selector at all, simply use
// no proxy
// no proxy
}
}
...
@@ -113,7 +113,7 @@ public final class JreProxySelector implements ProxySelector {
...
@@ -113,7 +113,7 @@ public final class JreProxySelector implements ProxySelector {
try
{
try
{
url
=
new
URL
(
context
.
getRepository
().
getUrl
());
url
=
new
URL
(
context
.
getRepository
().
getUrl
());
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
x
)
{
url
=
null
;
url
=
null
;
}
}
...
@@ -133,7 +133,7 @@ public final class JreProxySelector implements ProxySelector {
...
@@ -133,7 +133,7 @@ public final class JreProxySelector implements ProxySelector {
System
.
getProperty
(
"http.proxyPassword"
));
System
.
getProperty
(
"http.proxyPassword"
));
}
}
}
}
catch
(
SecurityException
e
)
{
catch
(
SecurityException
e
x
)
{
// oh well, let's hope the proxy can do without auth
// oh well, let's hope the proxy can do without auth
}
}
}
}
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/ManagedDependenciesFactory.java
View file @
ac54d7fe
...
@@ -28,5 +28,9 @@ import org.eclipse.aether.graph.Dependency;
...
@@ -28,5 +28,9 @@ import org.eclipse.aether.graph.Dependency;
*/
*/
public
interface
ManagedDependenciesFactory
{
public
interface
ManagedDependenciesFactory
{
/**
* Returns the managed dependencies.
*/
List
<
Dependency
>
getManagedDependencies
();
List
<
Dependency
>
getManagedDependencies
();
}
}
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java
View file @
ac54d7fe
...
@@ -34,8 +34,7 @@ public final class RepositoryConfiguration {
...
@@ -34,8 +34,7 @@ public final class RepositoryConfiguration {
private
final
boolean
snapshotsEnabled
;
private
final
boolean
snapshotsEnabled
;
/**
/**
* Creates a new {@code RepositoryConfiguration}.
* Creates a new {@code RepositoryConfiguration} instance.
*
* @param name The name of the repository
* @param name The name of the repository
* @param uri The uri of the repository
* @param uri The uri of the repository
* @param snapshotsEnabled {@code true} if the repository should enable access to
* @param snapshotsEnabled {@code true} if the repository should enable access to
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/transformation/GroovyBeansTransformation.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -101,7 +101,6 @@ public class GroovyBeansTransformation implements ASTTransformation {
...
@@ -101,7 +101,6 @@ public class GroovyBeansTransformation implements ASTTransformation {
/**
/**
* Extract a top-level <code>beans{}</code> closure from inside this block if
* Extract a top-level <code>beans{}</code> closure from inside this block if
* there is one. Removes it from the block at the same time.
* there is one. Removes it from the block at the same time.
*
* @param block a block statement (class definition)
* @param block a block statement (class definition)
* @return a beans Closure if one can be found, null otherwise
* @return a beans Closure if one can be found, null otherwise
*/
*/
...
@@ -128,9 +127,7 @@ public class GroovyBeansTransformation implements ASTTransformation {
...
@@ -128,9 +127,7 @@ public class GroovyBeansTransformation implements ASTTransformation {
}
}
}
}
}
}
return
null
;
return
null
;
}
}
}
}
}
}
spring-boot-cli/src/main/java/org/springframework/boot/groovy/EnableDeviceResolver.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -22,6 +22,11 @@ import java.lang.annotation.Retention;
...
@@ -22,6 +22,11 @@ import java.lang.annotation.Retention;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Target
;
import
org.springframework.boot.cli.compiler.autoconfigure.SpringMobileCompilerAutoConfiguration
;
/**
* Pseudo annotation used to trigger {@link SpringMobileCompilerAutoConfiguration}.
*/
@Target
(
ElementType
.
TYPE
)
@Target
(
ElementType
.
TYPE
)
@Documented
@Documented
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
...
...
spring-boot-cli/src/main/java/org/springframework/boot/groovy/EnableIntegrationPatterns.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -22,9 +22,13 @@ import java.lang.annotation.Retention;
...
@@ -22,9 +22,13 @@ import java.lang.annotation.Retention;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Target
;
import
org.springframework.boot.cli.compiler.autoconfigure.SpringIntegrationCompilerAutoConfiguration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.ImportResource
;
import
org.springframework.context.annotation.ImportResource
;
/**
* Pseudo annotation used to trigger {@link SpringIntegrationCompilerAutoConfiguration}.
*/
@Target
(
ElementType
.
TYPE
)
@Target
(
ElementType
.
TYPE
)
@Documented
@Documented
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
...
...
spring-boot-cli/src/main/java/org/springframework/boot/groovy/EnableJmsMessaging.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -22,6 +22,11 @@ import java.lang.annotation.Retention;
...
@@ -22,6 +22,11 @@ import java.lang.annotation.Retention;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Target
;
import
org.springframework.boot.cli.compiler.autoconfigure.JmsCompilerAutoConfiguration
;
/**
* Pseudo annotation used to trigger {@link JmsCompilerAutoConfiguration}.
*/
@Target
(
ElementType
.
TYPE
)
@Target
(
ElementType
.
TYPE
)
@Documented
@Documented
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
...
...
spring-boot-cli/src/main/java/org/springframework/boot/groovy/GroovyTemplate.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -28,6 +28,8 @@ import java.util.Map;
...
@@ -28,6 +28,8 @@ import java.util.Map;
import
org.codehaus.groovy.control.CompilationFailedException
;
import
org.codehaus.groovy.control.CompilationFailedException
;
/**
/**
* Helpful utilties for working with Groovy {@link Template}s.
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
abstract
class
GroovyTemplate
{
public
abstract
class
GroovyTemplate
{
...
...
spring-boot-samples/spring-boot-sample-data-mongodb/src/test/java/sample/data/mongo/SampleMongoApplicationTests.java
View file @
ac54d7fe
...
@@ -50,9 +50,9 @@ public class SampleMongoApplicationTests {
...
@@ -50,9 +50,9 @@ public class SampleMongoApplicationTests {
output
.
contains
(
"firstName='Alice', lastName='Smith'"
));
output
.
contains
(
"firstName='Alice', lastName='Smith'"
));
}
}
private
boolean
serverNotRunning
(
IllegalStateException
e
)
{
private
boolean
serverNotRunning
(
IllegalStateException
e
x
)
{
@SuppressWarnings
(
"serial"
)
@SuppressWarnings
(
"serial"
)
NestedCheckedException
nested
=
new
NestedCheckedException
(
"failed"
,
e
)
{
NestedCheckedException
nested
=
new
NestedCheckedException
(
"failed"
,
e
x
)
{
};
};
if
(
nested
.
contains
(
IOException
.
class
))
{
if
(
nested
.
contains
(
IOException
.
class
))
{
Throwable
root
=
nested
.
getRootCause
();
Throwable
root
=
nested
.
getRootCause
();
...
...
spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/SpringBootPluginExtension.groovy
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -19,6 +19,7 @@ package org.springframework.boot.gradle
...
@@ -19,6 +19,7 @@ package org.springframework.boot.gradle
import
org.springframework.boot.loader.tools.Layout
import
org.springframework.boot.loader.tools.Layout
import
org.springframework.boot.loader.tools.Layouts
import
org.springframework.boot.loader.tools.Layouts
/**
/**
* Gradle DSL Extension for 'Spring Boot'. Most of the time Spring Boot can guess the
* Gradle DSL Extension for 'Spring Boot'. Most of the time Spring Boot can guess the
* settings in this extension, but occasionally you might need to explicitly set one
* settings in this extension, but occasionally you might need to explicitly set one
...
@@ -81,7 +82,6 @@ public class SpringBootPluginExtension {
...
@@ -81,7 +82,6 @@ public class SpringBootPluginExtension {
/**
/**
* Convenience method for use in a custom task.
* Convenience method for use in a custom task.
*
* @return the Layout to use or null if not explicitly set
* @return the Layout to use or null if not explicitly set
*/
*/
Layout
convertLayout
()
{
Layout
convertLayout
()
{
...
...
spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/task/ProjectLibraries.java
View file @
ac54d7fe
/*
* Copyright 2012-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
.
boot
.
gradle
.
task
;
package
org
.
springframework
.
boot
.
gradle
.
task
;
...
@@ -26,7 +41,6 @@ class ProjectLibraries implements Libraries {
...
@@ -26,7 +41,6 @@ class ProjectLibraries implements Libraries {
/**
/**
* Create a new {@link ProjectLibraries} instance of the specified {@link Project}.
* Create a new {@link ProjectLibraries} instance of the specified {@link Project}.
*
* @param project the gradle project
* @param project the gradle project
*/
*/
public
ProjectLibraries
(
Project
project
)
{
public
ProjectLibraries
(
Project
project
)
{
...
@@ -35,7 +49,6 @@ class ProjectLibraries implements Libraries {
...
@@ -35,7 +49,6 @@ class ProjectLibraries implements Libraries {
/**
/**
* Set the name of the provided configuration. Defaults to 'providedRuntime'.
* Set the name of the provided configuration. Defaults to 'providedRuntime'.
*
* @param providedConfigurationName the providedConfigurationName to set
* @param providedConfigurationName the providedConfigurationName to set
*/
*/
public
void
setProvidedConfigurationName
(
String
providedConfigurationName
)
{
public
void
setProvidedConfigurationName
(
String
providedConfigurationName
)
{
...
...
spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/task/RunApp.java
View file @
ac54d7fe
...
@@ -95,8 +95,8 @@ public class RunApp extends DefaultTask {
...
@@ -95,8 +95,8 @@ public class RunApp extends DefaultTask {
getLogger
().
info
(
"Looking for main in: "
+
main
.
getOutput
().
getClassesDir
());
getLogger
().
info
(
"Looking for main in: "
+
main
.
getOutput
().
getClassesDir
());
try
{
try
{
return
MainClassFinder
.
findMainClass
(
main
.
getOutput
().
getClassesDir
());
return
MainClassFinder
.
findMainClass
(
main
.
getOutput
().
getClassesDir
());
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
x
)
{
throw
new
IllegalStateException
(
"Cannot find main class"
,
e
);
throw
new
IllegalStateException
(
"Cannot find main class"
,
e
x
);
}
}
}
}
...
...
spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java
View file @
ac54d7fe
...
@@ -51,7 +51,6 @@ import org.springframework.boot.loader.util.SystemPropertyUtils;
...
@@ -51,7 +51,6 @@ import org.springframework.boot.loader.util.SystemPropertyUtils;
* {@link Launcher} for archives with user-configured classpath and main class via a
* {@link Launcher} for archives with user-configured classpath and main class via a
* properties file. This model is often more flexible and more amenable to creating
* properties file. This model is often more flexible and more amenable to creating
* well-behaved OS-level services than a model based on executable jars.
* well-behaved OS-level services than a model based on executable jars.
*
* <p>
* <p>
* Looks in various places for a properties file to extract loader settings, defaulting to
* Looks in various places for a properties file to extract loader settings, defaulting to
* <code>application.properties</code> either on the current classpath or in the current
* <code>application.properties</code> either on the current classpath or in the current
...
@@ -62,7 +61,6 @@ import org.springframework.boot.loader.util.SystemPropertyUtils;
...
@@ -62,7 +61,6 @@ import org.springframework.boot.loader.util.SystemPropertyUtils;
* <code>file:</code> or any valid URL). Once that file is located turns it into
* <code>file:</code> or any valid URL). Once that file is located turns it into
* Properties and extracts optional values (which can also be provided overridden as
* Properties and extracts optional values (which can also be provided overridden as
* System properties in case the file doesn't exist):
* System properties in case the file doesn't exist):
*
* <ul>
* <ul>
* <li><code>loader.path</code>: a comma-separated list of directories to append to the
* <li><code>loader.path</code>: a comma-separated list of directories to append to the
* classpath (containing file resources and/or nested archives in *.jar or *.zip).
* classpath (containing file resources and/or nested archives in *.jar or *.zip).
...
@@ -345,7 +343,7 @@ public class PropertiesLauncher extends Launcher {
...
@@ -345,7 +343,7 @@ public class PropertiesLauncher extends Launcher {
try
{
try
{
return
loaderClass
.
getConstructor
(
ClassLoader
.
class
).
newInstance
(
parent
);
return
loaderClass
.
getConstructor
(
ClassLoader
.
class
).
newInstance
(
parent
);
}
}
catch
(
NoSuchMethodException
e
)
{
catch
(
NoSuchMethodException
e
x
)
{
// Ignore and try with URLs
// Ignore and try with URLs
}
}
...
...
spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/FilteredArchive.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -28,11 +28,14 @@ import java.util.jar.Manifest;
...
@@ -28,11 +28,14 @@ import java.util.jar.Manifest;
import
org.springframework.boot.loader.AsciiBytes
;
import
org.springframework.boot.loader.AsciiBytes
;
/**
/**
* Decorator to apply an {@link Archive.EntryFilter} to an existing {@link Archive}.
*
* @author Dave Syer
* @author Dave Syer
*/
*/
public
class
FilteredArchive
extends
Archive
{
public
class
FilteredArchive
extends
Archive
{
private
Archive
parent
;
private
Archive
parent
;
private
EntryFilter
filter
;
private
EntryFilter
filter
;
public
FilteredArchive
(
Archive
parent
,
EntryFilter
filter
)
{
public
FilteredArchive
(
Archive
parent
,
EntryFilter
filter
)
{
...
...
spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -22,14 +22,11 @@ import java.util.Set;
...
@@ -22,14 +22,11 @@ import java.util.Set;
/**
/**
* Helper class for resolving placeholders in texts. Usually applied to file paths.
* Helper class for resolving placeholders in texts. Usually applied to file paths.
*
* <p>
* <p>
* A text may contain {@code $ ...} placeholders, to be resolved as system properties:
* A text may contain {@code $ ...} placeholders, to be resolved as system properties:
* e.g. {@code $ user.dir} . Default values can be supplied using the ":" separator
* e.g. {@code $ user.dir} . Default values can be supplied using the ":" separator
* between key and value.
* between key and value.
*
* <p>
* <p>
*
* Adapted from Spring.
* Adapted from Spring.
*
*
* @author Juergen Hoeller
* @author Juergen Hoeller
...
@@ -40,13 +37,19 @@ import java.util.Set;
...
@@ -40,13 +37,19 @@ import java.util.Set;
*/
*/
public
abstract
class
SystemPropertyUtils
{
public
abstract
class
SystemPropertyUtils
{
/** Prefix for system property placeholders: "${" */
/**
* Prefix for system property placeholders: "${"
*/
public
static
final
String
PLACEHOLDER_PREFIX
=
"${"
;
public
static
final
String
PLACEHOLDER_PREFIX
=
"${"
;
/** Suffix for system property placeholders: "}" */
/**
* Suffix for system property placeholders: "}"
*/
public
static
final
String
PLACEHOLDER_SUFFIX
=
"}"
;
public
static
final
String
PLACEHOLDER_SUFFIX
=
"}"
;
/** Value separator for system property placeholders: ":" */
/**
* Value separator for system property placeholders: ":"
*/
public
static
final
String
VALUE_SEPARATOR
=
":"
;
public
static
final
String
VALUE_SEPARATOR
=
":"
;
private
static
final
String
SIMPLE_PREFIX
=
PLACEHOLDER_PREFIX
.
substring
(
1
);
private
static
final
String
SIMPLE_PREFIX
=
PLACEHOLDER_PREFIX
.
substring
(
1
);
...
@@ -166,7 +169,6 @@ public abstract class SystemPropertyUtils {
...
@@ -166,7 +169,6 @@ public abstract class SystemPropertyUtils {
* Search the System properties and environment variables for a value with the
* Search the System properties and environment variables for a value with the
* provided key. Environment variables in <code>UPPER_CASE</code> style are allowed
* provided key. Environment variables in <code>UPPER_CASE</code> style are allowed
* where System properties would normally be <code>lower.case</code>.
* where System properties would normally be <code>lower.case</code>.
*
* @param key the key to resolve
* @param key the key to resolve
* @param text optional extra context for an error message if the key resolution fails
* @param text optional extra context for an error message if the key resolution fails
* (e.g. if System properties are not accessible)
* (e.g. if System properties are not accessible)
...
...
spring-boot/src/main/java/org/springframework/boot/config/SimpleJsonParser.java
View file @
ac54d7fe
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -88,14 +88,14 @@ public class SimpleJsonParser implements JsonParser {
...
@@ -88,14 +88,14 @@ public class SimpleJsonParser implements JsonParser {
try
{
try
{
return
Long
.
valueOf
(
json
);
return
Long
.
valueOf
(
json
);
}
}
catch
(
NumberFormatException
e
)
{
catch
(
NumberFormatException
e
x
)
{
// ignore
// ignore
}
}
try
{
try
{
return
Double
.
valueOf
(
json
);
return
Double
.
valueOf
(
json
);
}
}
catch
(
NumberFormatException
e
)
{
catch
(
NumberFormatException
e
x
)
{
// ignore
// ignore
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainer.java
View file @
ac54d7fe
...
@@ -109,8 +109,8 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
...
@@ -109,8 +109,8 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer {
ReflectionUtils
.
findMethod
(
connector
.
getClass
(),
"getLocalPort"
),
ReflectionUtils
.
findMethod
(
connector
.
getClass
(),
"getLocalPort"
),
connector
)).
toString
();
connector
)).
toString
();
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
x
)
{
return
"could not determine port ( "
+
e
.
getMessage
()
+
")"
;
return
"could not determine port ( "
+
e
x
.
getMessage
()
+
")"
;
}
}
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java
View file @
ac54d7fe
package
org
.
springframework
.
boot
.
context
.
embedded
.
tomcat
;
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
4
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -16,6 +14,8 @@ package org.springframework.boot.context.embedded.tomcat;
...
@@ -16,6 +14,8 @@ package org.springframework.boot.context.embedded.tomcat;
* limitations under the License.
* limitations under the License.
*/
*/
package
org
.
springframework
.
boot
.
context
.
embedded
.
tomcat
;
import
org.apache.catalina.loader.WebappClassLoader
;
import
org.apache.catalina.loader.WebappClassLoader
;
/**
/**
...
...
spring-boot/src/main/java/org/springframework/boot/test/package-info.java
0 → 100644
View file @
ac54d7fe
/*
* Copyright 2012-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.
*/
/**
* Classes and utilities that are useful when unit-testing Spring Boot applications.
* This package is only intended for use in 'src/test' and should not be used in your
* 'src/main' code.
*/
package
org
.
springframework
.
boot
.
test
;
spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesTests.java
View file @
ac54d7fe
...
@@ -394,12 +394,14 @@ public class EnableConfigurationPropertiesTests {
...
@@ -394,12 +394,14 @@ public class EnableConfigurationPropertiesTests {
@Configuration
@Configuration
protected
static
class
DefaultConfiguration
{
protected
static
class
DefaultConfiguration
{
@Bean
@Bean
public
TestProperties
testProperties
()
{
public
TestProperties
testProperties
()
{
TestProperties
test
=
new
TestProperties
();
TestProperties
test
=
new
TestProperties
();
test
.
setName
(
"bar"
);
test
.
setName
(
"bar"
);
return
test
;
return
test
;
}
}
}
}
@Configuration
@Configuration
...
@@ -410,10 +412,12 @@ public class EnableConfigurationPropertiesTests {
...
@@ -410,10 +412,12 @@ public class EnableConfigurationPropertiesTests {
@EnableConfigurationProperties
@EnableConfigurationProperties
@Configuration
@Configuration
public
static
class
ExampleConfig
{
public
static
class
ExampleConfig
{
@Bean
@Bean
public
External
external
()
{
public
External
external
()
{
return
new
External
();
return
new
External
();
}
}
}
}
@EnableConfigurationProperties
(
External
.
class
)
@EnableConfigurationProperties
(
External
.
class
)
...
@@ -461,6 +465,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -461,6 +465,7 @@ public class EnableConfigurationPropertiesTests {
@ConfigurationProperties
(
name
=
"spring_test_external"
)
@ConfigurationProperties
(
name
=
"spring_test_external"
)
public
static
class
SystemEnvVar
{
public
static
class
SystemEnvVar
{
public
String
getVal
()
{
public
String
getVal
()
{
return
this
.
val
;
return
this
.
val
;
}
}
...
@@ -475,6 +480,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -475,6 +480,7 @@ public class EnableConfigurationPropertiesTests {
@Component
@Component
protected
static
class
TestConsumer
{
protected
static
class
TestConsumer
{
@Autowired
@Autowired
private
TestProperties
properties
;
private
TestProperties
properties
;
...
@@ -495,7 +501,9 @@ public class EnableConfigurationPropertiesTests {
...
@@ -495,7 +501,9 @@ public class EnableConfigurationPropertiesTests {
@ConfigurationProperties
@ConfigurationProperties
protected
static
class
NestedProperties
{
protected
static
class
NestedProperties
{
private
String
name
;
private
String
name
;
private
Nested
nested
=
new
Nested
();
private
Nested
nested
=
new
Nested
();
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
...
@@ -507,6 +515,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -507,6 +515,7 @@ public class EnableConfigurationPropertiesTests {
}
}
protected
static
class
Nested
{
protected
static
class
Nested
{
private
String
name
;
private
String
name
;
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
...
@@ -514,15 +523,18 @@ public class EnableConfigurationPropertiesTests {
...
@@ -514,15 +523,18 @@ public class EnableConfigurationPropertiesTests {
}
}
}
}
}
}
@ConfigurationProperties
@ConfigurationProperties
protected
static
class
BaseProperties
{
protected
static
class
BaseProperties
{
private
String
name
;
private
String
name
;
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
}
}
}
}
protected
static
class
DerivedProperties
extends
BaseProperties
{
protected
static
class
DerivedProperties
extends
BaseProperties
{
...
@@ -530,8 +542,11 @@ public class EnableConfigurationPropertiesTests {
...
@@ -530,8 +542,11 @@ public class EnableConfigurationPropertiesTests {
@ConfigurationProperties
@ConfigurationProperties
protected
static
class
TestProperties
{
protected
static
class
TestProperties
{
private
String
name
;
private
String
name
;
private
int
[]
array
;
private
int
[]
array
;
private
List
<
Integer
>
list
=
new
ArrayList
<
Integer
>();
private
List
<
Integer
>
list
=
new
ArrayList
<
Integer
>();
// No getter - you should be able to bind to a write-only bean
// No getter - you should be able to bind to a write-only bean
...
@@ -551,6 +566,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -551,6 +566,7 @@ public class EnableConfigurationPropertiesTests {
public
List
<
Integer
>
getList
()
{
public
List
<
Integer
>
getList
()
{
return
this
.
list
;
return
this
.
list
;
}
}
}
}
@ConfigurationProperties
(
ignoreUnknownFields
=
false
)
@ConfigurationProperties
(
ignoreUnknownFields
=
false
)
...
@@ -559,12 +575,10 @@ public class EnableConfigurationPropertiesTests {
...
@@ -559,12 +575,10 @@ public class EnableConfigurationPropertiesTests {
@ConfigurationProperties
(
name
=
"spring.foo"
)
@ConfigurationProperties
(
name
=
"spring.foo"
)
protected
static
class
EmbeddedTestProperties
extends
TestProperties
{
protected
static
class
EmbeddedTestProperties
extends
TestProperties
{
}
}
@ConfigurationProperties
(
ignoreUnknownFields
=
false
,
ignoreNestedProperties
=
true
)
@ConfigurationProperties
(
ignoreUnknownFields
=
false
,
ignoreNestedProperties
=
true
)
protected
static
class
IgnoreNestedTestProperties
extends
TestProperties
{
protected
static
class
IgnoreNestedTestProperties
extends
TestProperties
{
}
}
@ConfigurationProperties
@ConfigurationProperties
...
@@ -600,6 +614,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -600,6 +614,7 @@ public class EnableConfigurationPropertiesTests {
}
}
protected
static
class
MoreProperties
{
protected
static
class
MoreProperties
{
private
String
name
;
private
String
name
;
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
...
@@ -611,6 +626,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -611,6 +626,7 @@ public class EnableConfigurationPropertiesTests {
@ConfigurationProperties
(
path
=
"${binding.location:classpath:name.yml}"
)
@ConfigurationProperties
(
path
=
"${binding.location:classpath:name.yml}"
)
protected
static
class
ResourceBindingProperties
{
protected
static
class
ResourceBindingProperties
{
private
String
name
;
private
String
name
;
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
...
@@ -623,6 +639,7 @@ public class EnableConfigurationPropertiesTests {
...
@@ -623,6 +639,7 @@ public class EnableConfigurationPropertiesTests {
@EnableConfigurationProperties
@EnableConfigurationProperties
@ConfigurationProperties
(
path
=
"${binding.location:classpath:map.yml}"
)
@ConfigurationProperties
(
path
=
"${binding.location:classpath:map.yml}"
)
protected
static
class
ResourceBindingPropertiesWithMap
{
protected
static
class
ResourceBindingPropertiesWithMap
{
private
Map
<
String
,
String
>
mymap
;
private
Map
<
String
,
String
>
mymap
;
public
void
setMymap
(
Map
<
String
,
String
>
mymap
)
{
public
void
setMymap
(
Map
<
String
,
String
>
mymap
)
{
...
...
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