Package org.jboss.shrinkwrap.api

Examples of org.jboss.shrinkwrap.api.Node


        // Merge the auxilliary archives and collect the loadable extensions
        final Set<String> loadableExtensions = new HashSet<String>();
        final String loadableExtentionsPath = "META-INF/services/" + RemoteLoadableExtension.class.getName();
        for (Archive<?> aux : auxArchives) {
            Node node = aux.get(loadableExtentionsPath);
            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


    public RhqAgentPluginArchive withRequiredPluginsFrom(Collection<? extends Archive<?>> archives)
        throws IllegalArgumentException {
       
        delete(REQUIRED_PLUGINS_PATH);
       
        Node descriptor = get(PLUGIN_DESCRIPTOR_PATH);
        if (descriptor == null) {
            return this;
        }
       
        Map<String, Archive<?>> plugins = new HashMap<String, Archive<?>>();
View Full Code Here

        return withRequiredPluginsFrom(Arrays.asList(archives));
    }

    @Override
    public List<Archive<?>> getRequiredPlugins() {     
        Node requiredPluginsRoot = get(REQUIRED_PLUGINS_PATH);
        if (requiredPluginsRoot == null) {
            return null;
        }
       
        List<Archive<?>> ret = new ArrayList<Archive<?>>();
        for(Node plugin : requiredPluginsRoot.getChildren()) {
           Asset a = plugin.getAsset();
           if (a instanceof ArchiveAsset) {
               ret.add(((ArchiveAsset) a).getArchive());
           }
        }
View Full Code Here

                    e);
        }

        RhqAgentPluginArchive pluginArchive = archive.as(RhqAgentPluginArchive.class);

        Node descriptor = pluginArchive.get(ArchivePaths.create("META-INF/rhq-plugin.xml"));
        if (descriptor == null) {
            throw new DeploymentException("Plugin archive [" + archive + "] doesn't specify an RHQ plugin descriptor.");
        }

        boolean wasStarted = stopPc();
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

            throw new IllegalStateException(e);
        }
    }

    protected static String parseModule(WebArchive war) throws Exception {
        final Node awXml = war.get(ParseUtils.APPENGINE_WEB_XML);
        if (awXml == null) {
            throw new IllegalStateException("Missing appengine-web.xml: " + war);
        }
        final Map<String, String> results = ParseUtils.parseTokens(awXml, ParseUtils.MODULE);
        String module = results.get(ParseUtils.MODULE);
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

            e.setClassLoader(tempClassLoader);
            appModule.getEjbModules().add(e);
        }

        final EjbJar ejbJar;
        final Node ejbJarXml = archive.get(prefix.concat(EJB_JAR_XML));
        if (ejbJarXml != null) {
            try {
                ejbJar = ReadDescriptors.readEjbJar(ejbJarXml.getAsset().openStream());
            } catch (final OpenEJBException e) {
                throw new OpenEJBRuntimeException(e);
            }
        } else {
            ejbJar = new EjbJar();
        }

        if (ejbJar.getModuleName() == null) {
            final String name = archive.getName();
            if (name.endsWith("ar") && name.length() > 4) {
                ejbJar.setModuleName(name.substring(0, name.length() - ".jar".length()));
            } else {
                ejbJar.setModuleName(name);
            }
        }

        final EjbModule ejbModule = new EjbModule(ejbJar);
        ejbModule.setClassLoader(tempClassLoader);

        Node beansXml = archive.get(prefix.concat(BEANS_XML));
        if (beansXml == null && WEB_INF.equals(prefix)) {
            beansXml = archive.get(WEB_INF_CLASSES.concat(META_INF).concat(BEANS_XML));
        }
        if (beansXml != null) {
            ejbModule.getAltDDs().put(BEANS_XML, new AssetSource(beansXml.getAsset()));
        }

        final org.apache.xbean.finder.archive.Archive finderArchive = finderArchive(beansXml, archive, tempClassLoader, additionalPaths);

        ejbModule.setFinder(new FinderFactory.ModuleLimitedFinder(new FinderFactory.OpenEJBAnnotationFinder(finderArchive)));
        if (appModule.isWebapp()) { // war
            appModule.getWebModules().iterator().next().setFinder(ejbModule.getFinder());
        }

        appModule.getEjbModules().add(ejbModule);

        {
            Node persistenceXml = archive.get(prefix.concat(PERSISTENCE_XML));
            if (persistenceXml == null && WEB_INF.equals(prefix)) {
                persistenceXml = archive.get(WEB_INF_CLASSES.concat(META_INF).concat(PERSISTENCE_XML));
            }
            if (persistenceXml != null) {
                final Asset asset = persistenceXml.getAsset();
                if (UrlAsset.class.isInstance(asset)) {
                    appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(get(URL.class, "url", asset)));
                } else if (FileAsset.class.isInstance(asset)) {
                    try {
                        appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(get(File.class, "file", asset).toURI().toURL()));
                    } catch (final MalformedURLException e) {
                        appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(new AssetSource(persistenceXml.getAsset())));
                    }
                } else if (ClassLoaderAsset.class.isInstance(asset)) {
                    final URL url = get(ClassLoader.class, "classLoader", asset).getResource(get(String.class, "resourceName", asset));
                    if (url != null) {
                        appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(url));
                    } else {
                        appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(new AssetSource(persistenceXml.getAsset())));
                    }
                } else {
                    appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(new AssetSource(persistenceXml.getAsset())));
                }
            }
        }

        {
            final Node openejbJarXml = archive.get(prefix.concat(OPENEJB_JAR_XML));
            if (openejbJarXml != null) {
                ejbModule.getAltDDs().put(OPENEJB_JAR_XML, new AssetSource(openejbJarXml.getAsset()));
            }
        }

        {
            final Node validationXml = archive.get(prefix.concat(VALIDATION_XML));
            if (validationXml != null) {
                ejbModule.getAltDDs().put(VALIDATION_XML, new AssetSource(validationXml.getAsset()));
            }
        }

        {
            final Node resourcesXml = archive.get(prefix.concat(RESOURCES_XML));
            if (resourcesXml != null) {
                ejbModule.getAltDDs().put(RESOURCES_XML, new AssetSource(resourcesXml.getAsset()));
            }
        }

        {
            final Node envEntriesProperties = archive.get(prefix.concat(ENV_ENTRIES_PROPERTIES));
            if (envEntriesProperties != null) {
                InputStream is = null;
                final Properties properties = new Properties();
                try {
                    is = envEntriesProperties.getAsset().openStream();
                    properties.load(is);
                    ejbModule.getAltDDs().put(ENV_ENTRIES_PROPERTIES, properties);

                    // do it for test class too
                    appModule.getEjbModules().iterator().next().getAltDDs().put(ENV_ENTRIES_PROPERTIES, properties);
View Full Code Here

    }

    @Override
    protected Enumeration<URL> findResources(final String name) throws IOException {
        ArchivePath path = ArchivePaths.create(prefix + name);
        Node node = archive.get(path);
        if (node == null) {
            path = ArchivePaths.create(name);
            node = archive.get(path);

View Full Code Here

    }

    @Override
    protected URL findResource(final String name) {
        ArchivePath path = ArchivePaths.create(prefix + name);
        Node node = archive.get(path);
        if (node == null) {
            path = ArchivePaths.create(name);
            node = archive.get(path);
        }
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.