Package org.jboss.shrinkwrap.api

Examples of org.jboss.shrinkwrap.api.Node


            if (!prefixes.containsKey(arName)) {
                throw new IOException(u.toExternalForm() + " not found");
            }

            String path = prefixes.get(arName) + path(arName, u);
            Node node = archives.get(arName).get(path);
            if (node == null) {
                path = path(arName, u);
                node = archives.get(arName).get(path);
            }
            if (node == null) {
                throw new IOException(u.toExternalForm() + " not found");
            }

            final Asset asset = node.getAsset();
            if (UrlAsset.class.isInstance(asset)) {
                return URL.class.cast(Reflections.get(asset, "url")).openConnection();
            } else if (FileAsset.class.isInstance(asset)) {
                return File.class.cast(Reflections.get(asset, "file")).toURI().toURL().openConnection();
            } else if (ClassLoaderAsset.class.isInstance(asset)) {
View Full Code Here


    contributor.contributeProvider( context, provider );

    HostmapFunctionDescriptor funcDesc = rewriteRules.getFunction( "hostmap" );
    assertThat( funcDesc.config(), is( "/WEB-INF/hostmap.txt" ) );

    Node node = webArchive.get( "/WEB-INF/hostmap.txt" );
    String asset = IOUtils.toString( node.getAsset().openStream() );
    assertThat( asset, containsString( "test-host-external=test-host-internal" ) );

    // Just make sure it doesn't blow up.
    contributor.finalizeContribution( context );
View Full Code Here

    }

    protected File rearrangeEar(EnterpriseArchive ear) {
        final File root = getTempRoot();

        final Node appXml = ear.get(ParseUtils.APPLICATION_XML);
        if (appXml != null) {
            InputStream stream = appXml.getAsset().openStream();
            try {
                ApplicationDescriptor ad = Descriptors.importAs(ApplicationDescriptor.class).fromStream(stream);

                List<JavaArchive> libs = new ArrayList<JavaArchive>();
                String libDir = ad.getLibraryDirectory();
                if (libDir != null) {
                    libDir = "lib"; // default?
                }
                Node lib = ear.get(libDir);
                if (lib != null) {
                    // defensive copy
                    final Set<Node> children = new HashSet<Node>(lib.getChildren());
                    for (Node child : children) {
                        if (child.getPath().get().endsWith(".jar")) {
                            JavaArchive jar = ear.getAsType(JavaArchive.class, child.getPath());
                            libs.add(jar);
                        }
View Full Code Here

            handleApp(app);
        } else if (archive instanceof EnterpriseArchive) {
            EnterpriseArchive ear = EnterpriseArchive.class.cast(archive);
            if (appId == null) {
                Node aaXml = ear.get(ParseUtils.APPENGINE_APPLICATION_XML);
                if (aaXml == null) {
                    throw new IllegalArgumentException("Missing appengine-application.xml: " + ear);
                }
                try {
                    Map<String, String> results = ParseUtils.parseTokens(aaXml, ParseUtils.APPLICATION);
View Full Code Here

    contributor.contributeProvider( context, provider );

    HostmapFunctionDescriptor funcDesc = rewriteRules.getFunction( "hostmap" );
    assertThat( funcDesc.config(), is( "/WEB-INF/hostmap.txt" ) );

    Node node = webArchive.get( "/WEB-INF/hostmap.txt" );
    String asset = IOUtils.toString( node.getAsset().openStream() );
    assertThat( asset, containsString( "test-host-external=test-host-internal" ) );

    // Just make sure it doesn't blow up.
    contributor.finalizeContribution( context );
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 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

        }
    }

    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

        // Merge the auxiliary archives and collect the loadable extensions
        final Set<String> loadableExtensions = new HashSet<String>();
        final String loadableExtensionsPath = "META-INF/services/" + RemoteLoadableExtension.class.getName();
        for (Archive<?> aux : auxArchives) {
            Node node = aux.get(loadableExtensionsPath);
            if (node != null) {
                BufferedReader br = new BufferedReader(new InputStreamReader(node.getAsset().openStream()));
                try {
                    String line = br.readLine();
                    while (line != null) {
                        loadableExtensions.add(line);
                        line = br.readLine();
View Full Code Here

        processArchive("", archive);
    }

    protected void processArchive(String relativePath, Archive archive) {
        // Obtain the root
        final Node rootNode = archive.get(ArchivePaths.root());

        // Recursively process the root children
        for (Node child : rootNode.getChildren()) {
            processNode(relativePath, child);
        }
    }
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.