-
Mar 27th, 2008, 06:20 PM
#1
Public attribute dependency injection
Is it possible to use dependency injection from the config file for setting public attributes?
The class I am trying to create acts like a structure, it has no constructor, and no setter methods, just public attributes, its also marked final so I cannot extend it and create setter methods or constructors.
Given this class, and the fact I cannot modify it, is there a way to set its attributes from the config file?
-
Mar 28th, 2008, 12:36 AM
#2
You can create a wrapper class for that final class, and then can do the injection..
-
Mar 28th, 2008, 08:44 AM
#3
Extending AbstractFactoryBean is the best way to implement such a wrapper. It implements FactoryBean which is the basis of most of Spring's utility classes (like JndiObjectFactoryBean, ProxyFactoryBean, etc).
Bill
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules