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 } } }
/** * Attempt to guess the version of a resource loader. * * @param resourceLoader the resource loader to check (must not be {@code null}) * @return the version, or {@code null} if no version could be determined * @throws IOException if necessary resource(s) failed to load */ public static Version detectVersion(ResourceLoader resourceLoader) throws IOException { final Resource resource = resourceLoader.getResource("META-INF/MANIFEST.MF"); if (resource != null) { Manifest manifest; try (InputStream is = resource.openStream()) { manifest = new Manifest(is); } final Attributes mainAttributes = manifest.getMainAttributes(); final String versionString = mainAttributes.getValue(Attributes.Name.IMPLEMENTATION_VERSION); if (versionString != null) try { return Version.parse(versionString); } catch (IllegalArgumentException ignored) { } } return null; } }
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()); }
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(); }
ret.add(new ZipJavaFileObject(org.fakereplace.util.FileReader.readFileBytes(res.openStream()), binaryName, res.getURL().toURI())); } catch (URISyntaxException e) { e.printStackTrace();
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(); }
void addPermissions(final ModuleSpec.Builder builder, final ResourceLoader resourceLoader, final ModuleLoader moduleLoader) { final Resource resource = resourceLoader.getResource("META-INF/permissions.xml"); if (resource != null) { try { try (InputStream stream = resource.openStream()) { builder.setPermissionCollection(PermissionsXmlParser.parsePermissionsXml(stream, moduleLoader, builder.getName())); } } catch (XmlPullParserException | IOException ignored) { } } }
break; InputStream input = res.openStream(); try { manifest = new Manifest(input);
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; }
final List<Resource> resourceList = loader.loadResourceLocal(canonPath); for (Resource resource : resourceList) { return resource.openStream(); final List<Resource> resourceList = fallbackLoader.loadResourceLocal(canonPath); for (Resource resource : resourceList) { return resource.openStream();
final Resource resource = iterator.next(); if (jaxpResource != null) log.jaxpResourceLoaded(resource.getURL(), this); return resource.openStream(); final Resource resource = iterator.next(); if (jaxpResource != null) log.jaxpResourceLoaded(resource.getURL(), this); return resource.openStream();
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; }
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 } } }
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 } } }