org.jboss.util.timeout
Class TimeoutFactory

java.lang.Object
  extended by org.jboss.util.timeout.TimeoutFactory

public class TimeoutFactory
extends Object

The timeout factory.

Version:
$Revision: 1.2.6.9 $
Author:
Ole Husgaard, Dimitris Andreadis, Elias Ross, Adrian Brock

Constructor Summary
TimeoutFactory()
          Constructs a new TimeoutFactory that uses the default thread pool
TimeoutFactory(ThreadPool threadPool)
          Constructs a new TimeoutFactory that uses the provided ThreadPool
 
Method Summary
 void cancel()
          Cancels all submitted tasks, stops the worker thread and clean-ups everything except for the thread pool.
static Timeout createTimeout(long time, TimeoutTarget target)
          Schedules a new timeout using the singleton TimeoutFactory
static TimeoutFactory getSingleton()
          Lazy constructions of the TimeoutFactory singleton
 boolean isCancelled()
          Returns true if the TimeoutFactory has been cancelled, false if it is operational (i.e.
 Timeout schedule(long time, Runnable run)
          Schedules a new timeout.
 Timeout schedule(long time, TimeoutTarget target)
          Schedules a new timeout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeoutFactory

public TimeoutFactory(ThreadPool threadPool)
Constructs a new TimeoutFactory that uses the provided ThreadPool


TimeoutFactory

public TimeoutFactory()
Constructs a new TimeoutFactory that uses the default thread pool

Method Detail

getSingleton

public static TimeoutFactory getSingleton()
Lazy constructions of the TimeoutFactory singleton


createTimeout

public static Timeout createTimeout(long time,
                                    TimeoutTarget target)
Schedules a new timeout using the singleton TimeoutFactory


schedule

public Timeout schedule(long time,
                        TimeoutTarget target)
Schedules a new timeout.

Parameters:
time - absolute time
target - target to fire

schedule

public Timeout schedule(long time,
                        Runnable run)
Schedules a new timeout.

Parameters:
time - absolute time
run - runnable to run

cancel

public void cancel()
Cancels all submitted tasks, stops the worker thread and clean-ups everything except for the thread pool. Scheduling new timeouts after cancel is called results in a IllegalStateException.


isCancelled

public boolean isCancelled()
Returns true if the TimeoutFactory has been cancelled, false if it is operational (i.e. accepts timeout schedules).



Copyright © 2002 JBoss Group, LLC. All Rights Reserved.