private TldMetaData parseTLD(Resource tld) throws DeploymentUnitProcessingException { if (IMPLICIT_TLD.equals(tld.getName())) { // Implicit TLDs are different from regular TLDs return new TldMetaData(); } InputStream is = null; try { is = tld.openStream(); final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setXMLResolver(NoopXMLResolver.create()); XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(is); return TldMetaDataParser.parse(xmlReader); } catch (XMLStreamException e) { throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failToParseXMLDescriptor(tld.getName(), e.getLocation().getLineNumber(), e.getLocation().getColumnNumber()), e); } catch (IOException e) { throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failToParseXMLDescriptor(tld.getName()), e); } finally { try { if (is != null) { is.close(); } } catch (IOException e) { // Ignore } } }
public boolean hasNext() { Resource next; while (this.next == null && original.hasNext()) { next = original.next(); if (filter.accept(next.getName())) { this.next = next; } } return this.next != null; }
public boolean hasNext() { Resource next; while (this.next == null && original.hasNext()) { next = original.next(); if (filter.accept(next.getName())) { this.next = next; } } return this.next != null; }
/** * Lists resources in deployment using provided API for iterating resources * * @param classLoader the deployment class loader * @param rootDir directory which should be considered as root * @param recursive if true also a recursive resources are taken into account, otherwise only resources in rootDir are considered * @return list of resources returned by the API for iterating over deployment resources */ public static List<String> listResources(ModuleClassLoader classLoader, String rootDir, boolean recursive) { List<String> resourceList = new ArrayList<>(); Iterator<Resource> it = classLoader.iterateResources(rootDir, recursive); while (it.hasNext()) { resourceList.add(it.next().getName()); } return resourceList; }
while (itres.hasNext()) { Resource resource = itres.next(); String resname = resource.getName(); if (resname.startsWith(packageName) && resname.endsWith(".class")) { String className = resname.substring(0, resname.length() - 6).replace('/', '.');
private Index calculateModuleIndex(final Module module) throws ModuleLoadException, IOException { final Indexer indexer = new Indexer(); final PathFilter filter = PathFilters.getDefaultImportFilter(); final Iterator<Resource> iterator = module.iterateResources(filter); while (iterator.hasNext()) { Resource resource = iterator.next(); if(resource.getName().endsWith(".class")) { try (InputStream in = resource.openStream()) { indexer.index(in); } catch (Exception e) { ServerLogger.DEPLOYMENT_LOGGER.cannotIndexClass(resource.getName(), resource.getURL().toExternalForm(), e); } } } return indexer.complete(); }
private Index calculateModuleIndex(final Module module) throws ModuleLoadException, IOException { final Indexer indexer = new Indexer(); final PathFilter filter = PathFilters.getDefaultImportFilter(); final Iterator<Resource> iterator = module.iterateResources(filter); while (iterator.hasNext()) { Resource resource = iterator.next(); if(resource.getName().endsWith(".class")) { try (InputStream in = resource.openStream()) { indexer.index(in); } catch (Exception e) { ServerLogger.DEPLOYMENT_LOGGER.cannotIndexClass(resource.getName(), resource.getURL().toExternalForm(), e); } } } return indexer.complete(); }
while (itres.hasNext()) { Resource resource = itres.next(); String resname = resource.getName(); if (resname.startsWith(packageName) && resname.endsWith(".class")) { String className = resname.substring(0, resname.length() - 6).replace('/', '.');
private void resolveRuntimeIndex(Module module, List<Index> indexes) throws ModuleLoadException { Indexer indexer = new Indexer(); Iterator<Resource> resources = module.iterateResources(PathFilters.acceptAll()); while (resources.hasNext()) { Resource each = resources.next(); if (each.getName().endsWith(".class")) { try { ClassInfo clsInfo = indexer.index(each.openStream()); } catch (IOException e) { //System.err.println("error: " + each.getName() + ": " + e.getMessage()); } } } indexes.add(indexer.complete()); }
@Produces public Archive managementConsoleWar() throws Exception { // Load the management-ui webjars. WARArchive war = ShrinkWrap.create(WARArchive.class, "management-console-ui.war"); Module module = Module.getBootModuleLoader().loadModule("org.jboss.as.console"); Iterator<Resource> resources = module.globResources("*"); while (resources.hasNext()) { Resource each = resources.next(); war.add(new UrlAsset(each.getURL()), each.getName()); } war.setContextRoot(this.fraction.contextRoot()); return war; }
while (itres.hasNext()) { Resource res = itres.next(); if (res.getName().equals(JarFile.MANIFEST_NAME)) { if (manifest != null) { LOGGER.debugf("Cannot process multiple manifest entries for: %s", identifier);
private TldMetaData parseTLD(Resource tld) throws DeploymentUnitProcessingException { if (IMPLICIT_TLD.equals(tld.getName())) { // Implicit TLDs are different from regular TLDs return new TldMetaData(); } InputStream is = null; try { is = tld.openStream(); final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setXMLResolver(NoopXMLResolver.create()); XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(is); return TldMetaDataParser.parse(xmlReader); } catch (XMLStreamException e) { throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failToParseXMLDescriptor(tld.getName(), e.getLocation().getLineNumber(), e.getLocation().getColumnNumber()), e); } catch (IOException e) { throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failToParseXMLDescriptor(tld.getName()), e); } finally { try { if (is != null) { is.close(); } } catch (IOException e) { // Ignore } } }
String n = r.getName(); int indx = n.lastIndexOf(".class"); if (indx > 0)
private TldMetaData parseTLD(Resource tld) throws DeploymentUnitProcessingException { if (IMPLICIT_TLD.equals(tld.getName())) { // Implicit TLDs are different from regular TLDs return new TldMetaData(); } InputStream is = null; try { is = tld.openStream(); final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setXMLResolver(NoopXMLResolver.create()); XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(is); return TldMetaDataParser.parse(xmlReader); } catch (XMLStreamException e) { throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failToParseXMLDescriptor(tld.getName(), e.getLocation().getLineNumber(), e.getLocation().getColumnNumber()), e); } catch (IOException e) { throw new DeploymentUnitProcessingException(UndertowLogger.ROOT_LOGGER.failToParseXMLDescriptor(tld.getName()), e); } finally { try { if (is != null) { is.close(); } } catch (IOException e) { // Ignore } } }
protected List<Class<? extends ServerConfiguration>> findServerConfigurationImpls(Module module) throws ModuleLoadException, IOException, NoSuchFieldException, IllegalAccessException { Indexer indexer = new Indexer(); Iterator<Resource> resources = module.iterateResources(PathFilters.acceptAll()); while (resources.hasNext()) { Resource each = resources.next(); if (each.getName().endsWith(".class")) { try { ClassInfo clsInfo = indexer.index(each.openStream()); } catch (IOException e) { //System.err.println("error: " + each.getName() + ": " + e.getMessage()); } } } Index index = indexer.complete(); Set<ClassInfo> infos = index.getAllKnownImplementors(DotName.createSimple(ServerConfiguration.class.getName())); List<Class<? extends ServerConfiguration>> impls = new ArrayList<>(); for (ClassInfo info : infos) { try { Class<? extends ServerConfiguration> cls = (Class<? extends ServerConfiguration>) module.getClassLoader().loadClass(info.name().toString()); if (!Modifier.isAbstract(cls.getModifiers())) { impls.add(cls); } } catch (ClassNotFoundException e) { e.printStackTrace(); } } return impls; //List<AnnotationInstance> found = index.getAnnotations(DotName.createSimple(Configuration.class.getName())); //return found; }
private void initializeConfigFiltersFatJar() throws ModuleLoadException, IOException, ClassNotFoundException { Indexer indexer = new Indexer(); Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME); Iterator<Resource> iter = appModule.iterateResources(PathFilters.acceptAll()); while (iter.hasNext()) { Resource each = iter.next(); if (each.getName().endsWith(".class")) { if (!each.getName().equals("module-info.class")) { try (InputStream is = each.openStream()) { indexer.index(is); } catch (IOException e) { // ignore } } } } Index index = indexer.complete(); Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName())); for (ClassInfo each : impls) { String name = each.name().toString(); Class<? extends ConfigurationFilter> cls = (Class<? extends ConfigurationFilter>) appModule.getClassLoader().loadClass(name); try { ConfigurationFilter filter = cls.newInstance(); this.configView.withFilter(filter); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } } }
private void initializeConfigFiltersFatJar() throws ModuleLoadException, IOException, ClassNotFoundException { Indexer indexer = new Indexer(); Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME); Iterator<Resource> iter = appModule.iterateResources(PathFilters.acceptAll()); while (iter.hasNext()) { Resource each = iter.next(); if (each.getName().endsWith(".class")) { if (!each.getName().equals("module-info.class")) { try (InputStream is = each.openStream()) { indexer.index(is); } catch (IOException e) { // ignore } } } } Index index = indexer.complete(); Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName())); for (ClassInfo each : impls) { String name = each.name().toString(); Class<? extends ConfigurationFilter> cls = (Class<? extends ConfigurationFilter>) appModule.getClassLoader().loadClass(name); try { ConfigurationFilter filter = cls.newInstance(); this.configView.withFilter(filter); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } } }
private void initializeConfigFiltersFatJar() throws ModuleLoadException, IOException, ClassNotFoundException { Indexer indexer = new Indexer(); Module appModule = Module.getBootModuleLoader().loadModule(APPLICATION_MODULE_NAME); Iterator<Resource> iter = appModule.iterateResources(PathFilters.acceptAll()); while (iter.hasNext()) { Resource each = iter.next(); if (each.getName().endsWith(".class")) { if (!each.getName().equals("module-info.class")) { try (InputStream is = each.openStream()) { indexer.index(is); } catch (IOException e) { // ignore } } } } Index index = indexer.complete(); Set<ClassInfo> impls = index.getAllKnownImplementors(DotName.createSimple(ConfigurationFilter.class.getName())); for (ClassInfo each : impls) { String name = each.name().toString(); Class<? extends ConfigurationFilter> cls = (Class<? extends ConfigurationFilter>) appModule.getClassLoader().loadClass(name); try { ConfigurationFilter filter = cls.newInstance(); this.configView.withFilter(filter); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } } }
public ModuleSpec findModule(final String name, final ModuleLoader delegateLoader) throws ModuleLoadException { final ResourceLoader resourceLoader = this.resourceLoader; final String path = PathUtils.basicModuleNameToPath(name); if (path == null) { return null; // not valid, so not found } String basePath = modulesDirectory + "/" + path; Resource moduleXmlResource = resourceLoader.getResource(basePath + "/" + MODULE_FILE); if (moduleXmlResource == null) { return null; } ModuleSpec moduleSpec; try { try (final InputStream inputStream = moduleXmlResource.openStream()) { moduleSpec = ModuleXmlParser.parseModuleXml(factory, basePath, inputStream, moduleXmlResource.getName(), delegateLoader, name); } } catch (IOException e) { throw new ModuleLoadException("Failed to read " + MODULE_FILE + " file", e); } return moduleSpec; }