Package org.jboss.shrinkwrap.api

Examples of org.jboss.shrinkwrap.api.Node


    }

    public static Manifest getOrCreateManifest(Archive<?> archive) {
        Manifest manifest;
        try {
            Node node = archive.get(JarFile.MANIFEST_NAME);
            if (node == null) {
                manifest = new Manifest();
                Attributes attributes = manifest.getMainAttributes();
                attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
            } else {
                manifest = new Manifest(node.getAsset().openStream());
            }
            return manifest;
        } catch (Exception ex) {
            throw new IllegalStateException("Cannot obtain manifest", ex);
        }
View Full Code Here


        }
    }

    private URL getBeanXmlUrl(Archive archive, String beansXmlPath)
    {
        final Node beansXml = archive.get(beansXmlPath);

        if (beansXml == null)
        {
            return null;
        }

        try
        {
            String urlLocation = "archive://" + archive.getName() + "/" + beansXmlPath;

            return  new URL(null, urlLocation, new URLStreamHandler()
                        {
                            @Override
                            protected URLConnection openConnection(URL u) throws IOException
                            {
                                return new URLConnection(u)
                                {
                                    @Override
                                    public void connect() throws IOException
                                    {}

                                    @Override
                                    public InputStream getInputStream() throws IOException
                                    {
                                        return beansXml.getAsset().openStream();
                                    }
                                };
                            };
                        });
        }
View Full Code Here

    }

    @Override
    public URL findResource(final String name)
    {
        final Node node = findNode(name);
        if (node != null)
        {
            try
            {
                return new URL(null, "archive:" + archive.getName() + "/" + name, new ArchiveStreamHandler());
View Full Code Here

    }

    @Override
    public Enumeration<URL> findResources(final String name) throws IOException
    {
        final Node node = findNode(name);
        if (node != null)
        {
            return Collections.enumeration(Collections.singleton(new URL(null, "archive:" + archive.getName() + "/" + name, new ArchiveStreamHandler())));
        }
        if (useOnlyArchiveResources)
View Full Code Here

    }

    private Node findNode(final String name)
    {
        ArchivePath path = ArchivePaths.create(path(prefix, name));
        Node node = archive.get(path);
        if (node == null)
        {
            path = ArchivePaths.create(name);
            node = archive.get(path);
View Full Code Here

                @Override
                public InputStream getInputStream() throws IOException
                {
                    final ArchivePath path = convertToArchivePath(u);
                    Node node = archive.get(prefix + path.get());
                    if (node == null && !prefix.isEmpty())
                    { // WEB-INF/lib/x.jar!*
                        node = archive.get(path);
                    }

                    // SHRINKWRAP-308
                    if (node == null)
                    {
                        throw new FileNotFoundException("Requested path: " + path + " does not exist in " + archive.toString());
                    }

                    final Asset asset = node.getAsset();
                    if (asset == null)
                    {
                        return null;
                    }

View Full Code Here

        }
    }

    private Manifest getBundleManifest(Archive<?> archive) {
        try {
            Node node = archive.get(JarFile.MANIFEST_NAME);
            if (node == null)
                return null;

            Manifest manifest = new Manifest(node.getAsset().openStream());
            return manifest;
        } catch (Exception ex) {
            return null;
        }
    }
View Full Code Here

        }
        return new ProtocolMetaData().addContext(httpContext);
    }

    protected static Map<String, String> extractServlets(Archive<?> archive) {
        Node webXml = archive.get("WEB-INF/web.xml");
        InputStream stream = webXml.getAsset().openStream();
        try {
            WebAppDescriptor wad = Descriptors.importAs(WebAppDescriptor.class).from(stream);
            List<ServletMappingDef> mappings = wad.getServletMappings();
            Map<String, String> map = new HashMap<String, String>();
            for (ServletMappingDef smd : mappings) {
View Full Code Here

        }
    }

    private Manifest getBundleManifest(Archive<?> archive) {
        try {
            Node node = archive.get(JarFile.MANIFEST_NAME);
            if (node == null)
                return null;

            Manifest manifest = new Manifest(node.getAsset().openStream());
            return manifest;
        } catch (Exception ex) {
            return null;
        }
    }
View Full Code Here

    }

    private PortletDescriptor getOrCreatePortletDescriptor() {
        PortletDescriptor descriptor;

        Node portletXmlNode = this.get(PATH_PORTLET_DESCRIPTOR);
        if (null != portletXmlNode) {
            descriptor = Descriptors.importAs(PortletDescriptor.class).fromStream(portletXmlNode.getAsset().openStream());
            this.delete(PATH_PORTLET_DESCRIPTOR);
        } else {
            descriptor = Descriptors.create(PortletDescriptor.class)
                                .addDefaultNamespaces()
                                .version("2.0");
View Full Code Here

TOP

Related Classes of org.jboss.shrinkwrap.api.Node

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.