-
1. Re: Stateless Session Bean and @Out
monkeyden Nov 15, 2007 11:13 AM (in response to jfrankman)I might have guessed that CONVERSATION scope was the default but why are you opposed to specifying it? I think it will be outjected to CONVERSATION if the bean itself had this as it's scope.
-
2. Re: Stateless Session Bean and @Out
jfrankman Nov 15, 2007 12:54 PM (in response to jfrankman)From the documentation for the @Out annotation:
Specifies the scope to outject to. If no scope is explicitly specified, the default scope depends upon whether the value is an instance of a Seam component. If it is, the component scope is used. Otherwise, the scope of the component with the @Out attribute is used. But if the component scope is STATELESS, the EVENT scope is used. - http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.2/doc/seam/api/org/jboss/seam/annotations/Out.html
Here is how I understand itIf scope is explicitly specified: the specified scope is used otherwise: if the outjected variable is a seam component: The seam component's scope is used otherwise If scope of the component outjecting the variable is stateless event scope is used otherwise the scope of the component outjecting the variable is used
Looking at my example I would say that the List I am trying to outject is not a seam component. (The objects contained in the list are seam components, but the List being outjected is not). That is based on my understanding that a Seam component is declared with the @Name annotation. Is this correct? If anyone can confirm this or set me straight I would appreciate it.
This brings up more questions.
1. What is the difference between doing this:@Stateless @Name("clientTransmittalLineItemAction") public class MySessionBeanImpl implements MySessionBean {
and this?:@Stateful @Name("clientTransmittalLineItemAction") @Scope(ScopeType.STATELESS) public class MySessionBeanImpl implements MySessionBean {
2. Is the second option even possible?
3. T or F? if you have a stateless session bean there is not any point in using the @Scope annotation.
4. T or F? If you have a stateful session bean you can specify any scope using the @Scope annotation other than ScopeType.STATELESS
It seems that 90% of Seam examples in books and online all use SFSB. I am trying to understand when and how a SLSB would be better to use than a SFSB. Any help is appreciated. -
3. Re: Stateless Session Bean and @Out
pmuir Nov 15, 2007 1:06 PM (in response to jfrankman)1) The stateless scope is not very useful - put that bean into EVENT scope and it makes more sense
3) True, as the obtaining the instance is managed by EJB3 so instance variables won't be remembered
4) True.
SLSB is useful when your data needs no state (e.g. view only). -
4. Re: Stateless Session Bean and @Out
jfrankman Nov 15, 2007 1:14 PM (in response to jfrankman)Thanks Pete for the answers. That helps me alot. I will crack open an EJB book this weekend to get a little more detail.