JDBC works much like this. The connection pool implements all of the
interfaces and each implementation is a proxy. You can do the same.
Inject the provider at the top level and it can create a proxy. That
proxy creates other proxies. If you have other top level interfaces to
inject, use another provider and additional proxies.
Sent from my iPhone
On Feb 12, 2010, at 6:14 PM, bklough <[email protected]> wrote:
On Feb 12, 3:56 pm, Sam Berlin <[email protected]> wrote:
Is it possible to wrap the 'Connection' around some kind of
'ManagedConnection' that delegates to the actual Connection and
restablishes the connection if it fails? That way client code
doesn't
have to concern itself with the internals of how connection may
arbitrarily fail -- ManagedConnection will do it itself. The only
thing that has access to a raw Connection is ManagedConnection, and
everything else down the chain can pretend everything's fine.
- Show quoted text -
Yes. We all agree on that, and that's what I've done for the external
fail points, JNDI (ContextProvider) and JMS Connection
(ConnectionProvider). Anything needing JNDI is injected with a
ContextProvider; a ConnectionProvider for Connections and the
Provider .get()'s are used so that they get the existing instance, or
the instance that has been reconnected automagically for them.
I'm stuck at the last to points in the chain: MessageConsumer and
MessageProducer. These are JMS objects. It's dawning on me that I
need to implement the JMS MessageProducer interface with an
implementation that delegates those calls to a
messageProducerProvider.get().
It sounds like it boils down to maintaining the dependency chain via
Providers, yes?
--
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
.
--
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.