01: /* $Id: EventResponsePool.java,v 1.1 2005/04/08 06:06:37 vs152012 Exp $
02: * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
03: * Use is subject to license terms.
04: */
05: package com.sun.portal.portlet.impl;
06:
07: import com.sun.portal.common.pool.ObjectManager;
08: import com.sun.portal.common.pool.ObjectPool;
09: import com.sun.portal.portletappengine.ipc.EventResponse;
10: import com.sun.portal.portletcontainercommon.PortletContainerEventResponse;
11:
12: import java.util.logging.Level;
13: import java.util.logging.Logger;
14:
15: public class EventResponsePool extends ObjectPool {
16:
17: private static Logger logger;
18:
19: // constructor
20: private static class EventResponsePoolManager implements
21: ObjectManager {
22:
23: private static Logger logger;
24:
25: public EventResponsePoolManager(Logger log) {
26: logger = log;
27: }
28:
29: /**
30: * Creates a new object.
31: * <P>
32: * @param param Passed in params if needed.
33: */
34: public Object createObject(Object param) {
35: EventResponse aRes = new EventResponseImpl();
36:
37: if (logger.isLoggable(Level.INFO)) {
38: logger
39: .log(Level.INFO,
40: "ActionResponsePool.createObject(): created object");
41: }
42:
43: return aRes;
44: }
45:
46: /**
47: * Destroys an object.
48: */
49: public void destroyObject(Object o) {
50: //do nothing
51: }
52: }
53:
54: // constructor
55: public EventResponsePool(int minSize, int maxSize,
56: boolean overflow, int partitionSize, Logger log) {
57:
58: super (new EventResponsePoolManager(logger), minSize, maxSize,
59: overflow, partitionSize);
60: logger = log;
61: }
62:
63: /**
64: * Obtains an action response object from the pool.
65: * <P>
66: * @return <code>ActionResponse</code>
67: */
68: public EventResponse obtainObject(
69: PortletContainerEventResponse pceResponse) {
70:
71: if (logger.isLoggable(Level.INFO)) {
72: logger.log(Level.INFO,
73: "ActionResponsePool.obtainerObject(): obtained");
74: }
75:
76: EventResponseImpl aRes = (EventResponseImpl) (getPool()
77: .obtainObject(null));
78: aRes.init(pceResponse);
79: return aRes;
80: }
81:
82: /**
83: * Releases an object back to the pool.
84: *
85: * @param <code>ActionResponse</code>
86: */
87: public void releaseObject(EventResponse aRes) {
88: ((EventResponseImpl) aRes).clear();
89: getPool().releaseObject(aRes);
90:
91: if (logger.isLoggable(Level.INFO)) {
92: logger.log(Level.INFO,
93: "ActionResponsePool.releaseObject(): released");
94: }
95: }
96:
97: }
|