Issue Details (XML | Word | Printable)

Key: SPR-3800
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Mark Fisher
Reporter: Dave Syer
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Spring Framework

Inner beans cannot have a scope other than singleton?

Created: 23/Aug/07 03:56 PM   Updated: 20/Sep/07 07:47 AM   Resolved: 03/Sep/07 02:24 PM
Component/s: SpringCORE
Affects Version/s: 2.1 M3
Fix Version/s: 2.1 M4

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive inner-scope-test.zip (5 kB)
2. Zip Archive inner-scope-test.zip (4 kB)

Issue Links:
Related
 


 Description  « Hide

Inner beans cannot be scoped? It seems that the scope attribute is not noticed by the bean factory in an inner bean. Scope is only checked in a call to getBean in AbstractBeanFactory so it can never apply to an inner bean. Is this intentional - it seems somewhat limiting?



Dave Syer added a comment - 24/Aug/07 12:38 AM

Reading SPR-2744 it seems like the expected behaviour is to inherit scope from a parent bean - that makes sense to me, but it doesn't happen in practice. So maybe this is a regression?


Juergen Hoeller added a comment - 24/Aug/07 03:45 AM

Indeed, inner beans inherit the scope from their containing beans. I'll check whether that actually still works in the 2.1 codebase (if you have a specific test case around, please attach it!). I guess we should also consider validating inner bean definitions more aggressively, rejecting scopes that do not match the parent's.

Juergen


Dave Syer added a comment - 24/Aug/07 04:29 AM

Attached a test case.


Dave Syer added a comment - 28/Aug/07 02:26 AM

There are actually two issues here - inner beans do not inherit their parent's scope, and inner beans cannot be scoped explicitly (as per the issue description). I would like to see both fixed if that's possible. Shall we open another issue?


Dave Syer added a comment - 28/Aug/07 08:35 AM

Attached another versio nof test cases that explicitly test both scenarios


Mark Fisher added a comment - 03/Sep/07 02:24 PM

Inner beans can now be scoped explicitly. Also, when no scope is provided for an inner-bean it will inherit the containing bean's scope by default (even for 'custom' scopes). Both of the attached test-cases pass.