org.apache.commons.pool
Class Waiter

java.lang.Object
  extended by org.apache.commons.pool.Waiter

public class Waiter
extends Object

Object created by WaiterFactory. Maintains active / valid state, last passivated and idle times. Waits with configurable latency when doWait() method is called.

This class is *not* threadsafe.


Constructor Summary
Waiter(boolean active, boolean valid, long latency)
           
 
Method Summary
 void doWait()
          Wait for getLatency() ms.
 long getLastIdleTimeMs()
          Returns the last idle time for this instance in ms.
 long getLastPassivated()
          Returns the system time of this instance's last passivation.
 long getLatency()
           
 boolean isActive()
          Whether or not the instance is active.
 boolean isValid()
           
 void setActive(boolean active)
          Sets the active state and updates lastIdleTime or lastPassivated as appropriate.
 void setLatency(long latency)
           
 void setValid(boolean valid)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Waiter

public Waiter(boolean active,
              boolean valid,
              long latency)
Method Detail

doWait

public void doWait()
Wait for getLatency() ms.


isActive

public boolean isActive()
Whether or not the instance is active.

Returns:
true if the last lifecycle event for this instance was activation.

setActive

public void setActive(boolean active)

Sets the active state and updates lastIdleTime or lastPassivated as appropriate.

If the active state is changing from inactive to active, lastIdleTime is updated with the current time minus lastPassivated. If the state is changing from active to inactive, lastPassivated is updated with the current time.

WaiterFactory.activateObject(Object) and WaiterFactory.passivateObject(Object) invoke this method on their actual parameter, passing true and false, respectively.

Parameters:
active - new active state

getLatency

public long getLatency()

setLatency

public void setLatency(long latency)

isValid

public boolean isValid()

setValid

public void setValid(boolean valid)

getLastPassivated

public long getLastPassivated()

Returns the system time of this instance's last passivation.

When an instance is created, this field is initialized to the system time.

Returns:
time of last passivation

getLastIdleTimeMs

public long getLastIdleTimeMs()

Returns the last idle time for this instance in ms.

When an instance is created, and each subsequent time it is passivated, the lastPassivated property is updated with the current time. When the next activation occurs, lastIdleTime is updated with the elapsed time since passivation.

Returns:
last idle time


Copyright © 2001-2014 The Apache Software Foundation. All Rights Reserved.