19
19
package com .mongodb .util ;
20
20
21
21
import java .util .*;
22
- import java .util .concurrent .*;
22
+ import java .util .concurrent .Semaphore ;
23
+ import java .util .concurrent .TimeUnit ;
23
24
24
- import java .lang .management .*;
25
25
import javax .management .*;
26
26
27
27
public abstract class SimplePool <T > implements DynamicMBean {
@@ -48,6 +48,14 @@ public SimplePool( String name , int maxToKeep , int maxTotal , boolean trackLea
48
48
_maxTotal = maxTotal ;
49
49
_trackLeaks = trackLeaks || TRACK_LEAKS ;
50
50
_debug = debug ;
51
+ _mbeanInfo = new MBeanInfo ( this .getClass ().getName () , _name ,
52
+ new MBeanAttributeInfo []{
53
+ new MBeanAttributeInfo ( "name" , "java.lang.String" , "name of pool" , true , false , false ) ,
54
+ new MBeanAttributeInfo ( "size" , "java.lang.Integer" , "total size of pool" , true , false , false ) ,
55
+ new MBeanAttributeInfo ( "available" , "java.lang.Integer" , "total connections available" , true , false , false ) ,
56
+ new MBeanAttributeInfo ( "inUse" , "java.lang.Integer" , "number connections in use right now" , true , false , false ) ,
57
+ new MBeanAttributeInfo ( "everCreated" , "java.lang.Integer" , "number connections ever created" , true , false , false )
58
+ } , null , null , null );
51
59
52
60
}
53
61
@@ -295,14 +303,7 @@ public AttributeList getAttributes(String[] attributes){
295
303
}
296
304
297
305
public MBeanInfo getMBeanInfo (){
298
- return new MBeanInfo ( this .getClass ().getName () , _name ,
299
- new MBeanAttributeInfo []{
300
- new MBeanAttributeInfo ( "name" , "java.lang.String" , "name of pool" , true , false , false ) ,
301
- new MBeanAttributeInfo ( "size" , "java.lang.Integer" , "total size of pool" , true , false , false ) ,
302
- new MBeanAttributeInfo ( "available" , "java.lang.Integer" , "total connections available" , true , false , false ) ,
303
- new MBeanAttributeInfo ( "inUse" , "java.lang.Integer" , "number connections in use right now" , true , false , false ) ,
304
- new MBeanAttributeInfo ( "everCreated" , "java.lang.Integer" , "numbe connections ever created" , true , false , false )
305
- } , null , null , null );
306
+ return _mbeanInfo ;
306
307
}
307
308
308
309
public Object invoke (String actionName , Object [] params , String [] signature ){
@@ -335,6 +336,7 @@ public String toString(){
335
336
protected final int _maxTotal ;
336
337
protected final boolean _trackLeaks ;
337
338
protected final boolean _debug ;
339
+ protected final MBeanInfo _mbeanInfo ;
338
340
339
341
private final List <T > _avail = new ArrayList <T >();
340
342
protected final List <T > _availSafe = Collections .unmodifiableList ( _avail );
0 commit comments