SHRINKWRAP-112 - Create a Unified Importer API
aslak Jan 14, 2010 10:30 AMWe continue the discussion from [SHRINKWRAP-112|https://jira.jboss.org/jira/browse/SHRINKWRAP-112] This is the current unified API description.
{code} package org.jboss.shrinkwrap.api.importer; import java.io.File; import java.net.URL; import org.jboss.shrinkwrap.api.Assignable; /** * A Unified Import API to handle delegation to the appropriate importer. * ie: {@link ZipImporter} or {@link ExplodedImporter} * * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a> * @version $Revision: $ */ public interface Import extends Assignable { //-------------------------------------------------------------------------------------|| // Contracts --------------------------------------------------------------------------|| //-------------------------------------------------------------------------------------|| /** * Imports this path. * * Overloads {@link #from(File)}. * * @param path * @return * @throws ArchiveImportException */ Import from(String path) throws ArchiveImportException; /** * Imports the resource at the given {@link File}. * * Both files and directories are supported. * * @param file * @return * @throws ArchiveImportException */ Import from(File file) throws ArchiveImportException; /** * Imports the resource at the given {@link URL}. * * Overloads {@link #from(File)} if this is a file:// {@link URL}. * * @param url * @return * @throws ArchiveImportException */ Import from(URL url) throws ArchiveImportException; } {code}
[Current impl|http://shrinkwrap.pastebin.com/m58f16a3a] works in the following way: * from(String) ** from(new File(String)) * from(File) ** if File.isFile -> (should delegate to a lookup of a supported importer(based on extension?)) -> ZipImporter ** if File.isDirectory -> ExplodedImporter * from(URL) ** if URL.getProtocol == file:// -> from(new File(url)) ** if URL.getName -> (should delegate to a lookup of a supported importer(based on extension?)) -> ZipImporter
The big questions are: * what should from(String) do? * any missing common objects we should support in from(?)? ** InputStream?