Mar 27th, 2008, 06:20 PM
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
You can create a wrapper class for that final class, and then can do the injection..
Mar 28th, 2008, 08:44 AM
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).