public WaitForInstanceStartedTask(String name, Long provisionTimeOut) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); this.adminService = ServiceLocator.awaitService(moduleContext, AdminService.class); this.provisionTimeOut = provisionTimeOut; this.name = name; }
public WaitForContainerCreationTask(String container, Long provisionTimeOut) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); this.fabricService = ServiceLocator.awaitService(moduleContext, FabricService.class); this.provisionTimeOut = provisionTimeOut; this.container = container; }
public static <T> T awaitService(Class<T> type, String filterspec, long timeout, TimeUnit unit) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); return awaitService(moduleContext, type, filterspec, timeout, unit); }
public static <T> T awaitService(Class<T> type, long timeout, TimeUnit unit) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); return awaitService(moduleContext, type, null, timeout, unit); }
public static <T> T awaitService(Class<T> type, String filterspec) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); return awaitService(moduleContext, type, filterspec, DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); }
public static <T> T awaitService(Class<T> type) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); return awaitService(moduleContext, type, null, DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); }
public static <T> T awaitService(Class<T> type, String filterspec, long timeout, TimeUnit unit) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); return awaitService(moduleContext, type, filterspec, timeout, unit); }
public static <T> T awaitService(Class<T> type) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); return awaitService(moduleContext, type, null, DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); }
public static <T> T awaitService(Class<T> type, String filterspec) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); return awaitService(moduleContext, type, filterspec, DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); }
public static <T> T getRequiredService(Class<T> type) { return getRequiredService(RuntimeLocator.getRequiredRuntime().getModuleContext(), type); }
public static <T> T getRequiredService(Class<T> type) { T service = getService(RuntimeLocator.getRequiredRuntime().getModuleContext(), type); Assert.assertNotNull("Service available: " + type.getName(), service); return service; }
public Future<Set<Container>> prepareAsync(B builder) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class); try { FabricService fabricService = fabricProxy.getService(); CompletionService<Set<Container>> completionService = new ExecutorCompletionService<Set<Container>>(executorService); return completionService.submit(new CreateContainerTask(fabricService, builder)); } finally { fabricProxy.close(); } }
public static <T> T getService(Class<T> type) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); ServiceReference<T> sref = moduleContext.getServiceReference(type); return sref != null ? moduleContext.getService(sref) : null; }
/** * Create the containers. */ public Set<Container> build() { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); ServiceLocator.awaitService(moduleContext, ContainerRegistration.class); return build(Arrays.<B> asList(getOptionsBuilder())); }
public static <T> T getService(Class<T> type) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); ServiceReference<T> sref = moduleContext.getServiceReference(type); return sref != null ? moduleContext.getService(sref) : null; }
public static Boolean profileAvailable(String profile, String version, Long timeout) throws Exception { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); FabricService service = ServiceLocator.awaitService(moduleContext, FabricService.class); for (long t = 0; (!service.getDataStore().hasProfile(version, profile) && t < timeout); t += 2000L) { Thread.sleep(2000L); } return service.getDataStore().hasProfile(version, profile); }
@Before public void setUp() throws Exception { Runtime runtime = RuntimeLocator.getRequiredRuntime(); ModuleContext syscontext = runtime.getModuleContext(); ServiceReference<Resolver> sref = syscontext.getServiceReference(Resolver.class); Assert.assertNotNull("Resolver reference not null", sref); resolver = syscontext.getService(sref); }
private static CommandSession getCommandSession(PrintStream printStream) { CommandSession commandSession; if (RuntimeType.getRuntimeType() == RuntimeType.KARAF) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); CommandProcessor commandProcessor = ServiceLocator.awaitService(moduleContext, CommandProcessor.class); commandSession = commandProcessor.createSession(System.in, printStream, printStream); commandSession.put("APPLICATION", System.getProperty("karaf.name")); commandSession.put("USER", "karaf"); } else { commandSession = new SessionSupport(System.in, printStream) { @Override public Object execute(CharSequence cmdstr) throws Exception { List<String> tokens = Arrays.asList(cmdstr.toString().split("\\s")); List<Object> args = new ArrayList<Object>(tokens); args.remove(0); AbstractCommand command = (AbstractCommand) get(AbstractCommand.class.getName()); command.execute(this, args); return null; } }; } return commandSession; }
/** * Destroy the given containers */ public static void destroy(Set<Container> containers) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class); try { FabricService fabricService = fabricProxy.getService(); for (Container aux : containers) { try { //We want to use the latest metadata Container container = fabricService.getContainer(aux.getId()); container.destroy(true); } catch (Exception ex) { ex.printStackTrace(System.err); //noop } } } finally { fabricProxy.close(); } }
/** * Stop the given containers. * The container directory will not get deleted. */ public static void stop(Set<Container> containers) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class); try { FabricService fabricService = fabricProxy.getService(); for (Container aux : containers) { try { //We want to use the latest metadata Container updated = fabricService.getContainer(aux.getId()); updated.stop(true); } catch (Exception ex) { ex.printStackTrace(System.err); //noop } } } finally { fabricProxy.close(); } } }