Comment #59 on issue 62 by undeconstructed: Lifecycle support
http://code.google.com/p/google-guice/issues/detail?id=62
I have an interest in the Service approach being talked about here, but to
me that seems to be a separate issue to how this started out. Recently I
was trying to implement a service architecture on Guice, but ran into
various issues that made a quick solution impractical. A major one being
the difficulty in finding which bindings are really services, when the
interfaces they are bound to do not indicate this. That is, finding
implementations that are singletons with the required "Service" interface,
even when the bean itself might be bound to a provider method, returning
only a public interface for the service it offers.
The easiest way around this was (unfortunately) to switch to Spring, which
has two separate lifecycle concepts, 1) injection lifecycle (init, destroy,
etc,) 2) context lifecycle (start, stop). These two are well defined, but
also pretty simplistic, in that you get only one context lifecycle, that
will always start every bean with the right interface, as long is it is
defined at the top level in the config.
What I think would be more interesting to experiment with for this use case
is a general purpose service framework, built on top of Guice. This layer
would be able to offer features such as promotion of some interfaces from
an injector as services, while hiding all implemention; more complicated
state management (initialized, starting, started, going offline...); or
even automatic proxying/remoting. It might be possible to do something
like:
configure() {
bind(Someimpl.class)
bind(InternalThing.class).to(another.class)
bindAsService(MyService.class).to(myserviceimpl.class)
}
And then have MyService available to inject into other modules, while the
InternalThing binding would only be visible to those locally defined
bindings.
However, I don't really see this as a responsibility of Guice - Guice just
proviides some mechanisms that could really simplify the work.
--
You received this message because you are subscribed to the Google Groups
"google-guice-dev" 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-dev?hl=en.