Announcement Announcement Module
No announcement yet.
extending/'advising' the dependency injection mechanism? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • extending/'advising' the dependency injection mechanism?


    i am considering to implement a custom framework on top of spring.
    in this custom framework i need a specialized dependency injection mechanism:
    at component connection time i want to check certain conditions and depending on the result of the check perform varying dependency injections, e.g. hand back references to different implementations.

    so can the dependency injection mechanism itself be extended or 'advised' (in an aop sense)?

    i suspect this could be done somehow with 'TargetSources' by swapping one implementation against the one i really want 'early'.
    this does seem a bit complicated and error prone (race conditions?) though.

    as an absolute spring layperson i would very much appreciate help.
    as this issue is crucial in selecting a base framework for me.

    thanks a lot

  • #2
    The BeanPostProcessor mechanism sounds like what you want. It's ideal for use in building customizations of the IoC container. Spring IoC is extremely flexible and designed for extension.

    You can choose to perform additional injections, return a proxy etc. It's used by the auto proxy creators, but can also easily be used directly.