[cdi-dev] Application lifecycle events

Pete Muir pmuir at bleepbleep.org.uk
Tue Sep 6 10:47:11 EDT 2011


On 6 Sep 2011, at 15:33, Lincoln Baxter wrote:

> 
> 		• @Initialized @Application Object o;
> 		• @Destroyed @Application Object o;
> 
> WebApp - ServletContextInitialized /Destroyed (or just ServletContext)

Yeah, WebApp is simple, we pass the ServletContextEvent.

> Non WebApp - Are you thinking Java SE? If so, not sure you really need anything in the object except the command line arguments.

Currently the language doesn't I've added doesn't prohibit other payloads in situations others than the spec defines. Java SE usage (currently) falls outside the spec, so there we are free to do whatever. I was actually considering two types of application that can be deployed to a Java EE appserver beyond webapps - apps which deploy remote ejb endpoints only and rars.

> 
> 		• @Initialized @Session Object o;
> 		• @Destroyed @Session Object o;
> 
> WebApp - SessionInitialized /Destroyed(or just Session)

Yes, HttpSessionEvent is what I've specified here.

> Non WebApp - this seems like a pretty Web-oriented concept. Not sure it has a place in non Web.

Agreed, and nothing beyond webapps is specified.

> 
> 		• @Initialized @Conversation Object o;
> 		• @Destroyed @Conversation Object o;
> 
> WebApp - ConversationInitialized /Destroyed(or just Conversation)

You get a FacesContext if in JSF. When we extend conversations to Servlet, this would be replaced by a ServletRequestEvent.

> Non WebApp - this seems like a pretty Web-oriented concept. Not sure it has a place in non Web.

Yes.

> 
> 
> 		• @Initialized @Request Object o;
> 		• @Destroyed @Request Object o;
> 
> WebApp - RequestInitialized /Destroyed( This one cannot be just the Request because you also need access to the Response.)

You would get the ServletRequestEvent here.

> Non WebApp - this seems like a pretty Web-oriented concept. Not sure it has a place in non Web.

No, requests are not web-orientated. A request could be a remote EJB invocation, a JMS message inflow etc. I've spec'd web as ServletRequestEvent.

> 
> Not sure about JMS and Remote EJB initializations. Are these events exposed via another programmatic API currently? If so, what objects do they use?

I'm not sure tbh. JMS/EJB experts? :-)

> 
> javax.enterprise.context.lifecycle seems reasonable to me.
> 
> 
> --
> Lincoln Baxter, III
> JBoss, by Red Hat
> lbaxter at redhat.com
> 
> "If you want something, you'll find a way; if you don't, you'll find an excuse."
> 
> ----- Original Message -----
> From: "Pete Muir" <pmuir at bleepbleep.org.uk>
> To: "CDI-Dev" <cdi-dev at lists.jboss.org>
> Sent: Tuesday, September 6, 2011 8:05:58 AM
> Subject: [cdi-dev] Application lifecycle events
> 
> I've created a pull request for https://issues.jboss.org/browse/CDI-86 at https://github.com/jboss/cdi/pull/39.
> 
> This adds these events:
> 
> 		• @Initialized @Application Object o;
> 		• @Destroyed @Application Object o;
> 		• @Initialized @Session Object o;
> 		• @Destroyed @Session Object o;
> 		• @Initialized @Conversation Object o;
> 		• @Destroyed @Conversation Object o;
> 		• @Initialized @Request Object o;
> 		• @Destroyed @Request Object o;
> 
> The actual event type depends on why the context was initialized (e.g. if it's a web app you would normally see the relevant servlet event objects). More details in the pull
> 
> There are a few open issues on which I appreciate feedback:
> 
> * The CDI 1.0 spec doesn't define when a context is "initialized" (however the concept is implied), however the CDI spec introduces lifecycle events that require an event to be fired when a context is initialized. Either we need to rewrite the definition of this feature to use the CDI 1.0 language or we need to define when a context is initialized.
> * What should the event type be for requests initialized due to an EJB remote invocation and a JMS MessageListener invocation?
> * What should the event type be for applications initialized or destroyed when the application is not a web app?
> * The annotations for context lifecycle events are in the new package javax.enterprise.context.lifecycle. Should they be placed elsewhere (especially if we envision them being used for other purposes than context lifecycle events?)
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev




More information about the cdi-dev mailing list