Package org.jboss.msc.service
Class TimingServiceListener
- java.lang.Object
-
- org.jboss.msc.service.AbstractServiceListener<java.lang.Object>
-
- org.jboss.msc.service.TimingServiceListener
-
- All Implemented Interfaces:
ServiceListener<java.lang.Object>
public final class TimingServiceListener extends AbstractServiceListener<java.lang.Object> implements ServiceListener<java.lang.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.
-
-
Field Summary
Fields Modifier and Type Field Description private intcountprivate static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<TimingServiceListener>countUpdaterprivate longendprivate intfinishedprivate java.lang.RunnablefinishedTaskprivate static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<TimingServiceListener>finishedUpdaterprivate longstartprivate inttotalServicesprivate static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<TimingServiceListener>totalServicesUpdater
-
Constructor Summary
Constructors Constructor Description TimingServiceListener()Construct a new instance.TimingServiceListener(java.lang.Runnable finishedTask)Construct a new instance which calls the given task when the timing is done.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voiddone()voidfinishBatch()Call when all services in this timing group have been added.booleanfinished()Determine whether all services have finished.longgetElapsedTime()Get the elapsed time in milliseconds.intgetRemainingCount()Get the number of remaining services to start.intgetTotalCount()Get the total number of services being tracked.voidlistenerAdded(ServiceController<? extends java.lang.Object> serviceController)The listener has been added to a controller.voidtransition(ServiceController<? extends java.lang.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
-
-
-
-
Field Detail
-
finished
private volatile int finished
-
count
private volatile int count
-
totalServices
private volatile int totalServices
-
start
private final long start
-
end
private volatile long end
-
finishedTask
private final java.lang.Runnable finishedTask
-
finishedUpdater
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<TimingServiceListener> finishedUpdater
-
countUpdater
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<TimingServiceListener> countUpdater
-
totalServicesUpdater
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<TimingServiceListener> totalServicesUpdater
-
-
Constructor Detail
-
TimingServiceListener
public TimingServiceListener()
Construct a new instance.
-
TimingServiceListener
public TimingServiceListener(java.lang.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 java.lang.Object> serviceController)
The listener has been added to a controller.- Specified by:
listenerAddedin interfaceServiceListener<java.lang.Object>- Overrides:
listenerAddedin classAbstractServiceListener<java.lang.Object>- Parameters:
serviceController- the controller that this listener was added to
-
transition
public void transition(ServiceController<? extends java.lang.Object> controller, ServiceController.Transition transition)
Description copied from class:AbstractServiceListenerThe service has transitioned to a new sub-state.- Specified by:
transitionin interfaceServiceListener<java.lang.Object>- Overrides:
transitionin classAbstractServiceListener<java.lang.Object>- Parameters:
controller- the controllertransition- the transition that occurred
-
done
private void done()
-
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:
trueif 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
-
-