1 Reply Latest reply on Jan 30, 2008 2:57 PM by Pete Muir

    Trinidad (ADF Faces)  PhaseListener blocks application

    Tamara Pinos Newbie

      Hello, I have a rather critical problem. I modified the ADF lifecycle by creating a phaseListener that executes some code in the UPDATE_MODEL_VALUES afterPhase and we just realized that only one user can work in the application at a time.

      This is what happens, user1 opens the jsp and starts working, when a checkbox is selected (it also happens with other components) the afterPhase is executed, this method does some queries to the database and executes some other calculations and it takes about 30 seconds to do everything that it has to do. Now, the user2 logs into the system, and tries to go into the same page but the application does not respond, once the 30secs are over the application gets back to work and now user2 can do whatever he wants, but only after the phaseListener that the user1 fired has finished what it was doing, which means that during that period of time no one else can use the application!! we didn't notice this before because our previous tests took about 2 secs so it wasn't noticeable, but now that we are using real data obtained by external webServices the response takes a lot longer.

      this is my phaseListener


      [corresponding imports]

      public class LocalRoutinesPhaseListener implements PhaseListener {

      /**
      * Logger
      */
      private static Logger logger = Logger.getLogger(LocalRoutinesPhaseListener.class);

      private static final long serialVersionUID = 3576307615728932485L;

      public LocalRoutinesPhaseListener() {
      }

      public void beforePhase(PhaseEvent phaseEvent) {
      }

      public void afterPhase(PhaseEvent phaseEvent) {
      String viewId = phaseEvent.getFacesContext().getViewRoot().getViewId();
      if (viewId.contains(ValidationsPhaseListener.PARSE_WEB) || viewId.contains(ValidationsPhaseListener.POPUP_MR)
      || viewId.contains(ValidationsPhaseListener.EDIT_TASK)) {
      Boolean isPopUp = false;

      if (viewId.contains(ValidationsPhaseListener.POPUP_MR)) {
      isPopUp = true;
      }

      BTRenderWebUtil bTRenderWebUtil = new BTRenderWebUtil();
      FisaDataBean dataBean = bTRenderWebUtil.getDataBean();
      if (dataBean != null) {
      CoreInputHidden changedComponent = dataBean.getChangedComponent();
      String changedComponentId = null;
      AdfFacesContext adfContext = AdfFacesContext.getCurrentInstance();

      if (changedComponent != null && changedComponent.getValue() != null) {
      changedComponentId = changedComponent.getValue().toString();
      UIComponent component = null;
      if (changedComponentId != null) {
      component = new BTRenderWebUtil().findComponentInRoot(changedComponentId);

      if (component != null) {
      bTRenderWebUtil.executeLocalRutine(component, isPopUp); //<---- all the queries and calculations are executed in this method }
      }
      }
      changedComponent.setValue(null);
      adfContext.addPartialTarget(changedComponent);
      component = null;
      }
      }
      }
      }

      public PhaseId getPhaseId() {
      return PhaseId.UPDATE_MODEL_VALUES;
      }
      }

      this is the phasesListener configuration:


      <phase-listener>com.fisa.efisa.process.render.manage.bean.LocalRoutinesPhaseListener</phase-listener>


      Please tell me what is it that I'm doing wrong. I really hope you can help me, I think this is a serious problem because only one person can use the application at a time!!

      Thank you so much!!

      Tamara