Trull

edu.luc.cs.trull
Class ComponentSchedulerAdapter

java.lang.Object
  extended by edu.luc.cs.trull.ComponentSchedulerAdapter
All Implemented Interfaces:
ComponentScheduler, Scheduler

public class ComponentSchedulerAdapter
extends java.lang.Object
implements ComponentScheduler

An adapter for using any Scheduler as a ComponentScheduler.

See Also:
ComponentScheduler, Scheduler

Field Summary
private static org.apache.log4j.Logger logger
           
private  Scheduler scheduler
          The original scheduler instance.
 
Constructor Summary
ComponentSchedulerAdapter(Scheduler scheduler)
           
 
Method Summary
 void await()
          This method waits for the runner to finish processing all pending requests.
 void execute(java.lang.Runnable r)
          This method executes a Runnable and waits for its completion.
 void propertyChange(Component c, java.beans.PropertyChangeEvent event)
          This method sends an event to the component and waits until the component has processed the event.
 void resume(Component c)
          This method resumes a component and waits until the component has resumed.
 void schedule(java.lang.Runnable r)
          This method schedules a Runnable for later execution.
 void start(Component c)
          This method starts a component and waits until the component is ready.
 void start(Component c, java.beans.PropertyChangeEvent event)
          This method starts a component with the given event and waits until the component is ready.
 void stop(Component c)
          This method stops a component and waits until the component has stopped.
 void suspend(Component c)
          This method suspends a component and waits until the component has suspended.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.apache.log4j.Logger logger

scheduler

private Scheduler scheduler
The original scheduler instance.

Constructor Detail

ComponentSchedulerAdapter

public ComponentSchedulerAdapter(Scheduler scheduler)
Method Detail

await

public void await()
           throws java.lang.InterruptedException
Description copied from interface: ComponentScheduler
This method waits for the runner to finish processing all pending requests. This capability is important for avoiding race conditions.

Specified by:
await in interface ComponentScheduler
Specified by:
await in interface Scheduler
Throws:
java.lang.InterruptedException - if the current thread is interrupted before or while waiting.

execute

public void execute(java.lang.Runnable r)
             throws java.lang.InterruptedException
Description copied from interface: Scheduler
This method executes a Runnable and waits for its completion.

Specified by:
execute in interface Scheduler
Parameters:
r - the Runnable to be executed.
Throws:
java.lang.InterruptedException - if the current thread is interrupted while waiting.

propertyChange

public void propertyChange(Component c,
                           java.beans.PropertyChangeEvent event)
                    throws java.lang.InterruptedException
Description copied from interface: ComponentScheduler
This method sends an event to the component and waits until the component has processed the event.

Specified by:
propertyChange in interface ComponentScheduler
Parameters:
c - the component that will receive the event.
event - the event sent to the component.
Throws:
java.lang.InterruptedException

resume

public void resume(Component c)
            throws java.lang.InterruptedException
Description copied from interface: ComponentScheduler
This method resumes a component and waits until the component has resumed.

Specified by:
resume in interface ComponentScheduler
Parameters:
c - the component to be resumed.
Throws:
java.lang.InterruptedException

schedule

public void schedule(java.lang.Runnable r)
Description copied from interface: Scheduler
This method schedules a Runnable for later execution.

Specified by:
schedule in interface Scheduler
Parameters:
r - the Runnable to be scheduled.

start

public void start(Component c)
           throws java.lang.InterruptedException
Description copied from interface: ComponentScheduler
This method starts a component and waits until the component is ready.

Specified by:
start in interface ComponentScheduler
Parameters:
c - the component to be started.
Throws:
java.lang.InterruptedException

start

public void start(Component c,
                  java.beans.PropertyChangeEvent event)
           throws java.lang.InterruptedException
Description copied from interface: ComponentScheduler
This method starts a component with the given event and waits until the component is ready.

Specified by:
start in interface ComponentScheduler
Parameters:
c - the component to be started.
event - the event to be sent to the component.
Throws:
java.lang.InterruptedException

stop

public void stop(Component c)
          throws java.lang.InterruptedException
Description copied from interface: ComponentScheduler
This method stops a component and waits until the component has stopped.

Specified by:
stop in interface ComponentScheduler
Parameters:
c - the component to be stopped.
Throws:
java.lang.InterruptedException

suspend

public void suspend(Component c)
             throws java.lang.InterruptedException
Description copied from interface: ComponentScheduler
This method suspends a component and waits until the component has suspended.

Specified by:
suspend in interface ComponentScheduler
Parameters:
c - the component to be suspended.
Throws:
java.lang.InterruptedException

Trull

http://www.cs.luc.edu/trull/