Commit Graph

112 Commits

Author SHA1 Message Date
Chris Beams
b3ff9be78f M1 cut of environment, profiles and property work (SPR-7508)
Decomposed Environment interface into PropertySources, PropertyResolver
objects

    Environment interface and implementations are still present, but
    simpler.

    PropertySources container aggregates PropertySource objects;
    PropertyResolver provides search, conversion, placeholder
    replacement. Single implementation for now is
    PropertySourcesPlaceholderResolver

Renamed EnvironmentAwarePropertyPlaceholderConfigurer to
PropertySourcesPlaceholderConfigurer

    <context:property-placeholder/> now registers PSPC by default, else
    PPC if systemPropertiesMode* settings are involved

Refined configuration and behavior of default profiles

    See Environment interface Javadoc for details

Added Portlet implementations of relevant interfaces:

    * DefaultPortletEnvironment
    * PortletConfigPropertySource, PortletContextPropertySource
    * Integrated each appropriately throughout Portlet app contexts

Added protected 'createEnvironment()' method to AbstractApplicationContext

    Subclasses can override at will to supply a custom Environment
    implementation.  In practice throughout the framework, this is how
    Web- and Portlet-related ApplicationContexts override use of the
    DefaultEnvironment and swap in DefaultWebEnvironment or
    DefaultPortletEnvironment as appropriate.

Introduced "stub-and-replace" behavior for Servlet- and Portlet-based
PropertySource implementations

    Allows for early registration and ordering of the stub, then
    replacement with actual backing object at refresh() time.

    Added AbstractApplicationContext.initPropertySources() method to
    support stub-and-replace behavior. Called from within existing
    prepareRefresh() method so as to avoid impact with
    ApplicationContext implementations that copy and modify AAC's
    refresh() method (e.g.: Spring DM).

    Added methods to WebApplicationContextUtils and
    PortletApplicationContextUtils to support stub-and-replace behavior

Added comprehensive Javadoc for all new or modified types and members

Added XSD documentation for all new or modified elements and attributes

    Including nested <beans>, <beans profile="..."/>, and changes for
    certain attributes type from xsd:IDREF to xsd:string

Improved fix for detecting non-file based Resources in
PropertiesLoaderSupport (SPR-7547, SPR-7552)

    Technically unrelated to environment work, but grouped in with
    this changeset for convenience.

Deprecated (removed) context:property-placeholder
'system-properties-mode' attribute from spring-context-3.1.xsd

    Functionality is preserved for those using schemas up to and including
    spring-context-3.0.  For 3.1, system-properties-mode is no longer
    supported as it conflicts with the idea of managing a set of property
    sources within the context's Environment object. See Javadoc in
    PropertyPlaceholderConfigurer, AbstractPropertyPlaceholderConfigurer
    and PropertySourcesPlaceholderConfigurer for details.

Introduced CollectionUtils.toArray(Enumeration<E>, A[])

Work items remaining for 3.1 M2:

    Consider repackaging PropertySource* types; eliminate internal use
    of SystemPropertyUtils and deprecate

    Further work on composition of Environment interface; consider
    repurposing existing PlaceholderResolver interface to obviate need
    for resolve[Required]Placeholder() methods currently in Environment.

    Ensure configurability of placeholder prefix, suffix, and value
    separator when working against an AbstractPropertyResolver

    Add JNDI-based Environment / PropertySource implementatinos

    Consider support for @Profile at the @Bean level

    Provide consistent logging for the entire property resolution
    lifecycle; consider issuing all such messages against a dedicated
    logger with a single category.

    Add reference documentation to cover the featureset.
2011-01-03 09:04:34 +00:00
Chris Beams
b3e36a335d Eliminate reserved 'default' profile (SPR-7778)
There is no longer a reserved default profile named 'default'. Rather,
users must explicitly specify a default profile or profiles via

    ConfigurableEnvironment.setDefaultProfiles(String...)
        - or -
    spring.profile.default="pD1,pD2"

Per above, the setDefaultProfile(String) method now accepts a variable
number of profile names (one or more).  This is symmetrical with the
existing setActiveProfiles(String...) method.

A typical scenario might involve setting both a default profile as a
servlet context property in web.xml and then setting an active profile
when deploying to production.
2010-12-08 07:59:25 +00:00
Chris Beams
5062dc31af Support default profile (SPR-7508, SPR-7778)
'default' is now a reserved profile name, indicating
that any beans defined within that profile will be registered
unless another profile or profiles have been activated.

Examples below are expressed in XML, but apply equally when
using the @Profile annotation.

EXAMPLE 1:

        <beans>
            <beans profile="default">
                <bean id="foo" class="com.acme.EmbeddedFooImpl"/>
            </beans>
            <beans profile="production">
                <bean id="foo" class="com.acme.ProdFooImpl"/>
            </beans>
        </beans>

    In the case above, the EmbeddedFooImpl 'foo' bean will be
    registered if:
        a) no profile is active
        b) the 'default' profile has explicitly been made active

    The ProdFooImpl 'foo' bean will be registered if the 'production'
    profile is active.

EXAMPLE 2:

        <beans profile="default,xyz">
            <bean id="foo" class="java.lang.String"/>
        </beans>

    Bean 'foo' will be registered if any of the following are true:
        a) no profile is active
        b) 'xyz' profile is active
        c) 'default' profile has explicitly been made active
        d) both (b) and (c) are true

Note that the default profile is not to be confused with specifying no
profile at all.  When the default profile is specified, beans are
registered only if no other profiles are active; whereas when no profile
is specified, bean definitions are always registered regardless of which
profiles are active.

The default profile may be configured programmatically:

    environmnent.setDefaultProfile("embedded");

or declaratively through any registered PropertySource, e.g. system properties:

    -DdefaultSpringProfile=embedded

Assuming either of the above, example 1 could be rewritten as follows:

        <beans>
            <beans profile="embedded">
                <bean id="foo" class="com.acme.EmbeddedFooImpl"/>
            </beans>
            <beans profile="production">
                <bean id="foo" class="com.acme.ProdFooImpl"/>
            </beans>
        </beans>

It is unlikely that use of the default profile will make sense in
conjunction with a statically specified 'springProfiles' property.
For example, if 'springProfiles' is specified as a web.xml context
param, that profile will always be active for that application,
negating the possibility of default profile bean definitions ever
being registered.

The default profile is most useful for ensuring that a valid set of
bean definitions will always be registered without forcing users
to explictly specify active profiles.  In the embedded vs. production
examples above, it is assumed that the application JVM will be started
with -DspringProfiles=production when the application is in fact in
a production environment.  Otherwise, the embedded/default profile bean
definitions will always be registered.
2010-12-01 09:01:58 +00:00
Chris Beams
b33da670e5 Rename EnvironmentBeansTests* -> ProfileXmlBeanDefinitionTests*
Earlier naming reflected initial conception of 'environment-specific
bean definitions'. This notion has evolved into bean definitions
specific to particular profiles, and the new naming more clearly
expresses it.
2010-12-01 08:36:29 +00:00
Costin Leau
095a36e853 SPR-7470
+ add missing test class
2010-10-28 17:54:07 +00:00
Costin Leau
6ef987bced SPR-7470
+ add test for XML config with errors
2010-10-28 17:49:49 +00:00
Costin Leau
c13905ad16 SPR-7470
+ add c: namespace
2010-10-28 17:49:01 +00:00
Chris Beams
f480333d31 Merge 3.1.0 development branch into trunk
Branch in question is 'env' branch from git://git.springsource.org/sandbox/cbeams.git; merged into
git-svn repository with:

    git merge -s recursive -Xtheirs --no-commit env

No merge conflicts, but did need to

    git rm spring-build

prior to committing.

With this change, Spring 3.1.0 development is now happening on SVN
trunk. Further commits to the 3.0.x line will happen in an as-yet
uncreated SVN branch.  3.1.0 snapshots will be available
per the usual nightly CI build from trunk.
2010-10-25 19:48:20 +00:00
Juergen Hoeller
0195b0da3c BeanWrapper does not attempt to populate Map values on access (just auto-grows Map itself) 2010-10-14 00:14:50 +00:00
Chris Beams
05bcc4028d Fix assumption about file-based Resources in PropertiesLoaderSupport (SPR-7547)
When using PropertiesLoaderSupport implementations (principally
PropertyPlaceholderConfigurer), an assumption was made that any
Resource representing a set of properties must be file-based.  SPR-7547
exposed the fact that if a non-file-based Resource implementation such
as ByteArrayResource were passed in, an IllegalStateException would be thrown
from the AbstractResource base class' implementation of getFilename().

This is now patched, and PropertiesLoaderSupport implementations treat
Resource implementations equally, regardless of file-orientation.

See also SPR-7552.
2010-09-13 20:23:26 +00:00
Juergen Hoeller
a9da123259 temporarily disabled constructor argument caching for converted values (SPR-7423) 2010-08-19 09:30:04 +00:00
Juergen Hoeller
3c0ce48cbd added further test case for property type detection with generic interface 2010-07-26 20:39:27 +00:00
Chris Beams
45ed0ba43c licensing header 2010-06-28 23:20:44 +00:00
Chris Beams
cd271fca43 attempted to repro SPR-7318 to no avail 2010-06-28 22:57:26 +00:00
Juergen Hoeller
7f91153bba BeanWrapper/DataBinder's "autoGrowNestedPaths" works for Maps as well (SPR-7285) 2010-06-23 17:27:37 +00:00
Juergen Hoeller
11330baf77 DefaultListableBeanFactory checks for alias circle on registerAlias (avoiding endless loop; SPR-7274) 2010-06-10 21:45:47 +00:00
Juergen Hoeller
75c5405d6f added test for getType against an abstract FactoryBean 2010-05-27 13:45:44 +00:00
Arjen Poutsma
0b8140b50d Added DeprecatedBeanWarner 2010-05-17 14:31:48 +00:00
Juergen Hoeller
17a1362ed8 BeanDefinitionVisitor/PropertyPlaceholderConfigurer finds and resolves values in arrays as well (SPR-7136) 2010-05-03 12:26:32 +00:00
Chris Beams
3f06a92b6b getBean(Class<?>) now filters out bean definitions for which isAutowireCandidate() is false (SPR-7120) 2010-04-22 16:34:36 +00:00
Juergen Hoeller
12ce250c6c fixed constructor argument caching for prototypes with multiple constructor matches (SPR-7084) 2010-04-14 12:11:56 +00:00
Juergen Hoeller
03120b70d0 fixed URI construction to consider fragment as well (SPR-7083) 2010-04-09 15:26:43 +00:00
Juergen Hoeller
4d2a398cbc call setAccessible for public final field too (SPR-7078) 2010-04-08 12:15:18 +00:00
Juergen Hoeller
16eb915c95 ObjectFactoryCreatingFactoryBean creates a serializable ObjectFactory reference; added ProviderCreatingFactoryBean, exposing a serializable JSR-330 Provider reference (SPR-6998) 2010-03-30 14:45:43 +00:00
Chris Beams
351e72b6e2 incorrectly invoked factory methods now result in exceptions with more descriptive messages (SPR-5475) 2010-03-26 12:05:36 +00:00
Chris Beams
c13e5f9f5b SPR-7009, SPR-6972: backed out unintentionally committed tests 2010-03-23 15:29:35 +00:00
Chris Beams
c38c09bc35 SPR-6972: removed import 2010-03-23 12:06:24 +00:00
Chris Beams
77bb68b967 SPR-6972: failed attempt to reproduce issue 2010-03-23 12:06:16 +00:00
Juergen Hoeller
f30b0a86f7 autowire="byType" ignores parameter name when choosing a primary bean, as defined (SPR-6917) 2010-03-10 13:46:31 +00:00
Juergen Hoeller
6c0d934b92 do not try to convert read-only Collections/Maps (SPR-6808) 2010-02-08 12:29:21 +00:00
Costin Leau
1bbe93e535 SPR-3709
+ improved example to work with multi-nested declarations
+ used JDK 5 syntax
+ added documentation code into trunk (including unit test) for easier future reference
2010-01-27 12:25:04 +00:00
Juergen Hoeller
5f9b444319 bean properties of type enum array/collection can be populated with comma-separated String (SPR-6547) 2009-12-13 13:21:30 +00:00
Keith Donald
692b1ef636 found hotspot; added ConverisonServiceFactoryBean 2009-11-20 14:43:12 +00:00
Juergen Hoeller
46cd083976 added chaining-capable "add" method to MutablePropertyValues 2009-11-19 22:30:35 +00:00
Keith Donald
d85dc01e28 moved generic converter to spi; added entity converter; removed various service impls in favor of service factory 2009-11-19 09:10:51 +00:00
David Syer
66939ded0f RESOLVED - issue SPR-6366: Cannot import bean definitions using classpath*: resource location
http://jira.springframework.org/browse/SPR-6366
2009-11-17 09:53:10 +00:00
Juergen Hoeller
d0b6891275 child bean definition's scope attribute can be inherited from parent bean definition now (SPR-3542) 2009-11-12 00:09:05 +00:00
Arjen Poutsma
7ec9f1506a SPR-6005 - org.springframework.beans.propertyeditors.URIEditor does double escaping for % signes for URIs that contain a schema 2009-11-09 09:15:49 +00:00
David Syer
4be237dd84 RESOLVED - issue SPR-6195 2009-10-27 13:41:22 +00:00
Juergen Hoeller
cf580f024a added first cut of getBean(Class) lookup method 2009-10-20 19:52:30 +00:00
Juergen Hoeller
b152ac34fd CustomEditorConfigurer supports PropertyEditor instances again (with deprecation warning); for XFire compatibility (SPR-6157) 2009-10-01 13:40:55 +00:00
Keith Donald
3fa533ddd8 SPR-6032 & SPR-6033: Auto grow nested path enhancements to BeanWrapper 2009-09-29 19:54:35 +00:00
Juergen Hoeller
0f43d6c592 PropertyPlaceholderConfigurer supports "${myKey:myDefaultValue}" defaulting syntax 2009-09-24 22:34:02 +00:00
Juergen Hoeller
ad492e906e PropertyOverrideConfigurer's "ignoreInvalidKeys" ignores invalid property names as well (SPR-5792) 2009-09-24 14:40:13 +00:00
Juergen Hoeller
9ef1d2b1ad adapted to Converter signature change 2009-09-17 15:20:04 +00:00
Rob Harrop
01fb1825f5 [SPR-6063] fixed issue with inconsistent views of PropertyDescriptors 2009-09-16 09:53:14 +00:00
Juergen Hoeller
fd81aa205d protected @Autowired method can be overridden with non-annotated method to suppress injection; private @Autowired methods with same signature will be called individually across a hierarchy (SPR-6112) 2009-09-15 15:52:13 +00:00
Juergen Hoeller
e1a3e44485 initial JSR-330 injection support 2009-09-15 12:00:55 +00:00
Rob Harrop
1480202aa3 [SPR-5644] Support for Enum<?> and Enum<T> values as FQN.FIELD_NAME in type conversion 2009-09-11 18:31:51 +00:00
Juergen Hoeller
634d4b4d4c BeanFactory prefers local primary bean to primary bean in parent factory (SPR-5871) 2009-09-08 23:01:26 +00:00