Custom Scope not visible to child context [SPR-7089] #11749
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: declined
A suggestion or change that we don't feel we should currently apply
type: enhancement
A general enhancement
Jack Punt opened SPR-7089 and commented
A Custom Scope (FlexClientScope, in case cited) must be registered with the root applicationContext.
In order to add Beans (a
@RemotingDestination
) a sub-context is createdas the target for: setParent(rootAppCtx); register(clazz); refresh(); getBean(beanName);
In the case cited, an AnnotationConfigApplicationContext.
When refresh(), the clazz with
@Service
@RemotingDestination
@Scope
(value="flexclient", proxyMode = ScopedProxyMode.TARGET_CLASS)proceeds to AbstractBeanFactory.java line 320: which attempts to find the requested scope,
but looks only in the current/child ApplicationContext, failing to find the Scope in the parent.
The proposed fix is to add a method (near line 779, after getRegisteredScope()) something like:
And use Scope scope = getScopeUsingParents(scopeName);
instead of: Scope scope = this.scopes.get(scopeName);
In the appropriate places in AbstractBeanFactory.java
[Documentation may need to be upgraded to warn non-AbstractBeanFactory implementations
that they should also search the parents to find registered Scopes.]
Note: for my project this is a "Major" "Blocker" Priority
and requires a source-level patch and class replacement.
but having upgraded the AbstractBeanFactory.class, i'm back in business until next release.
I respect the fact that it is apparently not a common requirement,
(it has gone this long without complaint) but would appreciate a supported solution when possible.
Environmental Impact: The suggested fix is "benign" (has little effect on existing/working apps),
as all of them apparently register and access custom Scopes in the same appCtx.
That is: the new while loop only runs before or in place of existing code that throws an Exception.
So at worst: existing code that relied on not finding a Scope might fail to get an Exception.
Affects: 3.0.2
Reference URL: http://forum.springsource.org/showpost.php?p=294224&postcount=13
The text was updated successfully, but these errors were encountered: