Commit Graph

3711 Commits

Author SHA1 Message Date
Dave Syer 3e97cdbc3b Trim some fat from groovy templates
The old resolver class is deprecated already, and there's no reason
to continue to support the View and View resolver implementations
from Boot 1.1, so I removed those. Also there is no need to support
older versions of Groovy, so I removed a config class that was
conditional on a groovy version (by looking for the markup support).

Fixes gh-1578
2014-11-03 09:59:25 +00:00
Brian Clozel 18b8929335 Migrate to groovy templates from Spring 4.1
Update `GroovyTemplateAutoConfiguration` to use Spring 4.1 Groovy
Markup Template infrastructure instead of Boot's.

Fixes gh-1552
2014-11-03 09:59:25 +00:00
Phillip Webb 7dd6ae76c6 Merge branch 'gh-1001' 2014-11-02 21:52:17 -08:00
Phillip Webb 9d01d4fa84 Document configuration meta-data
Add an appendix to the reference documentation describing the format
of configuration meta-data and how the annotation processor can be used.

Closes gh-1001
2014-11-02 21:49:42 -08:00
Stephane Nicoll a46396f691 Add @NestedConfigurationProperty meta-data support
Add a @NestedConfigurationProperty annotation which can be used to
customize how configuration mete-data is generated.

Prior to this commit only inner-classes where considered nested
(see Tomcat in ServerProperties). Using this new annotation, the Ssl
property in ServerProperties can be detected as well.

See gh-1001
2014-11-02 21:46:36 -08:00
Stephane Nicoll fbf8f56a97 Generate standard configuration meta-data
Update the `spring-boot`, `spring-boot-autoconfigure` and
`spring-boot-actuator` project to generate configuration meta-data
files during compilation.

See gh-1001
2014-11-02 21:46:36 -08:00
Phillip Webb c73adcd198 Add a defaultValue attribute to config meta-data
Update `ConfigurationMetadataAnnotationProcessor` to include the
'defaultValue' of a property when possible. For example the
'defaultValue' or 'server.port' is '8080'.

Default values are detected by inspecting the field assignments of
@ConfigurationProperties items. In order to detect field values some
internals of the Java compiler are used. To save a dependency on
'tools.jar' internal javac classes are accessed using reflection.

See gh-1001
2014-11-02 21:46:35 -08:00
Stephane Nicoll 884c058e57 Add processor to generate configuration meta-data
Adds an annotation processor to generates a JSON meta-data file at
compile time from @ConfigurationProperties items. Each meta-data file
can include an array or 'properties' and 'groups'.

A 'property' is a single item that may appear in a Spring Boot
'application.properties' file with a given value. For example,
'server.port' and 'server.context-path' are properties. Each property
may optionally include 'type' and 'description' attributes to provide
the data type (e.g. `java.lang.Integer`, `java.lang.String`) and
some short documentation (taken from the field javadoc) about what the
property is for. For consistency, the type of a primitive is translated
to its wrapper counterpart, i.e. `boolean` becomes `java.lang.Boolean`.

A 'group' provides a higher level grouping of properties. For example
the 'server.port' and 'server.context-path' properties are in the
'server' group.

Both 'property' and 'group' items may additional have 'sourceType' and
'sourceMethod' attributes to indicate the source that contributed them.

Users may use `META-INF/additional-spring-configuration-metadata.json`
to manually provide additionally meta-data that is not covered by
@ConfigurationProperties objects. The contents of this file will be
read and merged with harvested items. The complete meta-data file is
finally written to `META-INF/spring-configuration-metadata.json`.

See gh-1001
2014-11-02 21:46:28 -08:00
Phillip Webb 45b579c439 Improve OnBeanCondition Performance
Update OnBeanCondition to use a new BeanTypeRegistry which includes
optimized code when using a DefaultListableBeanFactory. The optimized
version calculates bean types only once per bean and caches the result.

Prior to this change the sample "pet clinic" application would spend
400-500 milliseconds evaluating OnBeanConditions, after this change it
spends around 120 milliseconds.

Fixes gh-1803
2014-11-02 13:55:06 -08:00
Phillip Webb d6f2f0deee Merge branch '1.1.x' 2014-11-02 13:23:33 -08:00
Phillip Webb 5f80f3556b Use more specific WebSecurityConfigurer @Bean type
Update ManagementSecurityAutoConfiguration to return
IgnoredPathsWebSecurityConfigurerAdapter rather than
WebSecurityConfigurer<WebSecurity>.
2014-11-02 13:20:37 -08:00
Phillip Webb a490aef888 Merge remote-tracking branch 'springsource/1.1.x'
Conflicts:
	spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java
2014-11-01 19:47:47 -07:00
Phillip Webb 8ba71c88f5 Polish 2014-11-01 19:46:04 -07:00
Dave Syer b20d02a31d Make a lazy AuthenticationManager if we think it's already configured
Instead of just blindly creating the default authentication manager, after
thic change we count the beans of type GlobalAuthenticationManagerConfigurer
and assume that if we detect more than we expect (one from Boot and one from
Spring Security) then the user is telling us they want to configure the
AuthenticationManager themselves.

Fixes gh-1801
2014-11-01 18:10:27 +00:00
Phillip Webb aa2e32a041 Restore CLI startup performance
Change InitializrService to use a late binding CloseableHttpClient
since the calling `HttpClientBuilder.create().build()` is slow.

Fixes gh-1764
2014-11-01 09:56:28 -07:00
Phillip Webb 830ce80824 Polish CLI init command
Rename a few classes and methods and extract some logic into helper
classes. Also change 2 char shortcuts to a single char.

Closes gh-1751
2014-11-01 09:05:47 -07:00
Phillip Webb b89e5e0ab7 Apply eclipse formatting rules
Apply eclipse formatting rules to b2fe2dd9.

See gh-1751
2014-11-01 08:20:12 -07:00
Phillip Webb 8e16dfc951 Polish 2014-11-01 08:20:12 -07:00
Dave Syer f15cb7a720 Add tests for AuthenticationManager injected into security configurer
See gh-1801
2014-11-01 08:58:46 +00:00
Dave Syer 49fbf215a1 Switch to Dropwizard metrics 3.1.0
Fixes gh-1775
2014-10-31 18:52:42 +00:00
Dave Syer afb7156804 Add missing method for Java 1.7 2014-10-31 18:52:25 +00:00
Dave Syer a284d7bd3f Add Codahale metrics to /metrics endpoint
All metrics in the MetricRegistry have been added unconditionally for now.

Fixes gh-1795
2014-10-31 09:33:33 +00:00
Stephane Nicoll b2fe2dd912 Add init command to the CLI
This commit adds a new command to the CLI that allows to initialize a new
project from the command line. It uses the Spring initializr service to
actually generate the project.

The command offers two main operations:

1. Listing the capabilities of the service (--list or -l). This basically
dumps the defaults of a given service and the list of dependencies and
project types it supports
2. Generating a project. By default, http://start.spring.io is used and
its configured defaults are applied. Running spring init would therefore
have the same effect as clicking the 'generate project' on the UI without
entering any extra information. No file is overwritten by default.

The generation can be customized with the following options:

* --boot-version (-bv) Spring Boot version the project should use
* --dependencies (-d) comma separated list of dependencies to add to the
generated project
* --java-version (-jv) Java version to use
* --packaging (-p) the packaging for the project (jar, war)
* --target the url of the service to use

The actual type of the project can be defined in several ways:

1. Using the --type (-t) option that identifies a type that is supported
by the service
2. A combination of --build and/or --format that can be used to uniquely
identify matching these tags. Build represents the build system to use
(e.g. maven or gradle) while --format defines the format of the generated
project.

The project is saved on disk with the name provided by the server through
the Content-Disposition header, if any. It is possible to force it with
the --output option. It is possible to overwrite existing files by adding
the --force (-f) flag.

The --extract (-x) option allows to extract the project instead of saving
the zip archive. By default, the project is extracted in the current
working directory but it is possible to specify an alternate directory
using the --output option.

Fixes gh-1751
2014-10-31 08:39:03 +01:00
Phillip Webb 4b45ce9e57 Upgrade to Spring 4.1.2.BUILD-SNAPSHOT 2014-10-30 13:54:25 -07:00
Phillip Webb 931add4a7d Programmatically configure logback defaults
Update LogbackLoggingSystem to programmatically configure logback
defaults rather than parsing XML. This change shaves about 100ms off
the start up time.

Fixes gh-1796
2014-10-30 13:32:12 -07:00
Andy Wilkinson 36ffad2bb7 Merge branch '1.1.x' 2014-10-30 15:21:55 +00:00
Andy Wilkinson 0f17142366 Make GroovyWebConfiguration conditional on spring-webmvc's availability
GroovyWebConfiguration creates a GroovyTemplateViewResolver which is
a UrlBasedViewResolver sub-class. UrlBasedViewResolver is provided
by spring-webmvc. Previously, if a user configured a web application
but did not have spring-webmvc on the classpath, the application
would fail to start with a NoClassDefFoundError for
UrlBasedViewResolver.

This commit makes GroovyWebConfiguration conditional on
UrlBasedViewResolver being on the classpath so that it backs of in
the absence of spring-webmvc.

Fixes gh-1793
2014-10-30 15:18:39 +00:00
Andy Wilkinson 0cdb1d3f22 Make Spring Security's filter's order configurable and default to zero
Previously, Spring Security's filter had no configured order. Due to
the use of AnnotationAwareOrderComparater this meant that its order
defaulted to LOWEST_PRECEDENCE. This meant that a user had to declare
a FilterRegistrationBean for the filter and explicitly set its order
if they want another filter to run after Spring Security's.

This commit updates the security auto-configuration to assign a
default order of zero to Spring Security's filter, allowing filters
to be easily configured to run before it or after it. This default
value can overridden using the server.filter-order property. The
default order is also exposed as a constant on SecurityProperties,
allowing it to be referenced from other filter declarations.

Closes gh-1640
2014-10-30 14:11:45 +00:00
Phillip Webb cf24af0bfb Rework logging to prevent double initialization
Prior to this commit LoggingSystem initialization would happen multiple
times. Once to configure "quiet" logging, and again to configure correct
settings once the Application was initialized. This could cause problems
if `logging.groovy` logback files were used.

The logging system is now only initialized once (when possible) by
following these steps:

- Standard logging initialization occurs via the actual logging
  implementation used (e.g. logback will load a logback.xml file if it
  exists)
- beforeInitization() is called to prevent early log output.
  Implementations now either use a Filter or simply set the root logging
  level.
- initialize() is called with an optional log configuration file (e.g
  a custom logback.xml location) and an optional log output file (the
  default is null indicating console only output).

The initialize() method will attempt to prevent double initialization
by checking if a standard configuration file exists. Double
initialization now only occurs in the following situations:

- The user has a standard configuration file (e.g. classpath:logback.xml)
  but also specifies a logging.config property. Double initialization is
  required since the specified configuration file supersedes the default.
- The user has a standard configuration file (e.g. classpath:logback.xml)
  and specifies a logging.file property. Double initialization is
  required since the standard configuration may use a ${LOG_FILE}
  reference.

In addition this commit removes the `logging.console` option and now
assumes that logging either occurs only to console or to both the
console and a file. This restriction helps simplify the LoggingSystem
implementations. If file only logging is required a custom logback.xml
can be used.

Fixes gh-1091
See gh-1612, gh-1770
2014-10-30 00:13:13 -07:00
Phillip Webb d17b7c8195 Polish 2014-10-29 12:08:37 -07:00
Andy Wilkinson 466ed469eb Merge branch '1.1.x' 2014-10-29 17:52:30 +00:00
Andy Wilkinson e2dd659dd1 Include condition's location (class or method name) in message
Closes gh-1787
2014-10-29 17:51:17 +00:00
Andy Wilkinson c8d7a6dc24 Merge branch '1.1.x' 2014-10-29 17:47:28 +00:00
Andy Wilkinson 9a491013c3 Update email addresses in pom files to use new pivotal.io domain
Closes gh-1774
2014-10-29 17:47:13 +00:00
Andy Wilkinson 8a1e010d0a Allow multiple templateLoaderPaths to be configured for FreeMarker
Closes gh-1767
2014-10-29 17:42:48 +00:00
Andy Wilkinson ef2455938e Align new JavaMail dependencies with Spring IO Platform
Spring IO Platform already provides dependency management for JavaMail.
This commit updates Boot’s new JavaMail dependency management to align
with the Platform, thereby allowing the Platform to inherit Boot’s
dependency management instead of defining its own.
2014-10-29 17:05:48 +00:00
Stephane Nicoll 429da743f5 Add missing close 2014-10-29 15:44:53 +01:00
Stephane Nicoll ccc5e65779 Add email support
This commit adds a new starter to auto-configure a MailSender when the
necessary classes are present and when the property "spring.mail.host" is
set.

The auto-configuration also accepts any arbitrary properties that
JavaMail might need using the "spring.mail.properties" prefix.

Fixes gh-1760
2014-10-29 15:39:05 +01:00
Dave Syer 6ed2c65852 More testing of context hierarchy creation
There actually isn't anything much we can (or should) change here. Spring always
copies PropertySources and profiles down into the child context when you set its parent.
That seems sensible. So you can add a new profile in a child context but it will always
"inherit" from its parent.

See gh-1776
2014-10-29 12:31:07 +00:00
Stephane Nicoll 1709e79cb6 Merge pull request #1763 from sdeleuze/whitelabel-typo
* whitelabel-typo:
  Fix a typo in error.whitelabel.enabled
2014-10-29 08:56:56 +01:00
Sebastien Deleuze 7546f10aad Fix a typo in error.whitelabel.enabled 2014-10-29 08:56:12 +01:00
Andy Wilkinson 741d1f7273 Merge branch '1.1.x'
Conflicts:
	spring-boot-dependencies/pom.xml
2014-10-28 19:15:58 +00:00
Andy Wilkinson 812acec48f Upgrade to Spring Batch 3.0.2.RELEASE
Closes gh-1782
2014-10-28 19:14:34 +00:00
Andy Wilkinson b1e7cd0be2 Rename spring-boot-starter-cloud in spring-boot-dependencies
Fixes #1781
2014-10-28 19:08:43 +00:00
Andy Wilkinson 15a3a21417 Ignore JUL logging tests that only fail on Bamboo 2014-10-28 17:18:44 +00:00
Dave Syer af2a867d14 Remove missing module from pom (thanks Eclipse) 2014-10-28 16:14:45 +00:00
Andy Wilkinson d71afe0918 Remove redundant reference to renamed spring-boot-starter-cloud module 2014-10-28 16:13:26 +00:00
Dave Syer e2f2099197 Add test for gh-1776 2014-10-28 16:12:14 +00:00
Dave Syer b95e6fce6b Add 'Connectors' to project name 2014-10-28 16:11:45 +00:00
Dave Syer 7fa372555b Add @SuppressWarnings('serial') 2014-10-28 15:57:49 +00:00