01: /**
02: * $Id: ProviderGetterPool.java,v 1.12 2005/12/02 13:58:41 as133206 Exp $
03: * Copyright 2002 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.desktop.context;
14:
15: import com.sun.common.pool.ObjectPool;
16: import com.sun.common.pool.ObjectManager;
17:
18: import com.sun.portal.providers.context.ContainerProviderContext;
19: import com.sun.portal.desktop.monitoring.MonitoringSubsystemWrapper;
20:
21: import javax.servlet.http.HttpServletRequest;
22: import javax.servlet.http.HttpServletResponse;
23: import javax.servlet.ServletContext;
24:
25: public class ProviderGetterPool extends ObjectPool {
26: private static class ProviderGetterManager implements ObjectManager {
27: public Object createObject(Object param) {
28: ReusableProviderGetter pg = new ReusableProviderGetter();
29: pg.start();
30: return pg;
31: }
32:
33: public void destroyObject(Object o) {
34: ((ReusableProviderGetter) o).finish();
35: }
36: }
37:
38: public ProviderGetterPool(int minSize, int maxSize,
39: boolean overflow, int partitionSize) {
40: super (new ProviderGetterManager(), minSize, maxSize, overflow,
41: partitionSize);
42: MonitoringSubsystemWrapper.getDesktopMonitoringSubsystem()
43: .createPoolStatistic(getClass().getName(), minSize,
44: getPool());
45: }
46:
47: protected ReusableProviderGetter obtainGetter(
48: DesktopAppContext dac, DesktopContext dc,
49: ContainerProviderContext cpc, String parent,
50: String providerName, Monitor m, HttpServletRequest req,
51: HttpServletResponse res, HttpServletRequest origReq,
52: HttpServletResponse origRes, ServletContext sc) {
53: ReusableProviderGetter pg = (ReusableProviderGetter) (getPool()
54: .obtainObject(null));
55: pg.init(dac, dc, cpc, parent, providerName, m, req, res,
56: origReq, origRes, sc, this );
57: MonitoringSubsystemWrapper.getDesktopMonitoringSubsystem()
58: .updateGetterThreadPool(getPool());
59: return pg;
60: }
61:
62: void releaseGetter(ReusableProviderGetter pg) {
63: pg.clear();
64: getPool().releaseObject(pg);
65: MonitoringSubsystemWrapper.getDesktopMonitoringSubsystem()
66: .updateGetterThreadPool(getPool());
67: }
68: }
|