We've internally been struggling with the proper way to initialize
lifecycle dependencies. We have a separate ServiceRegistry that has a
register(Service) method, but the real issue comes from how to
properly tell Guice to eagerly construct Services that want to
register themselves with ServiceRegistry. Should we use @Singleton
with Stage.PRODUCTION and require that tests that want that service to
be initialized also use Stage.PRODUCTION? Or should we use
asEagerSingleton so tests don't accidentally pass/fail because we used
the wrong stage? Or, should we introduce a new annotation for
services have ServiceRegistry use Guice's SPI to lookup all services?
I think we're abusing @Singleton a bit too much.
Sam
On Tue, Dec 2, 2008 at 1:52 AM, Dhanji R. Prasanna <[EMAIL PROTECTED]> wrote:
>
> Yea. But lifecycle is a pretty big issue. We need to consider things
> like cycle ordering, inter-service dependence and idempotence.
>
> But I agree we should evangelize better lifecycle. I still think
> asEagerSingleton needs to be discouraged very strongly.
>
> Dhanji.
>
> On Tue, Dec 2, 2008 at 5:39 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>>
>> On Dec 1, 9:44 pm, "Dhanji R. Prasanna" <[EMAIL PROTECTED]> wrote:
>>> I am seeing loads of abuses of eager singleton as a "startup"
>>> lifecycle hook. I wonder if it would be worth us deprecating it or
>>> making it show a warning of some sort.
>>>
>>> Since this doesn't really mean anything in PROD mode, perhaps it
>>> should be an annotation instead? bind() .in(EagerSingleton.class).
>>> Thinking aloud...
>>
>> First we should provide guidance on how to do lifecycle with Guice.
>> I've started to poke at this problem, but I haven't done anything too
>> seriously yet. We should be evangelizing something along these
>> lines...
>>
>> public static void main(String[] args) {
>> Injector injector = Guice.createInjector(...)
>> Set<Service> services = injector.getInstance(...);
>> for (Service service : services) {
>> service.start();
>> }
>> }
>>
>> >
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---