01: /**
02: * $Id: NullObjectPool.java,v 1.7 2005/12/02 13:53:25 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.common.pool;
14:
15: import com.sun.portal.desktop.monitoring.PoolStatistic;
16:
17: public class NullObjectPool implements Pool {
18: private ObjectManager _objectManager;
19: private boolean _destroyed;
20: private int _leased;
21:
22: public NullObjectPool(ObjectManager objectManager) {
23: _objectManager = objectManager;
24: _destroyed = false;
25: }
26:
27: public Object obtainObject(Object param) {
28: if (_destroyed) {
29: throw new IllegalStateException();
30: }
31: _leased++;
32: if (poolStatistic != null) {
33: poolStatistic.setCurrent(_leased);
34: }
35: return _objectManager.createObject(param);
36: }
37:
38: public void releaseObject(Object o) {
39: _objectManager.destroyObject(o);
40: _leased--;
41: if (poolStatistic != null) {
42: poolStatistic.setCurrent(_leased);
43: }
44: }
45:
46: public int getLeased() {
47: return _leased;
48: }
49:
50: public int getMinSize() {
51: return 0;
52: }
53:
54: public int getMaxSize() {
55: return 0;
56: }
57:
58: public void setMaxSize(int maxSize) {
59: }
60:
61: public long size() {
62: return getLeased();
63: }
64:
65: public void destroy() {
66: _destroyed = true;
67: }
68:
69: public final boolean doesReuseObjects() {
70: return false;
71: }
72:
73: public void setPoolStatistic(PoolStatistic poolStatistic) {
74: this .poolStatistic = poolStatistic;
75: }
76:
77: private PoolStatistic poolStatistic;
78: }
|