PortletContainerImpl.java 文件源码

java
阅读 19 收藏 0 点赞 0 评论 0

项目:portals-pluto 作者:
/**
 * Fire Event for the portlet associated with the given portlet window and eventName
 * @param portletWindow  the portlet window.
 * @param request  the servlet request.
 * @param response  the servlet response.
 * @param event the event
 * @throws PortletException
 * @throws IOException
 * @throws PortletContainerException
 * 
 * @see javax.portlet.EventPortlet#processEvent(javax.portlet.EventRequest, javax.portlet.EventResponse)
 */
public void doEvent(PortletWindow portletWindow,
        HttpServletRequest request,
        HttpServletResponse response,
        Event event)
throws PortletException, IOException, PortletContainerException
{
    ensureInitialized();

    debugWithName("Event: "+event.getName()+" received for portlet: "
            + portletWindow.getPortletDefinition().getPortletName());

    PortletRequestContextService rcService = getContainerServices().getPortletRequestContextService();
    PortletEnvironmentService envService = getContainerServices().getPortletEnvironmentService();
    PortletInvokerService invoker = getContainerServices().getPortletInvokerService();

    PortletRequestContext requestContext = rcService.getPortletEventRequestContext(this, request, response, portletWindow);
    PortletEventResponseContext responseContext = rcService.getPortletEventResponseContext(this, request, response, portletWindow, requestContext);
    responseContext.setPropsAllowed(true);
    EventRequest portletRequest = envService.createEventRequest(requestContext, responseContext, event);
    EventResponse portletResponse = envService.createEventResponse(responseContext);

    FilterManager filterManager = filterInitialisation(portletWindow,PortletRequest.EVENT_PHASE);

    List<Event> events = null;
    try
    {
        invoker.event(requestContext, portletRequest, portletResponse, filterManager);

        debugWithName("Portlet event processed for: "
                + portletWindow.getPortletDefinition().getPortletName());

        // add http headers to response
        responseContext.processHttpHeaders();

        // Mark portlet interaction is completed: backend implementation can flush response state now
        responseContext.close();
        events = responseContext.getEvents();
    } catch (Throwable t) {

       // Throw away events and parameters that were set

       responseContext.reset();

       // just swallow the exception, ignoring changes to the response

       StringBuilder txt = new StringBuilder(128);
       txt.append("Exception during action request processing. Exception: ");

       StringWriter sw = new StringWriter();
       PrintWriter pw = new PrintWriter(sw);
       t.printStackTrace(pw);
       pw.flush();
       txt.append(sw.toString());

       LOG.warn(txt.toString());

    }
    finally
    {
        responseContext.release();
    }

    if (events != null && !events.isEmpty())
    {
        getContainerServices().getEventCoordinationService().processEvents(this, portletWindow, request, response, events);
    }

    debugWithName("Portlet event: "+ event.getName() +" fired for: " + portletWindow.getPortletDefinition().getPortletName());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号