01: // ***************************************************************
02: // * *
03: // * File: ThreadPool.java *
04: // * *
05: // * Copyright (c) 2001 Sun Microsystems, Inc. *
06: // * All rights reserved. *
07: // * *
08: // * *
09: // * Date - Dec/11/2001 *
10: // * Author - alejandro.abdelnur@sun.com *
11: // * *
12: // ***************************************************************
13:
14: package com.sun.portal.desktop.context;
15:
16: import com.sun.common.pool.ObjectPool;
17: import com.sun.common.pool.ObjectManager;
18:
19: import com.sun.portal.providers.Provider;
20: import com.sun.portal.providers.context.ContainerProviderContext;
21: import com.sun.portal.desktop.monitoring.MonitoringSubsystemWrapper;
22:
23: import javax.servlet.http.HttpServletRequest;
24: import javax.servlet.http.HttpServletResponse;
25: import javax.servlet.ServletConfig;
26: import javax.servlet.ServletContext;
27:
28: public class ProviderCallerPool extends ObjectPool {
29: private static class ProviderCallerManager implements ObjectManager {
30: public Object createObject(Object param) {
31: ReusableProviderCaller pc = new ReusableProviderCaller();
32: pc.start();
33: return pc;
34: }
35:
36: public void destroyObject(Object o) {
37: ((ReusableProviderCaller) o).finish();
38: }
39: }
40:
41: public ProviderCallerPool(int minSize, int maxSize,
42: boolean overflow, int partitionSize) {
43: super (new ProviderCallerManager(), minSize, maxSize, overflow,
44: partitionSize);
45: MonitoringSubsystemWrapper.getDesktopMonitoringSubsystem()
46: .createPoolStatistic(getClass().getName(), minSize,
47: getPool());
48: }
49:
50: protected ReusableProviderCaller obtainCaller(
51: DesktopAppContext dac, DesktopContext dc,
52: ContainerProviderContext cpc, Provider p, String parent,
53: Monitor m, HttpServletRequest req, HttpServletResponse res,
54: HttpServletRequest origReq, HttpServletResponse origRes,
55: ServletConfig scfg, ServletContext sc) {
56: ReusableProviderCaller pc = (ReusableProviderCaller) (getPool()
57: .obtainObject(null));
58: pc.init(dac, dc, cpc, p, parent, m, req, res, origReq, origRes,
59: scfg, sc, CommunityUserMembershipThreadLocalizer.get(dc
60: .getUserID()), this );
61: MonitoringSubsystemWrapper.getDesktopMonitoringSubsystem()
62: .updateCallerThreadPool(getPool());
63: return pc;
64: }
65:
66: void releaseCaller(ReusableProviderCaller pc) {
67: pc.clear();
68: getPool().releaseObject(pc);
69: MonitoringSubsystemWrapper.getDesktopMonitoringSubsystem()
70: .updateCallerThreadPool(getPool());
71: }
72: }
|