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 int
count
private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<TimingServiceListener>
countUpdater
private long
end
private int
finished
private java.lang.Runnable
finishedTask
private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<TimingServiceListener>
finishedUpdater
private long
start
private int
totalServices
private 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 void
done()
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 java.lang.Object> serviceController)
The listener has been added to a controller.void
transition(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:
listenerAdded
in interfaceServiceListener<java.lang.Object>
- Overrides:
listenerAdded
in 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:AbstractServiceListener
The service has transitioned to a new sub-state.- Specified by:
transition
in interfaceServiceListener<java.lang.Object>
- Overrides:
transition
in 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:
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
-
-