/**
   * This method is called after an attribute is added to the ServletRequest. Note that this should
   * only get called for remote WSRP portlets. For more info, see:
   * http://issues.liferay.com/browse/FACES-146
   */
  public void attributeAdded(ServletRequestAttributeEvent servletRequestAttributeEvent) {

    // NOTE: We only care about phases prior to the RENDER_PHASE because we're concerned here about
    // managed beans
    // that get added to the request scope when the BridgeRequestScope begins. We're trying to
    // provide those managed
    // beans with an opportunity to prepare for an unexpected invocation of their methods annotated
    // with
    // @PreDestroy.
    ServletRequest servletRequest = servletRequestAttributeEvent.getServletRequest();
    PortletPhase phase = (PortletPhase) servletRequest.getAttribute(Bridge.PORTLET_LIFECYCLE_PHASE);

    // If this is taking place within a PortletRequest handled by the bridge in any phase prior to
    // the
    // RENDER_PHASE, then
    if ((phase != null) && (phase != PortletPhase.RENDER_PHASE)) {

      // If the attribute being added is not excluded, then invoke all methods on the attribute
      // value (class
      // instance) that are annotated with the BridgeRequestScopeAttributeAdded annotation.
      String attributeName = servletRequestAttributeEvent.getName();
      BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
      BridgeConfig bridgeConfig = bridgeContext.getBridgeConfig();
      Set<String> excludedRequestScopeAttributes = bridgeConfig.getExcludedRequestAttributes();

      if (!excludedRequestScopeAttributes.contains(attributeName)) {

        Object attributeValue = servletRequestAttributeEvent.getValue();
        logger.trace("Attribute added name=[{0}] value=[{1}]", attributeName, attributeValue);

        if (attributeValue != null) {
          Method[] methods = attributeValue.getClass().getMethods();

          if (methods != null) {

            for (Method method : methods) {

              if (method != null) {

                if (method.isAnnotationPresent(BridgeRequestScopeAttributeAdded.class)) {

                  try {
                    method.invoke(attributeValue, new Object[] {});
                  } catch (Exception e) {
                    logger.error(e);
                  }
                }
              }
            }
          }
        }
      }
    }
  }
 @Override
 public void attributeRemoved(ServletRequestAttributeEvent _srae) {
   System.out.println(
       "edu.temple.cis3238.wiki.WikiEventMonitor.attribRemoved(): [name]" + _srae.getName());
 }
 /**
  * This method is called after an attribute is replaced in the ServletRequest. One might expect
  * that this is a good time to call any managed bean methods annotated with @BridgePreDestroy, but
  * that actually takes place in the Bridge's {@link RequestAttributeMap#remove(Object)} method.
  * Note that this should only get called for remote WSRP portlets. For more info, see:
  * http://issues.liferay.com/browse/FACES-146
  */
 public void attributeReplaced(ServletRequestAttributeEvent servletRequestAttributeEvent) {
   String attributeName = servletRequestAttributeEvent.getName();
   Object attributeValue = servletRequestAttributeEvent.getValue();
   logger.trace("Attribute replaced name=[{0}] value=[{1}]", attributeName, attributeValue);
 }