Java 类javax.portlet.EventRequest 实例源码

项目:spring4-understanding    文件:AnnotationMethodHandlerAdapter.java   
private String determineDefaultPhase(Method handlerMethod) {
    if (void.class != handlerMethod.getReturnType()) {
        return PortletRequest.RENDER_PHASE;
    }
    for (Class<?> argType : handlerMethod.getParameterTypes()) {
        if (ActionRequest.class.isAssignableFrom(argType) || ActionResponse.class.isAssignableFrom(argType) ||
                InputStream.class.isAssignableFrom(argType) || Reader.class.isAssignableFrom(argType)) {
            return PortletRequest.ACTION_PHASE;
        }
        else if (RenderRequest.class.isAssignableFrom(argType) || RenderResponse.class.isAssignableFrom(argType) ||
                OutputStream.class.isAssignableFrom(argType) || Writer.class.isAssignableFrom(argType)) {
            return PortletRequest.RENDER_PHASE;
        }
        else if (ResourceRequest.class.isAssignableFrom(argType) || ResourceResponse.class.isAssignableFrom(argType)) {
            return PortletRequest.RESOURCE_PHASE;
        }
        else if (EventRequest.class.isAssignableFrom(argType) || EventResponse.class.isAssignableFrom(argType)) {
            return PortletRequest.EVENT_PHASE;
        }
    }
    return "";
}
项目:spring4-understanding    文件:DispatcherPortlet.java   
/**
 * Trigger afterCompletion callbacks on the mapped HandlerInterceptors.
 * Will just invoke afterCompletion for all interceptors whose preHandle
 * invocation has successfully completed and returned true.
 * @param mappedHandler the mapped HandlerExecutionChain
 * @param interceptorIndex index of last interceptor that successfully completed
 * @param ex Exception thrown on handler execution, or null if none
 * @see HandlerInterceptor#afterRenderCompletion
 */
private void triggerAfterEventCompletion(HandlerExecutionChain mappedHandler, int interceptorIndex,
        EventRequest request, EventResponse response, Exception ex)
        throws Exception {

    // Apply afterCompletion methods of registered interceptors.
    if (mappedHandler != null) {
        HandlerInterceptor[] interceptors = mappedHandler.getInterceptors();
        if (interceptors != null) {
            for (int i = interceptorIndex; i >= 0; i--) {
                HandlerInterceptor interceptor = interceptors[i];
                try {
                    interceptor.afterEventCompletion(request, response, mappedHandler.getHandler(), ex);
                }
                catch (Throwable ex2) {
                    logger.error("HandlerInterceptor.afterCompletion threw exception", ex2);
                }
            }
        }
    }
}
项目:class-guard    文件:AnnotationMethodHandlerAdapter.java   
private String determineDefaultPhase(Method handlerMethod) {
    if (!void.class.equals(handlerMethod.getReturnType())) {
        return PortletRequest.RENDER_PHASE;
    }
    for (Class<?> argType : handlerMethod.getParameterTypes()) {
        if (ActionRequest.class.isAssignableFrom(argType) || ActionResponse.class.isAssignableFrom(argType) ||
                InputStream.class.isAssignableFrom(argType) || Reader.class.isAssignableFrom(argType)) {
            return PortletRequest.ACTION_PHASE;
        }
        else if (RenderRequest.class.isAssignableFrom(argType) || RenderResponse.class.isAssignableFrom(argType) ||
                OutputStream.class.isAssignableFrom(argType) || Writer.class.isAssignableFrom(argType)) {
            return PortletRequest.RENDER_PHASE;
        }
        else if (ResourceRequest.class.isAssignableFrom(argType) || ResourceResponse.class.isAssignableFrom(argType)) {
            return PortletRequest.RESOURCE_PHASE;
        }
        else if (EventRequest.class.isAssignableFrom(argType) || EventResponse.class.isAssignableFrom(argType)) {
            return PortletRequest.EVENT_PHASE;
        }
    }
    return "";
}
项目:class-guard    文件:PortletWrappingController.java   
public void handleEventRequest(
        EventRequest request, EventResponse response) throws Exception {

    if (!(this.portletInstance instanceof EventPortlet)) {
        logger.debug("Ignoring event request for non-event target portlet: " + this.portletInstance.getClass());
        return;
    }
    EventPortlet eventPortlet = (EventPortlet) this.portletInstance;

    // Delegate to PortletContentGenerator for checking and preparing.
    check(request, response);

    // Execute in synchronized block if required.
    if (isSynchronizeOnSession()) {
        PortletSession session = request.getPortletSession(false);
        if (session != null) {
            Object mutex = PortletUtils.getSessionMutex(session);
            synchronized (mutex) {
                eventPortlet.processEvent(request, response);
                return;
            }
        }
    }

    eventPortlet.processEvent(request, response);
}
项目:class-guard    文件:DispatcherPortlet.java   
/**
 * Trigger afterCompletion callbacks on the mapped HandlerInterceptors.
 * Will just invoke afterCompletion for all interceptors whose preHandle
 * invocation has successfully completed and returned true.
 * @param mappedHandler the mapped HandlerExecutionChain
 * @param interceptorIndex index of last interceptor that successfully completed
 * @param ex Exception thrown on handler execution, or null if none
 * @see HandlerInterceptor#afterRenderCompletion
 */
private void triggerAfterEventCompletion(HandlerExecutionChain mappedHandler, int interceptorIndex,
        EventRequest request, EventResponse response, Exception ex)
        throws Exception {

    // Apply afterCompletion methods of registered interceptors.
    if (mappedHandler != null) {
        HandlerInterceptor[] interceptors = mappedHandler.getInterceptors();
        if (interceptors != null) {
            for (int i = interceptorIndex; i >= 0; i--) {
                HandlerInterceptor interceptor = interceptors[i];
                try {
                    interceptor.afterEventCompletion(request, response, mappedHandler.getHandler(), ex);
                }
                catch (Throwable ex2) {
                    logger.error("HandlerInterceptor.afterCompletion threw exception", ex2);
                }
            }
        }
    }
}
项目:portals-pluto    文件:ComplexPayloadEventTest.java   
public TestResult checkExpectedEventWasFired(EventRequest request,
        EventResponse response) {
    tally(response);
    TestResult result = new TestResult();
    result.setSpecPLT("15.2.2");
    result.setDescription("Check to make sure the the " + 
            COMPLEX_PAYLOAD_EVENT + " event was fired.");
    if (COMPLEX_PAYLOAD_EVENT.equals(request.getEvent().getName())) {
        result.setReturnCode(TestResult.PASSED);
    } else {
        result.setReturnCode(TestResult.FAILED);
        result.setResultMessage("Expected event name to be '" +
                COMPLEX_PAYLOAD_EVENT + "' but it was actually '" +
                request.getEvent().getName().getClass().getName() + "'");
    }
    return result;
}
项目:portals-pluto    文件:ComplexPayloadEventTest.java   
public TestResult checkEventPayloadIsCorrectClass(EventRequest request,
        EventResponse response) {
    tally(response);
    TestResult result = new TestResult();
    result.setSpecPLT("15.2.2");
    result.setDescription("Check to make sure that payload is an instance" +
            "of " + ComposedObject.class);
    Object value = request.getEvent().getValue();
    if (value == null) {
        result.setReturnCode(TestResult.FAILED);
        result.setResultMessage("Expected event payload type to be '" + 
                ComposedObject.class.getName() + "' but it was null.");
    } else if (value instanceof ComposedObject) {
        result.setReturnCode(TestResult.PASSED);
    } else {
        result.setReturnCode(TestResult.FAILED);
        result.setResultMessage("Expected event payload type to be '" + 
                ComposedObject.class.getName() + "' but it was actually '" +
            request.getEvent().getValue() + "'");
    }
    return result;
}
项目:portals-pluto    文件:ComplexPayloadEventTest.java   
public TestResult checkEventPayloadIsCorrect(EventRequest request,
        EventResponse response) {
    tally(response);
    TestResult result = new TestResult();
    result.setSpecPLT("15.2.2");
    result.setDescription(
            "Check to make sure that the payload carries the " +
        "proper state information from the event.");
    ComposedObject value = (ComposedObject) request.getEvent().getValue();
    if (!TEST_COLOR.equals(value.getColor())) {
        result.setReturnCode(TestResult.FAILED);
        result.setResultMessage("Expected payload color to be " + 
                TEST_COLOR + " but it was " + value.getColor());
    } else if (!TEST_POINT.equals(value.getPoint())) { 
        result.setReturnCode(TestResult.FAILED);
        result.setResultMessage("Expected payload point to be " + 
                TEST_POINT + " but it was " + value.getPoint());
    } else {
        result.setReturnCode(TestResult.PASSED);
    }
    return result;
}
项目:portals-pluto    文件:SimplePayloadEventTest.java   
public TestResult checkExpectedEventWasFired(EventRequest request,
        EventResponse response) {
    tally(response);
    TestResult result = new TestResult();
    result.setSpecPLT("15.2.2");
    result.setDescription("Check to make sure the the " + 
            SIMPLE_PAYLOAD_EVENT + " event was fired.");
    Event event = request.getEvent();
    if (event == null) {
        throw new NullPointerException("No event was received!");
    }
    if (SIMPLE_PAYLOAD_EVENT.equals(event.getName())) {
        result.setReturnCode(TestResult.PASSED);
    } else {
        result.setReturnCode(TestResult.FAILED);
        result.setResultMessage("Expected event name to be '" +
                SIMPLE_PAYLOAD_EVENT + "' but it was actually '" +
                event.getName() + "'");
    }
    return result;
}
项目:portals-pluto    文件:SimplePayloadEventTest.java   
public TestResult checkEventPayloadIsCorrectClass(EventRequest request,
        EventResponse response) {
    tally(response);
    TestResult result = new TestResult();
    result.setSpecPLT("15.2.2");
    result.setDescription("Check to make sure that payload is an instance" +
                    "of " + String.class);
    Event event = request.getEvent();
    if (event == null) {
        throw new NullPointerException("No event received!");
    }
    Object value = event.getValue();
    if (value == null) {
        result.setReturnCode(TestResult.FAILED);
        result.setResultMessage("Expected event payload type to be '" + 
                String.class.getName() + "' but it was null.");
    } else if (value instanceof String) {
        result.setReturnCode(TestResult.PASSED);
    } else {
        result.setReturnCode(TestResult.FAILED);
        result.setResultMessage("Expected event payload type to be '" + 
                String.class.getName() + "' but it was actually '" +
                value.getClass().getName() + "'");
    }
    return result;
}
项目:portals-pluto    文件:SimplePayloadEventTest.java   
public TestResult checkEventPayloadIsCorrect(EventRequest request,
        EventResponse response) {
    tally(response);
    TestResult result = new TestResult();
    result.setSpecPLT("15.2.2");
    result.setDescription(
            "Check to make sure that the payload carries the " +
            "proper state information from the event.");
    String value = (String) request.getEvent().getValue();
    if (!SIMPLE_VALUE_PAYLOAD.equals(value)) {
        result.setReturnCode(TestResult.FAILED);
        result.setResultMessage("Expected payload color to be " + 
                SIMPLE_VALUE_PAYLOAD + " but it was " + value);
    } else {
        result.setReturnCode(TestResult.PASSED);
    }
    return result;
}
项目:portals-pluto    文件:TestCompanionPortlet.java   
@ProcessEvent(name = SimplePayloadEventTest.SIMPLE_PAYLOAD_EVENT)
public void processSimplePayload(EventRequest request, 
        EventResponse response) throws PortletException, IOException {

    StringBuilder feedback = new StringBuilder();
    feedback.append("Simple Payload Event received.");

    if (!SimplePayloadEventTest.SIMPLE_VALUE_PAYLOAD.equals(
            request.getEvent().getValue())) {
        feedback.append("  Payload DID NOT match expected value.");
    } else {
        feedback.append("  Payload matched expected value.");
    }

    response.setRenderParameter(EVENT_INFO_PARAM, feedback.toString());
}
项目:portals-pluto    文件:TestCompanionPortlet.java   
@ProcessEvent(name = ComplexPayloadEventTest.COMPLEX_PAYLOAD_EVENT)
public void processComplexPayload(EventRequest request, 
        EventResponse response) throws PortletException, IOException {

    StringBuilder feedback = new StringBuilder();
    feedback.append("Complex Payload Event received.");

    boolean failed = false;
    ComposedObject value = (ComposedObject) request.getEvent().getValue();
    if (!ComplexPayloadEventTest.TEST_COLOR.equals(value.getColor())) {
        feedback.append("  Color DID NOT match expected value.");
        failed = true;
    }
    if (!ComplexPayloadEventTest.TEST_POINT.equals(value.getPoint())) {
        feedback.append("  Point DID NOT match expected value.");
        failed = true;
    }
    if (!failed) {
        feedback.append("  Payload matched expected values.");
    }

    response.setRenderParameter(EVENT_INFO_PARAM, feedback.toString());
}
项目:portals-pluto    文件:DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventRequest_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
      throws PortletException, IOException {


   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   // Prereq for: V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventRequest_getAttribute
   portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventRequest_getAttribute", "Value1");

   // Prereq for: V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventRequest_getAttributeNames
   portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventRequest_getAttributeNames", "Value1");

   // Now do the actual dispatch
   String target = JSP_PREFIX + "DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventRequest" + JSP_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);

}
项目:portals-pluto    文件:DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventResponse_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
      throws PortletException, IOException {


   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   // Now do the actual dispatch
   String target = JSP_PREFIX + "DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventResponse" + JSP_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);

}
项目:portals-pluto    文件:PortletTagLibraryTests_SPEC2_26_IncludeJSPEvent_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
    throws PortletException, IOException {


  portletResp.setRenderParameters(portletReq);

  long tid = Thread.currentThread().getId();
  portletReq.setAttribute(THREADID_ATTR, tid);

  // Now do the actual dispatch
  String target = JSP_PREFIX + "PortletTagLibraryTests_SPEC2_26_IncludeJSPEvent" + JSP_SUFFIX
      + "?" + QUERY_STRING;
  PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
  rd.include(portletReq, portletResp);

}
项目:portals-pluto    文件:DispatcherTests6_SPEC2_19_FwdThenIncludeServletEvent_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp) throws PortletException, IOException {

   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   new StringWriter();

   // Multilevel forward / include
   portletReq.setAttribute(ATTR_DISPATCH_ACTION, "include");
   String targ = SERVLET_PREFIX + "DispatcherTests6_SPEC2_19_FwdThenIncludeServletEvent_servlet" + EXTRA_PATH + "?"
         + QUERY_STRING;
   portletReq.setAttribute(ATTR_DISPATCH_TARGET, targ);

   // Now do the actual dispatch
   String target = "/IncluderForwarderServlet" + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);

}
项目:portals-pluto    文件:DispatcherTests6_SPEC2_19_FwdThenForwardServletEvent_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp) throws PortletException, IOException {

   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   new StringWriter();

   // Multilevel forward / include
   portletReq.setAttribute(ATTR_DISPATCH_ACTION, "forward");
   String targ = SERVLET_PREFIX + "DispatcherTests6_SPEC2_19_FwdThenForwardServletEvent_servlet" + EXTRA_PATH + "?"
         + QUERY_STRING;
   portletReq.setAttribute(ATTR_DISPATCH_TARGET, targ);

   // Now do the actual dispatch
   String target = "/IncluderForwarderServlet" + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);

}
项目:portals-pluto    文件:AnnotationPortletConfigTests_SPEC2_28_EventDeclaration.java   
@EventMethod(
   portletName = "AnnotationPortletConfigTests_SPEC2_28_EventDeclaration", 
   processingEvents = @PortletQName(
      localPart = "AnnotationPortletConfigTests_SPEC2_28_EventDeclaration_a", 
      namespaceURI = "http://www.apache.org/portals/pluto/portlet-tck_3.0"
   ),
   publishingEvents = {
      @PortletQName(
         localPart = "AnnotationPortletConfigTests_SPEC2_28_EventDeclaration_b", 
         namespaceURI = "http://www.apache.org/portals/pluto/portlet-tck_3.0"
      )
   }
)
public void processEvent_a(EventRequest portletReq, EventResponse portletResp)
         throws PortletException, IOException {

   QName eventQName = new QName(
         "http://www.apache.org/portals/pluto/portlet-tck_3.0",
         "AnnotationPortletConfigTests_SPEC2_28_EventDeclaration_b");
   portletResp.setEvent(eventQName, "Hi!");
}
项目:portals-pluto    文件:DispatcherTests_SPEC2_19_ForwardServletEvent_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp) throws PortletException, IOException {

   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   TckParameters params = (TckParameters) portletReq.getEvent().getValue();
   for (Parameter p : params.getParams()) {
      portletResp.setRenderParameter(p.getName(), p.getVals());
   }

   // Now do the actual dispatch
   String target = SERVLET_PREFIX + "DispatcherTests_SPEC2_19_ForwardServletEvent_servlet" + SERVLET_SUFFIX + "?"
         + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);

}
项目:portals-pluto    文件:AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration2.java   
@EventMethod(
   portletName = "AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration2", 
   processingEvents = @PortletQName(
      localPart = "AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration2a", 
      namespaceURI = "http://www.apache.org/portals/pluto/portlet-tck_3.0"
   )
)
public void processEventa(EventRequest portletReq, EventResponse portletResp)
         throws PortletException, IOException {
   Event e = portletReq.getEvent();
   String eventPayload = (String) e.getValue();
   if(eventPayload!=null && eventPayload.equals("a")){
      MutableRenderParameters mutableRenderParameters = portletResp.getRenderParameters();
      mutableRenderParameters.setValue("tr0_a", "true");
   }
}
项目:portals-pluto    文件:AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration1.java   
@EventMethod(
   portletName = "AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration1", 
   processingEvents = @PortletQName(
      localPart = "AnnotationPortletAppConfigOverrideTests_SPEC1_28_EventConfiguration1", 
      namespaceURI = "http://www.apache.org/portals/pluto/portlet-tck_3.0"
   )
)
public void processEventTr0(EventRequest portletReq, EventResponse portletResp)
         throws PortletException, IOException {
   Event e = portletReq.getEvent();
   String eventPayload = (String) e.getValue();
   if(eventPayload!=null && eventPayload.equals("Hi!")){
      MutableRenderParameters mutableRenderParameters = portletResp.getRenderParameters();
      mutableRenderParameters.setValue("tr0", "true");
   }
}
项目:portals-pluto    文件:DispatcherReqRespTests4_SPEC2_19_IncludeServletEventResponse_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
      throws PortletException, IOException {


   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   // Now do the actual dispatch
   String target = SERVLET_PREFIX + "DispatcherReqRespTests4_SPEC2_19_IncludeServletEventResponse_servlet" + SERVLET_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.include(portletReq, portletResp);

}
项目:portals-pluto    文件:DispatcherReqRespTests4_SPEC2_19_IncludeServletEventRequest_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
      throws PortletException, IOException {


   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   // Prereq for: V2DispatcherReqRespTests4_SPEC2_19_IncludeServletEventRequest_getAttribute
   portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests4_SPEC2_19_IncludeServletEventRequest_getAttribute", "Value1");

   // Prereq for: V2DispatcherReqRespTests4_SPEC2_19_IncludeServletEventRequest_getAttributeNames
   portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests4_SPEC2_19_IncludeServletEventRequest_getAttributeNames", "Value1");

   // Now do the actual dispatch
   String target = SERVLET_PREFIX + "DispatcherReqRespTests4_SPEC2_19_IncludeServletEventRequest_servlet" + SERVLET_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.include(portletReq, portletResp);

}
项目:portals-pluto    文件:AnnotationTests_ProcessEvent_ApiEvent_event.java   
@ProcessEvent(qname = "{" + TCKNAMESPACE + "}AnnotationTests_ProcessEvent_ApiEvent")
public void handleEvnt(EventRequest req, EventResponse resp)
    throws PortletException, IOException {

  StringWriter writer = new StringWriter();

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

  /* TestCase: V2AnnotationTests_ProcessEvent_ApiEvent_qname */
  /* Details: "Method qname(): On an event request, the method is */
  /* executed if the Event qname matches the qname field" */
  TestResult tr0 = tcd.getTestResultFailed(V2ANNOTATIONTESTS_PROCESSEVENT_APIEVENT_QNAME);
  tr0.setTcSuccess(true);
  tr0.writeTo(writer);
  req.getPortletSession().setAttribute(
      Constants.RESULT_ATTR_PREFIX + "AnnotationTests_ProcessEvent_ApiEvent", writer.toString(),
      APPLICATION_SCOPE);

  LOGGER.trace("Resulting String: {}", writer);
}
项目:portals-pluto    文件:AnnotationTests_ProcessEvent_ApiEvent_event.java   
@ProcessEvent(name = "AnnotationTests_ProcessEvent_ApiEvent2")
public void nameEvnt(EventRequest req, EventResponse resp) throws PortletException, IOException {
  StringWriter writer = new StringWriter();

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();
  /* TestCase: V2AnnotationTests_ProcessEvent_ApiEvent_name */
  /* Details: "Method name(): On an event request, the method is */
  /* executed if the Event name matches the name field" */
  TestResult tr1 = tcd.getTestResultFailed(V2ANNOTATIONTESTS_PROCESSEVENT_APIEVENT_NAME);
  tr1.setTcSuccess(true);
  tr1.writeTo(writer);
  req.getPortletSession().setAttribute(
      Constants.RESULT_ATTR_PREFIX + "AnnotationTests_ProcessEvent_ApiEvent", writer.toString(),
      APPLICATION_SCOPE);

}
项目:portals-pluto    文件:DispatcherReqRespTests3_SPEC2_19_IncludeJSPEventRequest_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
      throws PortletException, IOException {


   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   // Prereq for: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPEventRequest_getAttribute
   portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPEventRequest_getAttribute", "Value1");

   // Prereq for: V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPEventRequest_getAttributeNames
   portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests3_SPEC2_19_IncludeJSPEventRequest_getAttributeNames", "Value1");

   // Now do the actual dispatch
   String target = JSP_PREFIX + "DispatcherReqRespTests3_SPEC2_19_IncludeJSPEventRequest" + JSP_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.include(portletReq, portletResp);

}
项目:portals-pluto    文件:DispatcherReqRespTests3_SPEC2_19_IncludeJSPEventResponse_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
      throws PortletException, IOException {


   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   // Now do the actual dispatch
   String target = JSP_PREFIX + "DispatcherReqRespTests3_SPEC2_19_IncludeJSPEventResponse" + JSP_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.include(portletReq, portletResp);

}
项目:portals-pluto    文件:DispatcherTests5_SPEC2_19_IncThenIncludeServletEvent_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp) throws PortletException, IOException {

   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   new StringWriter();

   // Multilevel forward / include
   portletReq.setAttribute(ATTR_DISPATCH_ACTION, "include");
   String targ = SERVLET_PREFIX + "DispatcherTests5_SPEC2_19_IncThenIncludeServletEvent_servlet" + EXTRA_PATH + "?"
         + QUERY_STRING;
   portletReq.setAttribute(ATTR_DISPATCH_TARGET, targ);

   // Now do the actual dispatch
   String target = SERVLET_INCFWD + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
   rd.include(portletReq, portletResp);

}
项目:portals-pluto    文件:DispatcherTests4_SPEC2_19_ForwardJSPEvent_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp) throws PortletException, IOException {

   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   new StringWriter();

   // Prereq for: V2DispatcherTests4_SPEC2_19_ForwardJSPEvent_invoke3
   portletReq = new EventRequestWrapper(portletReq);
   portletResp = new EventResponseWrapper(portletResp);

   // Now do the actual dispatch
   String target = JSP_PREFIX + "DispatcherTests4_SPEC2_19_ForwardJSPEvent" + JSP_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);

}
项目:portals-pluto    文件:PortletHubTests_SPEC_23_JSPRP_TX.java   
@EventMethod(portletName = "PortletHubTests_SPEC_23_JSPRP_TX", processingEvents = {
      @PortletQName(namespaceURI="http://www.apache.org/", localPart="prpevent")
})
public void doEvent(EventRequest eventReq, EventResponse eventResp) {

   MutableRenderParameters mrp = eventResp.getRenderParameters();
   String testcase = (String) eventReq.getEvent().getValue();

   if (testcase == null || testcase.isEmpty()) {

      mrp.setValue("status", "Failed. No test case parameter present.");

   } else if (testcase.equals(V3PORTLETHUBTESTS_SPEC_23_JSPRP_ACTION1) ||
         testcase.equals(V3PORTLETHUBTESTS_SPEC_23_JSPRP_ACTION2)) {

      mrp.setValue("status", "OK");
      mrp.setValue("prptestcase", testcase);
   }

}
项目:portals-pluto    文件:PortletHubTests_SPEC_23_JSAction.java   
@EventMethod(portletName = "PortletHubTests_SPEC_23_JSAction", processingEvents = {
      @PortletQName(namespaceURI="http://www.apache.org/", localPart="event")
})
public void doEvent(EventRequest eventReq, EventResponse eventResp) {

   MutableRenderParameters mrp = eventResp.getRenderParameters();
   String testcase = mrp.getValue("testcase");

   if (testcase == null || testcase.isEmpty()) {
      mrp.setValue("status", "Failed. No test case parameter present.");
   } else if (testcase.equals(V3PORTLETHUBTESTS_SPEC_23_JSACTION_ACTION6)) {
      mrp.setValue("status", "OK");
   } else {
      mrp.setValue("status", "Failed. Unknown test case: " + testcase);
   }

}
项目:portals-pluto    文件:AddlPortletTests_SPEC2_5_RenderGenericPortlet_event.java   
@ProcessEvent(qname = "AddlPortletTests_SPEC2_5_RenderGenericPortlet")
public void processEvent(EventRequest portletReq, EventResponse portletResp)
    throws PortletException, IOException {
  JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails();

  /* TestCase: V2AddlPortletTests_SPEC2_5_RenderGenericPortlet_eventDispatching1 */
  /* Details: "The GenericPortlet processEvent method will dispatch the */
  /* request to a subclass method annotated with the tag */
  /* @ProcessEvent(qname=&lt;eventname&gt;), where &lt;eventname&gt; */
  /* must be in the format provided by Qname.toString()" */

  Event event = portletReq.getEvent();
  String qName = event.getName();
  TestResult tr1 =
      tcd.getTestResultFailed(V2ADDLPORTLETTESTS_SPEC2_5_RENDERGENERICPORTLET_EVENTDISPATCHING1);
  if (qName.toString().equals("AddlPortletTests_SPEC2_5_RenderGenericPortlet")) {
    tr1.setTcSuccess(true);
  } else {
    tr1.appendTcDetail(
        "Failed because QName is not AddlPortletTests_SPEC2_5_RenderGenericPortlet");
  }
  portletReq.getPortletSession().setAttribute(
      Constants.RESULT_ATTR_PREFIX + "AddlPortletTests_SPEC2_5_RenderGenericPortlet_event_a",
      tr1.toString(), APPLICATION_SCOPE);
}
项目:portals-pluto    文件:AddlPortletTests_SPEC2_5_RenderGenericPortlet.java   
@ProcessEvent(name = "AddlPortletTests_SPEC2_5_RenderGenericPortlet_localPart")
public void processEvent(EventRequest portletReq, EventResponse response)
      throws PortletException, IOException {
   JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails();

   /*
    * TestCase:
    * V2AddlPortletTests_SPEC2_5_RenderGenericPortlet_eventDispatching2
    */
   /* Details: "The GenericPortlet processEvent method will dispatch the */
   /* request to a subclass method annotated with the tag */
   /* @ProcessEvent(name=&lt;event_name_local_part&gt;)" */
   TestResult tr2 = tcd.getTestResultFailed(
         V2ADDLPORTLETTESTS_SPEC2_5_RENDERGENERICPORTLET_EVENTDISPATCHING2);
   tr2.setTcSuccess(true);
   portletReq.getPortletSession().setAttribute(
         RESULT_ATTR_PREFIX
               + "AddlPortletTests_SPEC2_5_RenderGenericPortlet_event_b",
         tr2.toString(), APPLICATION_SCOPE);

}
项目:portals-pluto    文件:DispatcherReqRespTests2_SPEC2_19_ForwardServletEventResponse_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
      throws PortletException, IOException {


   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   // Now do the actual dispatch
   String target = SERVLET_PREFIX + "DispatcherReqRespTests2_SPEC2_19_ForwardServletEventResponse_servlet" + SERVLET_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);

}
项目:portals-pluto    文件:DispatcherReqRespTests2_SPEC2_19_ForwardServletEventRequest_event.java   
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
      throws PortletException, IOException {


   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   // Prereq for: V2DispatcherReqRespTests2_SPEC2_19_ForwardServletEventRequest_getAttribute
   portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests2_SPEC2_19_ForwardServletEventRequest_getAttribute", "Value1");

   // Prereq for: V2DispatcherReqRespTests2_SPEC2_19_ForwardServletEventRequest_getAttributeNames
   portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests2_SPEC2_19_ForwardServletEventRequest_getAttributeNames", "Value1");

   // Now do the actual dispatch
   String target = SERVLET_PREFIX + "DispatcherReqRespTests2_SPEC2_19_ForwardServletEventRequest_servlet" + SERVLET_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);

}
项目:spring4-understanding    文件:AnnotationMethodHandlerAdapter.java   
@Override
public void handleEvent(EventRequest request, EventResponse response, Object handler) throws Exception {
    Object returnValue = doHandle(request, response, handler);
    if (returnValue != null) {
        throw new IllegalStateException("Invalid event method return value: " + returnValue);
    }
}
项目:spring4-understanding    文件:AnnotationMethodHandlerAdapter.java   
public boolean match(PortletRequest request) {
    if (!this.modes.isEmpty() && !this.modes.contains(request.getPortletMode())) {
        return false;
    }
    if (StringUtils.hasLength(this.phase) &&
            !this.phase.equals(request.getAttribute(PortletRequest.LIFECYCLE_PHASE))) {
        return false;
    }
    if (StringUtils.hasLength(this.value)) {
        if (this.phase.equals(PortletRequest.ACTION_PHASE) &&
                !this.value.equals(request.getParameter(ActionRequest.ACTION_NAME))) {
            return false;
        }
        else if (this.phase.equals(PortletRequest.RENDER_PHASE) &&
                !(new WindowState(this.value)).equals(request.getWindowState())) {
            return false;
        }
        else if (this.phase.equals(PortletRequest.RESOURCE_PHASE) &&
                !this.value.equals(((ResourceRequest) request).getResourceID())) {
            return false;
        }
        else if (this.phase.equals(PortletRequest.EVENT_PHASE)) {
            Event event = ((EventRequest) request).getEvent();
            if (!this.value.equals(event.getName()) && !this.value.equals(event.getQName().toString())) {
                return false;
            }
        }
    }
    return (PortletAnnotationMappingUtils.checkRequestMethod(this.methods, request) &&
            PortletAnnotationMappingUtils.checkParameters(this.params, request) &&
            PortletAnnotationMappingUtils.checkHeaders(this.headers, request));
}
项目:spring4-understanding    文件:DefaultAnnotationHandlerMapping.java   
@Override
public boolean match(PortletRequest request) {
    if (!PortletRequest.EVENT_PHASE.equals(request.getAttribute(PortletRequest.LIFECYCLE_PHASE))) {
        return false;
    }
    if ("".equals(this.eventName)) {
        return true;
    }
    Event event = ((EventRequest) request).getEvent();
    return (this.eventName.equals(event.getName()) || this.eventName.equals(event.getQName().toString()));
}
项目:spring4-understanding    文件:PortletWrappingController.java   
@Override
public void handleEventRequest(
        EventRequest request, EventResponse response) throws Exception {

    if (!(this.portletInstance instanceof EventPortlet)) {
        logger.debug("Ignoring event request for non-event target portlet: " + this.portletInstance.getClass());
        return;
    }
    EventPortlet eventPortlet = (EventPortlet) this.portletInstance;

    // Delegate to PortletContentGenerator for checking and preparing.
    check(request, response);

    // Execute in synchronized block if required.
    if (isSynchronizeOnSession()) {
        PortletSession session = request.getPortletSession(false);
        if (session != null) {
            Object mutex = PortletUtils.getSessionMutex(session);
            synchronized (mutex) {
                eventPortlet.processEvent(request, response);
                return;
            }
        }
    }

    eventPortlet.processEvent(request, response);
}