Package org.jboss.shrinkwrap.api

Examples of org.jboss.shrinkwrap.api.Node


        }
    }

    private void validateBundleArchive(Archive<?> archive) throws Exception {
        Manifest manifest = null;
        Node node = archive.get(JarFile.MANIFEST_NAME);
        if (node != null) {
            manifest = new Manifest(node.getAsset().openStream());
        }
        OSGiManifestBuilder.validateBundleManifest(manifest);
    }
View Full Code Here


    private void filter()
    {
        fileOrClassNode = new HashMap<ArchivePath, Node>();
        nonFileNonClassAssets = new HashMap<ArchivePath, Asset>();
        Node node;
        Asset asset;
        for (Map.Entry<ArchivePath, Node> entry : archive.getContent().entrySet()) {
            node = entry.getValue();
            asset = node.getAsset();
            if (asset instanceof FileAsset || asset instanceof ClassAsset || (asset instanceof ClassLoaderAsset && isProperlyNestedClass(
                (ClassLoaderAsset) asset))) {
                fileOrClassNode.put(entry.getKey(), node);
            } else if (!ArchiveHelper.isNestedArchiveOfEAR(archive, node) && asset != null) {
                nonFileNonClassAssets.put(entry.getKey(), asset);
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 (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 AnnotationFinder(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 (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

    return createDeployment("bridge.context.application");
  }

  public static WebArchive createDeployment(String packageName) throws IOException {
    WebArchive war = createPortletDeployment(packageName);
    Node node = war.get("WEB-INF/portlet.xml");
    ArchivePath path = node.getPath();
    String s = Tools.read(node.getAsset().openStream(), Tools.UTF_8);
    s = s.replace("<portlet-info>", "<resource-bundle>bundle</resource-bundle>" + "<portlet-info>");
    war.delete(path);
    war.add(new StringAsset(s), path);
    war.addAsResource(new StringAsset("abc=def"), "bundle_fr_FR.properties");
    return war;
View Full Code Here

    return createDeployment("bridge.context.application");
  }

  public static WebArchive createDeployment(String packageName) throws IOException {
    WebArchive war = createServletDeployment(true, packageName);
    Node node = war.get("/WEB-INF/web.xml");
    ArchivePath path = node.getPath();
    String s = Tools.read(node.getAsset().openStream(), Tools.UTF_8);
    s = s.replace("<async-supported>true</async-supported>",
        "<init-param><param-name>juzu.resource_bundle</param-name><param-value>bundle</param-value></init-param>" +
            "<async-supported>true</async-supported>");
    war.delete(path);
    war.add(new StringAsset(s), path);
View Full Code Here

   private Manifest getBundleManifest(Archive<?> archive)
   {
      try
      {
         Node node = archive.get("META-INF/MANIFEST.MF");
         if (node == null)
            return null;

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

        log.debugf("Process archive '%s' with: %s", appArchive.getName(), archiveProcessor);
        archiveProcessor.process(appArchive, testClass);

        // Debug the application archive manifest
        ArchivePath manifestPath = ArchivePaths.create(JarFile.MANIFEST_NAME);
        Node node = appArchive.get(manifestPath);
        if (node == null) {
            log.errorf("Cannot find manifest in: %s", appArchive.getName());
        } else {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                IOUtil.copy(node.getAsset().openStream(), baos);
            } catch (IOException ex) {
            }
            log.debugf("Manifest for %s: \n%s", appArchive.getName(), new String(baos.toByteArray()));
        }
    }
View Full Code Here

        log.debugf("Process archive '%s' with: %s", appArchive.getName(), archiveProcessor);
        archiveProcessor.process(appArchive, testClass);

        // Debug the application archive manifest
        ArchivePath manifestPath = ArchivePaths.create(JarFile.MANIFEST_NAME);
        Node node = appArchive.get(manifestPath);
        if (node == null) {
            log.errorf("Cannot find manifest in: %s", appArchive.getName());
        } else {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                IOUtil.copy(node.getAsset().openStream(), baos);
            } catch (IOException ex) {
            }
            log.debugf("Manifest for %s: \n%s", appArchive.getName(), new String(baos.toByteArray()));
        }
    }
View Full Code Here

public class ManifestUtils {

    public static Manifest getManifest(Archive<?> archive, boolean create) {
        Manifest manifest = null;
        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 if (create) {
                manifest = new Manifest(node.getAsset().openStream());
            }
            return manifest;
        } catch (Exception ex) {
            throw new IllegalStateException("Cannot obtain manifest", ex);
        }
View Full Code Here

    }

    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

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.