AjaxPortletBridge, FacesContext and the lack of perfomance in JBoss Portal with Faces 1.2

These days my colleague Markus and me found a lack of perfomance in the JBossPortletBridge V.: 1.0.0.B6 .
We wonder about excorbitant CPU (  9 million calls / 150 page hits) usage by the contextCreated method of the Bridge:

public void contextCreated(ELContextEvent event) {
   // Add the portletConfig to the ELContext
   ELContext elContext = event.getELContext();
   if (elContext.getContext(PortletConfig.class) == null) {
      elContext.putContext(PortletConfig.class, portletConfig);
   }
}

The method is lightweight, but it is called very often (for every JSF tag) by the getELContext method of the FacesContext class. ContextCreated() is an implementation of the interface ELContextListener which is called in getELContext() of FacesContext. It doesn’t matter which implementation of FacesContextImpl is used, all Versions of Sun, Apache (myfaces-impl-1.2.6.jar) and JBoss (portletbridge-impl-1.0.0.B6.jar) call ELContextListener.ContextCreated() in a loop, which is called for every JSF-tag on each called website:

public ELContext getELContext() {
.....
   //notify ELContextListener that we have created this context
   ELContextListener[] listeners = application.getELContextListeners();
   if (listeners.length > 0){
     ELContextEvent event = new ELContextEvent(this.elContext);
     for (ELContextListener listener:listeners){
        listener.contextCreated(event);
     }
    }
.....
}

This loop is implemented since Faces 1.2.
However our webservers reached a cpu usage near 100% so we hadto find a way out… By using the “try and error” technique we found a solution:
We simply made an empty implementation of AjaxPortletBridge.contextCreated(). The result is stunning, we can’t find any impact on the application behaviour and the cpu usage is down to 10% 🙂
The simple question is what does AjaxPortletBridge.contextCreated() do? Is it really needed in all cases?

While searching Jira we found the following issue PORTLETBRIDGE-2 which does not really help.
I will ask the JBoss PortalBridge forum..

Leave a Reply

Your email address will not be published. Required fields are marked *

*