public class TestComponentListener extends java.lang.Object implements IManagedUpdateableListener, IVizUpdateableListener
This class realizes the IComponentListener interface and is used to test Component call backs in tests. It has a unlisted, volatile attribute called serviceLatch that is a CountDownLatch. It is instantiated in reset and constructor. This is used to utilize threads more effectively by waiting for a thread to be free in order to notify if a component was changed. The update operation calls countDown on the latch.
component
Constructor and Description |
---|
TestComponentListener()
The Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<SubscriptionType> |
getSubscriptions(IManagedUpdateable source)
Polls the listener for a list of the types of events it wants to receive
from the given source.
|
void |
reset()
This operation resets the countdownlatch to 0.
|
void |
update(IManagedUpdateable component,
SubscriptionType[] type)
Receive an update, including the source component and type of event that
triggered the update.
|
void |
update(IVizUpdateable component)
(non-Javadoc)
|
boolean |
wasNotified()
This operation returns the notification state of the listener.
|
public TestComponentListener()
The Constructor. Sets up the CountDownLatch to one.
public boolean wasNotified()
This operation returns the notification state of the listener.
True if the listener has been notified of an update, false otherwise.
public void reset()
This operation resets the countdownlatch to 0.
public void update(IVizUpdateable component)
update
in interface IVizUpdateableListener
component
- The component that was updated in some way.IUpdateableListener#update(IUpdateable component)
public java.util.ArrayList<SubscriptionType> getSubscriptions(IManagedUpdateable source)
IManagedUpdateableListener
getSubscriptions
in interface IManagedUpdateableListener
source
- The object which this listener will listen topublic void update(IManagedUpdateable component, SubscriptionType[] type)
IManagedUpdateableListener
update
in interface IManagedUpdateableListener
component
- The updateable component the update is coming fromtype
- The event type that of the update