Announcement Announcement Module
Collapse
No announcement yet.
How can I establish this injection with Spring IoC Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I establish this injection with Spring IoC

    Before:
    Class A, Class B (implements Interface C).
    Bean definitions: a(A), b(B).

    Result:
    Bean a can only be injected into C's child beans. When client code requesting b, Spring IoC will inject bean a into b, then inject b into a; at last, bean b is returned to the client code.



    Is that possible? Then HOW?
    Last edited by rrrrutdk; Jun 30th, 2008, 12:22 PM.

  • #2
    Are there any interfaces like this:


    ````public interface BeanTargetAware {

    ````````/**
    `````````* After a bean injected into the target bean,
    `````````* IoC container will invoke this callback method of
    `````````* the bean, using the target bean as parameter.
    `````````* @param beanTarget
    `````````* ``````` the target bean that this bean to be injected into
    `````````* @throws InjectionException
    `````````* ``````` when thrown, it means a failure of this injection.
    `````````*/
    ````````void setBeanTarget(Object beanTarget) throws InjectionException;
    ````}
    Last edited by rrrrutdk; Jun 30th, 2008, 09:06 AM.

    Comment


    • #3
      You may want to rethink your architecture on this component. Circular dependencies are a bad idea(TM).

      But if you insist on bringing future misery upon yourself, here you go:

      forum.springframework.org/showthread.php?t=41138

      Comment

      Working...
      X