-
1. Re: What will happen if both Sessionscoped and RequestScoped apply to one class?
alesj Jul 18, 2012 5:09 AM (in response to luyanfei78)Why don't you just try it? ;-)
-
2. Re: What will happen if both Sessionscoped and RequestScoped apply to one class?
luyanfei78 Jul 18, 2012 9:25 PM (in response to alesj)From specification, I can only infer this:
Login object will be putted in two context object, one for session scope, other for request scope. When request scope end, Login's destroy method will be called. if Login release resource in destroy method, you will not be able to use these resource in Login any more.
Ales, I want the answer theoretically. If this is not clear in specification, other jsr-299 implementation will be different.
-
3. Re: What will happen if both Sessionscoped and RequestScoped apply to one class?
jharting Jul 31, 2012 9:56 AM (in response to luyanfei78)A bean class or producer method or field may specify at most one scope type annotation. If a bean class or producer meth-
od or field specifies multiple scope type annotations, the container automatically detects the problem and treats it as a
definition error.
However, the first example is correct, because a stereotype defines a so-called "default" scope which means that the bean will be @RequestScoped unless the bean defines another scope explicitly in which case only the explicit scope is used.