Announcement Announcement Module
Collapse
No announcement yet.
How to know from one bean is another bean already loaded or not? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to know from one bean is another bean already loaded or not?

    Is it possible to know from one bean is another bean already loaded or not? First bean must to know it becase it's behaviour is different depends on another bean state.

  • #2
    Interesting problem if the beans cannot be specified as depended (for use of DI) and you also can't use depends-on.

    Use afterPropertiesSet to set an external resource or state holding bean; use context messages; if client is bean factory aware, query the context to see if the bean is present; add an Introduction to the possiblyLoaded to signal its instantiation; use a custom BeanFactoryPostProcessor to set client bean state.

    But, I'm sure there are better more Springish ways.

    Comment


    • #3
      It seems that you might want to do some re-design here.
      Use of strategy interface that encapsulates the changing behaviour vs. figuring out the type at runtime and acting on that.

      If you are not in controll of the injected code, you could wrap it in the delegate interface and use it that way.

      This way you only change configuration vs. adding code to the target bean.

      You could also take a look at implementating a custome "scope" for that type of a bean. 2.0 feature.

      Dmitry

      Comment

      Working...
      X