001: /*
002: * Copyright 2002-2005 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.springframework.web.portlet.context;
018:
019: import org.springframework.web.context.support.RequestHandledEvent;
020:
021: /**
022: * Portlet-specific subclass of RequestHandledEvent,
023: * adding portlet-specific context information.
024: *
025: * @author Juergen Hoeller
026: * @author John A. Lewis
027: * @since 2.0
028: * @see org.springframework.web.portlet.FrameworkPortlet
029: * @see org.springframework.context.ApplicationContext#publishEvent
030: */
031: public class PortletRequestHandledEvent extends RequestHandledEvent {
032:
033: /** Name of the portlet that handled the request */
034: private final String portletName;
035:
036: /** PortletMode of the request */
037: private final String portletMode;
038:
039: /** Type of Portlet Request */
040: private final String requestType;
041:
042: /**
043: * Create a new PortletRequestHandledEvent.
044: * @param source the component that published the event
045: * @param portletName the name of the portlet that handled the request
046: * @param portletMode the PortletMode of the request (usually 'view', 'edit', or 'help')
047: * @param requestType the type of Portlet request ('action' or 'render')
048: * @param sessionId the id of the HTTP session, if any
049: * @param userName the name of the user that was associated with the
050: * request, if any (usually the UserPrincipal)
051: * @param processingTimeMillis the processing time of the request in milliseconds
052: */
053: public PortletRequestHandledEvent(Object source,
054: String portletName, String portletMode, String requestType,
055: String sessionId, String userName, long processingTimeMillis) {
056:
057: super (source, sessionId, userName, processingTimeMillis);
058: this .portletName = portletName;
059: this .portletMode = portletMode;
060: this .requestType = requestType;
061: }
062:
063: /**
064: * Create a new PortletRequestHandledEvent.
065: * @param source the component that published the event
066: * @param portletName the name of the portlet that handled the request
067: * @param portletMode the PortletMode of the request (usually 'view', 'edit', or 'help')
068: * @param requestType the type of Portlet request ('action' or 'render')
069: * @param sessionId the id of the HTTP session, if any
070: * @param userName the name of the user that was associated with the
071: * request, if any (usually the UserPrincipal)
072: * @param processingTimeMillis the processing time of the request in milliseconds
073: * @param failureCause the cause of failure, if any
074: */
075: public PortletRequestHandledEvent(Object source,
076: String portletName, String portletMode, String requestType,
077: String sessionId, String userName,
078: long processingTimeMillis, Throwable failureCause) {
079:
080: super (source, sessionId, userName, processingTimeMillis,
081: failureCause);
082: this .portletName = portletName;
083: this .portletMode = portletMode;
084: this .requestType = requestType;
085: }
086:
087: /**
088: * Return the name of the portlet that handled the request.
089: */
090: public String getPortletName() {
091: return portletName;
092: }
093:
094: /**
095: * Return the mode of the portlet request (usually 'view', 'edit', or 'help').
096: */
097: public String getPortletMode() {
098: return portletMode;
099: }
100:
101: /**
102: * Return the the type of Portlet Request ('action' or 'render').
103: */
104: public String getRequestType() {
105: return requestType;
106: }
107:
108: public String getShortDescription() {
109: StringBuffer sb = new StringBuffer();
110: sb.append("portlet=[").append(this .portletName).append("]; ");
111: sb.append(super .getShortDescription());
112: return sb.toString();
113: }
114:
115: public String getDescription() {
116: StringBuffer sb = new StringBuffer();
117: sb.append("portlet=[").append(this .portletName).append("]; ");
118: sb.append("mode=[").append(this .portletMode).append("]; ");
119: sb.append("type=[").append(this .requestType).append("]; ");
120: sb.append(super .getDescription());
121: return sb.toString();
122: }
123:
124: public String toString() {
125: return ("PortletRequestHandledEvent: " + getDescription());
126: }
127:
128: }
|