Commit Graph

4174 Commits

Author SHA1 Message Date
Rossen Stoyanchev d2a4316a70 SPR-8218 MVC chapter updates
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4366 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-27 17:09:53 +00:00
Chris Beams d9b73461ff Upgrade javax.servlet dependency to 3.0 for .web
In support of SPR-7672 which will support code-based configuration
alternatives to web.xml using new features in the Servlet 3.0 API.

This upgrade does *not* force Spring users to upgrade to Servlet 3.0
capable containers.  Compatibility with and support for
javax.servlet >= 2.4 remains.

Issue: SPR-7672

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4365 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-26 13:34:21 +00:00
Chris Beams 5049cd0db3 Allow multiple locations via @PropertySource#value
Issue: SPR-8314

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4364 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-25 10:52:25 +00:00
Chris Beams 2a896753d4 Polish PropertySource and Environment Javadoc
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4363 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-25 10:52:03 +00:00
Arjen Poutsma 2e8c494824 Added tests for @RequestMaping produces and consumes
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4362 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-25 09:21:44 +00:00
Keith Donald fbf43508f1 Revised converter search algorithm to favor super classes before interface hierarchy
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4361 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-24 22:20:54 +00:00
Keith Donald 7d7e8ef7fb SPR-6749
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4360 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-24 19:40:14 +00:00
Keith Donald 8b9196ab7c polish
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4359 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-24 18:32:01 +00:00
Keith Donald 115348b6be added null binding check for primitives for all conversion results; polishing
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4358 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-24 17:53:18 +00:00
Rossen Stoyanchev af8f63fa65 SPR-7353 Use canWrite to narrow down list of producible types
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4357 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-24 17:22:22 +00:00
Keith Donald c3a037d7be added new ConverterRegistry operation; polishing
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4356 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-24 03:47:50 +00:00
Keith Donald 00bcadcbe5 added symmetry to ToString converters: SPR-8306
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4355 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-23 23:00:43 +00:00
Sam Brannen 1b71b04a3b Added Eclipse project dependency on org.springframework.asm
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4354 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-23 17:18:14 +00:00
Chris Beams c0b7d175e9 Delegate parent environment to child app contexts
Calls to AbstractApplicationContext#setParent delegate the parent
context environment to the child.

This ensures that any property sources added to the parent are available
to the child as well as ensuring that any profiles activated are
activated everywhere.

Child contexts may still choose to replace their environment (through an
ApplicationContextInitializer, for example).  In any case, however, in
the root/child web application context relationship established by
ContextLoader + DispatcherServlet, the child is guaranteed to have
already been given the parent environment by the time it is delegated
to any ACIs.

See AbstractApplicationContext#setParent for implementation

See FrameworkServlet#createWebApplicationContext for order in which
setParent then initializeWebApplicationContext are called.

Issue: SPR-8185

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4353 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-23 10:04:00 +00:00
Chris Beams f82aabb6c3 Introduce AnnotationConfigCapableApplicationContext
AnnotationConfigApplicationContext and
AnnotationConfigWebApplicationContext both expose #register and #scan
methods as of the completion of SPR-8320. This change introduces a new
interface that declares each of these methods and refactors ACAC and
ACWAC to implement it.

Beyond information value, this is useful for implementors of the
ApplicationContextInitializer interface, in that users may create an ACI
that works consistently across ACAC and ACWAC for standalone (e.g.
testing, batch) or web (e.g. production) use.

Issue: SPR-8365,SPR-8320

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4352 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-23 10:03:23 +00:00
Chris Beams 1fee0f3176 Introduce AnnotationConfigWAC #scan and #register
Primarily for use in conjunction with ApplicationContextInitializer,
these new #scan and #register methods mirror those in
AnnotationConfigApplicationContext. #setConfigLocation
and #setConfigLocations methods remain for compatibility with
ContextLoader-style initialization, but have been locally overridden
and documented clearly.

AnnotationConfigWebApplicationContext#loadBeanDefinitions Javadoc has
also been updated to explain the processing logic for each of these
potential inputs.

Issue: SPR-8320

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4351 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-23 10:02:50 +00:00
Chris Beams 1b34c00884 Support "contextInitializerClasses" init-param
FrameworkServlet now has support equivalent to ContextLoader and its
"contextInitializerClasses" context-param introduced in 3.1 M1.

This allows users to specify ApplicationContextInitializers at the root
(ContextLoader) level and/or at the DispatcherServlet level.

Issue: SPR-8366

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4350 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-23 10:02:18 +00:00
Chris Beams 8f4c1c339e Polish FrameworkServlet Javadoc; fix warnings
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4349 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-23 10:01:49 +00:00
Keith Donald 02d58b6a97 SPR-8364
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4348 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-23 07:38:27 +00:00
Keith Donald 888da26094 revised findCommonElement handling within TypeDescriptor.forObject(Object); we now fully introspect the collection elements to resolve the common type. We also support nested introspection e.g. collections of collections. Object.class is used to indicate no common type, and TypeDescriptor.NULL is used to indicate a null element value
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4347 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-23 05:21:02 +00:00
Keith Donald c9789d3a37 moved applyIndexedObject internal, now invoked inside forObject static factory method
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4346 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-23 01:08:18 +00:00
Keith Donald c42976ba7a SPR-8364
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4345 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-22 19:10:40 +00:00
Chris Beams a9530596bf Guard against null in #visitInnerClass
Issue: SPR-8358,SPR-8186

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4344 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-21 01:39:50 +00:00
Chris Beams 027e431bbd Register nested @Configuration classes automatically
The following is now possible:

@Configuration
public class AppConfig {
    @Inject DataSource dataSource;

    @Bean
    public MyBean myBean() {
        return new MyBean(dataSource);
    }

    @Configuration
    static class DatabaseConfig {
        @Bean
        DataSource dataSource() {
            return new EmbeddedDatabaseBuilder().build();
        }
    }
}

public static void main(String... args) {
    AnnotationConfigApplicationContext ctx =
        new AnnotationConfigApplicationContext(AppConfig.class);
    ctx.getBean(MyBean.class);     // works
    ctx.getBean(DataSource.class); // works
}

Notice that the @Import annotation was not used and that only AppConfig
was registered against the context. By virtue of the fact that
DatabaseConfig is a member class of AppConfig, it is automatically
registered when AppConfig is registered. This avoids an awkward and
redundant @Import annotation when the relationship is already implicitly
clear.

See @Configuration Javadoc for details.

Issue: SPR-8186

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4343 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-21 01:20:33 +00:00
Chris Beams 0181ed3213 Introduce ClassMetadata#getMemberClassNames
ClassMetadata implementations can now introspect their member (nested)
classes. This will allow for automatic detection of nested
@Configuration types in SPR-8186.

Issue: SPR-8358,SPR-8186

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4342 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-21 01:20:03 +00:00
Chris Beams 73eb53f002 Polish @Configuration-related Javadoc
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4341 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-21 01:19:25 +00:00
Rossen Stoyanchev 1b48f26900 SPR-7353 Respect 'produces' condition in ContentNegotiatingViewResolver, improve selection of more specific media type in a pair
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4340 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-20 17:02:20 +00:00
Chris Beams c834ba84f3 Rename {Default=>Standard}PortletEnvironment
Issue: SPR-8348

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4339 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-20 03:57:35 +00:00
Chris Beams 2b6bcf470c Rename {DefaultWeb=>StandardServlet}Environment
Issue: SPR-8348

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4338 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-20 03:55:56 +00:00
Chris Beams cf19ecc5a7 Rename {Default=>Standard}Environment
Issue: SPR-8348

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4337 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-20 03:53:37 +00:00
Chris Beams 74cd20abeb Polish Environment-related Javadoc
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4336 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-20 03:50:41 +00:00
Chris Beams 3fcb25c1c6 Introduce AbstractEnvironment#customizePropertySources
This new hook in the AbstractEnvironment lifecycle allows for more
explicit and predictable customization of property sources by
subclasses.  See Javadoc and existing implementations for detail.

Issue: SPR-8354

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4335 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-20 03:50:14 +00:00
Chris Beams ebea9ec66c Introduce reserved default profile support
AbstractEnvironment and subclasses now register a reserved default
profile named literally 'default' such that with no action on the part
of the user, beans defined against the 'default' profile will be
registered - if no other profiles are explicitly activated.

For example, given the following three files a.xml, b.xml and c.xml:

    a.xml
    -----
    <beans> <!-- no 'profile' attribute -->
        <bean id="a" class="com.acme.A"/>
    </beans>

    b.xml
    -----
    <beans profile="default">
        <bean id="b" class="com.acme.B"/>
    </beans>

    c.xml
    -----
    <beans profile="custom">
        <bean id="c" class="com.acme.C"/>
    </beans>

bootstrapping all of the files in a Spring ApplicationContext as
follows will result in beans 'a' and 'b', but not 'c' being registered:

    ApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.load("a.xml");
    ctx.load("b.xml");
    ctx.load("c.xml");
    ctx.refresh();
    ctx.containsBean("a"); // true
    ctx.containsBean("b"); // true
    ctx.containsBean("c"); // false

whereas activating the 'custom' profile will result in beans 'a' and
'c', but not 'b' being registered:

    ApplicationContext ctx = new GenericXmlApplicationContext();
    ctx.load("a.xml");
    ctx.load("b.xml");
    ctx.load("c.xml");
    ctx.getEnvironment().setActiveProfiles("custom");
    ctx.refresh();
    ctx.containsBean("a"); // true
    ctx.containsBean("b"); // false
    ctx.containsBean("c"); // true

that is, once the 'custom' profile is activated, beans defined against
the the reserved default profile are no longer registered. Beans not
defined against any profile ('a') are always registered regardless of
which profiles are active, and of course beans registered
against specific active profiles ('c') are registered.

The reserved default profile is, in practice, just another 'default
profile', as might be added through calling env.setDefaultProfiles() or
via the 'spring.profiles.default' property.  The only difference is that
the reserved default is added automatically by AbstractEnvironment
implementations.  As such, any call to setDefaultProfiles() or value set
for the 'spring.profiles.default' will override the reserved default
profile.  If a user wishes to add their own default profile while
keeping the reserved default profile as well, it will need to be
explicitly redeclared, e.g.:

    env.addDefaultProfiles("my-default-profile", "default")

The reserved default profile(s) are determined by the value returned
from AbstractEnvironment#getReservedDefaultProfiles().  This protected
method may be overridden by subclasses in order to customize the
set of reserved default profiles.

Issue: SPR-8203

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4334 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-20 03:49:15 +00:00
Chris Beams cd38a828d2 Remove AbstractEnvironment#getPropertyResolver
Method is obsolete now that Environment (thus AbstractEnvironment as
well) implements the ConfigurablePropertyResolver interface.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4333 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-20 03:48:19 +00:00
Chris Beams 71d713b604 Consolidate Environment tests
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4332 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-20 03:47:48 +00:00
Rossen Stoyanchev f30ae5abc8 SPR-8352 Init and apply MappedInterceptors from AbstractHandlerMapping
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4331 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-19 16:45:25 +00:00
Arjen Poutsma bd4a08df62 SPR-8296 - Extension for CastorMarshaller - additional unmarshaller properties
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4330 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-19 14:01:35 +00:00
Arjen Poutsma 84f00122b6 SPR-8295 - Extension for CastorMarshaller - additional marshaller properties
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4329 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-19 13:34:36 +00:00
Rossen Stoyanchev 408be8082a SPR-8350 ContentNegotiatingViewResolver initialization for nested ViewResolvers
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4328 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-19 13:07:15 +00:00
Rossen Stoyanchev 6e86bc5bc2 SPR-7353 Doc update for consumes/produces + changelog update
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4327 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-19 13:05:53 +00:00
Costin Leau 7a91725ba6 revised cache abstraction
- removed generics from Cache/CacheManager (they add no value since it's an SPI not API)
+ update docs and tests
+ renamed ConcurrentCacheFactoryBean to ConcurrentMapCacheFactoryBean

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4326 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-18 18:34:41 +00:00
Costin Leau 903928e504 revised cache abstraction
- removed AbstractDelegatingCache (a cache is not a map, no need to offer a template)
+ renamed ConcurrentCache to ConcurrentCacheMap

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4325 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-18 17:43:13 +00:00
Arjen Poutsma 66e1c8c743 @RequestMapping.consumes() and produces() now default to an empty array, instead of */*
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4324 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-18 11:34:47 +00:00
Arjen Poutsma 99e7650b53 Exposing HttpServletRequest/Response in ServletServerHttpRequest/Response
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4323 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-18 11:24:57 +00:00
Chris Beams 692245b0bc Revert #processConfigBeanDefinitions to 3.0.x API
Revert signature of
ConfigurationClassPostProcessor#processConfigBeanDefinitions to its form
found in the 3.0.x line.  Refactorings made during 3.1 development
caused otherwise package-private types such as
ConfigurationClassBeanDefinitionReader to escape through this public
method, causing issues for STS as well as being a general design issue.

Upon review, the refactorings could easily be backed out in favor of a
simpler approach, and this has been done.

This also means that ConfigurationClassBeanDefinitionReader can return
to package-private visibility, and this change has been made as well.

Issue: SPR-8200

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4322 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-18 08:53:46 +00:00
Chris Beams 2c75acba5a Remove ConfigurationClassParser from public API
Issue: SPR-8200

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4321 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-17 19:15:17 +00:00
Costin Leau 669c99e823 revise cache API
+ update failing test

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4320 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-17 18:16:07 +00:00
Costin Leau 8992fd80c0 revise cache API
+ update failing test

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4319 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-17 18:01:35 +00:00
Costin Leau 86a499b786 revise cache API
+ update failing AJ test

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4318 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-17 17:35:01 +00:00
Costin Leau e4ed1f1530 revise cache API
+ update failing test

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4317 50f2f4bb-b051-0410-bef5-90022cba6387
2011-05-17 17:09:49 +00:00