public RuntimePropertiesProvider() { this.runtime = RuntimeLocator.getRequiredRuntime(); }
/** * Create the default runtime instance from the given properties. * <p> * The {@link RuntimeFactory} is determined * <ol> * <li> Fully qualified class name as property under the key 'org.jboss.gravia.runtime.spi.RuntimeFactory' * <li> From a {@link ServiceLoader} of type {@link RuntimeFactory} * </ol> */ public static Runtime createRuntime(PropertiesProvider props) { IllegalArgumentAssertion.assertNotNull(props, "props"); RuntimeFactory factory = null; String className = (String) props.getProperty(RuntimeFactory.class.getName()); if (className != null) { try { factory = (RuntimeFactory) Class.forName(className).newInstance(); } catch (Exception ex) { throw new IllegalStateException("Cannot load runtime factory: " + className, ex); } } else { ServiceLoader<RuntimeFactory> loader = ServiceLoader.load(RuntimeFactory.class, RuntimeLocator.class.getClassLoader()); Iterator<RuntimeFactory> iterator = loader.iterator(); if (iterator.hasNext()) { factory = iterator.next(); } } return createRuntime(factory, props); }
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 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) { 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 awaitService(Class<T> type, long timeout, TimeUnit unit) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); return awaitService(moduleContext, type, null, timeout, unit); }
private String performCall(String path, Map<String, String> headers, long timeout, TimeUnit unit) throws Exception { Object port = RuntimeLocator.getRequiredRuntime().getProperty("org.osgi.service.http.port", "8080"); return HttpRequest.get("http://localhost:" + port + path, headers, timeout, unit); }
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; }
/** * Installs/starts the webapp as a module. */ @Override public void contextInitialized(ServletContextEvent event) { Runtime runtime = RuntimeLocator.getRequiredRuntime(); ServletContext servletContext = event.getServletContext(); Module module = runtime.getModule(servletContext.getClassLoader()); // Install the module if (module == null) { module = installWebappModule(servletContext); } // Start the module if (module != null) { servletContext.setAttribute(Module.class.getName(), module); try { module.start(); } catch (ModuleException ex) { throw new IllegalStateException(ex); } // HttpService integration BundleContext bundleContext = module.adapt(Bundle.class).getBundleContext(); servletContext.setAttribute(BundleContext.class.getName(), bundleContext); } }
/** * Create the containers. */ public Set<Container> build() { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); ServiceLocator.awaitService(moduleContext, ContainerRegistration.class); return build(Arrays.<B> asList(getOptionsBuilder())); }