org.ros.node.service
Class CountDownServiceServerListener<T,S>

java.lang.Object
  extended by org.ros.internal.node.CountDownRegistrantListener<ServiceServer<T,S>>
      extended by org.ros.node.service.CountDownServiceServerListener<T,S>
All Implemented Interfaces:
RegistrantListener<ServiceServer<T,S>>, ServiceServerListener<T,S>

public class CountDownServiceServerListener<T,S>
extends CountDownRegistrantListener<ServiceServer<T,S>>
implements ServiceServerListener<T,S>

A ServiceServerListener which uses CountDownLatch to track message invocations.


Method Summary
 void awaitShutdown()
          Wait for shutdown.
 boolean awaitShutdown(long timeout, java.util.concurrent.TimeUnit unit)
          Wait for shutdown within the given time period.
static
<T,S> CountDownServiceServerListener<T,S>
newDefault()
          Construct a CountDownServiceServerListener with all counts set to 1.
static
<T,S> CountDownServiceServerListener<T,S>
newFromCounts(int masterRegistrationSuccessCount, int masterRegistrationFailureCount, int masterUnregistrationSuccessCount, int masterUnregistrationFailureCount)
           
 void onShutdown(ServiceServer<T,S> server)
           
 
Methods inherited from class org.ros.internal.node.CountDownRegistrantListener
awaitMasterRegistrationFailure, awaitMasterRegistrationFailure, awaitMasterRegistrationSuccess, awaitMasterRegistrationSuccess, awaitMasterUnregistrationFailure, awaitMasterUnregistrationFailure, awaitMasterUnregistrationSuccess, awaitMasterUnregistrationSuccess, onMasterRegistrationFailure, onMasterRegistrationSuccess, onMasterUnregistrationFailure, onMasterUnregistrationSuccess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ros.internal.node.RegistrantListener
onMasterRegistrationFailure, onMasterRegistrationSuccess, onMasterUnregistrationFailure, onMasterUnregistrationSuccess
 

Method Detail

newDefault

public static <T,S> CountDownServiceServerListener<T,S> newDefault()
Construct a CountDownServiceServerListener with all counts set to 1.


newFromCounts

public static <T,S> CountDownServiceServerListener<T,S> newFromCounts(int masterRegistrationSuccessCount,
                                                                      int masterRegistrationFailureCount,
                                                                      int masterUnregistrationSuccessCount,
                                                                      int masterUnregistrationFailureCount)
Parameters:
masterRegistrationSuccessCount - the number of successful master registrations to wait for
masterRegistrationFailureCount - the number of failing master registrations to wait for
masterUnregistrationSuccessCount - the number of successful master unregistrations to wait for
masterUnregistrationFailureCount - the number of failing master unregistrations to wait for

onShutdown

public void onShutdown(ServiceServer<T,S> server)
Specified by:
onShutdown in interface ServiceServerListener<T,S>
Parameters:
server - the ServiceServer which has been shut down

awaitShutdown

public void awaitShutdown()
                   throws java.lang.InterruptedException
Wait for shutdown.

Throws:
java.lang.InterruptedException

awaitShutdown

public boolean awaitShutdown(long timeout,
                             java.util.concurrent.TimeUnit unit)
                      throws java.lang.InterruptedException
Wait for shutdown within the given time period.

Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument
Returns:
true if shutdown happened within the time period, false otherwise
Throws:
java.lang.InterruptedException