@Override public Object getProperty(String key, Object defaultValue) { return runtime.getProperty(key, defaultValue); } }
private Module mappedModule(Bundle bundle) { Module result = null; if (bundle != null) { Runtime runtime = RuntimeLocator.getRequiredRuntime(); result = runtime.getModule(bundle.getBundleId()); } return result; }
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); }
@Override public Module installPluginModule(Runtime runtime, ClassLoader classLoader) throws ModuleException { String resourceName = getBundleActivator().replace('.', '/') + ".class"; URL resurl = classLoader.getResource(resourceName); if (resurl == null) { RuntimeLogger.LOGGER.debug("Cannot load BundleActivator resource '{}'", resourceName); return null; } String urlpath = resurl.toExternalForm(); urlpath = urlpath.substring(0, urlpath.indexOf(resourceName)); urlpath = urlpath + JarFile.MANIFEST_NAME; Manifest manifest; try { manifest = new Manifest(new URL(urlpath).openStream()); } catch (Exception ex) { throw new ModuleException("Cannot load plugin manifest: " + urlpath, ex); } Dictionary<String, String> headers = new ManifestHeadersProvider(manifest).getHeaders(); headers.put(Constants.MODULE_ACTIVATOR, getClass().getName()); return runtime.installModule(classLoader, headers); }
@Override public Bundle[] getBundles() { List<Bundle> bundles = new ArrayList<Bundle>(); for (Module module : getRuntime().getModules()) { bundles.add(new BundleAdaptor(module)); } return bundles.toArray(new Bundle[bundles.size()]); }
private Module installWebappModule(ServletContext servletContext, Resource resource, Dictionary<String, String> headers) { String contextPath = servletContext.getContextPath(); Resource association = NamedResourceAssociation.getResource(contextPath); resource = association != null ? association : resource; AttachableSupport context = new AttachableSupport(); context.putAttachment(SERVLET_CONTEXT_KEY, servletContext); Module module; try { Runtime runtime = RuntimeLocator.getRequiredRuntime(); ClassLoader classLoader = servletContext.getClassLoader(); module = runtime.installModule(classLoader, resource, headers, context); } catch (RuntimeException rte) { throw rte; } catch (ModuleException ex) { throw new IllegalStateException(ex); } return module; }
context.addModuleListener(t); Runtime runtime = RuntimeLocator.getRequiredRuntime(); Set<Module> modules = runtime.getModules(); Iterator<Module> itmods = modules.iterator(); while (itmods.hasNext()) {
private void activateInternal() { Runtime runtime = this.runtime.get(); if (runtime.getProperty(RUNTIME_IDENTITY) == null) { System.setProperty(RUNTIME_IDENTITY, "wildfly"); } if (runtime.getProperty(RUNTIME_HOME_DIR) == null) { System.setProperty(RUNTIME_HOME_DIR, System.getProperty("jboss.home.dir")); } if (runtime.getProperty(RUNTIME_DATA_DIR) == null) { System.setProperty(RUNTIME_DATA_DIR, runtime.getProperty(RUNTIME_HOME_DIR) + "/standalone/data"); } if (runtime.getProperty(RUNTIME_CONF_DIR) == null) { System.setProperty(RUNTIME_CONF_DIR, runtime.getProperty(RUNTIME_HOME_DIR) + "/standalone/configuration"); } }
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; } }
public WaitForInstanceStartedTask(String name, Long provisionTimeOut) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); this.adminService = ServiceLocator.awaitService(moduleContext, AdminService.class); this.provisionTimeOut = provisionTimeOut; this.name = name; }
private Module installWebappModule(ServletContext servletContext, Resource resource, Dictionary<String, String> headers) { String contextPath = servletContext.getContextPath(); Resource association = NamedResourceAssociation.getResource(contextPath); resource = association != null ? association : resource; AttachableSupport context = new AttachableSupport(); context.putAttachment(SERVLET_CONTEXT_KEY, servletContext); Module module; try { Runtime runtime = RuntimeLocator.getRequiredRuntime(); ClassLoader classLoader = servletContext.getClassLoader(); module = runtime.installModule(classLoader, resource, headers, context); } catch (RuntimeException rte) { throw rte; } catch (ModuleException ex) { throw new IllegalStateException(ex); } return module; }
private void activateInternal() { Runtime runtime = this.runtime.get(); if (runtime.getProperty(RUNTIME_IDENTITY) == null) { System.setProperty(RUNTIME_IDENTITY, "tomcat"); } if (runtime.getProperty(RUNTIME_HOME_DIR) == null) { System.setProperty(RUNTIME_HOME_DIR, System.getProperty("catalina.home")); } if (runtime.getProperty(RUNTIME_DATA_DIR) == null) { System.setProperty(RUNTIME_DATA_DIR, runtime.getProperty(RUNTIME_HOME_DIR) + "/work"); } if (runtime.getProperty(RUNTIME_CONF_DIR) == null) { System.setProperty(RUNTIME_CONF_DIR, runtime.getProperty(RUNTIME_HOME_DIR) + "/conf"); } }
@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 WaitForContainerCreationTask(String container, Long provisionTimeOut) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); this.fabricService = ServiceLocator.awaitService(moduleContext, FabricService.class); this.provisionTimeOut = provisionTimeOut; this.container = container; }
private void setUp() { Runtime runtime = this.runtime.get(); if (runtime.getProperty(RUNTIME_IDENTITY) == null) { System.setProperty(RUNTIME_IDENTITY, "tomcat"); } if (runtime.getProperty(RUNTIME_HOME_DIR) == null) { System.setProperty(RUNTIME_HOME_DIR, System.getProperty("catalina.home")); } if (runtime.getProperty(RUNTIME_DATA_DIR) == null) { System.setProperty(RUNTIME_DATA_DIR, runtime.getProperty(RUNTIME_HOME_DIR) + "/work"); } if (runtime.getProperty(RUNTIME_CONF_DIR) == null) { System.setProperty(RUNTIME_CONF_DIR, runtime.getProperty(RUNTIME_HOME_DIR) + "/conf"); } }
@Override public Bundle getBundle(long id) { Module module = getRuntime().getModule(id); return module != null ? new BundleAdaptor(module) : null; }
public static <T> T awaitService(Class<T> type, String filterspec) { ModuleContext moduleContext = RuntimeLocator.getRequiredRuntime().getModuleContext(); return awaitService(moduleContext, type, filterspec, DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS); }
@Override public String getProperty(String key) { Object value = getRuntime().getProperty(key); return (value instanceof String ? (String) value : null); }
/** * 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); } }
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); }