@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); }
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 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; }