UimaAsExecutionEngine implements TaskExecutionEngine { @Override public String run(Task aConfiguration) throws ExecutionException, LifeCycleException { if (!(aConfiguration instanceof UimaTask)) { throw new ExecutionException("This engine can only execute [" + UimaTask.class.getName() + "]"); } configuration = (UimaTask) aConfiguration; ctx = contextFactory.createContext(aConfiguration); try { ResourceManager resMgr = newDefaultResourceManager(); AnalysisEngineDescription analysisDesc = configuration .getAnalysisEngineDescription(ctx); analysisDesc.resolveImports(resMgr); bindResource(analysisDesc, TaskContext.class, TaskContextProvider.class, TaskContextProvider.PARAM_FACTORY_NAME, contextFactory.getId(), TaskContextProvider.PARAM_CONTEXT_ID, ctx.getId()); ctx.message("Bound external resources"); ctx.getLifeCycleManager().initialize(ctx, aConfiguration); initializeService(); initializeClient(); ctx.getLifeCycleManager().begin(ctx, aConfiguration); process(); ctx.getLifeCycleManager().complete(ctx, aConfiguration); return ctx.getId(); } catch (LifeCycleException e) { ctx.getLifeCycleManager().fail(ctx, aConfiguration, e); throw e; } catch (Exception e) { ctx.getLifeCycleManager().fail(ctx, aConfiguration, e); throw new ExecutionException(e); } finally { destroy(); } }  @Override String run(Task aConfiguration); @Override void setContextFactory(TaskContextFactory aContextFactory); @Override TaskContextFactory getContextFactory();  }
@Test public void testInit() throws Exception { File repo = new File("target/repository"); FileUtils.deleteQuietly(repo); ((FileSystemStorageService) storageService).setStorageRoot(repo); assertNotNull(executionService); assertNotNull(contextFactory); AnalysisEngineDescription desc = createEngineDescription(DummyAE.class); DefaultUimaTask cfg = new DefaultUimaTask(); cfg.setReaderDescription(createReaderDescription(TestReader.class)); cfg.setAnalysisEngineDescription(desc); TaskExecutionEngine runner = executionService.createEngine(cfg); String uuid = runner.run(cfg); System.out.println("=== Experiments in repository ==="); List<TaskContextMetadata> experiments = storageService.getContexts(); for (TaskContextMetadata e : experiments) { System.out.println(e); } final StringBuilder sb = new StringBuilder(); storageService.retrieveBinary(uuid, "test", new StreamReader() { @Override public void read(InputStream aInputStream) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); Util.shoveAndClose(aInputStream, bos); sb.append(new String(bos.toByteArray(), "UTF-8")); } }); assertEquals("works", sb.toString()); }