[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| Re: [cdi-dev] This is StillDI | 
From: Ladislav Thon <lthon@xxxxxxxxxx>
 
 
1. Is there a portable way to run some code during application startup? The `@Initialized(ApplicationScoped.class) Object` event is fired during container initialization, which can be during application build, so that's not it. I propose CDI standardizes an `AfterStartup` event (symmetrically to existing `BeforeShutdown`), which is guaranteed to be fired during application startup. I personally find `AfterStartup` and `BeforeShutdown` a lot more natural than `@Initialized(ApplicationScoped.class) Object` and `@Destroyed(ApplicationScoped.class) Object`.  (Though to be perfectly honest, `BeforeShutdown` seems misnamed and, since all CDI contexts are invalid at that point in time, also quite useless.)
 
This is easy to implement in a fully runtime environment, so I took the liberty of adding that to StillDI, even though it isn't part of the extension API.
 
Is there some reason that the `@Initialized(ApplicationScoped.class) Object` event has to run at build time? Could it just be specified that it happens at runtime?
 
Currently I think this is the only way to ensure that something runs at startup with CDI so it would be a shame to break things that rely on that.
 
Regards,
Andrew
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU