private Module mappedModule(Bundle bundle) { Module result = null; if (bundle != null) { Runtime runtime = RuntimeLocator.getRequiredRuntime(); result = runtime.getModule(bundle.getBundleId()); } return result; }
public static RuntimeType getRuntimeType() { Runtime runtime = RuntimeLocator.getRequiredRuntime(); return RuntimeType.getRuntimeType(runtime); }
private ModuleContext getModuleContext(BundleContext bundleContext) { Bundle bundle = bundleContext.getBundle(); Runtime runtime = RuntimeLocator.getRequiredRuntime(); Module module = runtime.getModule(bundle.getBundleId()); return module != null ? module.getModuleContext() : null; } }
@Test public void testLogService() throws Exception { Runtime runtime = RuntimeLocator.getRequiredRuntime(); Module module = runtime.getModule(getClass().getClassLoader()); LogService log = getLogService(module.getModuleContext()); String msg = "LogServiceTest LogService "; log.log(LogService.LOG_ERROR, msg + " ERROR"); log.log(LogService.LOG_WARNING, msg + " WARNING"); log.log(LogService.LOG_INFO, msg + " INFO"); log.log(LogService.LOG_DEBUG, msg + " DEBUG"); }
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, 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 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) { 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) { T service = getService(RuntimeLocator.getRequiredRuntime().getModuleContext(), type); Assert.assertNotNull("Service available: " + type.getName(), service); return service; }
/** * 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 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; }
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); }
@Test public void testServiceAvailability() throws Exception { Runtime runtime = RuntimeLocator.getRequiredRuntime(); Module modA = runtime.getModule(getClass().getClassLoader()); ModuleContext ctxA = modA.getModuleContext(); ServiceReference<ServiceA> srefA = ctxA.getServiceReference(ServiceA.class); Assert.assertNotNull("ServiceReference not null", srefA); ServiceA srvA = ctxA.getService(srefA); Assert.assertEquals("ServiceA#1:ServiceA1#1:Hello", srvA.doStuff("Hello")); assertDisableComponent(ctxA, srvA); }