From 9e0d87c5189cf07f0122b5edfd91321fdf0de013 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Wed, 15 Jul 2009 19:38:47 +0000 Subject: [PATCH] SPR-5932 - Singleton @Bean methods behave like prototypes in a Spring DM environment * s/registerCallbacks/registerStaticCallbacks/ - see issue comments for full details --- .../context/annotation/ConfigurationClassEnhancer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java index 3fd7b5f928..9234b36403 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java @@ -117,7 +117,8 @@ class ConfigurationClassEnhancer { */ private Class createClass(Enhancer enhancer) { Class subclass = enhancer.createClass(); - Enhancer.registerCallbacks(subclass, this.callbackInstances.toArray(new Callback[this.callbackInstances.size()])); + // registering callbacks statically (as opposed to threadlocal) is critical for usage in an OSGi env (SPR-5932) + Enhancer.registerStaticCallbacks(subclass, this.callbackInstances.toArray(new Callback[this.callbackInstances.size()])); return subclass; }