Commit Graph

1181 Commits

Author SHA1 Message Date
Chris Beams d9ee958d88 Refactor JndiPropertySource
Prior to this change, JndiPropertySource worked directly against a JNDI
Context instance as its 'source' object.  This works well enough, but is
not nearly as fully-featured as Spring's existing JndiLocatorDelegate.

This change refactors JndiPropertySource from relying on an underlying
Context to relying on an underlying JndiLocatorDelegate.  By default,
the delegate's "resourceRef" property is set to true, meaning that the
implementation will always try to prepand a given name with
"java:comp/env/" before looking up the name, and upon failure will drop
back to the given name sans prefix.

See JndiPropertySource Javadoc for complete details.

Issue: SPR-8490
2011-07-02 21:26:44 +00:00
Chris Beams ce0a0ff3d4 Move JNDI_PROPERTY_SOURCE_ENABLED_FLAG constant
Move JNDI_PROPERTY_SOURCE_ENABLED_FLAG from JndiPropertySource to
StandardServletEnvironment, as this is the only context in which the
constant makes sense.
2011-07-02 21:26:38 +00:00
Chris Beams ea6d363c1e Return null from JndiPropertySource on lookup failure
Issue: SPR-8490
2011-07-02 21:26:30 +00:00
Costin Leau 26dbfba6c0 SPR-8477
+ add no-op cache implementations suitable for cache declarations w/o a backing store
2011-06-30 18:17:39 +00:00
David Syer bd0f68d095 SPR-5749: Add defensive matching using target class loader
* Changes to ASpectJExpressionPointcut plus some tests in Spring AOP
* plus some tests in groovy support
2011-06-24 17:23:43 +00:00
Juergen Hoeller 4664366aca getBean(name, type) attempts type conversion if necessary (SPR-8480) 2011-06-22 20:54:02 +00:00
Juergen Hoeller e0d558b084 getBean(name, type) attempts type conversion if necessary (SPR-8480) 2011-06-22 20:52:28 +00:00
Chris Beams 41e5d55d52 Fix bridge method detection for class hierarchies
Prior to this change, @Autowired injection against an instance of a
subclass having different visibility than its superclass would fail
if the @Autowired method is declared only in the superclass. This is due
to an apparent change in the rules around bridge method generation
between Java 5 and Java 6, and possibly even varying across compiler
vendors.

Now, BridgeMethodResolver is used consistently when detecting
@Autowired, @Inject and @Resource metadata to bypass these bridge
methods if they exist.

Issue: SPR-7900
2011-06-21 14:59:37 +00:00
Chris Beams 4fb811572e Compensate for Windows paths in XmlBeanFactoryTests
Issue: SPR-8439
2011-06-20 08:44:24 +00:00
David Syer 8e35734856 SPR-6268: check AnnotationUtils works with Groovy concrete classes (plus remove compiler warnings) 2011-06-17 13:35:57 +00:00
David Syer 64fd0b081d SPR-6268: Add proxy-target-class to <lang:groovy/> 2011-06-17 12:14:01 +00:00
Chris Beams 4fc386a4f5 Provide default ParameterNameDiscoverer for AACBF
Prior to this change, AbstractAutowireCapableBeanFactory did not support
a default ParameterNameDiscoverer.  This meant that attempting to use
<constructor-arg name=".."> syntax would fail (with a fairly obscure
exception) as that feature depends on a ParameterNameDiscoverer to
introspect the constructor arguments.

This lack of a default was originally intended to avoid a dependency on
ASM, but now that (a) .asm is a built-in module and (b) .beans has a
non-optional compile-time dependency on .asm, there is no reason not to
provide this default.

The net effect is that in a number of locations throughout the
framework, namely in GenericApplicationContext and
AbstractRefreshableApplicationContext, it is no longer necessary to
explicitly call AACBF#setParameterNameDiscoverer. This also means that
using a naked BeanFactory (likely for testing scenarios) is that much
easier.

Issue: SPR-8184
2011-06-17 09:47:19 +00:00
Chris Beams 8cb5c36512 Consolidate tests related to @Config inheritance
Issue: SPR-8183
2011-06-17 09:46:19 +00:00
Chris Beams cc814519c8 Revert "Re-enable ignored JMX tests"
As of SPR-8093, jmxremote_optional.jar is present on the build
server in jre/lib/ext, but it is not by default present on local
developer / user machines, meaning that the build ends up broken
by default.

Issue: SPR-8089, SPR-8093, SPR-8458
2011-06-16 06:34:23 +00:00
Juergen Hoeller f288060ad8 restored support for String-to-ContextResource conversion (SPR-8383) 2011-06-15 15:40:12 +00:00
Juergen Hoeller 5c1e86b47f refined WebLogic RMI descriptor to only mark 'getTargetInterfaceName' method as idempotent (SPR-8369) 2011-06-14 15:07:23 +00:00
Juergen Hoeller 878ff89014 added further conversion tests (triggered by 3.0.6 backports) 2011-06-13 23:57:53 +00:00
Juergen Hoeller 6c3cc786d0 added further conversion tests (triggered by 3.0.6 backports) 2011-06-13 23:43:46 +00:00
Chris Beams 234bca6462 Resolve ${...} placeholders in @PropertySource
Issue: SPR-8442
2011-06-13 04:23:08 +00:00
Chris Beams 799785abad Polish @EnableScheduling Javadoc 2011-06-12 06:56:37 +00:00
Chris Beams 2d68b726b5 Add syntax highlighting to Javadoc where necessary
Issue: SPR-8426
2011-06-12 06:56:17 +00:00
Sam Brannen c0131fe108 Polishing Eclipse classpath settings 2011-06-11 19:56:48 +00:00
Juergen Hoeller e1d81e04bc prepared Spring's DataSource and RowSet adapters for forward compatibility with JDBC 4.1 2011-06-09 23:09:55 +00:00
Juergen Hoeller c60511bf04 shortened build properties "org.junit.version" to "junit.version" and "org.testng.version" to "testng.version"; reverted SLF4J version back to 1.5.3 (for Hibernate 3.3.1 compatibility) 2011-06-09 09:58:15 +00:00
Chris Beams ae61aa3555 Revert introduction of AnnotationConfigCapableAC
Per review with Juergen in light of SPR-8413, which will revisit the
overall structure of ACAC and ACWAC.

Issue: SPR-8365, SPR-8413
2011-06-09 02:54:34 +00:00
Juergen Hoeller cac42ef233 fixed pattern list test 2011-06-07 23:24:30 +00:00
Chris Beams 4a3c1292bc Preserve DefaultContextLoadTimeWeaver no-arg ctor
Issue: SPR-8317
2011-06-06 13:15:10 +00:00
Chris Beams 620018d16b Introduce @EnableLoadTimeWeaving
Issue: SPR-8317
2011-06-06 08:31:18 +00:00
Mark Fisher 72420c79cb SPR-8205 added support for a 'trigger' attribute (bean ref) on scheduled-task elements 2011-06-03 18:54:21 +00:00
Sam Brannen f3f29412d4 Increased timeout in calls to assertStopWatchTimeLimit() to increase stability of the build. 2011-06-03 15:44:08 +00:00
Oliver Gierke c7a350cde7 SPR-7477 - Added lazy-init attribute to jee namespace 2011-06-03 08:51:56 +00:00
Sam Brannen 74b169e886 [SPR-8393] AnnotatedBeanDefinitionReader's constructor now inherits the Environment of supplied BeanDefinitionRegistry. 2011-06-02 17:33:12 +00:00
Chris Beams cee9da36eb Mention code alternatives in context and mvc XSDs 2011-06-02 14:45:00 +00:00
Chris Beams 9ca9287e35 Polish @Primary Javadoc 2011-06-02 14:44:26 +00:00
Chris Beams aa0c64d2f2 Polish @EnableScheduling Javadoc and related XSD 2011-06-02 14:43:59 +00:00
Chris Beams 3e5c6306be Polish @EnableAsync Javadoc and related XSD 2011-06-02 14:42:26 +00:00
Costin Leau 7be1b5c3f5 revised cache abstraction
+ remove generic signature on key generator (as the type is not used anywhere)
+ add a small improvement to CacheAspect to nicely handle the cases where the aspect is pulled in but not configured
2011-06-02 10:01:14 +00:00
Sam Brannen 0c775416a6 [SPR-8089][SPR-8093] Re-enabled ignored JMX tests based on the feedback that jmxremote_optional.jar is now present "jre/lib/ext/ in both 1.5 and 1.6 JDKs on the build server". 2011-06-01 14:12:03 +00:00
Chris Beams 4feacf31e7 Polish AdviceMode Javadoc 2011-05-31 06:41:35 +00:00
Chris Beams 2b4328023e Improve ApplicationContextInitializer sorting
ContextLoader and FrameworkServlet now use
AnnotationAwareOrderComparator to support @Order usage; previously
supported only implementation of the Ordered interface.
2011-05-30 12:55:33 +00:00
Juergen Hoeller 98c6a2784f RemoteExporter uses an opaque proxy for 'serviceInterface' exposure (no AOP interfaces exposed) 2011-05-29 20:52:37 +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
Keith Donald 01cbfd4f6f added null binding check for primitives for all conversion results; polishing 2011-05-24 17:53:18 +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 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 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 76e3d2855a Polish @Configuration-related Javadoc 2011-05-21 01:19:25 +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
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
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 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
Costin Leau 0b917e3f9c revise cache API
- eliminate unneeded methods
+ introduced value wrapper (name still to be decided) to avoid cache race conditions
+ improved name consistency
2011-05-17 16:50:00 +00:00
Costin Leau 700a02b094 SPR-8334
+ commit missing configs
2011-05-13 16:09:33 +00:00
Costin Leau cc519e7c6d SPR-8334
+ commit missing configs
2011-05-13 15:59:22 +00:00
Costin Leau a986d758e7 SPR-
+ remove duplicate class
2011-05-13 15:37:10 +00:00
Chris Beams 2afeb08e3c Fix @Autowired+@PostConstruct+@Configuration issue
A subtle issue existed with the way we relied on isCurrentlyInCreation
to determine whether a @Bean method is being called by the container
or by user code.  This worked in most cases, but in the particular
scenario laid out by SPR-8080, this approach was no longer sufficient.

This change introduces a ThreadLocal that contains the factory method
currently being invoked by the container, such that enhanced @Bean
methods can check against it to see if they are being called by the
container or not.  If so, that is the cue that the user-defined @Bean
method implementation should be invoked in order to actually create
the bean for the first time.  If not, then the cached instance of
the already-created bean should be looked up and returned.

See ConfigurationClassPostConstructAndAutowiringTests for
reproduction cases and more detail.

Issue: SPR-8080
2011-05-12 12:28:13 +00:00
Chris Beams 57206db152 Refine ignored @PropertySource log warning
If the enclosing environment does not implement ConfigurableEnvironment,
then @PropertySource annotations are ignored because there is no way to
add them to the Environment. Now checking first to see if there are any
@PropertySource annotations present before issuing the warning.

Issue: SPR-8314
2011-05-12 12:27:14 +00:00
Chris Beams c8bc54e0cc Introduce @PropertySource
Allows a convenient mechanism for contributing a PropertySource to the
enclosing Spring Environment. See @PropertySource Javadoc for
complete details and PropertySourceAnnotationTests for examples.

Issue: SPR-8314
2011-05-11 13:28:33 +00:00
Chris Beams 404f798048 Support 'required properties' precondition
Users may now call #setRequiredProperties(String...) against the
Environment (via its ConfigurablePropertyResolver interface) in order
to indicate which properties must be present.

Environment#validateRequiredProperties() is invoked by
AbstractApplicationContext during the refresh() lifecycle to perform
the actual check and a MissingRequiredPropertiesException is thrown
if the precondition is not satisfied.

Issue: SPR-8323
2011-05-11 07:36:04 +00:00
Chris Beams 693204aef8 Polish @Configuration Javadoc
Add note that nested @Configuration classes must be static.
2011-05-11 06:08:40 +00:00
Chris Beams 52bef0b7b0 Allow static modifier on @Bean methods
Declaring @Bean methods as 'static' is now permitted, whereas previously
it raised an exception at @Configuration class validation time.

A static @Bean method can be called by the container without requiring
the instantiation of its declaring @Configuration class. This is
particularly useful when dealing with BeanFactoryPostProcessor beans,
as they can interfere with the standard post-processing lifecycle
necessary to handle @Autowired, @Inject, @Value, @PostConstruct and
other annotations.

static @Bean methods cannot recieve CGLIB enhancement for scoping and
AOP concerns. This is acceptable in BFPP cases as they rarely if ever
need it, and should not in typical cases ever be called by another
@Bean method.  Once invoked by the container, the resulting bean will
be cached as usual, but multiple invocations of the static @Bean method
will result in creation of multiple instances of the bean.

static @Bean methods may not, for obvious reasons, refer to normal
instance @Bean methods, but again this is not likely a concern for BFPP
types. In the rare case that they do need a bean reference, parameter
injection into the static @Bean method is technically an option, but
should be avoided as it will potentially cause premature instantiation
of more beans that the user may have intended.

Note particularly that a WARN-level log message is now issued for any
non-static @Bean method with a return type assignable to BFPP.  This
serves as a strong recommendation to users that they always mark BFPP
@Bean methods as static.

See @Bean Javadoc for complete details.

Issue: SPR-8257, SPR-8269
2011-05-10 11:55:41 +00:00
Chris Beams 859185d086 Test interaction of @ComponentScan and @Import 2011-05-10 11:54:37 +00:00
Chris Beams d0c31ad84c Allow recursive use of @ComponentScan
Prior to this change, @ComponentScan annotations were only processed at
the first level of depth.  Now, the set of bean definitions resulting
from each declaration of @ComponentScan is checked for configuration
classes that declare @ComponentScan, and recursion is performed as
necessary.

Cycles between @ComponentScan declarations are detected as well. See
CircularComponentScanException.

Issue: SPR-8307
2011-05-08 13:49:35 +00:00
Chris Beams c2b030a50d Polish @EnableScheduling Javadoc 2011-05-08 13:48:02 +00:00
Chris Beams 7e398f101c Rename AsyncConfigurer#get{+Async}Executor 2011-05-07 09:32:03 +00:00
Chris Beams 358cbf4301 Polish @EnableScheduling Javadoc 2011-05-07 09:31:13 +00:00
Chris Beams d9a89529f0 Introduce @EnableScheduling 2011-05-06 19:09:24 +00:00
Chris Beams de50789cb6 Introduce @EnableAsync
Introduce @EnableAsync#order

AsyncAnnotationBeanPostProcessor's 'order' property is now mutable;
@EnableAsync's 'order()' attribute allows for setting it, but must
have a default value, thus uses the new Ordered#NOT_ORDERED
constant - a reserved negative number very unlikely to be otherwise
used that may be interpreted as 'not ordered', useful in annotation
defaulting scenarios where null is not an option.

Introduce first working cut of AsyncConfiguration

Remove AsyncCapability
2011-05-06 19:08:53 +00:00
Chris Beams cf0fc278bb Introduce @Role
As a mechanism for setting the 'role' hint on BeanDefinitions created
via component-scanning or @Bean methods.
2011-05-06 19:08:10 +00:00
Chris Beams 7b999c676f Introduce ReflectionUtils#getUniqueDeclaredMethods
This change is in support of certain polymorphism cases in
@Configuration class inheritance hierarchies.  Consider the following
scenario:

@Configuration
public abstract class AbstractConfig {
    public abstract Object bean();
}

@Configuration
public class ConcreteConfig {
    @Override
    @Bean
    public BeanPostProcessor bean() { ... }
}

ConcreteConfig overrides AbstractConfig's #bean() method with a
covariant return type, in this case returning an object of type
BeanPostProcessor.  It is critically important that the container
is able to detect the return type of ConcreteConfig#bean() in order
to instantiate the BPP at the right point in the lifecycle.

Prior to this change, the container could not do this.
AbstractAutowireCapableBeanFactory#getTypeForFactoryMethod called
ReflectionUtils#getAllDeclaredMethods, which returned Method objects
for both the Object and BeanPostProcessor signatures of the #bean()
method.  This confused the implementation sufficiently as not to
choose a type for the factory method at all.  This means that the
BPP never gets detected as a BPP.

The new method being introduced here, #getUniqueDeclaredMethods, takes
covariant return types into account, and filters out duplicates,
favoring the most specific / narrow return type.

Additionally, it filters out any CGLIB 'rewritten' methods, which
is important in the case of @Configuration classes, which are
enhanced by CGLIB.  See the implementation for further details.
2011-05-06 19:07:25 +00:00
Chris Beams 2bc3527f76 Consolidate annotation processing constants
Consolidating internal bean name and aspect class name constats within
AnnotationConfigUtils to allow access from both the context.config
and context.annotation packages without creating a relationship between
the two of them (they are unrelated leaf nodes in the packaging
currently).

The .transaction module does not have a similar utils class and already
has a relationship from transaction.config -> transaction.annotation,
so placing the constants in .annotation.TransactionManagementCapability
to be referenced by .config.AnnotationDrivenBeanDefinitionParser
2011-05-06 19:06:37 +00:00
Chris Beams 9a271ce6c9 Introduce ImportSelector interface
Allows @Enable* a layer of indirection for deciding which @Configuration
class(es) to @Import.

The @Import annotation may now accept @Configuration class literals
and/or ImportSelector class literals.
2011-05-06 19:06:02 +00:00
Chris Beams cdb01cbd37 Introduce ImportAware interface
@Configuration classes may implement ImportAware in order to be injected
with the AnnotationMetadata of their @Import'ing class.

Includes the introduction of a new PriorityOrdered
ImportAwareBeanPostProcessor that handles injection of the
importing class metadata.
2011-05-06 19:05:42 +00:00
Chris Beams 89005a5b70 Process all meta and local @Import declarations
Includes the introduction of AnnotationUtils#findAllAnnotationAttributes
to support iterating through all annotations declared on a given type
and interrogating each for the presence of a meta-annotation. See tests
for details.
2011-05-06 19:05:15 +00:00
Chris Beams 856da7edb9 Provide dedicated @ComponentScan processing
@ComponentScan is now checked for explicitly and handled immediately
when parsing @Configuration classes.
2011-05-06 19:04:35 +00:00
Chris Beams cd4fb665d9 Delegate ComponentScanBDP environment to scanner
Enables @Profile filtering within ComponentScanBeanDefinitionParser
2011-05-06 19:04:11 +00:00
Chris Beams 111fb71fe1 Remove "Feature" support introduced in 3.1 M1
Feature-related support such as @Feature, @FeatureConfiguration,
and FeatureSpecification types will be replaced by framework-provided
@Configuration classes and convenience annotations such as
@ComponentScan (already exists), @EnableAsync, @EnableScheduling,
@EnableTransactionManagement and others.

Issue: SPR-8012,SPR-8034,SPR-8039,SPR-8188,SPR-8206,SPR-8223,
SPR-8225,SPR-8226,SPR-8227
2011-05-06 19:03:52 +00:00
Chris Beams 0a790c143f Rename ConfigurationClassMethod => BeanMethod 2011-05-06 19:01:56 +00:00
Chris Beams f683f781c5 Revert deprecation of BDRU#registerWithGeneratedName
The overloading necessary to preserve the new signature as well as
the old causes ambiguities leading to deprecation warnings in some
caller scenarios.
2011-05-06 19:01:35 +00:00
Chris Beams 84a63b6d4b Prevent empty calls to ACAC #register and #scan 2011-05-06 19:01:11 +00:00
Chris Beams d2faef44fa Add comment on DisposableBean use in @Configuration
Issue: SPR-7901
2011-05-06 19:00:55 +00:00
Chris Beams d3678caa37 Polish Javadoc 2011-05-06 19:00:38 +00:00
Chris Beams f30b7e3125 Fix generics and serialization warnings 2011-05-06 19:00:14 +00:00
Chris Beams c51c340881 Update MockEnvironment / MockPropertySource types
Reflecting signature changes in getProperty() methods
2011-05-06 18:57:41 +00:00
Costin Leau 5206f5bc9a SPR-8238
+ add NPE test
2011-04-21 08:07:12 +00:00
Costin Leau e1d19d6c24 SPR-8238
+ add handling for null arguments to prevent NPE in default key generation
2011-04-21 08:00:42 +00:00
Micha Kiener 8adb9a88d0 SPR-6416, adding basic conversation object tests, improving the access time of the conversation object 2011-04-12 19:51:50 +00:00
Micha Kiener 3244e0a644 SPR-6416, adding repository timeout setting tests 2011-04-12 18:11:18 +00:00
Micha Kiener 8098ced387 SPR-6416, adding conversation manager test 2011-04-12 16:02:46 +00:00
Micha Kiener 58b779355b SPR-6416, reshaping removal of hierarchical conversations and adding repository test 2011-04-12 14:53:09 +00:00
Micha Kiener f812cd748e SPR-6416, initial commit for the conversation management 2011-04-12 13:21:18 +00:00
Sam Brannen 070b7b6afe polishing 2011-04-04 22:05:49 +00:00
Chris Beams 74f1e0e9d0 Touch up ApplicationContextInitializer Javadoc 2011-04-04 14:57:51 +00:00
Chris Beams 4f7bdbd3de Make ConfigurationClassBeanDefinitionReader public
Issue: SPR-8200
2011-04-04 14:14:17 +00:00
Rossen Stoyanchev 3f11fbafaa Predictable index position for BindingResult keys and parameter annotation convenience methods in MethodParameter 2011-03-31 14:16:37 +00:00
Sam Brannen 8568250e77 [SPR-8089] Added TODOs. 2011-03-28 19:01:33 +00:00
Sam Brannen 45c6eb1d62 [SPR-8089] re-ignoring JMX tests that require the presence of jmxremote_optional.jar. 2011-03-28 18:38:34 +00:00
Sam Brannen 309fa92199 [SPR-8089] re-ignoring JMX tests that require the presence of jmxremote_optional.jar. 2011-03-28 18:26:30 +00:00
Sam Brannen adfcc929fb [SPR-8091] developer notes 2011-03-28 18:09:14 +00:00
Costin Leau 5c3ceb8ef0 SPR-7971
+ add target object to KeyGenerator
2011-03-28 18:09:04 +00:00
Sam Brannen 71d70a6e06 [SPR-8089] cleaning up ignored and broken JMX tests; suppressing warnings; using generics where feasible; documented the jmxremote_optional.jar requirement in AbstractMBeanServerTests. 2011-03-28 17:57:01 +00:00
Costin Leau a3a0e5165c SPR-8007
+ add more logging
2011-03-28 12:10:26 +00:00
Costin Leau eb4b68ffda SPR-8007
SPR-7832
+ expose the invocation params through the cache root object
+ update javadocs
2011-03-28 11:36:05 +00:00
Chris Beams f4e1cde33b Eliminate warnings in .validation package
Issue: SPR-8062
2011-03-18 06:47:12 +00:00
Chris Beams 150838bfc1 Remove TODOs related to profile logging
Issue: SPR-8031, SPR-7508, SPR-8057
2011-03-15 12:57:43 +00:00
Chris Beams d471266d44 @Feature methods accept @Value-annotated params
Previously errors were being raised when trying to inject @Value
annotated paramaters such as:

@Feature
public FeatureSpec feature(@Value("#{environment['foo']}") String foo) {
    return new FeatureSpec(foo);
}

This is not so much because dependency resolution of @Value-annotated
types was failing, but rather because the 'early bean reference'
proxying mechanism was throwing an exception if any final type was
detected as a parameter. This is of course because final types are
non-subclassable by CGLIB.  On review, however, it's obvious that
certain final types must be allowed for injection.  @Value injection
is an obvious one, but the rarer case of a Spring bean of type String
or int is another.

The explicit guard against final types as parameters to @Feature methods
has been removed. Final types are still checked for, however, and if
found, no proxing is attempted.  The dependency is immediately resolved
against the current BeanFactory and injected into the @Feature method.

This means that @Value injection, @Qualifier injection, etc all work
as expected, but does mean that premature bean instantiation may occur
if a user unwittingly injects non-String, non-primitive final bean types
as @Feature method parameters.

Issue: SPR-7974
2011-03-15 07:09:49 +00:00
Chris Beams 43676bd660 Deregister @Configuration CGLIB callbacks
CGLIB-enhanced @Configuration subclasses now implement DisposableBean
such that Enhancer.registerStaticCallbacks(subclass, null) is invoked
on container shutdown. This ensures that garbage collection can work
properly and avoids memory consumption issues for applications that
create and destroy many application contexts within the same JVM.

Issue: SPR-7901
2011-03-14 09:20:19 +00:00
Chris Beams 76ce418556 Fix context:property-placeholder XSD type hierarchy
context:property-placeholder extends 'propertyPlaceholder' type
defintion once again.  This relationship was inadvertently removed in
3.1 M1, and the effect was that XML tooling would raise errors on
use of attributes like 'location'.

The updated schema has also been published to

    http://www.springframework.org/schema/context/spring-context-3.1.xsd

Issue: SPR-8037
2011-03-13 19:12:50 +00:00
Chris Beams 4cdb04ab25 Process @ImportResource with current ResourceLoader
Issue: SPR-7973
2011-03-12 12:24:38 +00:00
Chris Beams 704b229cc7 Test injection of Environment on @Feature methods
Issue: SPR-7975
2011-03-12 12:24:20 +00:00
Chris Beams 5cfbed8881 Test injection of special types on @Feature methods
Prove that injection of special container types such as ResourceLoader,
BeanFactory, etc already works with the current implementation of
@Feature methods.

Issue: SPR-7975
2011-03-11 12:40:51 +00:00
Chris Beams 5de35e8f92 Polishing 2011-03-10 14:08:58 +00:00
Costin Leau c3a635196b SPR-8015
+ update default key generator strategy to improve compatibility for implicit declaration on one arg method
+ updated docs
2011-03-06 17:13:24 +00:00
Costin Leau a4aca64007 + fix bug that prevented internal expression cache from being used 2011-03-06 17:06:28 +00:00
Costin Leau 5daad3e081 SPR-8006
+ fix contains/get race-condition of caches (by adding an extra cache call)
2011-03-06 12:27:46 +00:00
Costin Leau a20dd8095e + update copyright headers 2011-03-06 11:53:12 +00:00
Costin Leau fad2f2ca30 SPR-8006
SPR-8023
- remove unneeded method
2011-03-06 11:43:25 +00:00
Costin Leau 523a83ca28 SPR-8008
SPR-8023
+ fix bug in Ehcache cache that considered expired entries for key checks
2011-03-06 11:36:36 +00:00
Juergen Hoeller 716aa6974c fixed scheduling tests 2011-02-10 23:04:40 +00:00
Juergen Hoeller 0d70e08ac3 exceptions thrown by @Scheduled methods will be propagated to a registered ErrorHandler (SPR-7723) 2011-02-10 22:50:16 +00:00
Juergen Hoeller 03190950d1 polishing 2011-02-10 22:19:10 +00:00
Chris Beams 6bfead259e Further compensation for STS version mismatch
Current STS version of Spring (3.0.5) does not contain
the BeanUtils.instantiateClass(Class<?>, Class<T>) signature
that was added in 3.1.0, therefore NoSuchMethodErrors are
being thrown when STS classloads and delegates to
3.1.0 NamespaceHandler and BeanDefinitionParser implementations
on the user project classpath.

In this case, it's AbstractSpecificationBeanDefinitionParser
doing the calling to the unknown new method.  In this specific
example, reverting back to the old single-arg signature is actually
not a problem, because it does accept Class<T> and returns an
instance of type T, which was the desired behavior in the first
place.

The newer signature remains in order to accommodate callers
who do not know the generic type of the Class to be instantiated
(i.e. Class<?>), but do know the type that it should be assignable
to -- this becomes the second argument Class<T>, and an instance
of type T is returned (if indeed it is assignable to the specified
type; otherwise IllegalArgumentException.
2011-02-10 17:59:26 +00:00
Juergen Hoeller ce761d3fe8 renamed AbstractPropertyPlaceholderConfigurer to PlaceholderConfigurerSupport 2011-02-10 02:01:02 +00:00
Juergen Hoeller 47c9278e32 renamed AbstractPropertyPlaceholderConfigurer to PlaceholderConfigurerSupport 2011-02-10 01:55:11 +00:00
Juergen Hoeller 93304b5ff2 removed ConversionService/TypeConverter convenience methods in order to restore 3.0's SPI (for backwards compatibility with implementers) 2011-02-10 01:36:57 +00:00
Chris Beams b7d7fa7b7e Further compensations for STS; binary compat fixes
Defensively catch NoSuchMethodError when calling BDPD.getEnvironment()
and supply a DefaultEnvironment if not available.

Replace the single-arg constructor for BDPD and deprecate, preserving
binary compat particularly for Spring Integration who instantiates
this class directly, which is unusual.
2011-02-10 00:30:30 +00:00
Chris Beams 9cc125531b Fix STS compatibility issues; other improvements
Revert changes to ParserContext, ReaderContext, and XmlReaderContext

    These changes cause cross-version incompatibilities at tooling time
    -- for instance, an STS version that ships with Spring 3.0.5
    classloads the ParserContext defined in that version, whereas it
    classloads NamespaceHandlers and BeanDefinitionParsers (by default)
    from the user application classpath, which may be building against
    3.1.0. If so, the changes introduced to these types in 3.1.0 are
    incompatible with expectations in the 3.0.5 world and cause all
    manner of problems.  In this case, it was NoSuchMethodError due to
    the newly-added XmlReaderContext.getProblemReporter() method; also
    IncompatibleClassChangeError due to the introduction of the
    ComponentRegistrar interface on ParserContext.

    Each of these problems have been mitigated, though the solutions
    are not ideal. The method mentioned has been removed, and instead
    the problemReporter field is now accessed reflectively.
    ParserContext now no longer implements ComponentRegistrar, and
    rather a ComponentRegistrarAdapter class has been introduced that
    passes method calls through to a ParserContext delegate.

Introduce AbstractSpecificationBeanDefinitionParser

    AbstractSpecificationBeanDefinitionParser has been introduced in
    order to improve the programming model for BeanDefinitionParsers
    that have been refactored to the new FeatureSpecification model.
    This new base class and it's template method implementation of
    parse/doParse ensure that common concerns like (1) adapting a
    ParserContext into a SpecificationContext, (2) setting source and
    source name on the specification, and (3) actually executing the
    specification are all managed by the base class.  The subclass
    implementation of doParse need only actually parse XML, populate
    and return the FeatureSpecification object.  This change removed
    the many duplicate 'createSpecificationContext' methods that had
    been lingering.

Minor improvement to BeanDefinitionReaderUtils API

    Introduced new BeanDefinitionReaderUtils#registerWithGeneratedName
    variant that accepts BeanDefinition as opposed to
    AbstractBeanDefinition, as BeanDefinition is all that is actually
    necessary to satisfy the needs of the method implementation. The
    latter variant accepting AbstractBeanDefinition has been deprecated
    but remains intact and delegates to the new variant in order to
    maintain binary compatibility.
2011-02-09 16:44:26 +00:00
Arjen Poutsma 91debc3a35 Fixing compilation error with javac. 2011-02-09 09:39:29 +00:00
Chris Beams c58b63a982 Revert signature change in BDRU.registerWithGeneratedName
This change broke binary compatibility as evidenced by running
the greenhouse test suite and finding that Spring Integration's
AbstractConsumerEndpointParser.parseInternal fails with
NoSuchMethodError when trying to invoke.
2011-02-09 06:57:24 +00:00
Chris Beams b1756e2f17 Sync pom.xml deps with ivy.xml changes since 3.0.5 2011-02-09 06:56:53 +00:00
Chris Beams 2f7c2230f0 Include license.txt and notice.txt in module JARs 2011-02-09 06:56:40 +00:00
Chris Beams 906b50ef51 Add FeatureMethodErrorTests
Capture common mistakes with @Feature method declarations and ensure
that useful error messages are produced.
2011-02-09 06:54:02 +00:00
Sam Brannen e7c2713fd4 polishing JavaDoc 2011-02-08 22:08:38 +00:00
Chris Beams 2d76dde611 Rename ExecutorContext => SpecificationContext 2011-02-08 19:08:41 +00:00
Chris Beams c5063004eb Rename spring.{profile}.active => {profiles}
Same for spring.profiles.default
2011-02-08 19:07:46 +00:00
Chris Beams a2bc381ade Extract ProblemCollector interface 2011-02-08 19:07:03 +00:00
Chris Beams b4fea47d5c Introduce FeatureSpecification support
Introduce FeatureSpecification interface and implementations

    FeatureSpecification objects decouple the configuration of
    spring container features from the concern of parsing XML
    namespaces, allowing for reuse in code-based configuration
    (see @Feature* annotations below).

    * ComponentScanSpec
    * TxAnnotationDriven
    * MvcAnnotationDriven
    * MvcDefaultServletHandler
    * MvcResources
    * MvcViewControllers

Refactor associated BeanDefinitionParsers to delegate to new impls above

    The following BeanDefinitionParser implementations now deal only
    with the concern of XML parsing.  Validation is handled by their
    corresponding FeatureSpecification object.  Bean definition creation
    and registration is handled by their corresponding
    FeatureSpecificationExecutor type.

    * ComponentScanBeanDefinitionParser
    * AnnotationDrivenBeanDefinitionParser (tx)
    * AnnotationDrivenBeanDefinitionParser (mvc)
    * DefaultServletHandlerBeanDefinitionParser
    * ResourcesBeanDefinitionParser
    * ViewControllerBeanDefinitionParser

Update AopNamespaceUtils to decouple from XML (DOM API)

    Methods necessary for executing TxAnnotationDriven specification
    (and eventually, the AspectJAutoProxy specification) have been
    added that accept boolean arguments for whether to proxy
    target classes and whether to expose the proxy via threadlocal.

    Methods that accepted and introspected DOM Element objects still
    exist but have been deprecated.

Introduce @FeatureConfiguration classes and @Feature methods

    Allow for creation and configuration of FeatureSpecification objects
    at the user level.  A companion for @Configuration classes allowing
    for completely code-driven configuration of the Spring container.

    See changes in ConfigurationClassPostProcessor for implementation
    details.

    See Feature*Tests for usage examples.

    FeatureTestSuite in .integration-tests is a JUnit test suite designed
    to aggregate all BDP and Feature* related tests for a convenient way
    to confirm that Feature-related changes don't break anything.
    Uncomment this test and execute from Eclipse / IDEA. Due to classpath
    issues, this cannot be compiled by Ant/Ivy at the command line.

Introduce @FeatureAnnotation meta-annotation and @ComponentScan impl

    @FeatureAnnotation provides an alternate mechanism for creating
    and executing FeatureSpecification objects.  See @ComponentScan
    and its corresponding ComponentScanAnnotationParser implementation
    for details.  See ComponentScanAnnotationIntegrationTests for usage
    examples

Introduce Default[Formatting]ConversionService implementations

    Allows for convenient instantiation of ConversionService objects
    containing defaults appropriate for most environments.  Replaces
    similar support originally in ConversionServiceFactory (which is now
    deprecated). This change was justified by the need to avoid use
    of FactoryBeans in @Configuration classes (such as
    FormattingConversionServiceFactoryBean). It is strongly preferred
    that users simply instantiate and configure the objects that underlie
    our FactoryBeans. In the case of the ConversionService types, the
    easiest way to do this is to create Default* subtypes. This also
    follows convention with the rest of the framework.

Minor updates to util classes

    All in service of changes above. See diffs for self-explanatory
    details.

    * BeanUtils
    * ObjectUtils
    * ReflectionUtils
2011-02-08 14:42:33 +00:00
Chris Beams b04987ccc3 Make ObjectUtils.addObjectToArray() generic 2011-02-08 13:01:29 +00:00
Costin Leau fb57316afa renamed EhcacheCacheManager to EhCacheCacheManager 2011-02-07 17:45:29 +00:00
Costin Leau ca2dbc1c59 renamed EhcacheCacheManager to EhCacheCacheManager 2011-02-07 17:44:41 +00:00
Costin Leau 4da39b48f7 moved cache abstraction from context.support to context 2011-02-07 17:41:25 +00:00
Keith Donald fbb1fa33a1 added support for Instant and MutableDateTime binding to JodaTime formatting system; allow for use of @DateTimeFormat on any ReadableInstant field 2011-02-04 20:17:52 +00:00
Keith Donald ff7f3aebea reordered interface operations for clarity 2011-02-04 18:20:05 +00:00
Keith Donald 7d1104e442 SPR-7875 2011-02-04 18:17:30 +00:00
Costin Leau 44b5df0db1 SPR-7887
+ add javadoc on JBoss LTW for usage on JBoss 6.0
2011-02-01 10:19:23 +00:00
Costin Leau f191be56d1 SPR-4331
LTW for WebSphere
2011-02-01 10:17:42 +00:00
Rossen Stoyanchev abff2b959b SPR-7912 Add tests for FormattingConversionServiceFactoryBean, update reference docs, and remove mvc:formatters 2011-01-27 11:26:19 +00:00
Rossen Stoyanchev 149348c907 SPR-7912 Introduce FormatterRegistrar interface and FormattingConversionServiceFactoryBean enhancements. 2011-01-26 22:20:49 +00:00
Rossen Stoyanchev f26b499cbd SPR-7732, SPR-6506, SPR-7191 MVC Namespace improvements to the annotation-driven element - custom message converters, formatters, and message codes resolver. 2011-01-25 17:49:57 +00:00
Juergen Hoeller d3d7634574 added tests with error in BindingResult (SPR-7809) 2011-01-18 21:39:08 +00:00
Keith Donald 5d6840e877 array autogrow on set e.g. array[0]=foo 2011-01-07 17:28:18 +00:00
Chris Beams a7293d2961 Introduce ApplicationContextInitializer interface
Designed primarily for use in conjunction with web applications
to provide a convenient mechanism for configuring the container
programmatically.

ApplicationContextInitializer implementations are specified through the
new "contextInitializerClasses" servlet context parameter, then detected
and invoked by ContextLoader in its customizeContext() method.

In any case, the semantics of ApplicationContextInitializer's
initialize(ConfigurableApplicationContext) method require that
invocation occur *prior* to refreshing the application context.

ACI implementations may also implement Ordered/PriorityOrdered and
ContextLoader will sort instances appropriately prior to invocation.

Specifically, this new support provides a straightforward way to
programmatically access the container's Environment for the purpose
of adding, removing or otherwise manipulating PropertySource objects.

See Javadoc for further details.

Also note that ApplicationContextInitializer semantics overlap to
some degree with Servlet 3.0's notion of ServletContainerInitializer
classes. As Spring 3.1 development progresses, we'll likely see
these two come together and further influence one another.
2011-01-07 09:57:57 +00:00
Keith Donald 0fb631348e switched to better encapsulated convert(Object, TypeDescriptor) where possible 2011-01-07 05:57:25 +00:00
Keith Donald 4c9731d572 added forNestedType(MethodParameter) for resolution of nested parameter types for collection, array, and map parameter types 2011-01-06 21:59:34 +00:00
Sam Brannen 61cfb96d95 Changed slf4j.jcl dependency from 1.5.6 to 1.5.3 for consistency with build.versions. 2011-01-06 20:05:22 +00:00
Keith Donald c6c782df59 forNestedType usage clarification 2011-01-06 18:33:50 +00:00
Keith Donald 7ec5f1694b temp added ignore on 2 new failing tests until time to investigate 2011-01-06 12:00:51 +00:00
Keith Donald 86f1179606 temp added ignore on 2 new failing tests until time to investigate 2011-01-06 11:41:30 +00:00
Chris Beams 15ac99f59c Introduce and integrate JndiPropertySource
DefaultWebEnvironment automatically adds a JndiPropertySource if
a "jndiPropertySourceEnabled" property is detected in any of the
other other default property sources.
2011-01-06 07:43:29 +00:00
Chris Beams 9420bdc246 Document createEnvironment() methods
in AbstractApplicationContext and SpringContextResourceAdapter
2011-01-05 22:25:42 +00:00
Chris Beams 7f8ede1407 Remove dead code
* removed registerStandardBeanFactoryPostProcessors() methods
* removed commented-out test from PropertyResourceConfigurerTests
2011-01-05 22:24:55 +00:00
Chris Beams 431eaf6df8 Refactor PropertyPlaceholderConfigurer hierarchy
PropertySourcesPlaceholderConfigurer accommodates recent changes in
Environment and PropertySource APIs, e.g. no longer assuming enumerability
of property names.

PSPC reuses as much functionality as possible from
AbstractPropertyPlaceholderConfigurer, but overrides
postProcessBeanFactory() and defines its own variation on
processProperties() in order to accept a PropertyResolver rather than
a PropertySource.

AbstractPropertyPlaceholderConfigurer introduces doProcessProperties()
method to encapsulate that which is actually common, such as the
visiting of each bean definition once a StringValueResolver has been
created in the subclass.
2011-01-05 22:24:37 +00:00
Chris Beams 2b99cf6d29 Refactor Environment and PropertySource
* Environment now extends PropertyResolver
* Environment no longer exposes resolver and sources
* PropertySource is String,Object instead of String,String
* PropertySource no longer assumes enumerability of property names
* Introduced EnumerablePropertySource for those that do have enumerable property names
2011-01-05 22:24:14 +00:00
Juergen Hoeller 3fe2d037ed fixed AbstractBindingResult to avoid NPE in "hashCode()" if target is null (SPR-7682) 2011-01-05 19:42:35 +00:00
Keith Donald fe386f1c10 spr7816 2011-01-05 06:23:04 +00:00
Keith Donald 39e0c29d19 TypeDescriptor cleanup and general polishing; fixed a number of bugs related to TypeDescriptor usage in client code across beans and spel packages 2011-01-05 05:49:33 +00:00
Chris Beams 5e6912302a Introduce "Aware" superinterface
All existing *Aware interfaces have been refactored to extend this
new marker interface, serving two purposes:

    * Easy access to a type hierarchy that can answer the question
      "What *Aware interfaces are available?", without requiring
      text-based searches. Also clearly excludes false positives like
      TargetClassAware and ParamAware, which while similarly named,
      are not semantically similar to traditional *Aware interfaces
      in Spring.

    * Minor potential performance improvements in
      AbstractAutowireCapableBeanFactory and
      ApplicationContextAwareProcessor. Both have blocks of sequential
      instanceof checks in order to invoke any *Aware interface callback
      methods. For a bean that implements none of these interfaces,
      the whole sequence can be avoided by guarding first with
          if (bean instanceof Aware) {
              ...
          }

Implementors of custom *Aware-style interfaces (and presumably
the BeanPostProcessors that handle them), are encouraged to refactor to
extending this interface for consistency with the framework as well as
the points above.
2011-01-03 10:13:57 +00:00
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
Sam Brannen b130a36af7 [SPR-7850][SPR-7851] Upgraded to JUnit 4.8.1 and TestNG 5.12.1; added changelog entries for 3.1.0.M1. 2010-12-30 08:00:58 +00:00
Chris Beams 9f5fd3afcf Normalize indentation of Apache license URL
In accordance with recommendations at
http://www.apache.org/licenses/LICENSE-2.0.html.

A number of classes had strayed from this format, now all
are the same.
2010-12-22 21:40:19 +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 e693d9fa58 Polish JavaDoc 2010-12-08 07:58:47 +00:00
Chris Beams b50abc67de Add Hamcrest 1.1 as test-time dependency for .context
Provides a richer set of Matcher implementations than JUnit's hamcrest
package.
2010-12-07 06:56:55 +00:00
Chris Beams e0c5ced695 Use dot notation rather than camel case for profile props (SPR-7508)
Before this change, the following properties could be used to manipulate
Spring profile behavior:

    -DspringProfiles=p1,p2
    -DdefaultSpringProfile=pD

These properties have been renamed to follow usual Java conventions for
property naming:

    -Dspring.profile.active=p1,p2
    -Dspring.profile.default=pD
2010-12-05 20:14:26 +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 c8b4915891 Remove obsolete ConfigurationClassPostProcessor.getOrder() 2010-12-01 08:36:12 +00:00
Chris Beams 4214bc0735 Minor post-merge cleanup 2010-10-25 19:54: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 b0ea2b13d2 polishing 2010-10-20 21:15:22 +00:00
Ramnivas Laddad 92298469bf Fixed configuration of AnnotationAsyncExecutionAspect (was incorrectly under the same name as that for transaction management aspect) 2010-10-17 22:33:30 +00:00
Juergen Hoeller 8c9b64c948 added mode="proxy"/"aspectj" and proxy-target-class options to task namespace; switched to concise names for async aspects 2010-10-15 20:50:23 +00:00
Juergen Hoeller 1f1577e33e fixed @Value injection to correctly cache temporary null results for non-singleton beans (SPR-7614) 2010-10-14 19:49:29 +00:00
Juergen Hoeller 1933b648c3 fixed @Value injection to correctly cache temporary null results for non-singleton beans (SPR-7614) 2010-10-14 19:40:36 +00:00
Juergen Hoeller ae3cfff380 fixed JodaTimeContextHolder to use a non-inheritable ThreadLocal and expose a reset method (SPR-7441); use of remove() even when being called with a null argument 2010-10-11 18:55:21 +00:00
Juergen Hoeller 722778c74a SpEL MapAccessor consistently rejects "target.key" style access to Maps if no such key is found (SPR-7614) 2010-10-10 20:22:15 +00:00
Juergen Hoeller d78eda8aeb polishing 2010-10-10 18:31:43 +00:00
Juergen Hoeller 061063257a optimized @Bean error messages (SPR-7628, SPR-7629) 2010-10-10 18:31:03 +00:00
Juergen Hoeller b7b2a25953 fixed ApplicationContext event processing for repeated invocations to non-singleton listener beans (SPR-7563) 2010-10-01 22:16:21 +00:00
Juergen Hoeller 5f2d88f74a polishing 2010-09-09 09:04:40 +00:00
Chris Beams 6f69b7b752 Allow class-relative resource loading in GenericXmlApplicationContext (SPR-7530)
Before:

    - new GenericXmlApplicationContext("com/acme/path/to/resource.xml");

    - GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
      ctx.load("com/acme/path/to/resource.xml");
      ctx.refresh();

After:

    - The above remain supported, as well as new class-relative variants

    - import com.acme.path.to.Foo;
      new GenericXmlApplicationContext(Foo.class, "resource.xml");

    - import com.acme.path.to.Foo;
      GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
      ctx.load(Foo.class, "resource.xml");
      ctx.refresh();

These changes are generally aligned with signatures long available in
ClassPathXmlApplicationContext. As GenericXmlApplicationContext is
intended to be a more flexible successor to CPXAC (and FSXAC), it's
important that all the same conveniences are available.
2010-09-08 15:30:48 +00:00
Juergen Hoeller 479b4c1b84 added bean type to post-processing log statement (SPR-7524) 2010-09-06 20:06:48 +00:00
Juergen Hoeller 05a3f3ad8d avoid failures in case of manually registered null instance (SPR-7523) 2010-09-06 19:47:16 +00:00