001: /*
002: * Copyright 2002 Sun Microsystems, Inc. All
003: * rights reserved. Use of this product is subject
004: * to license terms. Federal Acquisitions:
005: * Commercial Software -- Government Users
006: * Subject to Standard License Terms and
007: * Conditions.
008: *
009: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010: * are trademarks or registered trademarks of Sun Microsystems,
011: * Inc. in the United States and other countries.
012: */
013: package com.sun.portal.portlet.impl;
014:
015: import javax.servlet.ServletContext;
016:
017: import javax.servlet.http.HttpServletRequest;
018: import javax.servlet.http.HttpServletResponse;
019:
020: import javax.portlet.RenderRequest;
021: import javax.portlet.PortletContext;
022: import javax.portlet.PortalContext;
023:
024: import com.sun.portal.common.pool.ObjectPool;
025: import com.sun.portal.common.pool.ObjectManager;
026:
027: import java.util.logging.Logger;
028: import java.util.logging.Level;
029:
030: import com.sun.portal.portletcontainercommon.PortletContainerRenderRequest;
031: import com.sun.portal.portletcontainercommon.PortletContainerRenderResponse;
032:
033: import com.sun.portal.portletcontainercommon.descriptor.PortletDescriptor;
034: import com.sun.portal.log.common.PortalLogger;
035:
036: /**
037: * This class maintains reusable portlet request objects in a pool.
038: * <P>
039: * Clients can use the <code>obtainObject()</code> method to retrieve an
040: * portlet request object, and <code>releaseObject()</code> to release
041: * it back to the pool once is done with it.
042: **/
043: public class RenderRequestPool extends ObjectPool {
044:
045: private static java.util.logging.Logger _logger = PortalLogger
046: .getLogger(RenderRequestPool.class);
047:
048: private static class RenderRequestPoolManager implements
049: ObjectManager {
050: //SecurityManager _securityManager = null;
051: // constructor
052: public RenderRequestPoolManager(ServletContext context,
053: Logger logger) {
054: }
055:
056: /**
057: * Creates a new object.
058: * <P>
059: * @param param Passed in params if needed.
060: */
061: public Object createObject(Object param) {
062: RenderRequestImpl rReq = new RenderRequestImpl();
063:
064: _logger.finest("PSPL_PAECSPPI0007");
065:
066: return rReq;
067: }
068:
069: /**
070: * Destroys an object.
071: */
072: public void destroyObject(Object o) {
073: //do nothing
074: }
075: }
076:
077: // constructor
078: public RenderRequestPool(ServletContext context, int minSize,
079: int maxSize, boolean overflow, int partitionSize,
080: Logger logger) {
081:
082: super (new RenderRequestPoolManager(context, logger), minSize,
083: maxSize, overflow, partitionSize);
084: }
085:
086: /**
087: * Obtains an portlet request object from the pool.
088: * <P>
089: * @param req The <code>HttpServletRequest</code> object
090: * @param res The <code>HttpServletResponse</code> object
091: * <P>
092: * @return <code>RenderRequest</code>
093: */
094: public RenderRequest obtainObject(HttpServletRequest req,
095: HttpServletResponse res,
096: PortletContainerRenderRequest pContReq,
097: PortletContainerRenderResponse pContRes,
098: PortletContext context, PortalContext portalContext,
099: PortletDescriptor pDescriptor) {
100:
101: _logger.finest("PSPL_PAECSPPI0008");
102: RenderRequestImpl rReq = (RenderRequestImpl) (getPool()
103: .obtainObject(null));
104: rReq.init(req, res, pContReq, pContRes, context, portalContext,
105: pDescriptor, _logger);
106:
107: return (RenderRequestImpl) rReq;
108: }
109:
110: /**
111: * Releases an object back to the pool.
112: *
113: * @param <code>RenderRequest</code>
114: */
115: public void releaseObject(RenderRequest rReq) {
116: ((RenderRequestImpl) rReq).clear();
117: getPool().releaseObject(rReq);
118:
119: _logger.finest("PSPL_PAECSPPI0009");
120: }
121: }
|