Package org.jboss.shrinkwrap.api

Examples of org.jboss.shrinkwrap.api.Node


   }

   @Override
   protected URL findResource(final String name)
   {
      final Node a = archive.get(name);
      if (a == null)
      {
         return null;
      }
      try
      {
         return new URL(null, ARCHIVE_PROTOCOL + name, new URLStreamHandler()
         {
            @Override
            protected java.net.URLConnection openConnection(URL u) throws java.io.IOException
            {
               return new URLConnection(u)
               {
                  @Override
                  public void connect() throws IOException
                  {
                  }

                  @Override
                  public InputStream getInputStream()
                        throws IOException
                  {
                     return a.getAsset().openStream();
                  }
               };
            }

            ;
View Full Code Here


/**
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
public class GaeApplicationArchiveProcessor extends AbstractApplicationArchiveProcessor {
    protected void handleWebArchive(WebArchive war) {
        final Node lib = war.get("WEB-INF/lib");
        if (lib != null) {
            final Set<Node> libs = lib.getChildren();
            for (Node jar : libs) {
                if (jar.getPath().get().contains("appengine-api"))
                    return;
            }
        }
View Full Code Here

    }

    static void addCompatibility(WebArchive war, Properties extra) {
        final Properties properties = new Properties();

        final Node node = war.get("WEB-INF/classes/" + COMPATIBILITY_PROPERTIES);
        if (node != null) {
            InputStream is = node.getAsset().openStream();
            try {
                properties.load(is);
            } catch (IOException e) {
                throw new RuntimeException("Cannot read compatibility properties.", e);
            } finally {
                Utils.safeClose(is);
            }
            war.delete(node.getPath());
        }

        for (String key : extra.stringPropertyNames()) {
            if (properties.containsKey(key) == false) {
                properties.setProperty(key, extra.getProperty(key));
View Full Code Here

public class UserLoginApplicationArchiveProcessor extends AbstractApplicationArchiveProcessor {
    private static final String WEB_XML_PATH = "WEB-INF/web.xml";

    @Override
    protected void handleWebArchive(WebArchive war) {
        Node node = war.get(WEB_XML_PATH);
        if (node == null) {
            throw new IllegalStateException("No web.xml in .war: " + war.toString(true));
        }

        war.addClass(GetLoginUrlServlet.class);

        WebAppDescriptor webXml = Descriptors.importAs(WebAppDescriptor.class).fromStream(node.getAsset().openStream());
        war.delete(WEB_XML_PATH); // delete first, so we can re-add
        webXml.servlet(UserLogin.USER_LOGIN_SERVLET_PATH + "-servlet", GetLoginUrlServlet.class.getName(), new String[]{"/" + UserLogin.USER_LOGIN_SERVLET_PATH});
        war.setWebXML(new StringAsset(webXml.exportAsString()));
    }
View Full Code Here

    protected boolean isAllowedDuplicate(Node node) {
        return ALLOWED_DUPLICATES.contains(node.getPath().get());
    }

    public boolean include(ArchivePath path) {
        Node node = uber.get(path);
        if (node != null && isAllowedDuplicate(node) == false) {
            Asset asset = node.getAsset();
            if (asset != null) {
                Asset other = archive.get(path).getAsset();
                validate(path, equal(asset, other));
            }
            return false;
View Full Code Here

        // 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

        // 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

    FileUtils.deleteDirectory(dir);
    dir.mkdirs();
    Map<ArchivePath, Node> content = super.getArchive().getContent();
    for (Entry<ArchivePath, Node> entry : content.entrySet()) {
      ArchivePath path = entry.getKey();
      Node node = entry.getValue();
          String pathName = PathUtil.optionallyRemovePrecedingSlash(path.get());
          File target = new File(dir, pathName);
          boolean isDirectory = node.getAsset() == null;
          InputStream stream = null;
          if (!isDirectory) {
              stream = node.getAsset().openStream();
              target.getParentFile().mkdirs();
            OutputStream out = new FileOutputStream(target);
            IOUtil.copy(stream, out);
          }
          else
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 List<String> extractServlets(Archive<?> archive) {
        Node webXml = archive.get("WEB-INF/web.xml");
        InputStream stream = webXml.getAsset().openStream();
        try {
            WebAppDescriptor wad = Descriptors.importAs(WebAppDescriptor.class).fromStream(stream);
            List<ServletMappingDef> mappings = wad.getServletMappings();
            List<String> list = new ArrayList<String>();
            for (ServletMappingDef smd : mappings) {
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.