package net.catpad.infobus.test.test1;

import net.catpad.infobus.CannotExecuteCommQueueItemException;
import net.catpad.infobus.CommQueueItem;
import net.catpad.infobus.ServiceId;
import net.catpad.infobus.ServiceLauncher;


public class PassTo3CommQueueItem extends CommQueueItem {

  public PassTo3CommQueueItem(ServiceLauncher serviceLauncher) {
    super(serviceLauncher);
  }

  @Override
  public void execute(ServiceId serviceId)
      throws CannotExecuteCommQueueItemException, InterruptedException {
    
    System.out.println("In the context of " + serviceId.toString());
    
    Thread.sleep(50);
    
    serviceLauncher.getInfoBus().postItem(InfoBusTest1.SERVICE_1, 
        new PassTo1CommQueueItem(serviceLauncher));
    
    //////////////////////////////////////////////////////////////////////////////////
    // Uncomment the next line to see how the service failover architecture works --->
        //////////////////////////////////////////////////////////////////////////////////
    // throw new NullPointerException();    
  }
}