Hi

We're developing a site based on MyFaces, Facelets and Seam, and now we're a 
little concerned about the performance - it's a bit slow. While analyzing the 
code I found out some strange Seam behavior.

Background: All our Seam beans are normal JavaBeans (no EJB beans). We'r 
running the web application in Tomcat (no EE container).

Case: I have a SESSION scoped bean called mainBean with (among other things) a 
@DataModel getter, a @DataModelSelection setter and an @In setter like the 
following fragment. 

  |     @In(create = true)
  |     public void setWebUser(WebUserBean webUser) {
  |         log.debug(" === Injecting @In 'webUser' (#0 times).", 
bullCounter3++);
  |         this.webUser = webUser;
  |     }
  | 
  |     @DataModel
  |     public List<MooxObject> getMainListItems() {
  |         log.debug(" === Reading @DataModel 'getMainListItems' (#0 times).", 
bullCounter++);
  |         if (isCurrentList())
  |             return currentMainObjectAsList().getListItems();
  |         else
  |             return null;            
  |     }
  | 
  | 
  |     protected MooxObject selectedListItem;
  | 
  |     @DataModelSelection("mainListItems")
  |     public void setSelectedListItem(MooxObject selectedListItem) {
  |         log.debug(" === Injecting @DataModelSelection 'setSelectedListItem' 
(#0 times).", bullCounter2++);
  |         this.selectedListItem = selectedListItem;   
  |     }
  | 

The page that uses mainBean can contain either nothing, an object or a list. We 
use facelets' <ui:include> to alter the page depending on what it contains. 

The strange thing is that the annotated getters and setters are called multiple 
times for each request. I've included three different log outputs to visualize 
it:

With an empty page (no reference to @DataModel):

  | [org.jboss.seam.jsf.SeamPhaseListener - 40] before phase: RESTORE_VIEW(1)
  | [org.jboss.seam.jsf.SeamPhaseListener - 84] after phase: RESTORE_VIEW(1)
  | [org.jboss.seam.jsf.SeamPhaseListener - 40] before phase: RENDER_RESPONSE(6)
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(54 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (27 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(55 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(56 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (28 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(57 times).
  | [org.jboss.seam.jsf.SeamPhaseListener - 84] after phase: RENDER_RESPONSE(6)
  | 
The strange thing is that @DataModel getter is called twice, although never 
referenced. And webUser bean is injected 4 times.

With a single object page (no reference to @DataModel): 

  | [org.jboss.seam.jsf.SeamPhaseListener - 40] before phase: RESTORE_VIEW(1)
  | [org.jboss.seam.jsf.SeamPhaseListener - 84] after phase: RESTORE_VIEW(1)
  | [org.jboss.seam.jsf.SeamPhaseListener - 40] before phase: RENDER_RESPONSE(6)
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(560 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 130]  === Injecting 
@DataModelSelection 'setSelectedListItem' (228 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (298 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(561 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(562 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 130]  === Injecting 
@DataModelSelection 'setSelectedListItem' (229 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 268] ** MainBean - 
setCurrentObject
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (299 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(563 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(564 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (300 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(565 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(566 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (301 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(567 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(568 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (302 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(569 times).
  | [org.jboss.seam.jsf.SeamPhaseListener - 84] after phase: RENDER_RESPONSE(6)
  | 
Now we have 5 @DataModel gets and 10 @In injections. The @DataModelSelection is 
injected twice.

With a list (two reference to @DataModel in one Tomahawk <t:dataTable>): 

  | [org.jboss.seam.jsf.SeamPhaseListener - 40] before phase: RESTORE_VIEW(1)
  | [org.jboss.seam.jsf.SeamPhaseListener - 84] after phase: RESTORE_VIEW(1)
  | [org.jboss.seam.jsf.SeamPhaseListener - 40] before phase: RENDER_RESPONSE(6)
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(570 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (303 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(571 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(572 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 268] ** MainBean - 
setCurrentObject from: [USER/USER:68 (norman)] to: [LIST/LIST:0 
(lists.alias.members)]
  | [com.fastsearch.w2p.moox.serviceinterfaces.ListServiceDecorator - 496] 
Populating list with 8 members...
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (304 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (305 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (306 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (307 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (308 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (309 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(573 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(574 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 130]  === Injecting 
@DataModelSelection 'setSelectedListItem' (230 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (310 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(575 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(576 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 130]  === Injecting 
@DataModelSelection 'setSelectedListItem' (231 times).
  |    (and a fiew more hundred injections...)
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (425 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(797 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(798 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 130]  === Injecting 
@DataModelSelection 'setSelectedListItem' (342 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 118]  === Reading @DataModel 
'getMainListItems' (426 times).
  | [com.fastsearch.w2p.moox.beans.MainBean - 48]  === Injecting @In 'webUser' 
(799 times).
  | [org.jboss.seam.jsf.SeamPhaseListener - 84] after phase: RENDER_RESPONSE(6)
  | 
It seems like every time mainBean is accessed (several times in each row in the 
table) it's reinitialized.


And now my questions:

  | * Are we doing something terribly wrong? Why do we get all these 
injections? 
  | 
  | * For best performance - Should we use several small beans with a lot of 
dependencies, or a fiew bigger beans?
  | 
  | * For best performance - Should we try to have big scopes (like SESSION) to 
reduce the number of bean instanses, or should we try to minimize the scope (to 
EVENT)? 
  | 
  | 
  | Finally I'd like to say that except for this injection mystery, Seam really 
rocks! (I can't imagine JSF without it...)

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4039101#4039101

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4039101
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to