org.jboss.msc.service
Class TimingServiceListener

java.lang.Object
  extended by org.jboss.msc.service.AbstractServiceListener<Object>
      extended by org.jboss.msc.service.TimingServiceListener
All Implemented Interfaces:
ServiceListener<Object>

public final class TimingServiceListener
extends AbstractServiceListener<Object>
implements ServiceListener<Object>

A service listener which times service start. The timing starts from the moment the listener is created and ends when the last service is batched and the services are all started.

Author:
David M. Lloyd

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.msc.service.ServiceListener
ServiceListener.Inheritance
 
Constructor Summary
TimingServiceListener()
          Construct a new instance.
TimingServiceListener(Runnable finishedTask)
          Construct a new instance which calls the given task when the timing is done.
 
Method Summary
 void finishBatch()
          Call when all services in this timing group have been added.
 boolean finished()
          Determine whether all services have finished.
 long getElapsedTime()
          Get the elapsed time in milliseconds.
 int getRemainingCount()
          Get the number of remaining services to start.
 int getTotalCount()
          Get the total number of services being tracked.
 void listenerAdded(ServiceController<? extends Object> serviceController)
          The listener has been added to a controller.
 void transition(ServiceController<? extends Object> controller, ServiceController.Transition transition)
          The service has transitioned to a new sub-state.
 
Methods inherited from class org.jboss.msc.service.AbstractServiceListener
dependencyFailed, dependencyFailureCleared, immediateDependencyAvailable, immediateDependencyUnavailable, serviceRemoveRequestCleared, serviceRemoveRequested, transitiveDependencyAvailable, transitiveDependencyUnavailable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.msc.service.ServiceListener
dependencyFailed, dependencyFailureCleared, immediateDependencyAvailable, immediateDependencyUnavailable, serviceRemoveRequestCleared, serviceRemoveRequested, transitiveDependencyAvailable, transitiveDependencyUnavailable
 

Constructor Detail

TimingServiceListener

public TimingServiceListener()
Construct a new instance.


TimingServiceListener

public TimingServiceListener(Runnable finishedTask)
Construct a new instance which calls the given task when the timing is done.

Parameters:
finishedTask - the finish task
Method Detail

listenerAdded

public void listenerAdded(ServiceController<? extends Object> serviceController)
The listener has been added to a controller.

Specified by:
listenerAdded in interface ServiceListener<Object>
Overrides:
listenerAdded in class AbstractServiceListener<Object>
Parameters:
serviceController - the controller that this listener was added to

transition

public void transition(ServiceController<? extends Object> controller,
                       ServiceController.Transition transition)
Description copied from class: AbstractServiceListener
The service has transitioned to a new sub-state.

Specified by:
transition in interface ServiceListener<Object>
Overrides:
transition in class AbstractServiceListener<Object>
Parameters:
controller - the controller
transition - the transition that occurred

finishBatch

public void finishBatch()
Call when all services in this timing group have been added.


finished

public boolean finished()
Determine whether all services have finished.

Returns:
true if all services have finished

getRemainingCount

public int getRemainingCount()
Get the number of remaining services to start.

Returns:
the remaining count

getTotalCount

public int getTotalCount()
Get the total number of services being tracked.

Returns:
the total count

getElapsedTime

public long getElapsedTime()
Get the elapsed time in milliseconds.

Returns:
the elapsed time, or -1 if not finished yet


Copyright © 2011. All Rights Reserved.