This content has been marked as final.
Show 2 replies
-
1. Re: CDI @Dependent scope in Seam
germanescobar Dec 15, 2009 8:43 PM (in response to mauro.castaldo)I think that if you don't define a scope for A, you will be able to achieve that.
@Name("a") public class A { ... }
-
2. Re: CDI @Dependent scope in Seam
mauro.castaldo Dec 15, 2009 9:09 PM (in response to mauro.castaldo)Unfortunately if you don't specify any scope you get the default one!
Seam reference:
When no scope is explicitly specified, the default depends upon the component type. For stateless session beans, the default is STATELESS. For entity beans and stateful session beans, the default is CONVERSATION. For JavaBeans, the default is EVENT.I found a workaround using STATELESS scope and manually creating instance A inside the @Create method of B (I cannot inject
a
using @In annotation because to keep one instance I needone time
injection only during initialization of componentsc
andd
):public class B { ... @Create public void initialize() { this.a = (A) Component.forName("a").newInstance(); Component.forName("a").callCreateMethod(this.a); } ... }
As you can see, being
a
an instance of a stateless scoped bean, you have to manually call post-construct / pre-destroy lifecycle methods.
This don't seems to be a very elegant solution.Anyway, thanks for your answer!
Mauro.