12 Replies Latest reply on Oct 5, 2007 10:17 AM by diegocoronel

    Performance: @Name and @Stateless

    diegocoronel

      Hi, im using seam generator and my system is really big, im using jboss 4.2.1 and seam 2.0 RC1, im with performance problems , all my beans are just with @Name and i want to know if i use @Stateless is better to increase performance ?? My navigation is taking 15 seconds per page. Im using drools too. I used a breakpoint in my bean constructor and saw that it is stoping for each method im using in my page. I tried @Scope (Sco..Type.EVENT) but its still stoping in constructor class... even if my search come back to same page... ill really apreciate if you guys help me about this problem.

      Sry about my english.. and congratulations about seam.. im loving this idea.

      Diego Coronel
      Developer

        • 1. Re: Performance: @Name and @Stateless
          swd847

          The only time I have seen navigation that slow with seam was when I forgot go change all my pages.xml schema from 1.2 to 2.0, it still works but as the schema is not longer included in the 2.0 jar it has to download it from the SEAM website for every request, resulting in a really slow webapp.

          Can you be more specific as to where the bottleneck is?

          Stuart

          • 2. Re: Performance: @Name and @Stateless
            diegocoronel

            Hi swd847,

            So, my .xhtml

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml"
             xmlns:ui="http://java.sun.com/jsf/facelets"
             xmlns:h="http://java.sun.com/jsf/html"
             xmlns:f="http://java.sun.com/jsf/core"
             xmlns:s="http://jboss.com/products/seam/taglib"
             xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
            <head>
             <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            


            and my page.xml

            <?xml version="1.0" encoding="UTF-8"?>
            <page xmlns="http://jboss.com/products/seam/pages"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd">
            
             <param name="firstResult" value="#{acaoList.firstResult}"/>
             <param name="order" value="#{acaoList.order}"/>
             <param name="from"/>
            
            <param name="acaoIdAcao" value="#{acaoHome.acaoIdAcao}"/>
            
            </page>
            


            is it wrong ??

            Im worried because im using just @Name and no EJB3 like @Stateless... and my bean is been created every method that my .xhtml is using.. i used a breakpoint in my constructor and always is stoping there. I tried @Scope(ScopeTyper.EVENT) and i stoped in breakpoint like 5 times again.... is this normal ?? Can I get better performance with EJB3 @Stateless ?

            ty.

            • 3. Re: Performance: @Name and @Stateless
              swd847

              Can you post your full XHTML page and your backing bean code? And probably also the code for the entities that are in acaoList?

              Which constructor is being called 5 times? The constructor for acaoList?

              The easiest (and only good way) of figuring out what is slowing you down on is to run your code through a profiler.

              • 4. Re: Performance: @Name and @Stateless
                pmuir

                A component in event scope should have it's constructor called once per request.

                • 5. Re: Performance: @Name and @Stateless
                  diegocoronel

                  Hi.. here is my full Edit.xhtml

                  <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                  
                  <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                   xmlns:s="http://jboss.com/products/seam/taglib"
                   xmlns:ui="http://java.sun.com/jsf/facelets"
                   xmlns:f="http://java.sun.com/jsf/core"
                   xmlns:h="http://java.sun.com/jsf/html"
                   xmlns:a="https://ajax4jsf.dev.java.net/ajax"
                   xmlns:rich="http://richfaces.ajax4jsf.org/rich"
                   template="../../layout/template.xhtml">
                  
                  <ui:define name="body">
                  <h:panelGrid columns="1">
                  <h:outputText value="#{resourceOM.omLabelCadastro}" class="titulo" rendered="#{!omHome.managed}"></h:outputText>
                  <h:outputText value="#{resourceOM.omLabelAlteracao}" class="titulo" rendered="#{omHome.managed}"></h:outputText>
                  <rich:spacer height="3" />
                  </h:panelGrid>
                   <rich:simpleTogglePanel switchType="ajax">
                   <h:form id="omSearch" styleClass="edit">
                  
                   <s:decorate id="omNomeDecoration" template="/layout/edit.xhtml">
                   <ui:define name="label">#{resourceOM.omLabelNome}</ui:define>
                   <h:inputText id="txNomeCompleto"
                   size="75"
                   maxlength="50"
                   required="true"
                   value="#{omHome.instance.txNomeCompleto}">
                   </h:inputText>
                   </s:decorate>
                  
                   <s:decorate id="omCodomDecoration" template="/layout/edit.xhtml">
                   <ui:define name="label">#{resourceOM.omLabelCodom}</ui:define>
                   <h:inputText id="txCodom"
                   size="30"
                   required="true"
                   maxlength="6"
                   value="#{omHome.instance.txCodom}">
                   </h:inputText>
                   </s:decorate>
                  
                   <s:decorate id="omSiglaDecoration" template="/layout/edit.xhtml">
                   <ui:define name="label">#{resourceOM.omLabelSigla}</ui:define>
                   <h:inputText id="txSigla"
                   size="35"
                   required="true"
                   maxlength="30"
                   value="#{omHome.instance.txSigla}">
                   </h:inputText>
                   </s:decorate>
                  
                   <s:decorate id="nbOmDecoration" template="/layout/edit.xhtml">
                   <ui:define name="label">#{resourceOM.omLabelNivel}</ui:define>
                   <h:selectOneMenu id="nbOm" value="#{omHome.instance.nbNivelOm}" required="true" styleClass="texto">
                   <s:selectItems value="#{nivelDomains}" var="nivelDomain"
                   label="#{nivelDomain.nivelName}"
                   noSelectionLabel="#{msg.APP_NOSELECTION_LABEL}"/>
                   <s:convertEnum/>
                   </h:selectOneMenu>
                   </s:decorate>
                  
                   <s:decorate id="omPaiDecoration" template="/layout/edit.xhtml">
                   <ui:define name="label">#{resourceOM.omLabelOmPai}</ui:define>
                   <h:selectOneMenu id="nbOmPai" value="#{omHome.instance.om}" styleClass="texto">
                   <s:selectItems value="#{omList.resultList}" var="om"
                   label="#{om.txSigla}"
                   noSelectionLabel="#{msg.APP_NOSELECTION_LABEL}"/>
                   <s:convertEntity />
                   </h:selectOneMenu>
                   </s:decorate>
                  
                   <s:decorate id="txLocalidadeDecoration" template="/layout/edit.xhtml">
                   <ui:define name="label">#{resourceOM.omLabelLocalidade}</ui:define>
                   <h:selectOneMenu id="localidade" required="true" value="#{omHome.instance.localidade}">
                   <s:selectItems value="#{localidadeList.resultList}" var="localidadeItem"
                   label="#{localidadeItem.txLocalidade}"
                   noSelectionLabel="#{msg.APP_NOSELECTION_LABEL}"/>
                   <s:convertEntity/>
                   </h:selectOneMenu>
                   </s:decorate>
                  
                   <s:decorate id="omEnderecoDecoration" template="/layout/edit.xhtml">
                   <ui:define name="label">#{resourceOM.omLabelEndereco}</ui:define>
                   <h:inputText id="txEndereco"
                   size="75"
                   maxlength="75"
                   value="#{omHome.instance.txEndereco}">
                   </h:inputText>
                   </s:decorate>
                  
                   <s:decorate id="omCepDecoration" template="/layout/edit.xhtml">
                   <ui:define name="label">#{resourceOM.omLabelCep}</ui:define>
                   <h:inputText id="txCep"
                   size="10"
                   required="false"
                   maxlength="8"
                   value="#{omHome.instance.txCep}">
                   </h:inputText>
                   </s:decorate>
                  
                   <s:decorate id="omTelefoneDecoration" template="/layout/edit.xhtml">
                   <ui:define name="label">#{resourceOM.omLabelTelefone}</ui:define>
                   <h:inputText id="txTelefone"
                   size="20"
                   required="false"
                   maxlength="15"
                   value="#{omHome.instance.txTelefone}">
                   </h:inputText>
                   </s:decorate>
                  
                   <h:panelGrid columns="1">
                   <rich:spacer height="2" />
                   <h:panelGrid columns="3" border="0" cellpadding="0" cellspacing="0">
                   <h:commandButton id="save"
                   styleClass="bt_salvar"
                   action="#{omHome.persist}"
                   rendered="#{!omHome.managed}"/>
                   <rich:spacer width="3" rendered="#{!omHome.managed}" />
                  
                   <h:commandButton id="update"
                   styleClass="bt_salvar"
                   action="#{omHome.update}"
                   rendered="#{omHome.managed}"/>
                   <rich:spacer width="3" rendered="#{omHome.managed}" />
                  
                   <s:button id="cancel"
                   styleClass="bt_cancelar"
                   view="/faces/om/OmList.xhtml" />
                   </h:panelGrid>
                  
                   </h:panelGrid>
                   </h:form>
                  
                   <!-- inicio -->
                   <h:form>
                   <h:panelGrid columns="3">
                   <rich:spacer height="1" />
                   <rich:spacer height="1" />
                   <rich:spacer height="1" />
                   <h:outputText value="#{resourceOM.omAtividadesDisponiveis}" styleClass="titulo2" />
                   <rich:spacer height="1" />
                   <h:outputText value="#{resourceOM.omAtividadesSelecionadas}" styleClass="titulo2" />
                   <h:selectManyListbox
                   value="#{omHome.atividadesAssociadas}"
                   styleClass="texto"
                   size="10">
                  
                   <s:selectItems
                   value="#{omHome.atividadeDisponiveis}"
                   var="atv"
                   label="#{atv.txAtividade}"/>
                  
                   <s:convertEntity />
                  
                   </h:selectManyListbox>
                  
                   <h:panelGrid columns="3">
                   <rich:spacer width="5" />
                   <h:commandButton id="incluir"
                   styleClass="but_inclusao"
                   action="#{omHome.addAtividade}" />
                   <rich:spacer width="5" />
                   <rich:spacer width="5" />
                   <h:commandButton id="remover"
                   styleClass="but_remocao"
                   action="#{omHome.delAtividade}" />
                   <rich:spacer width="5" />
                   <rich:spacer width="5" />
                   <h:commandButton id="incluirAll"
                   styleClass="but_todos_inclusao"
                   action="#{omHome.addAllAtividade}" />
                   <rich:spacer width="5" />
                   <rich:spacer width="5" />
                   <h:commandButton id="removerAll"
                   styleClass="but_todos_remocao"
                   action="#{omHome.delAllAtividade}" />
                   <rich:spacer width="5" />
                   </h:panelGrid>
                  
                   <h:selectManyListbox
                   value="#{omHome.atividadesRemovidos}"
                   styleClass="texto"
                   size="10">
                  
                   <s:selectItems
                   value="#{omHome.atividadeSelecionadas}"
                   var="atv"
                   label="#{atv.txAtividade}"/>
                  
                   <s:convertEntity />
                  
                   </h:selectManyListbox>
                  
                   </h:panelGrid>
                   <h:panelGrid columns="3">
                   <rich:spacer height="1" />
                   <rich:spacer height="1" />
                   <rich:spacer height="1" />
                   <h:outputText value="#{resourceOM.omModulosDisponiveis}" styleClass="titulo2" />
                   <rich:spacer height="1" />
                   <h:outputText value="#{resourceOM.omModulosSelecionadas}" styleClass="titulo2" />
                   <h:selectManyListbox
                   value="#{omHome.modulosAssociados}"
                   styleClass="texto"
                   size="10">
                  
                   <s:selectItems
                   value="#{omHome.modulosDisponiveis}"
                   var="modulos"
                   label="#{modulos.txModulo}"/>
                  
                   <s:convertEntity />
                  
                   </h:selectManyListbox>
                  
                   <h:panelGrid columns="3">
                   <rich:spacer width="5" />
                   <h:commandButton id="incluirMod"
                   styleClass="but_inclusao"
                   action="#{omHome.addModulo}" />
                   <rich:spacer width="5" />
                   <rich:spacer width="5" />
                   <h:commandButton id="removerMod"
                   styleClass="but_remocao"
                   action="#{omHome.delModulo}" />
                   <rich:spacer width="5" />
                   <rich:spacer width="5" />
                   <h:commandButton id="incluirAllMod"
                   styleClass="but_todos_inclusao"
                   action="#{omHome.addAllModulo}" />
                   <rich:spacer width="5" />
                   <rich:spacer width="5" />
                   <h:commandButton id="removerAllMod"
                   styleClass="but_todos_remocao"
                   action="#{omHome.delAllModulo}" />
                   <rich:spacer width="5" />
                   </h:panelGrid>
                  
                   <h:selectManyListbox
                   value="#{omHome.modulosRemovidos}"
                   styleClass="texto"
                   size="10">
                  
                   <s:selectItems
                   value="#{omHome.modulosSelecionados}"
                   var="modulos"
                   label="#{modulos.txModulo}"/>
                  
                   <s:convertEntity />
                  
                   </h:selectManyListbox>
                   </h:panelGrid>
                  
                   <h:panelGrid columns="3">
                   <rich:spacer height="1" />
                   <rich:spacer height="1" />
                   <rich:spacer height="1" />
                   <h:outputText value="#{resourceOM.omFuncionalidadeDisponiveis}" styleClass="titulo2" />
                   <rich:spacer height="1" />
                   <h:outputText value="#{resourceOM.omFuncionalidadeSelecionadas}" styleClass="titulo2" />
                  
                   <h:selectManyListbox
                   value="#{omHome.funcionalidadesAssociadas}"
                   styleClass="texto"
                   size="10">
                  
                   <s:selectItems
                   value="#{omHome.funcionalidadesDisponiveis}"
                   var="func"
                   label="#{func.txNomeFuncionalidade}"/>
                  
                   <s:convertEntity />
                  
                   </h:selectManyListbox>
                  
                   <h:panelGrid columns="3">
                   <rich:spacer width="5" />
                   <h:commandButton id="incluirFunc"
                   styleClass="but_inclusao"
                   action="#{omHome.addFuncionalidade}" />
                   <rich:spacer width="5" />
                   <rich:spacer width="5" />
                   <h:commandButton id="removerFunc"
                   styleClass="but_remocao"
                   action="#{omHome.delFuncionalidade}" />
                   <rich:spacer width="5" />
                   <rich:spacer width="5" />
                   <h:commandButton id="incluirAllFunc"
                   styleClass="but_todos_inclusao"
                   action="#{omHome.addAllFuncionalidade}" />
                   <rich:spacer width="5" />
                   <rich:spacer width="5" />
                   <h:commandButton id="removerAllFunc"
                   styleClass="but_todos_remocao"
                   action="#{omHome.delAllFuncionalidade}" />
                   <rich:spacer width="5" />
                   </h:panelGrid>
                  
                   <h:selectManyListbox
                   value="#{omHome.funcionalidadesRemovidas}"
                   styleClass="texto"
                   size="10">
                  
                   <s:selectItems
                   value="#{omHome.funcionalidadesSelecionadas}"
                   var="func"
                   label="#{func.txNomeFuncionalidade}"/>
                  
                   <s:convertEntity />
                  
                   </h:selectManyListbox>
                   </h:panelGrid>
                   </h:form>
                  
                  </rich:simpleTogglePanel>
                  </ui:define>
                  </ui:composition>
                  
                  


                  my edit.page.xml
                  <?xml version="1.0" encoding="UTF-8"?>
                  <page xmlns="http://jboss.com/products/seam/pages"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd"
                   no-conversation-view-id="/OmList.xhtml"
                   login-required="true">
                  
                   <begin-conversation join="true"/>
                  
                   <action execute="#{omHome.wire}"/>
                  
                   <navigation from-action="#{omHome.persist}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmList.xhtml"/>
                   </navigation>
                  
                   <param name="omFrom"/>
                   <param name="omIdOm" value="#{omHome.omIdOm}"/>
                  
                   <navigation from-action="#{omHome.update}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmList.xhtml"/>
                   </navigation>
                  
                  
                   <!-- Navegação para o componente de seleção de dados -->
                   <!-- Atividade -->
                   <navigation from-action="#{omHome.addAtividade}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmEdit.xhtml"/>
                   </navigation>
                   <navigation from-action="#{omHome.delAtividade}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmEdit.xhtml"/>
                   </navigation>
                   <navigation from-action="#{omHome.addAllAtividade}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmEdit.xhtml"/>
                   </navigation>
                   <navigation from-action="#{omHome.delAllAtividade}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmEdit.xhtml"/>
                   </navigation>
                   <!-- Módulo -->
                   <navigation from-action="#{omHome.addModulo}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmEdit.xhtml"/>
                   </navigation>
                   <navigation from-action="#{omHome.delModulo}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmEdit.xhtml"/>
                   </navigation>
                   <navigation from-action="#{omHome.addAllModulo}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmEdit.xhtml"/>
                   </navigation>
                   <navigation from-action="#{omHome.delAllModulo}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmEdit.xhtml"/>
                   </navigation>
                   <!-- Funcionalidade -->
                   <navigation from-action="#{omHome.addFuncionalidade}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmEdit.xhtml"/>
                   </navigation>
                   <navigation from-action="#{omHome.delFuncionalidade}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmEdit.xhtml"/>
                   </navigation>
                   <navigation from-action="#{omHome.addAllFuncionalidade}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmEdit.xhtml"/>
                   </navigation>
                   <navigation from-action="#{omHome.delAllFuncionalidade}">
                   <end-conversation/>
                   <redirect view-id="/faces/om/OmEdit.xhtml"/>
                   </navigation>
                  
                  </page>
                  
                  


                  and my omHome
                  package br.gov.exercito.silog.beans;
                  
                  import java.util.ArrayList;
                  import java.util.HashSet;
                  import java.util.Iterator;
                  import java.util.List;
                  import java.util.Set;
                  
                  import javax.persistence.EntityManager;
                  
                  import org.jboss.seam.annotations.In;
                  import org.jboss.seam.annotations.Name;
                  import org.jboss.seam.annotations.security.Restrict;
                  import org.jboss.seam.faces.FacesMessages;
                  
                  import br.gov.exercito.silog.overriden.SilogHome;
                  
                  @Name("omHome")
                  public class OmHome extends SilogHome<Om> {
                  
                   private static final long serialVersionUID = 1L;
                  
                   @In
                   EntityManager entityManager;
                  
                   @In
                   private FacesMessages facesMessages;
                  
                   private Om om;
                   private List<Atividade> atividadeDisponiveis;
                   private Set<Atividade> atividadeSelecionadas = new HashSet<Atividade>();
                   private Set<Modulo> modulosDisponiveis = new HashSet<Modulo>();
                   private Set<Modulo> modulosSelecionados = new HashSet<Modulo>();
                   private Set<Funcionalidade> funcionalidadesDisponiveis = new HashSet<Funcionalidade>();
                   private Set<Funcionalidade> funcionalidadesSelecionadas = new HashSet<Funcionalidade>();
                   private Atividade[] atividadesAssociadas;
                   private Atividade[] atividadesRemovidos;
                   private Modulo[] modulosAssociados;
                   private Modulo[] modulosRemovidos;
                   private Funcionalidade[] funcionalidadesAssociadas;
                   private Funcionalidade[] funcionalidadesRemovidas;
                  
                   /*
                   * Código Gerado Pelo Seam
                   */
                   @In(create = true)
                   OmHome omHome;
                  
                   Integer idOmDelete;
                  
                   public void setOmIdOm(Integer id) {
                   setId(id);
                   if(!isManaged())
                   clearAll();
                   }
                  
                   public Integer getOmIdOm() {
                   return (Integer) getId();
                   }
                  
                   @Override
                   protected Om createInstance() {
                   Om om = new Om();
                   return om;
                   }
                  
                   public void wire() {
                   }
                  
                   public boolean isWired() {
                   if (getInstance().getOm() == null)
                   return false;
                   return true;
                   }
                  
                   public Om getDefinedInstance() {
                   return isIdDefined() ? getInstance() : null;
                   }
                  
                   public List<OmFuncionalidade> getOmFuncionalidades() {
                   return getInstance() == null ? null : new ArrayList<OmFuncionalidade>(
                   getInstance().getOmFuncionalidades());
                   }
                   public List<Om> getOms() {
                   return getInstance() == null ? null : new ArrayList<Om>(getInstance()
                   .getOms());
                   }
                   public List<UsuarioAtorOm> getUsuarioAtorOms() {
                   return getInstance() == null ? null : new ArrayList<UsuarioAtorOm>(
                   getInstance().getUsuarioAtorOms());
                   }
                   public List<OmModulo> getOmModulos() {
                   return getInstance() == null ? null : new ArrayList<OmModulo>(
                   getInstance().getOmModulos());
                   }
                  
                   public Integer getIdOmDelete() {
                   return idOmDelete;
                   }
                  
                   public void setIdOmDelete(Integer idOmDelete) {
                   this.idOmDelete = idOmDelete;
                   }
                  
                   /*
                   * Criação de Objetos de relacionamentos
                   */
                  
                   public OmModulo newOmModulo(Om om, Modulo modulo){
                  
                   OmModuloId id = new OmModuloId();
                   id.setIdOm(om.getIdOm());
                   id.setIdModulo(modulo.getIdModulo());
                  
                   OmModulo omModulo = new OmModulo();
                   omModulo.setId(id);
                   omModulo.setOm(om);
                   omModulo.setModulo(modulo);
                   return omModulo;
                   }
                  
                  
                   public OmFuncionalidade newOmFuncionalidade(Om om, Funcionalidade funcionalidade){
                  
                   OmFuncionalidadeId id = new OmFuncionalidadeId();
                   id.setIdOm(om.getIdOm());
                   id.setIdFuncionalidade(funcionalidade.getIdFuncionalidade());
                  
                   OmFuncionalidade omFuncionalidade = new OmFuncionalidade();
                   omFuncionalidade.setOm(om);
                   omFuncionalidade.setFuncionalidade(funcionalidade);
                   omFuncionalidade.setId(id);
                   return omFuncionalidade;
                   }
                  
                   public void prepareToEdit() {
                   clearAll();
                   this.om = this.instance;
                   setData();
                   inicializarSelecionados();
                   inicializarDisponiveis();
                   }
                  
                   public void createNew() {
                   setOmIdOm(null);
                   this.om = new Om();
                   setData();
                   }
                  
                   public void setData() {
                   if (atividadeDisponiveis == null) {
                   atividadeDisponiveis = entityManager.createQuery("from Atividade")
                   .getResultList();
                   }
                   }
                  
                   private void clearAll() {
                   this.om = null;
                   this.atividadeDisponiveis = null;
                   this.atividadeSelecionadas.clear();
                   this.modulosDisponiveis.clear();
                   this.modulosSelecionados.clear();
                   this.funcionalidadesDisponiveis.clear();
                   this.funcionalidadesSelecionadas.clear();
                   }
                  
                   // adicionar objetos individualmente
                  
                   public void addAtividade() {
                   if (atividadesAssociadas != null) {
                   for (Atividade atividade : atividadesAssociadas) {
                   atividadeSelecionadas.add(atividade);
                   atividadeDisponiveis.remove(atividade);
                   Iterator<Modulo> i = atividade.getModulos().iterator();
                   while (i.hasNext()) {
                   Modulo modulo = i.next();
                   modulosDisponiveis.add(modulo);
                   }
                   }
                   }
                   }
                  
                   public void addModulo() {
                   if (modulosAssociados != null) {
                   for (Modulo modulo : modulosAssociados) {
                   modulosSelecionados.add(modulo);
                   modulosDisponiveis.remove(modulo);
                  
                   if (isManaged()) {
                   OmModulo omModulo = newOmModulo(this.om, modulo);
                   this.om.getOmModulos().add(omModulo);
                   }
                  
                   Iterator<Funcionalidade> i = modulo.getFuncionalidades()
                   .iterator();
                   while (i.hasNext()) {
                   Funcionalidade funcionalidade = i.next();
                   funcionalidadesDisponiveis.add(funcionalidade);
                   }
                   }
                   }
                   }
                  
                   public void addFuncionalidade() {
                   if (funcionalidadesAssociadas != null) {
                   for (Funcionalidade funcionalidade : funcionalidadesAssociadas) {
                   funcionalidadesSelecionadas.add(funcionalidade);
                   funcionalidadesDisponiveis.remove(funcionalidade);
                  
                   if (isManaged()) {
                   OmFuncionalidade omFuncionalidade = newOmFuncionalidade(
                   this.om, funcionalidade);
                   this.om.getOmFuncionalidades().add(omFuncionalidade);
                   }
                   }
                   }
                   }
                  
                   public void delAtividade() {
                   if (atividadesRemovidos != null) {
                  
                   for (Atividade atividade : atividadesRemovidos) {
                   atividadeSelecionadas.remove(atividade);
                   atividadeDisponiveis.add(atividade);
                  
                   Iterator<Modulo> i = atividade.getModulos().iterator();
                   while (i.hasNext()) {
                   Modulo modulo = i.next();
                   modulosDisponiveis.remove(modulo);
                   modulosSelecionados.remove(modulo);
                   if (isManaged()) {
                   OmModulo omModulo = newOmModulo(this.om, modulo);
                   this.om.getOmModulos().remove(omModulo);
                   }
                  
                   Iterator<Funcionalidade> f = modulo.getFuncionalidades()
                   .iterator();
                   while (f.hasNext()) {
                   Funcionalidade funcionalidade = f.next();
                   funcionalidadesDisponiveis.remove(funcionalidade);
                   funcionalidadesSelecionadas.remove(funcionalidade);
                  
                   if (isManaged()) {
                   OmFuncionalidade omFuncionalidade = newOmFuncionalidade(
                   this.om, funcionalidade);
                   this.om.getOmFuncionalidades().remove(
                   omFuncionalidade);
                   }
                   }
                   }
                   }
                   }
                   }
                  
                   public void delModulo() {
                   if (modulosRemovidos != null) {
                  
                   for (Modulo modulo : modulosRemovidos) {
                   modulosSelecionados.remove(modulo);
                   modulosDisponiveis.add(modulo);
                  
                   if (isManaged()) {
                   OmModulo omModulo = newOmModulo(this.om, modulo);
                   this.om.getOmModulos().remove(omModulo);
                   }
                  
                   Iterator<Funcionalidade> i = modulo.getFuncionalidades()
                   .iterator();
                   while (i.hasNext()) {
                   Funcionalidade funcionalidade = i.next();
                   funcionalidadesDisponiveis.remove(funcionalidade);
                   funcionalidadesSelecionadas.remove(funcionalidade);
                  
                   if (isManaged()) {
                   OmFuncionalidade omFuncionalidade = newOmFuncionalidade(
                   this.om, funcionalidade);
                   this.om.getOmFuncionalidades().remove(
                   omFuncionalidade);
                   }
                   }
                   }
                   }
                  
                   }
                  
                   public void delFuncionalidade() {
                   if (funcionalidadesRemovidas != null) {
                   for (Funcionalidade funcionalidade : funcionalidadesRemovidas) {
                   funcionalidadesSelecionadas.remove(funcionalidade);
                   funcionalidadesDisponiveis.add(funcionalidade);
                  
                   if (isManaged()) {
                   OmFuncionalidade omFuncionalidade = newOmFuncionalidade(
                   this.om, funcionalidade);
                   this.om.getOmFuncionalidades().remove(omFuncionalidade);
                   }
                   }
                   }
                  
                   }
                  
                   public void addAllAtividade() {
                   if (atividadeDisponiveis.size() > 0) {
                   for (Atividade atividade : atividadeDisponiveis) {
                   atividadeSelecionadas.add(atividade);
                  
                   Iterator<Modulo> i = atividade.getModulos().iterator();
                   while (i.hasNext()) {
                   Modulo modulo = i.next();
                   modulosDisponiveis.add(modulo);
                   }
                   }
                   atividadeDisponiveis.clear();
                   }
                   }
                  
                   public void addAllModulo() {
                   if (modulosDisponiveis.size() > 0) {
                   for (Modulo modulo : modulosDisponiveis) {
                   modulosSelecionados.add(modulo);
                  
                   if (isManaged()) {
                   OmModulo omModulo = newOmModulo(this.om, modulo);
                   this.om.getOmModulos().add(omModulo);
                   }
                  
                   Iterator<Funcionalidade> i = modulo.getFuncionalidades()
                   .iterator();
                   while (i.hasNext()) {
                   Funcionalidade funcionalidade = i.next();
                   funcionalidadesDisponiveis.add(funcionalidade);
                   }
                   }
                   modulosDisponiveis.clear();
                   }
                   }
                  
                   public void addAllFuncionalidade() {
                   if (funcionalidadesDisponiveis.size() > 0) {
                   for (Funcionalidade funcionalidade : funcionalidadesDisponiveis) {
                   funcionalidadesSelecionadas.add(funcionalidade);
                  
                   if (isManaged()) {
                   OmFuncionalidade omFuncionalidade = newOmFuncionalidade(
                   this.om, funcionalidade);
                   this.om.getOmFuncionalidades().add(omFuncionalidade);
                   }
                   }
                   funcionalidadesDisponiveis.clear();
                   }
                   }
                  
                   public void delAllAtividade() {
                   if (atividadeSelecionadas.size() > 0) {
                   for (Atividade atividade : atividadeSelecionadas) {
                   atividadeDisponiveis.add(atividade);
                   }
                   atividadeSelecionadas.clear();
                   modulosDisponiveis.clear();
                   modulosSelecionados.clear();
                   funcionalidadesDisponiveis.clear();
                   funcionalidadesSelecionadas.clear();
                  
                   if (isManaged()) {
                   this.om.getOmModulos().clear();
                   this.om.getOmFuncionalidades().clear();
                   }
                   }
                   }
                  
                   public void delAllModulo() {
                   if (modulosSelecionados.size() > 0) {
                   for (Modulo modulo : modulosSelecionados) {
                   modulosDisponiveis.add(modulo);
                   }
                   modulosSelecionados.clear();
                   funcionalidadesDisponiveis.clear();
                   funcionalidadesSelecionadas.clear();
                  
                   if (isManaged()) {
                   this.om.getOmModulos().clear();
                   this.om.getOmFuncionalidades().clear();
                   }
                   }
                   }
                  
                   public void delAllFuncionalidade() {
                   if (funcionalidadesSelecionadas.size() > 0) {
                   for (Funcionalidade funcionalidade : funcionalidadesSelecionadas) {
                   funcionalidadesDisponiveis.add(funcionalidade);
                   }
                   funcionalidadesSelecionadas.clear();
                  
                   if (isManaged()) {
                   this.om.getOmFuncionalidades().clear();
                   }
                  
                   }
                   }
                  
                   public void setAtividadeDisponiveis(List<Atividade> atividadeDisponiveis) {
                   this.atividadeDisponiveis = atividadeDisponiveis;
                   }
                  
                   public void setAtividadeSelecionadas(Set<Atividade> atividadeSelecionadas) {
                   this.atividadeSelecionadas = atividadeSelecionadas;
                   }
                  
                   public void setModulosDisponiveis(Set<Modulo> modulosDisponiveis) {
                   this.modulosDisponiveis = modulosDisponiveis;
                   }
                  
                   public void setModulosSelecionados(Set<Modulo> modulosSelecionados) {
                   this.modulosSelecionados = modulosSelecionados;
                   }
                  
                   public void setFuncionalidadesDisponiveis(
                   Set<Funcionalidade> funcionalidadesDisponiveis) {
                   this.funcionalidadesDisponiveis = funcionalidadesDisponiveis;
                   }
                  
                   public void setFuncionalidadesSelecionadas(
                   Set<Funcionalidade> funcionalidadesSelecionadas) {
                   this.funcionalidadesSelecionadas = funcionalidadesSelecionadas;
                   }
                  
                   public void setAtividadesAssociadas(Atividade[] atividadesAssociadas) {
                   this.atividadesAssociadas = atividadesAssociadas;
                   }
                  
                   public void setAtividadesRemovidos(Atividade[] atividadesRemovidos) {
                   this.atividadesRemovidos = atividadesRemovidos;
                   }
                  
                   public void setModulosAssociados(Modulo[] modulosAssociados) {
                   this.modulosAssociados = modulosAssociados;
                   }
                  
                   public void setModulosRemovidos(Modulo[] modulosRemovidos) {
                   this.modulosRemovidos = modulosRemovidos;
                   }
                  
                   public void setFuncionalidadesAssociadas(
                   Funcionalidade[] funcionalidadesAssociadas) {
                   this.funcionalidadesAssociadas = funcionalidadesAssociadas;
                   }
                  
                   public void setFuncionalidadesRemovidas(
                   Funcionalidade[] funcionalidadesRemovidas) {
                   this.funcionalidadesRemovidas = funcionalidadesRemovidas;
                   }
                  
                  
                   private void inicializarSelecionados() {
                   Iterator<OmModulo> om = this.om.getOmModulos().iterator();
                   while (om.hasNext()) {
                   Modulo modulo = om.next().getModulo();
                   atividadeDisponiveis.remove(modulo.getAtividade());
                   atividadeSelecionadas.add(modulo.getAtividade());
                   modulosSelecionados.add(modulo);
                   }
                  
                   Iterator<OmFuncionalidade> of = this.om.getOmFuncionalidades()
                   .iterator();
                   while (of.hasNext()) {
                   Funcionalidade funcionalidade = of.next().getFuncionalidade();
                   funcionalidadesSelecionadas.add(funcionalidade);
                   }
                   }
                  
                   private void inicializarDisponiveis() {
                   for (Atividade atividade : atividadeSelecionadas) {
                   Iterator<Modulo> i = atividade.getModulos().iterator();
                   while (i.hasNext()) {
                   Modulo modulo = i.next();
                   if (!modulosSelecionados.contains(modulo)) {
                   modulosDisponiveis.add(modulo);
                   }
                   }
                   }
                  
                   for (Modulo modulo : modulosSelecionados) {
                   Iterator<Funcionalidade> f = modulo.getFuncionalidades().iterator();
                   while (f.hasNext()) {
                   Funcionalidade funcionalidade = f.next();
                   if (!funcionalidadesSelecionadas.contains(funcionalidade)) {
                   funcionalidadesDisponiveis.add(funcionalidade);
                   }
                   }
                   }
                   }
                  
                   public List<Atividade> getAtividadeDisponiveis() {
                   return atividadeDisponiveis;
                   }
                  
                   public Set<Atividade> getAtividadeSelecionadas() {
                   return atividadeSelecionadas;
                   }
                  
                   public Set<Modulo> getModulosDisponiveis() {
                   return modulosDisponiveis;
                   }
                  
                   public Set<Modulo> getModulosSelecionados() {
                   return modulosSelecionados;
                   }
                  
                   public Set<Funcionalidade> getFuncionalidadesDisponiveis() {
                   return funcionalidadesDisponiveis;
                   }
                  
                   public Set<Funcionalidade> getFuncionalidadesSelecionadas() {
                   return funcionalidadesSelecionadas;
                   }
                  
                   public Atividade[] getAtividadesAssociadas() {
                   return atividadesAssociadas;
                   }
                  
                   public Atividade[] getAtividadesRemovidos() {
                   return atividadesRemovidos;
                   }
                  
                   public Modulo[] getModulosAssociados() {
                   return modulosAssociados;
                   }
                  
                   public Modulo[] getModulosRemovidos() {
                   return modulosRemovidos;
                   }
                  
                   public Funcionalidade[] getFuncionalidadesAssociadas() {
                   return funcionalidadesAssociadas;
                   }
                  
                   public Funcionalidade[] getFuncionalidadesRemovidas() {
                   return funcionalidadesRemovidas;
                   }
                  
                   @Override
                   @Restrict("#{s:hasPermission('omHome','cad_om_incluir',this)}")
                   public String persist() {
                  
                   String returned = super.persist();
                  
                   Om om = this.instance;
                  
                   if(om.getOm() == null){
                   om.setOm(om);
                   }
                  
                   for(Modulo modulo : modulosSelecionados){
                   om.getOmModulos().add(newOmModulo(om, modulo));
                   }
                  
                   for(Funcionalidade funcionalidade : funcionalidadesSelecionadas){
                   om.getOmFuncionalidades().add(newOmFuncionalidade(om, funcionalidade));
                   }
                  
                   super.update();
                  
                   return returned;
                   }
                  
                   @Override
                   @Restrict("#{s:hasPermission('omHome','cad_om_excluir',this)}")
                   public String remove() {
                  
                   Om om = this.getEntityManager().find(Om.class, getIdOmDelete());
                   this.setInstance(om);
                  
                   String removed = "";
                   if(om.getOms().isEmpty() && om.getUsuarioAtorOms().isEmpty()){
                   removed = super.remove();
                   facesMessages.addToControl("removed", "Registro removido com sucesso");
                   }
                   else{
                   facesMessages.addToControl("removed", "O registro possui relacionamentos e não pode ser excluído");
                   }
                  
                   return removed;
                   }
                  
                   @Override
                   @Restrict("#{s:hasPermission('omHome','cad_om_alterar',this) || s:hasPermission('omHome','cad_om_incluir',this) || s:hasPermission('omHome','cad_om_excluir',this)}")
                   public String update() {
                   // TODO Auto-generated method stub
                   return super.update();
                   }
                  
                   @Override
                   @Restrict("#{s:hasPermission('omHome','cad_om_consultar',this) || s:hasPermission('omHome','cad_om_alterar',this) || s:hasPermission('omHome','cad_om_incluir',this) || s:hasPermission('omHome','cad_om_excluir',this) || s:hasPermission('omHome','cad_om_consultar_submeter',this)}")
                   public Om find() {
                   return super.find();
                   }
                  }
                  


                  and my omList
                  package br.gov.exercito.silog.beans;
                  
                  import org.jboss.seam.annotations.Name;
                  import org.jboss.seam.framework.EntityQuery;
                  import java.util.List;
                  import java.util.Arrays;
                  
                  @Name("omList")
                  public class OmList extends EntityQuery {
                  
                   private static final long serialVersionUID = 1L;
                  
                   private static final String[] RESTRICTIONS = {
                   "lower(om.txCodom) like lower('%'||#{omList.om.txCodom}||'%')",
                   "lower(om.txSigla) like lower('%'||#{omList.om.txSigla}||'%')",
                   "lower(om.localidade.txLocalidade) like lower('%'||#{omList.om.txLocalidade}||'%')",
                   "lower(om.txNomeCompleto) like lower('%'||#{omList.om.txNomeCompleto}||'%')"};
                  
                   private Om om = new Om();
                  
                   @Override
                   public String getEjbql() {
                   return "select om from Om om";
                   }
                  
                   @Override
                   public Integer getMaxResults() {
                   return null;
                   }
                  
                   public Om getOm() {
                   return om;
                   }
                  
                   @Override
                   public List<String> getRestrictions() {
                   return Arrays.asList(RESTRICTIONS);
                   }
                  
                  }
                  
                  


                  well.. sry about all those codes... but if you explain me whats wrong ill probably understand what happens and increase my system performance....

                  and pete... my constructor is called for each method in my .xhtml and not per request.. maybe im doing something wrong.. can you help me abou that ??

                  ty for your answer guys...

                  • 6. Re: Performance: @Name and @Stateless
                    diegocoronel

                    i tried to use Scope(ScopeType.EVENT) but its still calling my constructor for each method in my .xhtml...

                    • 7. Re: Performance: @Name and @Stateless
                      p-a

                      Maybe just out of the blue, but try removing:

                      @In(create = true)
                      OmHome omHome;
                      

                      (since you're not referencing it anywhere in your code anyways..)

                      • 8. Re: Performance: @Name and @Stateless
                        diegocoronel

                        ty.. but anyone can help me ?? or.. anyone can tell me if i use session beans (@Stateless @Name) is better than use only @Name ??

                        • 9. Re: Performance: @Name and @Stateless
                          pmuir

                          @Stateless Seam components have a different contract from JavaBean Seam components - to make a choice you need to understand the difference which is explained in the reference manual.

                          I'm pretty sure that using @Stateless beans is going to improve the performance of your app significantly.

                          You don't really post enough information to for people to help you with your performance issue.

                          • 10. Re: Performance: @Name and @Stateless
                            pmuir

                            oops,

                            I'm pretty sure that using @Stateless beans isn't going to improve the performance of your app significantly.

                            • 11. Re: Performance: @Name and @Stateless
                              diegocoronel

                              Ok, ty for your help, i saw in my code that my menu was using

                              if(Identity.instance().hasPermission("Modulo", "modulo_"+modulo.getTxModulo(), this)){
                              and now i got my menu from database ... i won like 20 sec with this change... probably i did something wrong with hasPermission.

                              • 12. Re: Performance: @Name and @Stateless
                                diegocoronel

                                just to complete... my iterator with hasPermission had more then 30 elements... :)