Commit Graph

172 Commits

Author SHA1 Message Date
Dave Syer
b32297078f Re-org README a bit 2013-12-24 13:39:21 +00:00
Dave Syer
aee42fcc18 Add instanceof check and nice fat error message
If Logback and another SLF4J implementation are both on the classpath
it is possible for the LogbackLoggingSystem to fail to locate
a LoggerContext. Rather than a ClassCastException it is better to
make an assertion with an error message.

Fixes gh-162
2013-12-24 09:54:35 +00:00
Dave Syer
22762f2004 Adjust @PropertySource handling so @Conditionals are accounted for
User can now do this, for instance:

    @Configuration
    @PropertySource("classpath:my.properties")
    public class MainConfiguration {}

    @Configuration
    @PropertySource("classpath:foo.properties")
    @Profile("foo")
    public class FooConfiguration {}

and the "foo" properties ar eonly loaded in the "foo" profile.
2013-12-23 13:14:41 +00:00
Dave Syer
bd0a499ab8 Parse @PropertySource annotations on SpringApplication sources
If any of the sources has a @PropertySource annotation (or many)
then we can add those properties to the Environment. It's a nice
convenient way of specifying a custom external properties location
for an app.

One problem is that Spring will come along and parse the same
annotations later as part of the @Configuration parsing. The
user has pretty limited control over how that is done, and it
will never be done in a "natural" way for a Boot application
(which would prefer that the default application.properties
is applied *last*, whereas Spring will apply the @PropertySource
last).

To get round that problem we add the property sources with
a different name (key in the PropertySources in Environment),
prefixing named property sources with "boot.", and adding
others with a name that is the same as the resource location
(instead of its description, which is the default for
Spring).

Another problem is that Spring doesn't know about YAML, so
the user is currently restricted to using properties files
with this annotation.
2013-12-23 09:22:15 +00:00
Dave Syer
808daa54e5 Make SpringApplication.getSources() do what it says on the can
We still need the distinction internally between initial and additional
sources, but the SpringApplication API (getSources()) itself doen't
need to reflect that.
2013-12-23 08:58:09 +00:00
Dave Syer
fa507005cd Use ServletWrappingController for jolokia instead of Servlet
We get more control over the handling and in particular the registration
of the endpoint this way. It was practically impossible to disable the
AgentServlet bean when in a parent context of the management server
because of lifecyce issues - you don't know that the user wants a
separate management server until too late.

This approach also makes it possible to test with spring-test MVC
support.
2013-12-20 19:49:48 +00:00
Dave Syer
75af18df7d Add support for beans{} in CLI scripts
User can add (a single) beans{} DSL declaration (see GroovyBeanDefinitionReader
in Spring 4 for more detail) anywhere at the top level of an application source
file. It will be compiled to a closure and fed in to the application context
through a GroovyBeanDefinitionReader. Cool!

The example spring-boot-cli/samples/beans.groovy runs in an integration test
and passes (see SampleIntegrationTests).
2013-12-19 17:11:01 +00:00
Phillip Webb
fa1ff72fb1 Restore quiet logging on startup
Reinstate initializeWithSensibleDefaults() on AbstractLoggingSystem
beforeInitialize(). This is required to ensure no superfluous logging
output occurs when starting up a spring boot application from the
command line.

It appears that commit e9c649dfb2
modified the logic in an attempt to prevent double initialization.

fixes gh-174
2013-12-18 10:46:49 -08:00
Phillip Webb
7c57541d50 Filter duplicates from SpringFactories loading
Filter duplicate class names when loading spring.factories files. The
prevents errors if -source jars are included on the classpath.

fixes gh-161
2013-12-18 09:55:06 -08:00
Dave Syer
0d0de05ae6 Add support for Groovy bean builder sources 2013-12-18 15:01:56 +00:00
Dave Syer
1194fc882b Add feature to SimpleJsonParser
Now it can parse nested lists as map values.

Fixes gh-169
2013-12-17 09:53:21 +00:00
Dave Syer
bddf624bcb Merge EnableConfigurationPropertiesTests
Fixes gh-168
2013-12-17 09:40:34 +00:00
Phillip Webb
513c6a1de2 Polish 2013-12-16 14:38:52 -08:00
Phillip Webb
983ef16eae Remove SystemProperties from tests in strict mode
Remove system properties when testing strict property binding. This
prevents test failures that can occur if the local environment happens
to have certain environment variables defined.
2013-12-16 12:59:49 -08:00
johnou
e9c649dfb2 Avoid double logging config init + support for slf4j-log4j. 2013-12-16 16:21:08 +00:00
Dave Syer
a8c69220c7 Only log startup info (PID etc) for root context
Fixes gh-153
2013-12-11 10:35:40 +00:00
Glenn Renfro
6cf3b91b2e Allow use of underscores in @ConfigurationProperties prefix
Currently the PropertiesConfigurationFilter filters them out.
Thus when deploying to IAAS these environment variables are ignored.

Fixes gh-154
2013-12-11 10:17:55 +00:00
Dave Syer
76ea99ad0b Add instance id suffix to Tomcat Engine name
Fixes gh-160
2013-12-11 09:46:36 +00:00
Dave Syer
4ab77ca893 Added exceptionIfInvalid attribute to @ConfigurationProperties
Default behaviour unchanged, but if you want to ignore validation errors
you can switch them off for indivdual beans now.

Fixes gh-144
2013-12-05 09:16:23 +00:00
Ivan Sopov
40bfd295eb minor fix for javadoc 2013-12-02 14:39:10 +02:00
Dave Syer
4a60e3ccf6 Unignore condition tests 2013-11-29 17:20:30 +00:00
Dave Syer
c16b5d277e Add test for Valve added 2013-11-29 17:06:08 +00:00
Dave Syer
6cfbcafc10 Switch to httpcomponents for better error handling in tests 2013-11-29 16:56:17 +00:00
Dave Syer
d39fc5bb92 Tidy up some tests 2013-11-28 17:35:48 +00:00
Dave Syer
9db55a3b71 Add explicit test for config file and SpringApplication 2013-11-28 16:46:21 +00:00
Dave Syer
131cfd6114 Update @SpringApplicationConfiguration after comment in 3e6c1b 2013-11-28 15:45:57 +00:00
Dave Syer
3e6c1b435f Add @SpringApplicationConfiguration (for integration testing)
Example:

    @RunWith(SpringJUnit4ClassRunner.class)
    @SpringApplicationConfiguration(classes = SampleDataJpaApplication.class)
    public class CityRepositoryIntegrationTests {

    	@Autowired
    	CityRepository repository;

Fixes gh-66.
2013-11-28 14:35:36 +00:00
Dave Syer
67cc427d2b Expose local port in EmbeddedServletContainer 2013-11-27 15:50:46 +00:00
Dave Syer
d1dcb015b6 Ensure only supported listeners are instantiated
Previously all EventListeners were eagerly instantiated
but that can cause problems because it happens quite early
in the lifecycle. Better to be explicit about the
supported types.
2013-11-27 15:04:05 +00:00
Dave Syer
aefec4c16a Check that SessionScope is available early 2013-11-27 14:04:09 +00:00
Dave Syer
564475556e Allow for commandLineArgs to be already present in Environment 2013-11-26 10:00:50 +00:00
Phillip Webb
f4f668a52b Polish 2013-11-25 17:12:56 -08:00
Dave Syer
aeb0f0a625 Add random.* property source 2013-11-25 15:08:53 +00:00
Dave Syer
94c5203de6 Add more smarts to properties binding
* Underscores are allowed as nested property field separators
* System and env vars are only considered for binding if they
look like they apply to a given bean when ignoreUnknownFields
is false
2013-11-25 15:08:53 +00:00
Christian Dupuis
e06596ada8 Merge pull request #132 from nitram509/fix-exception-msg-typos
fixed typos in Exception messages
2013-11-25 02:25:17 -08:00
Dave Syer
98ae4ed928 Add ignoreNestedFields option to @ConfigurationProperties
@ConfigurationProperties(ignoreUnkownFields=false,ignoreNestedFields=true)
is now a useful option for binding to "top-level" command line options
(without a prefix). In that case we don't try to bind to `server.*` and
other common prefixed property values (at the cost of not being able to
bind to nested beans).
2013-11-25 09:15:09 +00:00
nitram509
cbc9c6a156 fixed 3 x typos in Exception messages 2013-11-24 13:40:50 +01:00
Dave Syer
8efa2fc569 Use server.port=0 for scanning
This leverages existing capabilities of teh JDK and the OS
to grab a port at random and not have it stolen by another
process. It's very hard to avoid that race condition in
pure Java code, so why bother?

User can set port<0 to disable autoStart of connectors (e.g.
to start a web application context but not have it listen on
any port). In that case the actual socket port will be set to
0 (and therefore if it ever starts up the local port will
be random).
2013-11-23 11:26:58 +00:00
Dave Syer
61dd7d1dbb Add port scan to ServerProperties (server.scan=true)
Also moved ServerProperties to autoconfigure project.
2013-11-22 16:56:43 +00:00
Dave Syer
bd26b28aa5 Extract actuator security into separate classes
So spring-security + a web app is secure by default
(you don't need the actuator).
2013-11-21 16:47:29 +00:00
Dave Syer
285dd5b270 ApplicationContextInitializers now listen for ContextRefreshedEvent
The AutoConfigurationReportLoggingInitializer wasn't working in
non-GenericApplicationContext becasue teh BeanFatcory wasn't available
for registering its listener during initialization. Instead of
relying on that rather fragile state I decided to give any
ApplicationContextInitializer that was itself an ApplicationListener
an explicit callback with a ContextRefreshedEvent, and move that
interface up a level in the logging initializer. Works much better.
2013-11-21 09:35:00 +00:00
Dave Syer
40b787c71a Add test for allowed/disallowed fields 2013-11-20 15:59:46 +00:00
Dave Syer
6d4d495003 Tweak ApplicationContext ID
VCAP environemt applied consistently, and more tests.

[Fixes #60750138] [bs-351] Add API for application context id
2013-11-20 10:55:14 +00:00
Dave Syer
439f041354 Remove test resources from tests JAR 2013-11-20 08:41:10 +00:00
nitram509
c50fe0733b TomcatEmbeddedServletContainer now fails fast, if there are exceptions during protocol handler startup (re-throw exception) 2013-11-19 13:35:06 +00:00
Dave Syer
caffc28b4c Add test for initializers when child context created 2013-11-19 09:03:43 +00:00
Dave Syer
71fd474ed2 Ensure ApplicationContextInitializers are not overwritten
SpringApplicationBuilder has to be careful not to overwrite the
default initializers if user calls its initializers() method.

Fixes gh-120.
2013-11-18 09:59:11 +00:00
Dave Syer
17de6689ab ENsure Vcap initializer runs before config file parser
Fixes gh-119.
2013-11-17 15:29:12 +00:00
Phillip Webb
64f32893bb Source format and clean-up 2013-11-16 00:08:18 -08:00
Phillip Webb
883fd9162f Polish 2013-11-16 00:08:17 -08:00