@Test public void execute() throws Exception { put("testing.*=other"); Map<String, String> conf = createConf(); declare(conf, "default", FailCommandScriptHandler.class); declare(conf, "other", FailCommandScriptHandler.class); CommandScriptHandlerDispatcher dispatcher = create(conf); CommandScript script = script("stage"); ExecutionContext something = context("something", ExecutionPhase.MAIN); try { dispatcher.execute(ExecutionMonitor.NULL, something, script); fail(); } catch (MessageException e) { assertThat(e.message, is("default")); assertThat(e.context.getPhase(), is(ExecutionPhase.MAIN)); } ExecutionContext testing = context("testing"); try { dispatcher.execute(ExecutionMonitor.NULL, testing, script); fail(); } catch (MessageException e) { assertThat(e.message, is("other")); assertThat(e.context.getPhase(), is(ExecutionPhase.MAIN)); } }
@Override public void execute( ExecutionMonitor monitor, ExecutionContext context, T script) throws InterruptedException, IOException { ExecutionScriptHandler<T> target = resolve(context, script); assert target != null; YSLOG.info("I01002", target.getHandlerId(), context.getBatchId(), context.getFlowId(), context.getPhase(), context.getExecutionId(), script.getId()); target.execute(monitor, context, script); }
ExecutionScriptHandlerDispatcher implements ExecutionScriptHandler<T> { @Override public void execute( ExecutionMonitor monitor, ExecutionContext context, T script) throws InterruptedException, IOException { ExecutionScriptHandler<T> target = resolve(context, script); assert target != null; YSLOG.info("I01002", target.getHandlerId(), context.getBatchId(), context.getFlowId(), context.getPhase(), context.getExecutionId(), script.getId()); target.execute(monitor, context, script); } }
ExecutionScriptHandlerDispatcher implements ExecutionScriptHandler<T> { @Override public void execute( ExecutionMonitor monitor, ExecutionContext context, T script) throws InterruptedException, IOException { ExecutionScriptHandler<T> target = resolve(context, script); assert target != null; YSLOG.info("I01002", target.getHandlerId(), context.getBatchId(), context.getFlowId(), context.getPhase(), context.getExecutionId(), script.getId()); target.execute(monitor, context, script); } protected  ExecutionScriptHandlerDispatcher(Class<? extends ExecutionScriptHandler<T>> handlerKind); }
ExecutionScriptHandlerDispatcher implements ExecutionScriptHandler<T> { @Override public void execute( ExecutionMonitor monitor, ExecutionContext context, T script) throws InterruptedException, IOException { ExecutionScriptHandler<T> target = resolve(context, script); assert target != null; YSLOG.info("I01002", target.getHandlerId(), context.getBatchId(), context.getFlowId(), context.getPhase(), context.getExecutionId(), script.getId()); target.execute(monitor, context, script); } protected  ExecutionScriptHandlerDispatcher(Class<? extends ExecutionScriptHandler<T>> handlerKind); @Override void configure(ServiceProfile<?> profile); @Override String getHandlerId(); @Override String getResourceId(
            ExecutionContext context,
            ExecutionScript script); @Override Map<String, String> getProperties(
            ExecutionContext context,
            ExecutionScript script); @Override Map<String, String> getEnvironmentVariables(
            ExecutionContext context,
            ExecutionScript script); @Override void setUp(ExecutionMonitor monitor, ExecutionContext context); @Override void execute(
            ExecutionMonitor monitor,
            ExecutionContext context,
            T script); @Override void cleanUp(ExecutionMonitor monitor, ExecutionContext context); }
ExecutionScriptHandlerDispatcher implements ExecutionScriptHandler<T> { @Override public void execute( ExecutionMonitor monitor, ExecutionContext context, T script) throws InterruptedException, IOException { ExecutionScriptHandler<T> target = resolve(context, script); assert target != null; YSLOG.info("I01002", target.getHandlerId(), context.getBatchId(), context.getFlowId(), context.getPhase(), context.getExecutionId(), script.getId()); target.execute(monitor, context, script); } protected  ExecutionScriptHandlerDispatcher(Class<? extends ExecutionScriptHandler<T>> handlerKind); @Override void configure(ServiceProfile<?> profile); @Override String getHandlerId(); @Override String getResourceId(
            ExecutionContext context,
            ExecutionScript script); @Override Map<String, String> getProperties(
            ExecutionContext context,
            ExecutionScript script); @Override Map<String, String> getEnvironmentVariables(
            ExecutionContext context,
            ExecutionScript script); @Override void setUp(ExecutionMonitor monitor, ExecutionContext context); @Override void execute(
            ExecutionMonitor monitor,
            ExecutionContext context,
            T script); @Override void cleanUp(ExecutionMonitor monitor, ExecutionContext context);  }