net.sf.infrared.agent.transport
Class PeriodicFlushPolicy

java.lang.Object
  extended bynet.sf.infrared.agent.transport.PeriodicFlushPolicy
All Implemented Interfaces:
FlushPolicy

public class PeriodicFlushPolicy
extends Object
implements FlushPolicy

A FlushPolicy implementation that runs a background thread to keep flushing the Aggregator at a configurable frequency.


Field Summary
static long DEFAULT_FREQUENCY
           
 
Constructor Summary
PeriodicFlushPolicy()
           
 
Method Summary
 boolean activate()
          Activates this FlushPolicy.
protected  void finalize()
           
 Aggregator getAggregator()
          Gets the Aggregator object that has been associated with this policy.
 long getFrequency()
          Gets the frequency in which this policy is set to flush the associated aggregator.
 boolean isActive()
          Checks if this policy is active.
 void setAggregator(Aggregator aggregator)
          Sets the Aggregator object to be used.
 void setFrequency(long time)
          Sets the frequency in which this polciy should flush the aggregator.
 boolean shutDown()
          Shuts down this FlushPolicy.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FREQUENCY

public static final long DEFAULT_FREQUENCY
See Also:
Constant Field Values
Constructor Detail

PeriodicFlushPolicy

public PeriodicFlushPolicy()
Method Detail

activate

public boolean activate()
Activates this FlushPolicy. Starts a background thread which does the periodic flushes. When this method returns it can be gaurenteed that the background thread has actually started running. Calling activate on an already active policy is ignored and the method returns false. Note: A non-null Aggregator should be set before calling this method.

Specified by:
activate in interface FlushPolicy
Returns:
true if the policy has been activated, else false.
See Also:
setAggregator(net.sf.infrared.agent.transport.Aggregator)

shutDown

public boolean shutDown()
Shuts down this FlushPolicy. If this policy had been active, calling this method initiates shutdown of the background thread, and returns true. If this policy has not been active, calling this method has no effect and returns false.

Specified by:
shutDown in interface FlushPolicy
Returns:
true if the policy had been shutdown, else false

setAggregator

public void setAggregator(Aggregator aggregator)
Sets the Aggregator object to be used. When this policy is active, the flush method of this Aggregator will be called at the specified frequency.

Specified by:
setAggregator in interface FlushPolicy
Parameters:
aggregator -
See Also:
getAggregator()

getAggregator

public Aggregator getAggregator()
Gets the Aggregator object that has been associated with this policy. For a newly created policy, this method returns null.

Returns:
aggregator
See Also:
setAggregator(net.sf.infrared.agent.transport.Aggregator)

isActive

public boolean isActive()
Checks if this policy is active. A policy, when created, is inactive. An inactive ploicy can be actiavted by calling the activate method. An active policy can be inactivated by calling the shutDown method.

Specified by:
isActive in interface FlushPolicy
Returns:
true if the policy is active, else false.
See Also:
activate(), shutDown()

setFrequency

public void setFrequency(long time)
Sets the frequency in which this polciy should flush the aggregator.

Parameters:
time - the frequency in milliseconds

getFrequency

public long getFrequency()
Gets the frequency in which this policy is set to flush the associated aggregator. A newly created policy will return the public constant specified by DEFAULT_FREQUENCY.

Returns:

finalize

protected void finalize()
                 throws Throwable
Throws:
Throwable