Package org.jboss.modules

Examples of org.jboss.modules.Resource


     * @param name name of the agent file
     * @return object referencing the file from our module
     */
    private Resource getExportedResource(String name) {
        Module module = Module.forClass(getClass());
        Resource r = module.getExportedResource("rhq-agent", name);
        return r;
    }
View Full Code Here


        Module module = deploymentUnit.getAttachment(Attachments.MODULE);
        try {
            Iterator<Resource> resources = module.globResources("META-INF/**.tld");
            while (resources.hasNext()) {
                final Resource resource = resources.next();
                //horrible hack
                //we don't want to parse JSF TLD's
                //this would be picked up by the shared tlds check below, but this means we don't
                //waste time re-parsing them
                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;
                    }
                    final TldMetaData value = parseTLD(resource);
                    if(sharedTldUris.contains(value.getUri())) {
                        //don't re-include shared TLD's
                        continue;
                    }
                    String key = "/" + resource.getName();
                    if (!tlds.containsKey(key)) {
                        tlds.put(key, value);
                    }
                    if (!tlds.containsKey(value.getUri())) {
                        tlds.put(value.getUri(), value);
View Full Code Here

    public static Iterator<Resource> filtered(final PathFilter filter, final Iterator<Resource> original) {
        return new Iterator<Resource>() {
            private Resource next;

            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;
            }
View Full Code Here

        // Install gravia features to the repository
        ModuleClassLoader classLoader = Module.getCallerModule().getClassLoader();
        Iterator<Resource> itres = classLoader.iterateResources("META-INF/repository-content", false);
        while(itres.hasNext()) {
            Resource res = itres.next();
            try {
                InputStream input = res.openStream();
                RepositoryReader reader = new DefaultRepositoryXMLReader(input);
                org.jboss.gravia.resource.Resource auxres = reader.nextResource();
                while (auxres != null) {
                    if (storage.getResource(auxres.getIdentity()) == null) {
                        storage.addResource(auxres);
                    }
                    auxres = reader.nextResource();
                }
            } catch (IOException e) {
                throw new IllegalStateException("Cannot install feature to repository: " + res.getName());
            }
        }
    }
View Full Code Here

        // Install gravia features to the repository
        ModuleClassLoader classLoader = Module.getCallerModule().getClassLoader();
        Iterator<Resource> itres = classLoader.iterateResources("META-INF/environment-content", false);
        while(itres.hasNext()) {
            Resource modres = itres.next();
            try {
                InputStream input = modres.openStream();
                RepositoryReader reader = new DefaultRepositoryXMLReader(input);
                org.jboss.gravia.resource.Resource xmlres = reader.nextResource();
                while (xmlres != null) {
                    if (environment.getResource(xmlres.getIdentity()) == null) {
                        DefaultResourceBuilder builder = new DefaultResourceBuilder();
                        for (Capability cap : xmlres.getCapabilities(null)) {
                            builder.addCapability(cap.getNamespace(), cap.getAttributes(), cap.getDirectives());
                        }
                        for (Requirement req : xmlres.getRequirements(null)) {
                            builder.addCapability(req.getNamespace(), req.getAttributes(), req.getDirectives());
                        }
                        environment.addResource(builder.getResource());
                    }
                    xmlres = reader.nextResource();
                }
            } catch (IOException e) {
                throw new IllegalStateException("Cannot install resource to environment: " + modres.getName());
            }
        }
    }
View Full Code Here

    private Manifest getManifest() throws IOException {
        if(manifest != null)
            return manifest;

        final Resource manifestResource = getResource("META-INF/MANIFEST.MF");
        if(manifestResource  == null)
            return null;
        final InputStream manifestStream = manifestResource.openStream();
        try {
            manifest = new Manifest(manifestStream);
        } finally {
            if(manifestStream != null) manifestStream.close();
        }
View Full Code Here

        public TestResourceLoader create() {
            return resourceLoader;
        }

        public TestResourceLoaderBuilder addResource(final String name, final URL resourceUrl) {
            addResource(name, new Resource() {
                @Override
                public String getName() {
                    return name;
                }
View Full Code Here

            return this;
        }

        public TestResourceLoaderBuilder addResource(final String name, final File resource) throws MalformedURLException {
            final URL url = resource.toURI().toURL();
            addResource(name, new Resource() {
                @Override
                public String getName() {
                    return name;
                }
View Full Code Here

    public static Iterator<Resource> filtered(final PathFilter filter, final Iterator<Resource> original) {
        return new Iterator<Resource>() {
            private Resource next;

            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;
            }
View Full Code Here

TOP

Related Classes of org.jboss.modules.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.