Commit Graph
31 Commits
Author SHA1 Message Date
Chris Beams 39c43de27d Allow other delimiters in profile XML attribute
Previously, only commas could delimit <beans profile="p1,p2"/>.  Now, as
with <bean alias="..."/>, the profile attribute allows for delimiting
by comma, space and/or semicolon.

BeanDefinitionParserDelegate.MULTI_VALUE_ATTRIBUTE_DELIMITERS has been
added as a constant to reflect the fact this set of delimiters is used
in multiple locations throughout the framework.
BDPD.BEAN_NAME_DELIMITERS now refers to the above and has been has been
preserved but deprecated for backward compat (though use outside the
framework is unlikely).

Changes originally based on user comment at
http://blog.springsource.com/2011/02/11/spring-framework-3-1-m1-released/comment-page-1/#comment-184455

Issue: SPR-8033

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4081 50f2f4bb-b051-0410-bef5-90022cba6387
2011-03-11 04:08:10 +00:00
Chris Beams f455b1e89a 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.


git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3804 50f2f4bb-b051-0410-bef5-90022cba6387
2010-12-01 09:01:58 +00:00
Chris Beams 839cb85688 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.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3803 50f2f4bb-b051-0410-bef5-90022cba6387
2010-12-01 08:36:29 +00:00
Costin Leau b43727f3b2 SPR-7470
+ add test for XML config with errors

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3785 50f2f4bb-b051-0410-bef5-90022cba6387
2010-10-28 17:49:49 +00:00
Costin Leau f578693015 SPR-7470
+ add c: namespace

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3784 50f2f4bb-b051-0410-bef5-90022cba6387
2010-10-28 17:49:01 +00:00
Chris Beams 45e5b46fc2 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.

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3782 50f2f4bb-b051-0410-bef5-90022cba6387
2010-10-25 19:48:20 +00:00
Chris Beams 9cc8d7ef91 SPR-7009, SPR-6972: backed out unintentionally committed tests
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3145 50f2f4bb-b051-0410-bef5-90022cba6387
2010-03-23 15:29:35 +00:00
Chris Beams 667eed1794 SPR-6972: failed attempt to reproduce issue
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3142 50f2f4bb-b051-0410-bef5-90022cba6387
2010-03-23 12:06:16 +00:00
Costin Leau 18afcd07c3 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

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2867 50f2f4bb-b051-0410-bef5-90022cba6387
2010-01-27 12:25:04 +00:00
David Syer d349ea9ea6 RESOLVED - issue SPR-6366: Cannot import bean definitions using classpath*: resource location
http://jira.springframework.org/browse/SPR-6366

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2444 50f2f4bb-b051-0410-bef5-90022cba6387
2009-11-17 09:53:10 +00:00
Juergen Hoeller dacde6959a fixed accidental test failures
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1760 50f2f4bb-b051-0410-bef5-90022cba6387
2009-08-25 13:49:10 +00:00
Juergen Hoeller 1cbc4ac602 try to create unknown collection implementation types via default constructor
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1759 50f2f4bb-b051-0410-bef5-90022cba6387
2009-08-25 13:29:22 +00:00
Juergen Hoeller efa6b14250 XML constructor-arg element allows for specifying a constructor argument by name now, with target argument names read from the class file via ASM or from Java 6's @ConstructorProperties annotation (SPR-3313)
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1305 50f2f4bb-b051-0410-bef5-90022cba6387
2009-06-03 10:21:57 +00:00
Juergen Hoeller 448b018f47 storing type information as specified (SPR-5556, SPR-5562); explicit XML array element in spring-beans-3.0.xsd (SPR-5543)
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1003 50f2f4bb-b051-0410-bef5-90022cba6387
2009-04-15 22:27:32 +00:00
Juergen Hoeller 6656a76cae prototype beans receive independent collection/array even when based on single value (SPR-5512)
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@663 50f2f4bb-b051-0410-bef5-90022cba6387
2009-02-21 18:04:08 +00:00
Juergen Hoeller 305deb9631 SimpleAliasRegistry detects resolved aliases that loop back to the original name (SPR-5419); PropertyPlaceholderConfigurer does not modify Map in case of equal String keys (SPR-5318); inner class names in Java source style ("java.lang.Thread.State") supported as well (SPR-5210)
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@657 50f2f4bb-b051-0410-bef5-90022cba6387
2009-02-19 16:17:35 +00:00
Arjen Poutsma 1aa53e5199 Renamed ShortcutTests to SimplePropertyNamespaceHandlerTests
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@571 50f2f4bb-b051-0410-bef5-90022cba6387
2009-01-22 11:41:14 +00:00
Chris Beams 7487ab1794 polishing .beans tests
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@509 50f2f4bb-b051-0410-bef5-90022cba6387
2008-12-24 22:02:08 +00:00
Chris Beams be0dcb3617 polishing .beans tests
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@507 50f2f4bb-b051-0410-bef5-90022cba6387
2008-12-24 21:52:19 +00:00
Chris Beams 2874ee27b9 polishing .beans tests
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@505 50f2f4bb-b051-0410-bef5-90022cba6387
2008-12-24 20:17:43 +00:00
Chris Beams b103e44949 polishing .beans tests
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@504 50f2f4bb-b051-0410-bef5-90022cba6387
2008-12-24 19:34:04 +00:00
Chris Beams 58903fa010 + polishing .beans tests
+ removed unnecessary dependency on hibernate


git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@503 50f2f4bb-b051-0410-bef5-90022cba6387
2008-12-24 19:14:15 +00:00
Arjen Poutsma 5c4d60475c Moved tests from testsuite to beans
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@202 50f2f4bb-b051-0410-bef5-90022cba6387
2008-10-29 18:20:29 +00:00
Arjen Poutsma af1de81bc8 Moved tests from testsuite to beans
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@201 50f2f4bb-b051-0410-bef5-90022cba6387
2008-10-29 18:14:22 +00:00
Arjen Poutsma b0711f48c7 Moved tests from testsuite to beans
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@200 50f2f4bb-b051-0410-bef5-90022cba6387
2008-10-29 18:08:07 +00:00
Arjen Poutsma 2a30d0558e Moved tests from testsuite to beans
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@199 50f2f4bb-b051-0410-bef5-90022cba6387
2008-10-29 18:03:15 +00:00
Arjen Poutsma 314952d4a4 Moved tests from testsuite to beans
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@198 50f2f4bb-b051-0410-bef5-90022cba6387
2008-10-29 17:59:31 +00:00
Arjen Poutsma 22267b8be8 Moved tests from testsuite to beans
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@197 50f2f4bb-b051-0410-bef5-90022cba6387
2008-10-29 17:55:46 +00:00
Arjen Poutsma 6ac513e3e7 Moved tests over from testsuite to beans
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@195 50f2f4bb-b051-0410-bef5-90022cba6387
2008-10-29 17:45:51 +00:00
Arjen Poutsma c5a7344404 Moved tests over from testsuite to beans
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@193 50f2f4bb-b051-0410-bef5-90022cba6387
2008-10-29 17:32:01 +00:00
Arjen Poutsma 3a853157df Added more modules
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@106 50f2f4bb-b051-0410-bef5-90022cba6387
2008-10-21 08:04:24 +00:00