-
1. Re: Let's use component scope before lookupInStatefulContext
shane.bryzak Oct 25, 2007 10:39 PM (in response to dmitriy.lapko)Seems reasonable. Could you open a JIRA request for this?
-
3. Re: Let's use component scope before lookupInStatefulContext
pmuir Oct 26, 2007 7:21 AM (in response to dmitriy.lapko)I'm concerned about this as it drastically changes the behaviour of @In - currently if you have a component called user, in the session scope, and outject a variable called user into a the event scope, you would get the variable NOT the component injected. With this proposed change you would get the component injected.
This would alter the behaviour described in a number places here
http://docs.jboss.org/seam/2.0.0.CR3/reference/en/html/concepts.html
Or i have I misunderstood what you want to do? -
4. Re: Let's use component scope before lookupInStatefulContext
dmitriy.lapko Oct 26, 2007 7:58 AM (in response to dmitriy.lapko)Yes, I thought about this - that such feature can influence outjection. But if I'm sure, that I wouldn't in any place outject any property with name, equal to my component name, I could just specify it in @Name annotation, like:
@Name(value = "loginBean", limitSearchByGivenScope="true")
So in method lookupInStatefulContext we can check if there is a component with such name and it is marked with a propery 'limitSearchByGivenScope', then it should search only in given scope.
If I suppose, that I would use this possibility to overwrite component by outjected object, I would't use this option.
Really, I spent last 2 days JProfiling my application and see method getInstance in my hotspots. Too much of calls to method BaseContext.get and ServerConversationContext.isPerNestedConversation... -
5. Re: Let's use component scope before lookupInStatefulContext
pmuir Oct 26, 2007 8:07 AM (in response to dmitriy.lapko)Ok, I see the problem, but I don't think this is the solution (as it is basically alters the entire way Seam works).
perNestedConversation: what version of Seam? As we removed the annotation scan for perNestedConversation for CR3 at least. -
6. Re: Let's use component scope before lookupInStatefulContext
pmuir Oct 26, 2007 8:22 AM (in response to dmitriy.lapko)So, you can skip the lookupInStatefullContexts if you use Component.getInstance("foo", SESSION);
You can use this in your app using @In(scope=SESSION) Foo foo;
However you still have to do a lookupInStatefulContexts when injecting objects into JSF.
You should raise JIRA issues if you spot Seam internally not explicitly scoping getInstance() inside instance methods. -
7. Re: Let's use component scope before lookupInStatefulContext
dmitriy.lapko Oct 26, 2007 9:14 AM (in response to dmitriy.lapko)Ok, thank you for answer about fixing perNestedConversation, I used previous CR and didn't had this update. Now I updated seam and it works better, thank you again :)
But...
I made a little experiment concerning lookupInStatefulContexts.
1 code:<ui:repeat value="#{itemResultList.resultList}" var="#{item}"> <tr> <td class="itemListCenter"> #{itemBrowseList.getItemQuantity(item)} </td> </tr> </ui:repeat>
2 code:<ui:repeat value="#{itemResultList.resultList}" var="#{item}"> <tr> <td class="itemListCenter"> #{baseComponent.itemBrowseList.getItemQuantity(item)} </td> </tr> </ui:repeat>
The only difference is that in second example itemBrowseList is returned by EVENT scoped component with method:public ItemBrowseListComp getItemBrowseList() { return (ItemBrowseListComp) Component.getInstance("itemBrowseList", ScopeType.SESSION); }
itemBrowseList is in SESSION scope.
I measure time for RENDER_RESPONSE phase. Page contains a lot of other code, by the way.
I use last sources of Seam from CVS.
Result list contains 100 elements.
So,
for code 1: approx. 540ms (#{itemBrowseList.getItemQuantity(item)})
for code 2: approx. 310ms (#{baseComponent.itemBrowseList.getItemQuantity(item)})
So, difference - (540-310)/100 alsmost 2ms for each EL!
I'll raise a JIRE issue for this. And until it will be implemented, I will use this ugly code for my system... -
8. Re: Let's use component scope before lookupInStatefulContext
dmitriy.lapko Oct 26, 2007 9:36 AM (in response to dmitriy.lapko)Or, better, to use something like this:
in BaseComponent:@Factory(value="itemBrowseListEvent", scope=ScopeType.EVENT) public ItemBrowseListComp getItemBrowseList() { return (ItemBrowseListComp) Component.getInstance("itemBrowseList", ScopeType.SESSION); }
and on pages:#{itemBrowseListEvent.getItemQuantity(item)}