/**
* Periodically check the idle object count for the pool. At most one idle object will be added per period. If there is an exception when calling {@link ObjectPool#addObject()} then no more checks will be performed.
* @param pool the pool to check periodically.
* @param minIdle if the {@link ObjectPool#getNumIdle()} is less than this then add an idle object.
* @param period the frequency to check the number of idle objects in a pool, see{@link Timer#schedule(TimerTask,long,long)}.
* @return the {@link TimerTask} that will periodically check the pools idle object count.
* @throws IllegalArgumentException when <code>pool</code> is <code>null</code> orwhen <code>minIdle</code> is negative or when <code>period</code> isn't valid for {@link Timer#schedule(TimerTask,long,long)}.
* @since Pool 1.3
*/
public static TimerTask checkMinIdle(final ObjectPool pool,final int minIdle,final long period) throws IllegalArgumentException {
if (pool == null) {
throw new IllegalArgumentException("keyedPool must not be null.");
}
if (minIdle < 0) {
throw new IllegalArgumentException("minIdle must be non-negative.");
}
final TimerTask task=new ObjectPoolMinIdleTimerTask(pool,minIdle);
getMinIdleTimer().schedule(task,0L,period);
return task;
}

Example 5

From project harmony, under directory /harmony.adapter.uclp/src/main/java/org/opennaas/extensions/idb/da/argia/webservice/.

/**
* Schedules the rotate task using either a fixed time interval scheme or a relative time interval scheme as specified by the chukwaCollector.isFixedTimeRotatorScheme configuration parameter. If the value of this parameter is true then next rotation will be scheduled at a fixed offset from the current rotateInterval. This fixed offset is provided by chukwaCollector.fixedTimeIntervalOffset configuration parameter.
*/
void scheduleNextRotation(){
long delay=rotateInterval;
if (if_fixed_interval) {
long currentTime=System.currentTimeMillis();
delay=getDelayForFixedInterval(currentTime,rotateInterval,offsetInterval);
}
rotateTimer=new Timer();
rotateTimer.schedule(new TimerTask(){
public void run(){
rotate();
}
}
,delay);
}

Example 24

From project CIShell, under directory /clients/remoting/org.cishell.reference.remoting/src/org/cishell/reference/remoting/.