public static ResourceLoaderSpec createLoaderSpec(Resource resource) throws IOException { try { return createLoaderSpec( VFS.getChild( resource.getURL().toURI() ) ); } catch (URISyntaxException e) { //ffs e.printStackTrace(); return 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; }
Module module = Module.forClass(getClass()); Resource r = module.getExportedResource("config", configFile); return r.getURL().toString(); } catch (Throwable t) {
/** * Load a local exported resource from a specific root from this module class loader. * * @param root the root name * @param name the resource name * @return the resource, or {@code null} if it was not found */ @Deprecated Resource loadResourceLocal(final String root, 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); if (loaders != null) { for (ResourceLoader loader : loaders) { if (root.equals(loader.getRootName())) { final Resource resource = loader.getResource(name); if (jaxpResource != null) Module.log.jaxpResourceLoaded(resource.getURL(), module); return resource; } } } return null; }
@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; }
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(); }
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(); }
final Iterator<Resource> iterator = loader.loadResourceLocal(canonPath).iterator(); if (iterator.hasNext()) { final URL url = iterator.next().getURL(); if (jaxpResource != null) log.jaxpResourceLoaded(url, this); return url; final Iterator<Resource> iterator = fallbackLoader.loadResourceLocal(canonPath).iterator(); if (iterator.hasNext()) { final URL url = iterator.next().getURL(); if (jaxpResource != null) log.jaxpResourceLoaded(url, this); return url;
final List<Resource> resourceList = loader.loadResourceLocal(canonPath); for (Resource resource : resourceList) { final URL url = resource.getURL(); if (jaxpResource != null) log.jaxpResourceLoaded(url, this); list.add(url); final List<Resource> resourceList = fallbackLoader.loadResourceLocal(canonPath); for (Resource resource : resourceList) { final URL url = resource.getURL(); if (jaxpResource != null) log.jaxpResourceLoaded(url, this); list.add(url);
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();