[cdi-dev] Clarify scopes and serialization

Antoine Sabot-Durand antoine at sabot-durand.net
Mon Feb 2 09:57:38 EST 2015


In 6.6.1 we have :

	• A managed bean is passivation capable if and only if the bean class is serializable and all interceptors and decorators of the bean are passivation capable.
so the concept of “passivation” is rather well defined.



> Le 1 févr. 2015 à 17:49, Mark Struberg <struberg at yahoo.de> a écrit :
> 
> See 6.6.5 of the Spec. Serializable all over the place.
> 
> The important point is also the difference between the requirement for Bean<T> instances to be PassivationCapable and the Contextual Instances to be Serializable.
> 
> 
> E.g. for @ApplicationScoped the ContextualInstance doesn't need to be Serializable, but the Bean<T> for it needs to be PassivationCapable. The reason is that the Bean<T> instance gets stored in the Proxy. And this Proxy needs to be Serializable because otherwise you would not be able to inject it into a @SessionScoped bean (or any other bean with passivating scope).
> 
> 
> 
> LieGrue,
> strub
> 
> 
> 
> 
> 
> On Sunday, 1 February 2015, 13:37, Antonio Goncalves <antonio.goncalves at gmail.com> wrote:
> 
> 
>> 
>> 
>> Hi all,
>> 
>> 
>> I was reading the CDI 1.2 spec and couldn't clearly find the way serialization and scopes work. The only explicit sentence I found was :
>> 
>> 
>> 
>> 
>> 1.3.1. JSF example
>> The @SessionScoped annotation defined in Section 2.4.1, “Built-in scope types” is a scope
>> 
>> type that specifies the lifecycle of instances of Login. Managed beans with this scope must be
>> serializable.
>> 
>> 
>> 
>> 
>> The Weld documentation is a bit more explicit :
>> 
>> 
>> 5.2. Built-in scopes
>> Managed beans with scope @SessionScoped or @ConversationScoped must be serializable, since the container passivates the HTTP session from time to time.
>> 
>> 
>> 
>> 
>> And in the Java EE Tutorial we find (http://docs.oracle.com/javaee/6/tutorial/doc/gjbbk.html) :
>> 
>> 
>> Beans that use session, application, or conversation scope must be serializable, but beans that use request scope do not have to be serializable.
>> 
>> 
>> 
>> 
>> 
>> This even made be doubt about the application scope ?!?
>> 
>> 
>> 
>> 
>> Any way, could we clarify this in the CDI spec ?
>> 
>> 
>> 
>> --
>> 
>> Antonio Goncalves
>> Software architect, Java Champion and Pluralsight author
>> 
>> Web site | Twitter | LinkedIn | Pluralsight | Paris JUG | Devoxx France
>> _______________________________________________
>> cdi-dev mailing list
>> cdi-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>> 
>> Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
>> 
>> 
> 
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
> 
> Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.jboss.org/pipermail/cdi-dev/attachments/20150202/038aa914/attachment.bin 


More information about the cdi-dev mailing list