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 } } }
if(resource.getURL().toString().contains("com/sun/jsf-impl/main")) { continue; if(resource.getName().startsWith("META-INF/")) { if(tlds.containsKey(resource.getName())) { continue; if(resource.getURL().getProtocol().equals("vfs")) { continue; String key = "/" + resource.getName(); if (!tlds.containsKey(key)) { tlds.put(key, value);
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(); }
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; }
if (iterator.hasNext()) { final Resource resource = iterator.next(); if (jaxpResource != null) log.jaxpResourceLoaded(resource.getURL(), this); return resource.openStream(); if (iterator.hasNext()) { final Resource resource = iterator.next(); if (jaxpResource != null) log.jaxpResourceLoaded(resource.getURL(), this); return resource.openStream();
public static ResourceLoaderSpec createLoaderSpec(Resource resource) throws IOException { try { return createLoaderSpec( VFS.getChild( resource.getURL().toURI() ) ); } catch (URISyntaxException e) { //ffs e.printStackTrace(); return null; } }
/** * 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 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(); }
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; }
/** * Load a local exported resource from this class loader. * * @param name the resource name * @return the list of resources */ public List<Resource> loadResourceLocal(final String name) { final Map<String, List<ResourceLoader>> paths = this.paths.get().getAllPaths(); final String path = Module.pathOf(name); final URLConnectionResource jaxpResource = jaxpImplResources.get(name); final List<ResourceLoader> loaders = paths.get(path); final List<Resource> list = new ArrayList<Resource>(loaders == null ? 1 : loaders.size()); if (loaders != null) { for (ResourceLoader loader : loaders) { final Resource resource = loader.getResource(name); if (resource != null) { if (jaxpResource != null) Module.log.jaxpResourceLoaded(resource.getURL(), module); list.add(resource); } } } return list.isEmpty() ? Collections.emptyList() : list; }
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) { } } }
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()); }
while (resources.hasNext()) { Resource res = resources.next(); if (!res.getName().endsWith(".class")) { continue; String binaryName = res.getName().replace("/", ".").substring(0, res.getName().length() - 6); try { ret.add(new ZipJavaFileObject(org.fakereplace.util.FileReader.readFileBytes(res.openStream()), binaryName, res.getURL().toURI())); } catch (URISyntaxException e) { e.printStackTrace();
@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; }
/** * 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; }
Module module = Module.forClass(getClass()); Resource r = module.getExportedResource("config", configFile); return r.getURL().toString(); } catch (Throwable t) {
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();
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; }
if(resource.getURL().toString().contains("com/sun/jsf-impl/main")) { continue; if(resource.getName().startsWith("META-INF/")) { if(tlds.containsKey(resource.getName())) { continue; if(resource.getURL().getProtocol().equals("vfs")) { continue; String key = "/" + resource.getName(); if (!tlds.containsKey(key)) { tlds.put(key, value);
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('/', '.');