Announcement Announcement Module
No announcement yet.
Handling Failed Beans Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Handling Failed Beans

    Hello all,

    Let's say I have a bean in my config file which I wish to inject into my application which can become invalid due to external circumstances (for example, it's a remote object and the machine it's running on has died). Further when this bean fails, I want to replace it with another.

    What's the best way to go about getting a new bean injected? Should I be using perhaps some form of smart beanfactory that can do this for me or should I just make the lookup of my bean configurable via spring and have my application code handle doing a new lookup when my old bean has died?

    Is injection even the right mechanism for this?



  • #2
    If different remote object follows same behaviour with different implementation than injection should be best strategy (different impl for same interface behaviour)

    I think your application code should handle post-action for on the fly bean state using smart BeanFactory interface as proposed by you.



    • #3
      For the special case of remote beans you might have a look at what the proxy factory you are using provides.

      For example, the RmiProxyFactoryBean has a refreshStubOnConnectFailure property which allows exception handling to a degree. Other remoting factories (e.g. for EJB access) provide similar properties.