Results 1 to 3 of 3

Thread: Public attribute dependency injection

  1. #1
    Join Date
    Mar 2008
    Posts
    3

    Default 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?

  2. #2

    Default

    You can create a wrapper class for that final class, and then can do the injection..

  3. #3
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    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
  •