JBoss Modular Service Kernel API 1.0.0.Beta1

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

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 serviceFailed(ServiceController<? extends Object> serviceController, StartException reason)
          The service start has failed.
 void serviceStarted(ServiceController<? extends Object> serviceController)
          The service is started (up).
 
Methods inherited from class org.jboss.msc.service.AbstractServiceListener
serviceRemoved, serviceStarting, serviceStopped, serviceStopping
 
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
serviceRemoved, serviceStarting, serviceStopped, serviceStopping
 

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

serviceStarted

public void serviceStarted(ServiceController<? extends Object> serviceController)
The service is started (up). Called after the state transitions from STARTING to UP.

Specified by:
serviceStarted in interface ServiceListener<Object>
Overrides:
serviceStarted in class AbstractServiceListener<Object>
Parameters:
serviceController - the controller

serviceFailed

public void serviceFailed(ServiceController<? extends Object> serviceController,
                          StartException reason)
The service start has failed. Called after the state transitions from STARTING to START_FAILED.

Specified by:
serviceFailed in interface ServiceListener<Object>
Overrides:
serviceFailed in class AbstractServiceListener<Object>
Parameters:
serviceController - the controller
reason - the reason for failure

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

JBoss Modular Service Kernel API 1.0.0.Beta1

Copyright © 2010 JBoss, a division of Red Hat, Inc.