From 7a9f9febf808722d33698789cc93da4ee40b0ec9 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 11 Jun 2010 13:48:52 +0000 Subject: [PATCH] added warnings regarding accidental usage of @Configurable on a managed bean (SPR-7216) git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3414 50f2f4bb-b051-0410-bef5-90022cba6387 --- spring-framework-reference/src/aop.xml | 10 ++++++++++ spring-framework-reference/src/scheduling.xml | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/spring-framework-reference/src/aop.xml b/spring-framework-reference/src/aop.xml index 62bf969ee41..20499a289b7 100644 --- a/spring-framework-reference/src/aop.xml +++ b/spring-framework-reference/src/aop.xml @@ -2959,6 +2959,16 @@ public class Account { </bean> + + Do not activate @Configurable + processing through the bean configurer aspect unless you really + mean to rely on its semantics at runtime. In particular, make sure + that you do not use @Configurable + on bean classes which are registered as regular Spring beans with + the container: You would get double initialization otherwise, once + through the container and once through the aspect. + +
Unit testing <interfacename>@Configurable</interfacename> objects diff --git a/spring-framework-reference/src/scheduling.xml b/spring-framework-reference/src/scheduling.xml index 79eaad2b9cf..9042f924b25 100644 --- a/spring-framework-reference/src/scheduling.xml +++ b/spring-framework-reference/src/scheduling.xml @@ -553,6 +553,17 @@ public void doSomething() { and must not expect any arguments. If the method needs to interact with other objects from the Application Context, then those would typically have been provided through dependency injection. + + + Make sure that you are not initializing multiple instances + of the same @Scheduled annotation class at runtime, unless you do + want to schedule callbacks to each such instance. Related to this, + make sure that you do not use @Configurable on bean classes which + are annotated with @Scheduled and registered as regular Spring beans + with the container: You would get double initialization otherwise, + once through the container and once through the @Configurable aspect, + with the consequence of each @Scheduled method being invoked twice. +