Something worth investigating:
If I use a singleton-scoped bean, the value of this in the constructor of Foo is :
Code:
com.acme.Foo@bb3f71
If I use a different scoped bean, e.g. myCustomScope-scoped bean, the constructor of Foo is called twice, and the values of this in the constructor of Foo are :
Code:
com.acme.Foo$$EnhancerByCGLIB$$5da7bf49@3aff84
and
Code:
com.acme.Foo@db681c
The second call to the constructor originates from within the custom scope, and uses.. objectFactory. Might this lead to the solution? Shouldn't the custom scope return a proxied bean instead of an unproxied bean?
Excerpt from the custom scope:
Code:
@Override
public synchronized Object get( String aBeanName, ObjectFactory<?> aObjectFactory ) {
Map beanRepositoryForCurrentGame = getBeanRepositoryForCurrentGame();
if ( !beanRepositoryForCurrentGame.containsKey( aBeanName ) ) {
// bean with name aBeanName not found, instantiating an instance and adding it to the beanRepository for the scope value.
Object bean = aObjectFactory.getObject();
beanRepositoryForCurrentGame.put( aBeanName, bean );