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
47da8a81
Commit
47da8a81
authored
Jan 10, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
26d900f3
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
112 additions
and
66 deletions
+112
-66
howto.md
docs/howto.md
+1
-1
ManagementSecurityAutoConfiguration.java
...te/autoconfigure/ManagementSecurityAutoConfiguration.java
+2
-1
EndpointWebMvcAutoConfigurationTests.java
...e/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
+2
-1
EnvironmentMvcEndpointTests.java
...oot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java
+2
-1
JolokiaEndpointTests.java
...ework/boot/actuate/endpoint/mvc/JolokiaEndpointTests.java
+2
-1
AutoConfigurationSorter.java
...framework/boot/autoconfigure/AutoConfigurationSorter.java
+1
-1
SecurityAutoConfiguration.java
...oot/autoconfigure/security/SecurityAutoConfiguration.java
+2
-1
RabbitAutoconfigurationTests.java
...boot/autoconfigure/amqp/RabbitAutoconfigurationTests.java
+12
-7
AopAutoConfigurationTests.java
...ork/boot/autoconfigure/aop/AopAutoConfigurationTests.java
+4
-2
TomcatDataSourceConfigurationTests.java
...utoconfigure/jdbc/TomcatDataSourceConfigurationTests.java
+2
-1
JmsTemplateAutoConfigurationTests.java
.../autoconfigure/jms/JmsTemplateAutoConfigurationTests.java
+6
-3
HibernateJpaAutoConfigurationTests.java
...configure/orm/jpa/HibernateJpaAutoConfigurationTests.java
+3
-2
ServerPropertiesAutoConfigurationTests.java
...configure/web/ServerPropertiesAutoConfigurationTests.java
+2
-2
InitCommand.java
...ava/org/springframework/boot/cli/command/InitCommand.java
+2
-2
TestRunner.java
...a/org/springframework/boot/cli/testrunner/TestRunner.java
+2
-1
SampleSecureApplication.java
.../src/main/java/sample/secure/SampleSecureApplication.java
+2
-1
SampleService.java
...ple-secure/src/main/java/sample/secure/SampleService.java
+2
-2
SampleServletApplication.java
...rc/main/java/sample/servlet/SampleServletApplication.java
+1
-1
logback.xml
.../spring-boot-sample-web-ui/src/main/resources/logback.xml
+3
-3
PropertiesLauncher.java
...a/org/springframework/boot/loader/PropertiesLauncher.java
+35
-17
EnvironmentDelegateApplicationListener.java
...text/listener/EnvironmentDelegateApplicationListener.java
+1
-0
ContextIdApplicationContextInitializerTests.java
...tializer/ContextIdApplicationContextInitializerTests.java
+5
-3
EnvironmentDelegateApplicationContextInitializerTests.java
...nvironmentDelegateApplicationContextInitializerTests.java
+4
-5
FileEncodingApplicationListenerTests.java
...ontext/listener/FileEncodingApplicationListenerTests.java
+6
-3
LoggingApplicationListenerTests.java
...oot/context/listener/LoggingApplicationListenerTests.java
+2
-1
EnableConfigurationPropertiesTests.java
...ontext/properties/EnableConfigurationPropertiesTests.java
+6
-3
No files found.
docs/howto.md
View file @
47da8a81
...
...
@@ -935,7 +935,7 @@ additional ones:
*
declarative for all applications by adding a
`MTEA-INF/spring.factories`
and packaging a jar file that the
applications all use as a library
Any
`ApplicationContextInitializer`
registered programmatically or via
`spring.factories`
that is also an
`ApplicationListener`
will be
automatically cross registered (and vice versa for listeners that are
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementSecurityAutoConfiguration.java
View file @
47da8a81
...
...
@@ -128,7 +128,8 @@ public class ManagementSecurityAutoConfiguration {
IgnoredRequestConfigurer
ignoring
=
builder
.
ignoring
();
// The ignores are not cumulative, so to prevent overwriting the defaults we
// add them back.
List
<
String
>
ignored
=
SpringBootWebSecurityConfiguration
.
getIgnored
(
this
.
security
);
List
<
String
>
ignored
=
SpringBootWebSecurityConfiguration
.
getIgnored
(
this
.
security
);
ignored
.
addAll
(
Arrays
.
asList
(
getEndpointPaths
(
this
.
endpointHandlerMapping
,
false
)));
if
(!
this
.
management
.
getSecurity
().
isEnabled
())
{
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
View file @
47da8a81
...
...
@@ -142,7 +142,8 @@ public class EndpointWebMvcAutoConfigurationTests {
@Test
public
void
contextPath
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
applicationContext
,
"management.contextPath:/test"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
applicationContext
,
"management.contextPath:/test"
);
this
.
applicationContext
.
register
(
RootConfig
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
ManagementServerPropertiesAutoConfiguration
.
class
,
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java
View file @
47da8a81
...
...
@@ -59,7 +59,8 @@ public class EnvironmentMvcEndpointTests {
@Before
public
void
setUp
()
{
this
.
mvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
context
).
build
();
EnvironmentTestUtils
.
addEnvironment
((
ConfigurableApplicationContext
)
this
.
context
,
"foo:bar"
);
EnvironmentTestUtils
.
addEnvironment
(
(
ConfigurableApplicationContext
)
this
.
context
,
"foo:bar"
);
}
@Test
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaEndpointTests.java
View file @
47da8a81
...
...
@@ -66,7 +66,8 @@ public class JolokiaEndpointTests {
@Before
public
void
setUp
()
{
this
.
mvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
context
).
build
();
EnvironmentTestUtils
.
addEnvironment
((
ConfigurableApplicationContext
)
this
.
context
,
"foo:bar"
);
EnvironmentTestUtils
.
addEnvironment
(
(
ConfigurableApplicationContext
)
this
.
context
,
"foo:bar"
);
}
@Test
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java
View file @
47da8a81
...
...
@@ -15,6 +15,7 @@
*/
package
org
.
springframework
.
boot
.
autoconfigure
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
...
...
@@ -37,7 +38,6 @@ import org.springframework.core.type.classreading.MetadataReader;
import
org.springframework.core.type.classreading.MetadataReaderFactory
;
import
org.springframework.util.Assert
;
/**
* Sort {@link EnableAutoConfiguration auto-configuration} classes into priority order by
* reading {@link Ordered} and {@link AutoConfigureAfter} annotations (without loading
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfiguration.java
View file @
47da8a81
...
...
@@ -27,7 +27,8 @@ import org.springframework.security.authentication.AuthenticationManager;
@Configuration
@ConditionalOnClass
(
AuthenticationManager
.
class
)
@EnableConfigurationProperties
@Import
({
SpringBootWebSecurityConfiguration
.
class
,
AuthenticationManagerConfiguration
.
class
})
@Import
({
SpringBootWebSecurityConfiguration
.
class
,
AuthenticationManagerConfiguration
.
class
})
public
class
SecurityAutoConfiguration
{
@Bean
(
name
=
"org.springframework.autoconfigure.security.SecurityProperties"
)
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoconfigurationTests.java
View file @
47da8a81
...
...
@@ -65,9 +65,10 @@ public class RabbitAutoconfigurationTests {
public
void
testRabbitTemplateWithOverrides
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.host:remote-server"
,
"spring.rabbitmq.port:9000"
,
"spring.rabbitmq.username:alice"
,
"spring.rabbitmq.password:secret"
,
"spring.rabbitmq.virtual_host:/vhost"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.host:remote-server"
,
"spring.rabbitmq.port:9000"
,
"spring.rabbitmq.username:alice"
,
"spring.rabbitmq.password:secret"
,
"spring.rabbitmq.virtual_host:/vhost"
);
this
.
context
.
refresh
();
CachingConnectionFactory
connectionFactory
=
this
.
context
.
getBean
(
CachingConnectionFactory
.
class
);
...
...
@@ -80,7 +81,8 @@ public class RabbitAutoconfigurationTests {
public
void
testRabbitTemplateEmptyVirtualHost
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.virtual_host:"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.virtual_host:"
);
this
.
context
.
refresh
();
CachingConnectionFactory
connectionFactory
=
this
.
context
.
getBean
(
CachingConnectionFactory
.
class
);
...
...
@@ -91,7 +93,8 @@ public class RabbitAutoconfigurationTests {
public
void
testRabbitTemplateVirtualHostMissingSlash
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.virtual_host:foo"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.virtual_host:foo"
);
this
.
context
.
refresh
();
CachingConnectionFactory
connectionFactory
=
this
.
context
.
getBean
(
CachingConnectionFactory
.
class
);
...
...
@@ -102,7 +105,8 @@ public class RabbitAutoconfigurationTests {
public
void
testRabbitTemplateDefaultVirtualHost
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.virtual_host:/"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.virtual_host:/"
);
this
.
context
.
refresh
();
CachingConnectionFactory
connectionFactory
=
this
.
context
.
getBean
(
CachingConnectionFactory
.
class
);
...
...
@@ -126,7 +130,8 @@ public class RabbitAutoconfigurationTests {
public
void
testStaticQueues
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
RabbitAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.dynamic:false"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.rabbitmq.dynamic:false"
);
this
.
context
.
refresh
();
// There should NOT be an AmqpAdmin bean when dynamic is switch to false
this
.
thrown
.
expect
(
NoSuchBeanDefinitionException
.
class
);
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/aop/AopAutoConfigurationTests.java
View file @
47da8a81
...
...
@@ -56,7 +56,8 @@ public class AopAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
AopAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.aop.proxyTargetClass:true"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.aop.proxyTargetClass:true"
);
this
.
context
.
refresh
();
TestAspect
aspect
=
this
.
context
.
getBean
(
TestAspect
.
class
);
assertFalse
(
aspect
.
isCalled
());
...
...
@@ -70,7 +71,8 @@ public class AopAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
AopAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.aop.proxyTargetClass:false"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.aop.proxyTargetClass:false"
);
this
.
context
.
refresh
();
TestAspect
aspect
=
this
.
context
.
getBean
(
TestAspect
.
class
);
assertFalse
(
aspect
.
isCalled
());
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/TomcatDataSourceConfigurationTests.java
View file @
47da8a81
...
...
@@ -56,7 +56,8 @@ public class TomcatDataSourceConfigurationTests {
@Test
public
void
testDataSourcePropertiesOverridden
()
throws
Exception
{
this
.
context
.
register
(
TomcatDataSourceConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.url:jdbc:foo//bar/spam"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.datasource.url:jdbc:foo//bar/spam"
);
this
.
context
.
refresh
();
assertEquals
(
"jdbc:foo//bar/spam"
,
this
.
context
.
getBean
(
org
.
apache
.
tomcat
.
jdbc
.
pool
.
DataSource
.
class
)
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jms/JmsTemplateAutoConfigurationTests.java
View file @
47da8a81
...
...
@@ -118,7 +118,8 @@ public class JmsTemplateAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jms.pubSubDomain:false"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jms.pubSubDomain:false"
);
this
.
context
.
refresh
();
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
ActiveMQConnectionFactory
connectionFactory
=
this
.
context
...
...
@@ -134,7 +135,8 @@ public class JmsTemplateAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.inMemory:false"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.inMemory:false"
);
this
.
context
.
refresh
();
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
ActiveMQConnectionFactory
connectionFactory
=
this
.
context
...
...
@@ -153,7 +155,8 @@ public class JmsTemplateAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
TestConfiguration
.
class
,
JmsTemplateAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.inMemory:false"
,
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.activemq.inMemory:false"
,
"spring.activemq.brokerURL:tcp://remote-host:10000"
);
this
.
context
.
refresh
();
JmsTemplate
jmsTemplate
=
this
.
context
.
getBean
(
JmsTemplate
.
class
);
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfigurationTests.java
View file @
47da8a81
...
...
@@ -38,8 +38,9 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
@Test
public
void
testCustomNamingStrategy
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jpa.hibernate.namingstrategy:"
+
"org.hibernate.cfg.EJB3NamingStrategy"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jpa.hibernate.namingstrategy:"
+
"org.hibernate.cfg.EJB3NamingStrategy"
);
setupTestConfiguration
();
this
.
context
.
refresh
();
LocalContainerEntityManagerFactoryBean
bean
=
this
.
context
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfigurationTests.java
View file @
47da8a81
...
...
@@ -86,8 +86,8 @@ public class ServerPropertiesAutoConfigurationTests {
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
register
(
Config
.
class
,
ServerPropertiesAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"server.tomcat.basedir:target/foo"
,
"server.port:9000"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"server.
tomcat.basedir:target/foo"
,
"server.
port:9000"
);
this
.
context
.
refresh
();
ServerProperties
server
=
this
.
context
.
getBean
(
ServerProperties
.
class
);
assertNotNull
(
server
);
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/InitCommand.java
View file @
47da8a81
...
...
@@ -75,8 +75,8 @@ public class InitCommand extends OptionParsingCommand {
ClassLoader
loader
=
Thread
.
currentThread
().
getContextClassLoader
();
boolean
enhanced
=
false
;
SourceOptions
sourceOptions
=
new
SourceOptions
(
options
,
loader
,
"init.groovy"
,
"spring.groovy"
);
SourceOptions
sourceOptions
=
new
SourceOptions
(
options
,
loader
,
"
init.groovy"
,
"
spring.groovy"
);
String
[]
sources
=
sourceOptions
.
getSourcesArray
();
if
(!(
loader
instanceof
GroovyClassLoader
))
{
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/testrunner/TestRunner.java
View file @
47da8a81
...
...
@@ -43,7 +43,8 @@ public class TestRunner {
* @param sources
* @param args
*/
public
TestRunner
(
TestRunnerConfiguration
configuration
,
String
[]
sources
,
String
[]
args
)
{
public
TestRunner
(
TestRunnerConfiguration
configuration
,
String
[]
sources
,
String
[]
args
)
{
this
.
sources
=
sources
.
clone
();
this
.
compiler
=
new
GroovyCompiler
(
configuration
);
}
...
...
spring-boot-samples/spring-boot-sample-secure/src/main/java/sample/secure/SampleSecureApplication.java
View file @
47da8a81
...
...
@@ -41,7 +41,8 @@ public class SampleSecureApplication implements CommandLineRunner {
.
commaSeparatedStringToAuthorityList
(
"ROLE_USER"
)));
try
{
System
.
out
.
println
(
service
.
secure
());
}
finally
{
}
finally
{
SecurityContextHolder
.
clearContext
();
}
}
...
...
spring-boot-samples/spring-boot-sample-secure/src/main/java/sample/secure/SampleService.java
View file @
47da8a81
...
...
@@ -22,11 +22,11 @@ import org.springframework.stereotype.Service;
/**
* @author Dave Syer
*
*
*/
@Service
public
class
SampleService
{
@Secured
(
"ROLE_USER"
)
public
String
secure
()
{
return
"Hello Security"
;
...
...
spring-boot-samples/spring-boot-sample-servlet/src/main/java/sample/servlet/SampleServletApplication.java
View file @
47da8a81
...
...
@@ -51,7 +51,7 @@ public class SampleServletApplication extends SpringBootServletInitializer {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SpringApplication
.
run
(
SampleServletApplication
.
class
,
args
);
}
@Override
protected
SpringApplicationBuilder
configure
(
SpringApplicationBuilder
application
)
{
return
application
.
sources
(
SampleServletApplication
.
class
);
...
...
spring-boot-samples/spring-boot-sample-web-ui/src/main/resources/logback.xml
View file @
47da8a81
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include
resource=
"org/springframework/boot/logging/logback/base.xml"
/>
<include
resource=
"org/springframework/boot/logging/logback/base.xml"
/>
<!-- logger name="org.springframework" level="DEBUG"/-->
</configuration>
spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java
View file @
47da8a81
...
...
@@ -74,6 +74,7 @@ import org.springframework.boot.loader.util.SystemPropertyUtils;
* </ul>
*
* @author Dave Syer
* @author Janne Valkealahti
*/
public
class
PropertiesLauncher
extends
Launcher
{
...
...
@@ -326,27 +327,39 @@ public class PropertiesLauncher extends Launcher {
@Override
protected
ClassLoader
createClassLoader
(
List
<
Archive
>
archives
)
throws
Exception
{
ClassLoader
loader
=
super
.
createClassLoader
(
archives
);
String
classLoaderType
=
getProperty
(
"loader.classLoader"
);
if
(
classLoaderType
!=
null
)
{
Class
<?>
type
=
Class
.
forName
(
classLoaderType
,
true
,
loader
);
try
{
loader
=
(
ClassLoader
)
type
.
getConstructor
(
ClassLoader
.
class
)
.
newInstance
(
loader
);
}
catch
(
NoSuchMethodException
e
)
{
try
{
loader
=
(
ClassLoader
)
type
.
getConstructor
(
URL
[].
class
,
ClassLoader
.
class
).
newInstance
(
new
URL
[
0
],
loader
);
}
catch
(
NoSuchMethodException
ex
)
{
loader
=
(
ClassLoader
)
type
.
newInstance
();
}
}
this
.
logger
.
info
(
"Using custom class loader: "
+
classLoaderType
);
String
customLoaderClassName
=
getProperty
(
"loader.classLoader"
);
if
(
customLoaderClassName
!=
null
)
{
loader
=
wrapWithCustomClassLoader
(
loader
,
customLoaderClassName
);
this
.
logger
.
info
(
"Using custom class loader: "
+
customLoaderClassName
);
}
return
loader
;
}
@SuppressWarnings
(
"unchecked"
)
private
ClassLoader
wrapWithCustomClassLoader
(
ClassLoader
parent
,
String
loaderClassName
)
throws
Exception
{
Class
<
ClassLoader
>
loaderClass
=
(
Class
<
ClassLoader
>)
Class
.
forName
(
loaderClassName
,
true
,
parent
);
try
{
return
loaderClass
.
getConstructor
(
ClassLoader
.
class
).
newInstance
(
parent
);
}
catch
(
NoSuchMethodException
e
)
{
// Ignore and try with URLs
}
try
{
return
loaderClass
.
getConstructor
(
URL
[].
class
,
ClassLoader
.
class
)
.
newInstance
(
new
URL
[
0
],
parent
);
}
catch
(
NoSuchMethodException
ex
)
{
// Ignore and try without any arguments
}
return
loaderClass
.
newInstance
();
}
private
String
getProperty
(
String
propertyKey
)
throws
Exception
{
return
getProperty
(
propertyKey
,
null
);
}
...
...
@@ -356,18 +369,21 @@ public class PropertiesLauncher extends Launcher {
manifestKey
=
propertyKey
.
replace
(
"."
,
"-"
);
manifestKey
=
toCamelCase
(
manifestKey
);
}
String
property
=
SystemPropertyUtils
.
getProperty
(
propertyKey
);
if
(
property
!=
null
)
{
String
value
=
SystemPropertyUtils
.
resolvePlaceholders
(
property
);
this
.
logger
.
fine
(
"Property '"
+
propertyKey
+
"' from environment: "
+
value
);
return
value
;
}
if
(
this
.
properties
.
containsKey
(
propertyKey
))
{
String
value
=
SystemPropertyUtils
.
resolvePlaceholders
(
this
.
properties
.
getProperty
(
propertyKey
));
this
.
logger
.
fine
(
"Property '"
+
propertyKey
+
"' from properties: "
+
value
);
return
value
;
}
try
{
// Prefer home dir for MANIFEST if there is one
Manifest
manifest
=
new
ExplodedArchive
(
this
.
home
).
getManifest
();
...
...
@@ -379,7 +395,9 @@ public class PropertiesLauncher extends Launcher {
}
}
catch
(
IllegalStateException
ex
)
{
// Ignore
}
// Otherwise try the parent archive
Manifest
manifest
=
createArchive
().
getManifest
();
if
(
manifest
!=
null
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/context/listener/EnvironmentDelegateApplicationListener.java
View file @
47da8a81
...
...
@@ -50,6 +50,7 @@ public class EnvironmentDelegateApplicationListener implements
private
SimpleApplicationEventMulticaster
multicaster
;
@Override
public
void
onApplicationEvent
(
ApplicationEvent
event
)
{
if
(
event
instanceof
SpringApplicationEnvironmentAvailableEvent
)
{
List
<
ApplicationListener
<
ApplicationEvent
>>
delegates
=
getListeners
(((
SpringApplicationEnvironmentAvailableEvent
)
event
)
...
...
spring-boot/src/test/java/org/springframework/boot/context/initializer/ContextIdApplicationContextInitializerTests.java
View file @
47da8a81
...
...
@@ -42,7 +42,8 @@ public class ContextIdApplicationContextInitializerTests {
@Test
public
void
testNameAndPort
()
{
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
context
,
"spring.application.name:foo"
,
"PORT:8080"
);
EnvironmentTestUtils
.
addEnvironment
(
context
,
"spring.application.name:foo"
,
"PORT:8080"
);
this
.
initializer
.
initialize
(
context
);
assertEquals
(
"foo:8080"
,
context
.
getId
());
}
...
...
@@ -59,8 +60,9 @@ public class ContextIdApplicationContextInitializerTests {
@Test
public
void
testCloudFoundry
()
{
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
context
,
"spring.config.name:foo"
,
"PORT:8080"
,
"vcap.application.name:bar"
,
"vcap.application.instance_index:2"
);
EnvironmentTestUtils
.
addEnvironment
(
context
,
"spring.config.name:foo"
,
"PORT:8080"
,
"vcap.application.name:bar"
,
"vcap.application.instance_index:2"
);
this
.
initializer
.
initialize
(
context
);
assertEquals
(
"bar:2"
,
context
.
getId
());
}
...
...
spring-boot/src/test/java/org/springframework/boot/context/initializer/EnvironmentDelegateApplicationContextInitializerTests.java
View file @
47da8a81
...
...
@@ -46,9 +46,8 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
@Test
public
void
orderedInitialize
()
throws
Exception
{
StaticApplicationContext
context
=
new
StaticApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
context
,
"context.initializer.classes:"
+
MockInitB
.
class
.
getName
()
+
","
+
MockInitA
.
class
.
getName
());
EnvironmentTestUtils
.
addEnvironment
(
context
,
"context.initializer.classes:"
+
MockInitB
.
class
.
getName
()
+
","
+
MockInitA
.
class
.
getName
());
this
.
initializer
.
initialize
(
context
);
assertThat
(
context
.
getBeanFactory
().
getSingleton
(
"a"
),
equalTo
((
Object
)
"a"
));
assertThat
(
context
.
getBeanFactory
().
getSingleton
(
"b"
),
equalTo
((
Object
)
"b"
));
...
...
@@ -79,8 +78,8 @@ public class EnvironmentDelegateApplicationContextInitializerTests {
@Test
public
void
notAnInitializerClass
()
throws
Exception
{
StaticApplicationContext
context
=
new
StaticApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
context
,
"context.initializer.classes:"
+
Object
.
class
.
getName
());
EnvironmentTestUtils
.
addEnvironment
(
context
,
"context.initializer.classes:"
+
Object
.
class
.
getName
());
this
.
thrown
.
expect
(
IllegalArgumentException
.
class
);
this
.
initializer
.
initialize
(
context
);
}
...
...
spring-boot/src/test/java/org/springframework/boot/context/listener/FileEncodingApplicationListenerTests.java
View file @
47da8a81
...
...
@@ -25,6 +25,8 @@ import org.springframework.core.env.ConfigurableEnvironment;
import
org.springframework.core.env.StandardEnvironment
;
/**
* Tests for {@link FileEncodingApplicationListener}.
*
* @author Dave Syer
*/
public
class
FileEncodingApplicationListenerTests
{
...
...
@@ -36,7 +38,8 @@ public class FileEncodingApplicationListenerTests {
@Test
(
expected
=
IllegalStateException
.
class
)
public
void
testIllegalState
()
{
EnvironmentTestUtils
.
addEnviroment
(
this
.
environment
,
"spring.mandatory_file_encoding:FOO"
);
EnvironmentTestUtils
.
addEnviroment
(
this
.
environment
,
"spring.mandatory_file_encoding:FOO"
);
this
.
initializer
.
onApplicationEvent
(
this
.
event
);
}
...
...
@@ -48,8 +51,8 @@ public class FileEncodingApplicationListenerTests {
@Test
public
void
testSunnyDayMandated
()
{
Assume
.
assumeNotNull
(
System
.
getProperty
(
"file.encoding"
));
EnvironmentTestUtils
.
addEnviroment
(
this
.
environment
,
"spring.mandatory_file_encoding:"
+
System
.
getProperty
(
"file.encoding"
));
EnvironmentTestUtils
.
addEnviroment
(
this
.
environment
,
"spring.mandatory_file_encoding:"
+
System
.
getProperty
(
"file.encoding"
));
this
.
initializer
.
onApplicationEvent
(
this
.
event
);
}
...
...
spring-boot/src/test/java/org/springframework/boot/context/listener/LoggingApplicationListenerTests.java
View file @
47da8a81
...
...
@@ -108,7 +108,8 @@ public class LoggingApplicationListenerTests {
@Test
public
void
testOverrideConfigDoesNotExist
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"logging.config: doesnotexist.xml"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"logging.config: doesnotexist.xml"
);
this
.
initializer
.
initialize
(
this
.
context
.
getEnvironment
(),
this
.
context
.
getClassLoader
());
// Should not throw
...
...
spring-boot/src/test/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesTests.java
View file @
47da8a81
...
...
@@ -184,7 +184,8 @@ public class EnableConfigurationPropertiesTests {
@Test
public
void
testCollectionPropertiesBindingFromYamlArray
()
{
this
.
context
.
register
(
TestConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
,
"list[0]:1"
,
"list[1]:2"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"name:foo"
,
"list[0]:1"
,
"list[1]:2"
);
this
.
context
.
refresh
();
assertEquals
(
2
,
this
.
context
.
getBean
(
TestProperties
.
class
).
getList
().
size
());
}
...
...
@@ -227,7 +228,8 @@ public class EnableConfigurationPropertiesTests {
@Test
public
void
testBindingDirectlyToFileResolvedFromEnvironment
()
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"binding.location:classpath:other.yml"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"binding.location:classpath:other.yml"
);
this
.
context
.
register
(
ResourceBindingProperties
.
class
,
TestConfiguration
.
class
);
this
.
context
.
refresh
();
assertEquals
(
1
,
...
...
@@ -317,7 +319,8 @@ public class EnableConfigurationPropertiesTests {
@Test
public
void
testMultipleExplicitTypes
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"external.name:foo"
,
"another.name:bar"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"external.name:foo"
,
"another.name:bar"
);
this
.
context
.
register
(
FurtherExampleConfig
.
class
);
this
.
context
.
refresh
();
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
External
.
class
).
getName
());
...
...
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