01: /**
02: * $Id: ObjectPool.java,v 1.4 2002/06/20 22:54:31 cathywu 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: public class ObjectPool {
16:
17: private Pool _pool;
18:
19: // maxSize = 0 --> NullObjectPool (create objects with every obtain)
20: // partitions = 1 --> SimpleObjectPool (a single internal pool, all obtains are synch on the same monitor)
21: // partitions > 1 --> ParallelObjectPool (#partitions# of internal pool, each partition has its own monitor)
22: // partitions should be prime number (3,5,7,11,13,17,19,....)
23:
24: public ObjectPool(ObjectManager objectManager, int minSize,
25: int maxSize, boolean overflow, int partitions) {
26: if (maxSize == 0) {
27: _pool = new NullObjectPool(objectManager);
28: } else if (partitions == 1) {
29: _pool = new SimpleObjectPool(objectManager, minSize,
30: maxSize, overflow);
31: } else {
32: _pool = new ParallelObjectPool(objectManager, minSize,
33: maxSize, overflow, partitions);
34: }
35: }
36:
37: public Pool getPool() {
38: return _pool;
39: }
40:
41: }
|