001: /* $Id: EventRequestImpl.java,v 1.6 2006/08/03 09:58:04 dg154973 Exp $
002: * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
003: * Use is subject to license terms.
004: */
005: package com.sun.portal.portlet.impl;
006:
007: import com.sun.portal.log.common.PortalLogger;
008: import com.sun.portal.portletappengine.ipc.EventRequest;
009: import com.sun.portal.portletcontainercommon.PortletContainerEventRequest;
010: import com.sun.portal.portletcontainercommon.PortletContainerEventResponse;
011: import com.sun.portal.portletcontainercommon.descriptor.PortletDescriptor;
012:
013: import javax.servlet.http.HttpServletRequest;
014: import javax.servlet.http.HttpServletResponse;
015: import javax.portlet.PortletContext;
016: import javax.portlet.PortalContext;
017: import java.io.IOException;
018: import java.io.InputStream;
019: import java.io.ObjectInputStream;
020: import java.util.logging.Level;
021: import java.util.logging.LogRecord;
022: import java.util.logging.Logger;
023:
024: public class EventRequestImpl extends PortletRequestImpl implements
025: EventRequest {
026: private PortletContainerEventRequest pceRequest = null;
027: private HttpServletRequest request = null;
028: private String name = null;
029: private InputStream evtStream = null;
030: // Create a logger for this class
031: private static Logger debugLogger = PortalLogger
032: .getLogger(EventRequestImpl.class);
033:
034: public EventRequestImpl() {
035: }
036:
037: void init(HttpServletRequest req, HttpServletResponse res,
038: PortletContainerEventRequest pceRequest,
039: PortletContainerEventResponse pceResponse,
040: PortletContext context, PortalContext portalContext,
041: PortletDescriptor pDescriptor) {
042:
043: super .init(req, res, pceRequest, pceResponse, context,
044: portalContext, pDescriptor, null);
045: this .pceRequest = pceRequest;
046: this .request = request;
047: }
048:
049: public void clear() {
050: super .clear();
051: try {
052: if (evtStream != null)
053: evtStream.reset();
054: } catch (IOException ioe) {
055: if (debugLogger.isLoggable(Level.SEVERE)) {
056: LogRecord logRecord = new LogRecord(Level.SEVERE,
057: "PSPL_PAECSPPI0014");
058: logRecord.setThrown(ioe);
059: logRecord.setLoggerName(debugLogger.getName());
060: debugLogger.log(logRecord);
061: }
062: }
063: request = null;
064: pceRequest = null;
065: }
066:
067: public String getEventName() {
068: return name;
069: }
070:
071: public void setEventName(String name) {
072: this .name = name;
073: }
074:
075: public InputStream getEventStream() {
076: return evtStream;
077: }
078:
079: public void setEventStream(InputStream evtStream) {
080: this .evtStream = evtStream;
081: }
082:
083: public Object getEventData() {
084: Object evtData = null;
085: ObjectInputStream ois = null;
086: // In case of failure since event data is null, eventStream can be null
087: if (evtStream == null)
088: return null;
089: try {
090: if (evtStream instanceof ObjectInputStream) {
091: ois = (ObjectInputStream) evtStream;
092: } else {
093: ois = new ObjectInputStream(evtStream);
094: }
095: evtData = ois.readObject();
096: } catch (IOException ioe) {
097: if (debugLogger.isLoggable(Level.SEVERE)) {
098: LogRecord logRecord = new LogRecord(Level.SEVERE,
099: "PSPL_PAECSPPI0015");
100: logRecord.setThrown(ioe);
101: logRecord.setLoggerName(debugLogger.getName());
102: debugLogger.log(logRecord);
103: }
104: } catch (ClassNotFoundException cnfe) {
105: if (debugLogger.isLoggable(Level.SEVERE)) {
106: LogRecord logRecord = new LogRecord(Level.SEVERE,
107: "PSPL_PAECSPPI0015");
108: logRecord.setThrown(cnfe);
109: logRecord.setLoggerName(debugLogger.getName());
110: debugLogger.log(logRecord);
111: }
112: }
113: return evtData;
114: }
115: }
|