Problem: Would like to lazy-initialize the heavy weight dependencies and enable them to re-establish themselves upon a loss of and reacquisition of a resource they depend upon.
Example: JMS with JNDI. The dependencies start at a JNDI Context, which connects to a JNDI provider to provide lookup of administered objects, specifically, a named ConnectionFactory. The ConnectionFactory creates Connections, but, in doing so, creates Socket connections (typically) to the JMS provider (say, JBoss). The Connection provides a Session, which in turn provides MessageConsumers| Producers. However, the session requires a named Destination, which is retrieved via the Context. Problem: JMS provider bites the bullet, taking with it the the JNDI provider and the JMS provider. This can be detected via an ExceptionListener on the Connection. Easy enough to go into a while loop issuing connects until JBoss comes back up, at which point Contexts and Connections may be re-established. At this point, however, every other instance of a Connection is invalid, and, depending upon the JMS provider's JNDI implmentation, the Context may be as well. Question: How to re-establish the dependency instances that have already been wired? For the JMS savy, onMessage() and receive() issues may be ignored (one's a "listener" thread, the other a wait- forever). This is actually applicable to Socket Producer/Consumers, Database failovers, etc.., hence the post. My sense is that implementing Providers for each heavy weight object is the way to go, using a Callable in a separate thread to re-connect in the get() method. The problem of re-establishing the dependency graph still exists, however, as the ExceptionListener for the Connection will get tripped in its own thread and then all those existing dependent instances (Context, ConnectionFactory, Connection, MessageProducer|Consumers) will need to be notified, somehow. Right? Or am I missing the eloquent part? :-) Seems there's a kickin' Pattern for DI and this issue in here somewhere? Any takers? -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
