Commit Graph

7873 Commits

Author SHA1 Message Date
Chris Beams
367a0c2933 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
2011-05-26 13:34:21 +00:00
Chris Beams
2ceeff370a Allow multiple locations via @PropertySource#value
Issue: SPR-8314
2011-05-25 10:52:25 +00:00
Chris Beams
0756a6abfe Polish PropertySource and Environment Javadoc 2011-05-25 10:52:03 +00:00
Arjen Poutsma
37d955b35b Added tests for @RequestMaping produces and consumes 2011-05-25 09:21:44 +00:00
Keith Donald
f43d0e1003 Revised converter search algorithm to favor super classes before interface hierarchy 2011-05-24 22:20:54 +00:00
Keith Donald
ad93d20a6c SPR-6749 2011-05-24 19:40:14 +00:00
Keith Donald
47e3f0948d polish 2011-05-24 18:32:01 +00:00
Keith Donald
01cbfd4f6f added null binding check for primitives for all conversion results; polishing 2011-05-24 17:53:18 +00:00
Rossen Stoyanchev
c5833b192e SPR-7353 Use canWrite to narrow down list of producible types 2011-05-24 17:22:22 +00:00
Keith Donald
d02e37a307 added new ConverterRegistry operation; polishing 2011-05-24 03:47:50 +00:00
Keith Donald
e25fbf2533 added symmetry to ToString converters: SPR-8306 2011-05-23 23:00:43 +00:00
Sam Brannen
e11d7c328f Added Eclipse project dependency on org.springframework.asm 2011-05-23 17:18:14 +00:00
Chris Beams
c4363673dc 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
2011-05-23 10:04:00 +00:00
Chris Beams
c696e195fa 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
2011-05-23 10:03:23 +00:00
Chris Beams
e128ee2464 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
2011-05-23 10:02:50 +00:00
Chris Beams
56720fc42c 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
2011-05-23 10:02:18 +00:00
Chris Beams
3c6254df90 Polish FrameworkServlet Javadoc; fix warnings 2011-05-23 10:01:49 +00:00
Keith Donald
7430fcd904 SPR-8364 2011-05-23 07:38:27 +00:00
Keith Donald
5c67dbf424 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 2011-05-23 05:21:02 +00:00
Keith Donald
79f9d1cfc6 moved applyIndexedObject internal, now invoked inside forObject static factory method 2011-05-23 01:08:18 +00:00
Keith Donald
4d6a5849f7 SPR-8364 2011-05-22 19:10:40 +00:00
Chris Beams
4a6101a697 Guard against null in #visitInnerClass
Issue: SPR-8358,SPR-8186
2011-05-21 01:39:50 +00:00
Chris Beams
95b1dbadb0 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
2011-05-21 01:20:33 +00:00
Chris Beams
5b2c7c4e58 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
2011-05-21 01:20:03 +00:00
Chris Beams
76e3d2855a Polish @Configuration-related Javadoc 2011-05-21 01:19:25 +00:00
Rossen Stoyanchev
5fa7f24794 SPR-7353 Respect 'produces' condition in ContentNegotiatingViewResolver, improve selection of more specific media type in a pair 2011-05-20 17:02:20 +00:00
Chris Beams
c481d2e9fb Rename {Default=>Standard}PortletEnvironment
Issue: SPR-8348
2011-05-20 03:57:35 +00:00
Chris Beams
f893b62a9b Rename {DefaultWeb=>StandardServlet}Environment
Issue: SPR-8348
2011-05-20 03:55:56 +00:00
Chris Beams
c06752ef72 Rename {Default=>Standard}Environment
Issue: SPR-8348
2011-05-20 03:53:37 +00:00
Chris Beams
615fcff7ae Polish Environment-related Javadoc 2011-05-20 03:50:41 +00:00
Chris Beams
7271ba8182 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
2011-05-20 03:50:14 +00:00
Chris Beams
c4a13507f0 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
2011-05-20 03:49:15 +00:00
Chris Beams
415057c184 Remove AbstractEnvironment#getPropertyResolver
Method is obsolete now that Environment (thus AbstractEnvironment as
well) implements the ConfigurablePropertyResolver interface.
2011-05-20 03:48:19 +00:00
Chris Beams
818467b9e5 Consolidate Environment tests 2011-05-20 03:47:48 +00:00
Rossen Stoyanchev
0bf92782ea SPR-8352 Init and apply MappedInterceptors from AbstractHandlerMapping 2011-05-19 16:45:25 +00:00
Arjen Poutsma
60aa598c03 SPR-8296 - Extension for CastorMarshaller - additional unmarshaller properties 2011-05-19 14:01:35 +00:00
Arjen Poutsma
dd8a9cce05 SPR-8295 - Extension for CastorMarshaller - additional marshaller properties 2011-05-19 13:34:36 +00:00
Rossen Stoyanchev
5ac2e4418f SPR-8350 ContentNegotiatingViewResolver initialization for nested ViewResolvers 2011-05-19 13:07:15 +00:00
Rossen Stoyanchev
100fed47f3 SPR-7353 Doc update for consumes/produces + changelog update 2011-05-19 13:05:53 +00:00
Costin Leau
b39673aa79 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
2011-05-18 18:34:41 +00:00
Costin Leau
dadd0f57ee revised cache abstraction
- removed AbstractDelegatingCache (a cache is not a map, no need to offer a template)
+ renamed ConcurrentCache to ConcurrentCacheMap
2011-05-18 17:43:13 +00:00
Arjen Poutsma
1eaca65720 @RequestMapping.consumes() and produces() now default to an empty array, instead of */* 2011-05-18 11:34:47 +00:00
Arjen Poutsma
a618bcc8cd Exposing HttpServletRequest/Response in ServletServerHttpRequest/Response 2011-05-18 11:24:57 +00:00
Chris Beams
4520ea8690 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
2011-05-18 08:53:46 +00:00
Chris Beams
6fcea8b99d Remove ConfigurationClassParser from public API
Issue: SPR-8200
2011-05-17 19:15:17 +00:00
Costin Leau
8dfcae535e revise cache API
+ update failing test
2011-05-17 18:16:07 +00:00
Costin Leau
0eb40e1e5e revise cache API
+ update failing test
2011-05-17 18:01:35 +00:00
Costin Leau
dea1fc933f revise cache API
+ update failing AJ test
2011-05-17 17:35:01 +00:00
Costin Leau
861e481755 revise cache API
+ update failing test
2011-05-17 17:09:49 +00:00
Costin Leau
3699a037a5 revise cache API
+ add missing files (remember to check "show unversioned files")
2011-05-17 16:58:15 +00:00