public void removeListener(SessionListener sessionListener) {
   final ServletExternalContext.SessionListeners listeners =
       (ServletExternalContext.SessionListeners)
           portletSession.getAttribute(
               ServletExternalContext.SESSION_LISTENERS, PortletSession.APPLICATION_SCOPE);
   if (listeners != null) listeners.removeListener(sessionListener);
 }
 public void addListener(SessionListener sessionListener) {
   ServletExternalContext.SessionListeners listeners =
       (ServletExternalContext.SessionListeners)
           portletSession.getAttribute(
               ServletExternalContext.SESSION_LISTENERS, PortletSession.APPLICATION_SCOPE);
   if (listeners == null) {
     listeners = new ServletExternalContext.SessionListeners();
     portletSession.setAttribute(
         ServletExternalContext.SESSION_LISTENERS, listeners, PortletSession.APPLICATION_SCOPE);
   }
   listeners.addListener(sessionListener);
 }