01: // ***************************************************************
02: // * *
03: // * File: ObjectPool.java *
04: // * *
05: // * Copyright (c) 2002 Sun Microsystems, Inc. *
06: // * All rights reserved. *
07: // * *
08: // * *
09: // * Author - alejandro.abdelnur@sun.com *
10: // * *
11: // ***************************************************************
12:
13: package com.sun.portal.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: }
|