KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > snaq > util > ObjectPoolEvent


1 /*
2     DBPool - JDBC Connection Pool Manager
3     Copyright (c) Giles Winstanley
4 */

5 package snaq.util;
6
7 import java.util.*;
8
9 /**
10  * Event for ObjectPool objects.
11  * @author Giles Winstanley
12  */

13 public class ObjectPoolEvent extends EventObject
14 {
15     public static final int CHECKOUT = 1;
16     public static final int CHECKIN = 2;
17     public static final int MAX_POOL_LIMIT_REACHED = 3;
18     public static final int MAX_POOL_LIMIT_EXCEEDED = 4;
19     public static final int MAX_SIZE_LIMIT_REACHED = 5;
20     public static final int MAX_SIZE_LIMIT_ERROR = 6;
21     public static final int PARAMETERS_CHANGED = 7;
22     public static final int POOL_RELEASED = 8;
23
24     private int index, type;
25
26
27     /**
28      * Creates a new PoolEvent.
29      */

30     public ObjectPoolEvent(ObjectPool pool, int type)
31     {
32         super(pool);
33         this.type = type;
34     }
35
36     /**
37      * Returns the pool for which this event was created.
38      */

39     public ObjectPool getPool() { return (ObjectPool)getSource(); }
40
41     /**
42      * Returns the type of event this object represents.
43      */

44     public int getType() { return type; }
45
46     /**
47      * Returns the type of event this object represents as a string.
48      */

49 /* public String getTypeString()
50     {
51         switch(type)
52         {
53             case CHECKOUT: return "CHECKOUT";
54             case CHECKIN: return "CHECKIN";
55             case MAX_POOL_LIMIT_REACHED: return "MAX_POOL_LIMIT_REACHED";
56             case MAX_POOL_LIMIT_EXCEEDED: return "MAX_POOL_LIMIT_EXCEEDED";
57             case MAX_SIZE_LIMIT_REACHED: return "MAX_SIZE_LIMIT_REACHED";
58             case MAX_SIZE_LIMIT_ERROR: return "MAX_SIZE_LIMIT_ERROR";
59             case PARAMETERS_CHANGED: return "PARAMETERS_CHANGED";
60             case POOL_RELEASED: return "POOL_RELEASED";
61         }
62         return "Invalid";
63     }*/

64
65     public boolean isPoolCheckOut() { return type == CHECKOUT; }
66     public boolean isPoolCheckIn() { return type == CHECKIN; }
67     public boolean isMaxPoolLimitReached() { return type == MAX_POOL_LIMIT_REACHED; }
68     public boolean isMaxPoolLimitExceeded() { return type == MAX_POOL_LIMIT_EXCEEDED; }
69     public boolean isMaxSizeLimitReached() { return type == MAX_SIZE_LIMIT_REACHED; }
70     public boolean isMaxSizeLimitError() { return type == MAX_SIZE_LIMIT_ERROR; }
71     public boolean isPoolParametersChanged() { return type == PARAMETERS_CHANGED; }
72     public boolean isPoolReleased() { return type == POOL_RELEASED; }
73 }
Popular Tags