01: /*
02: DBPool - JDBC Connection Pool Manager
03: Copyright (c) Giles Winstanley
04: */
05: package snaq.util;
06:
07: import java.util.*;
08:
09: /**
10: * Event for ObjectPool objects.
11: * @author Giles Winstanley
12: */
13: public class ObjectPoolEvent extends EventObject {
14: public static final int CHECKOUT = 1;
15: public static final int CHECKIN = 2;
16: public static final int MAX_POOL_LIMIT_REACHED = 3;
17: public static final int MAX_POOL_LIMIT_EXCEEDED = 4;
18: public static final int MAX_SIZE_LIMIT_REACHED = 5;
19: public static final int MAX_SIZE_LIMIT_ERROR = 6;
20: public static final int PARAMETERS_CHANGED = 7;
21: public static final int POOL_RELEASED = 8;
22:
23: private int index, type;
24:
25: /**
26: * Creates a new PoolEvent.
27: */
28: public ObjectPoolEvent(ObjectPool pool, int type) {
29: super (pool);
30: this .type = type;
31: }
32:
33: /**
34: * Returns the pool for which this event was created.
35: */
36: public ObjectPool getPool() {
37: return (ObjectPool) getSource();
38: }
39:
40: /**
41: * Returns the type of event this object represents.
42: */
43: public int getType() {
44: return type;
45: }
46:
47: /**
48: * Returns the type of event this object represents as a string.
49: */
50: /* public String getTypeString()
51: {
52: switch(type)
53: {
54: case CHECKOUT: return "CHECKOUT";
55: case CHECKIN: return "CHECKIN";
56: case MAX_POOL_LIMIT_REACHED: return "MAX_POOL_LIMIT_REACHED";
57: case MAX_POOL_LIMIT_EXCEEDED: return "MAX_POOL_LIMIT_EXCEEDED";
58: case MAX_SIZE_LIMIT_REACHED: return "MAX_SIZE_LIMIT_REACHED";
59: case MAX_SIZE_LIMIT_ERROR: return "MAX_SIZE_LIMIT_ERROR";
60: case PARAMETERS_CHANGED: return "PARAMETERS_CHANGED";
61: case POOL_RELEASED: return "POOL_RELEASED";
62: }
63: return "Invalid";
64: }*/
65:
66: public boolean isPoolCheckOut() {
67: return type == CHECKOUT;
68: }
69:
70: public boolean isPoolCheckIn() {
71: return type == CHECKIN;
72: }
73:
74: public boolean isMaxPoolLimitReached() {
75: return type == MAX_POOL_LIMIT_REACHED;
76: }
77:
78: public boolean isMaxPoolLimitExceeded() {
79: return type == MAX_POOL_LIMIT_EXCEEDED;
80: }
81:
82: public boolean isMaxSizeLimitReached() {
83: return type == MAX_SIZE_LIMIT_REACHED;
84: }
85:
86: public boolean isMaxSizeLimitError() {
87: return type == MAX_SIZE_LIMIT_ERROR;
88: }
89:
90: public boolean isPoolParametersChanged() {
91: return type == PARAMETERS_CHANGED;
92: }
93:
94: public boolean isPoolReleased() {
95: return type == POOL_RELEASED;
96: }
97: }
|