Methods Summary |
---|
protected boolean | canCreate()Since this method would be called only if the pool is empty
return (isBounded == null) ? true : (createdCount < maxLimit);
|
protected java.lang.Object | checkin(java.lang.Object object)Notification when an object is put back into the pool (checkin).
int size = list.size();
long now = _clock.getTime();
if (size < maxStrongRefs) {
list.addAsLastNode(new TimeStampedSoftDListNode(object, now, object));
} else {
list.addAsLastNode(new TimeStampedSoftDListNode(new SoftReference(object), now, null));
}
return this;
|
protected java.lang.Object | checkout(java.lang.Object param)Notification when an object is given out from the pool (checout).
return obtainObject(param);
|
public void | epilog()
|
public boolean | getExecuteIfMissed()Determine to execute the service method of this object even if it has
missed the right schedule.
return true;
|
public boolean | getExecutionTolerance(long missedByMillis)Determine to execute the service method of this object when the
schedule is delayed by 'missedByMillis' milli seconds.
return true;
|
public long | getFrequency()Get the frequency (time interval) at which service() method will be invoked.
return this.maxIdleTime;
|
public int | getMaxLimit()
return this.maxLimit;
|
private void | initPool()
list = new DList();
super.collection = list;
super.preload((minSize < initialSize) ? initialSize : minSize);
scheduler.addTimeRepeatableTask(this, (int) maxIdleTime);
|
private java.lang.Object | obtainObject(java.lang.Object param)
SoftReference ref;
Object object = null;
int notifyCount = 0;
for (int size = list.size(); size > 0; size--) {
TimeStampedSoftDListNode tsNode = (TimeStampedSoftDListNode) list.getDListNodeAt(0);
list.delink(tsNode);
if (tsNode.isSoftRef == null) {
ref = (SoftReference) tsNode.object;
if ((object = ref.get()) != null) {
break;
} else {
notifyCount++;
}
} else {
object = tsNode.object;
break;
}
}
if (object == null) {
try {
object = factory.create(param);
afterCreate(object);
} catch (PoolException poolEx) {
}
}
super.createdCount -= notifyCount;
if (notifyCount == 1) {
super.collection.notify();
} else if (notifyCount > 1) {
super.collection.notifyAll();
}
return object;
|
public void | prolog()
|
public void | service()
int killedCount = 0;
long now = _clock.getTime();
long allowed = now - maxIdleTime;
TimeStampedSoftDListNode tsNode = null;
FastStack stack = new FastStack();
synchronized (super.collection) {
Object done = null;
while (done == null) {
tsNode = (TimeStampedSoftDListNode) list.getFirstDListNode();
if (tsNode == null) { //Empty list
done = new Object();
} else if (tsNode.timeStamp <= allowed) {
//Need to destroy the contained object
list.delink(tsNode);
stack.push(tsNode.object);
killedCount++;
} else {
//This node is not old enough
done = new Object();
}
} //End of for loop
super.createdCount -= killedCount;
int deficit = list.size() - minSize;
super.preload(0 - deficit);
if (killedCount == 0) {
} else if (killedCount == 1) {
collection.notify();
} else {
collection.notifyAll();
}
} // end of synchronized
//Now destroy all collected objects
while (! stack.isEmpty()) {
Object object = stack.pop();
beforeDestroy(object);
factory.destroy(object);
}
//Bug 4677074 System.out.println("Leaving service after killing " + killedCount + " (idle) objects. Now size: " + list.size());
//Bug 4677074 begin
_logger.log(Level.FINE,"Leaving service after killing " + killedCount + " (idle) objects. Now size: " + list.size());
//Bug 4677074 end
|
public void | setMaxLimit(int limit)
if ((limit <= 0) || (limit >= Integer.MAX_VALUE-1)) {
this.isBounded = null;
} else {
this.isBounded = Boolean.valueOf(true);
this.maxLimit = limit;
}
|
public java.lang.String | toString()Print an identification for the object.
return "";
|