/** * Create a service sequence with the given list of services * @param name service name * @param children initial sequence */ public WorkflowSequenceService(String name, Service... children) { super(name); for (Service service : children) { addService(service); } } /** * Create a service sequence with the given list of services
if (isInState(STATE.STARTED)) { Exception e = (failureCause instanceof Exception) ? (Exception) failureCause : new Exception(failureCause); noteFailure(e); stop(); started = startNextService(); } catch (Exception e) { noteFailure(e); started = false; stop();
/** * When started * @throws Exception */ @Override protected void serviceStart() throws Exception { if (!startNextService() && stopIfNoChildServicesAtStartup) { //nothing to start -so stop stop(); } }
if (isInState(STATE.STOPPED)) { if (!isInState(STATE.STARTED)) { head.init(getConfig()); head.registerServiceListener(this); head.start(); } catch (RuntimeException e) { noteFailure(e); throw e;
public WorkflowSequenceService buildService(Service... services) { WorkflowSequenceService parent = new WorkflowSequenceService("test", services); parent.init(new Configuration()); return parent; }
@Test public void testSequence() throws Throwable { MockService one = new MockService("one", false, 100); MockService two = new MockService("two", false, 100); ServiceParent parent = startService(one, two); waitForParentToStop(parent); assertStopped(one); assertStopped(two); assert ((WorkflowSequenceService) parent).getPreviousService().equals(two); }
@Test public void testVarargsConstructor() throws Throwable { MockService one = new MockService("one", false, 100); MockService two = new MockService("two", false, 100); ServiceParent parent = new WorkflowSequenceService("test", one, two); parent.init(new Configuration()); parent.start(); waitForParentToStop(parent); assertStopped(one); assertStopped(two); }
/** * State change event relays service stop events to * {@link #onServiceCompleted(Service)}. Subclasses can * extend that with extra logic * @param service the service that has changed. */ @Override public void stateChanged(Service service) { // only react to the state change when it is the current service // and it has entered the STOPPED state if (service == activeService && service.isInState(STATE.STOPPED)) { onServiceCompleted(service); } }
if (isInState(STATE.STOPPED)) { if (!isInState(STATE.STARTED)) { head.init(getConfig()); head.registerServiceListener(this); head.start(); } catch (RuntimeException e) { noteFailure(e); throw e;
public WorkflowSequenceService buildService(Service... services) { WorkflowSequenceService parent = new WorkflowSequenceService("test", services); parent.init(new Configuration()); return parent; }
/** * When started * @throws Exception */ @Override protected void serviceStart() throws Exception { if (!startNextService() && stopIfNoChildServicesAtStartup) { //nothing to start -so stop stop(); } }
@Test public void testSequence() throws Throwable { MockService one = new MockService("one", false, 100); MockService two = new MockService("two", false, 100); ServiceParent parent = startService(one, two); waitForParentToStop(parent); assertStopped(one); assertStopped(two); assert ((WorkflowSequenceService) parent).getPreviousService().equals(two); }
@Test public void testVarargsConstructor() throws Throwable { MockService one = new MockService("one", false, 100); MockService two = new MockService("two", false, 100); ServiceParent parent = new WorkflowSequenceService("test", one, two); parent.init(new Configuration()); parent.start(); waitForParentToStop(parent); assertStopped(one); assertStopped(two); }
/** * State change event relays service stop events to * {@link #onServiceCompleted(Service)}. Subclasses can * extend that with extra logic * @param service the service that has changed. */ @Override public void stateChanged(Service service) { // only react to the state change when it is the current service // and it has entered the STOPPED state if (service == activeService && service.isInState(STATE.STOPPED)) { onServiceCompleted(service); } }
if (isInState(STATE.STARTED)) { Exception e = (failureCause instanceof Exception) ? (Exception) failureCause : new Exception(failureCause); noteFailure(e); stop(); started = startNextService(); } catch (Exception e) { noteFailure(e); started = false; stop();
@Test public void testFailingSequence() throws Throwable { MockService one = new MockService("one", true, 100); MockService two = new MockService("two", false, 100); WorkflowSequenceService parent = (WorkflowSequenceService) startService(one, two); waitForParentToStop(parent); assertStopped(one); assertInState(two, Service.STATE.NOTINITED); assertEquals(one, parent.getPreviousService()); }
/** * Create a service sequence with the given list of services * @param name service name * @param children initial sequence */ public WorkflowSequenceService(String name, Service... children) { super(name); for (Service service : children) { addService(service); } } /** * Create a service sequence with the given list of services
@Test public void testFailingSequence() throws Throwable { MockService one = new MockService("one", true, 100); MockService two = new MockService("two", false, 100); WorkflowSequenceService parent = (WorkflowSequenceService) startService(one, two); waitForParentToStop(parent); assertStopped(one); assertInState(two, Service.STATE.NOTINITED); assertEquals(one, parent.getPreviousService()); }
} /** * Create a service sequence with the given list of services * @param name service name * @param children initial sequence */ public WorkflowSequenceService(String name, List<Service> children) { super(name); for (Service service : children) { addService(service); } }
} /** * Create a service sequence with the given list of services * @param name service name * @param children initial sequence */ public WorkflowSequenceService(String name, List<Service> children) { super(name); for (Service service : children) { addService(service); } }