[weld-dev] Maintenance release

Mark Struberg struberg at yahoo.de
Sun Jan 10 16:36:41 EST 2010


Hi Gavin!

A few random observations from a non-native english speaker, so beg your pardon if I got something wrong ;)

Clarifying the 'Context' lifespan:

I think it is currently not clear what a Context instance represents.

While the wording in the default scope lifecycle section (6.7) suggests that there are n (multiple) Context objects for a specific Scope annotation [1] (e.g. one SessionContext instance for each session), the system eventing section (11.5.2) [2] only allows adding a single Context for a Scope annotation (kind of a Context-Facade?).

[1] 6.7.2
The session context is shared between all servlet requests that occur _in_the_same_HTTP_session (->another session gets another session context?). The session context is destroyed when the HTTPSession times out, after all HttpSessionListeners have been called, and at the very end of any request in which invalidate() was called, after all filters and ServletRequestListeners have been called (->again backs the n-contexts theory).


[2] 11.5.2
AfterBeanDiscovery#addContext() registers a custom Context object with the container.
(-> no way to add a 'ContextFactory')


While this doesn't make much difference for our built in scopes (e.g. OWB currently implements the n-context strategy with a ContextFactory while weld seems to use 1 SessionContext instance, isn't?) it may make a difference for portable extensions. And it is really confusing for people who only want to write an extension providing a Context for a custom scope.

Btw, we should also add a note to the Context interface decription (or somewhere else?) to explicitely state that a Context implementation is obliged to destroy all Contextual instances if they are not needed any longer. This includes listening to the BeforeShutdown event (11.5.4) and destroying all beans properly... 
Almost all extensions I've seen so far don't destroy their Contextuals, thus imho no @PreDestroy will get called on them, etc...


LieGrue,
strub


--- On Thu, 1/7/10, Gavin King <gavin.king at gmail.com> wrote:

> From: Gavin King <gavin.king at gmail.com>
> Subject: Re: [weld-dev] Maintenance release
> To: "Java Community Process JSR #299 Expert List" <JSR-299-EG at jcp.org>, "Weld-Dev" <weld-dev at lists.jboss.org>
> Date: Thursday, January 7, 2010, 9:29 PM
> Here's another area of
> clarification:
> 
> The spec is underdefined in section 7.3.6. Various
> clarifications are
> needed, including that:
> 
>     * the instance of EntityManager associated
> with a resource
> declaration is the same instance that would be injected
> using
> @PersistenceContext, i.e. the JPA transaction-scoped
> container-managed
> persistence context reference,
>     * stateful EJB references are not
> automatically destroyed by the
> container (the app must call the @Remove method
> explicitly), and
>     * EJB and web service references are truly
> @Dependent scoped
> (instance per injection)
> 
> We should remove this sentence: "When the destroy() method
> is called,
> the container discards this internal reference and performs
> any
> cleanup required of state associated with the client or
> transaction."
> 
> On Tue, Dec 29, 2009 at 4:44 PM, Gavin King <gavin.king at gmail.com>
> wrote:
> > Folks, I want to start work on the first CDI
> maintenance release, and
> > push it out fairly quickly. We've already discussed a
> couple of things
> > that we wanted in CDI 1.0, but had to delay to the
> maintenance
> > release:
> 
> 
> -- 
> Gavin King
> gavin.king at gmail.com
> http://in.relation.to/Bloggers/Gavin
> http://hibernate.org
> http://seamframework.org
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev
> 


      



More information about the weld-dev mailing list