[jboss-svn-commits] JBoss Common SVN: r3482 - in declarchive/trunk: impl-base/src/main/java/org/jboss/declarchive/impl/base and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Aug 25 01:36:01 EDT 2009
Author: ALRubinger
Date: 2009-08-25 01:36:00 -0400 (Tue, 25 Aug 2009)
New Revision: 3482
Added:
declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveImpl.java
Removed:
declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/MemoryArchiveImpl.java
Modified:
declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/Archive.java
declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/ArchiveBase.java
declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/MemoryMapArchiveBase.java
declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/path/BasicPath.java
declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/VfsArchiveBase.java
declarchive/trunk/impl-vfs/src/test/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveTestCase.java
Log:
[TMPARCH-16] Reimplement the VFS Memory Archive. Needs more support from VFS to be fully-functional. Needs proper tests.Consolidated some logic from MemoryMap impl into a common ArchiveBase as part of related refactoring.
Modified: declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/Archive.java
===================================================================
--- declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/Archive.java 2009-08-24 18:51:35 UTC (rev 3481)
+++ declarchive/trunk/api/src/main/java/org/jboss/declarchive/api/Archive.java 2009-08-25 05:36:00 UTC (rev 3482)
@@ -121,10 +121,10 @@
Map<Path, Asset> getContent();
/**
- * Add an archive under a specific and maintain the archive name a context path.
+ * Add an archive under a specific context and maintain the archive name as context path.
*
* @param path to use
- * @param arhive to add
+ * @param archive to add
* @return
* @throws IllegalArgumentException If the path or archive are not specified
*/
Modified: declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/ArchiveBase.java
===================================================================
--- declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/ArchiveBase.java 2009-08-24 18:51:35 UTC (rev 3481)
+++ declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/ArchiveBase.java 2009-08-25 05:36:00 UTC (rev 3482)
@@ -16,25 +16,30 @@
*/
package org.jboss.declarchive.impl.base;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.Asset;
+import org.jboss.declarchive.api.AssetNotFoundException;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.impl.base.path.BasicPath;
/**
* ArchiveBase
*
- * Base implementation of {@link Archive}
+ * Base implementation of {@link Archive}. Contains
+ * support for operations (typically overloaded) that are
+ * not specific to any particular storage implementation,
+ * and may be delegated to other forms.
*
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
* @version $Revision: $
*/
-public abstract class ArchiveBase<T extends Archive<T>>
+public abstract class ArchiveBase<T extends Archive<T>> implements Archive<T>
{
//-------------------------------------------------------------------------------------||
@@ -46,447 +51,194 @@
*/
private static final Logger log = Logger.getLogger(ArchiveBase.class.getName());
- /**
- * Extension for Java Archives
- */
- public static final String EXTENSION_JAR = ".jar";
-
- /**
- * Delimiter for paths while looking for resources
- */
- private static final char DELIMITER_RESOURCE_PATH = '/';
-
- /**
- * Delimiter for paths in fully-qualified class names
- */
- private static final char DELIMITER_CLASS_NAME_PATH = '.';
-
- /**
- * The filename extension appended to classes
- */
- private static final String EXTENSION_CLASS = ".class";
-
//-------------------------------------------------------------------------------------||
// Instance Members -------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
/**
- * The ClassLoader used in loading resources and classes into the virtual deployment
+ * Name of the archive
*/
- private final ClassLoader classLoader;
+ private final String name;
//-------------------------------------------------------------------------------------||
- // Constructors -----------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
/**
* Constructor
*
- * Creates a new instance using the Thread Context ClassLoader
- * from which we'll load resources by default
- */
- protected ArchiveBase()
- {
- // Use the TCCL
- this(SecurityActions.getThreadContextClassLoader());
- }
-
- /**
- * Constructor
+ * Creates a new Archive with the specified name
*
- * Creates a new instance using the specified ClassLoader
- * from which we'll load resources by default
- *
- * @param The ClassLoader to use by default
+ * @param name Name of the archive
+ * @throws IllegalArgumentException If the name was not specified
*/
- protected ArchiveBase(final ClassLoader cl)
+ protected ArchiveBase(final String name) throws IllegalArgumentException
{
- // Invoke super
- super();
+ // Precondition checks
+ Validate.notNullOrEmpty(name, "name must be specified");
- // Precondition check
- if (cl == null)
- {
- throw new IllegalArgumentException("ClassLoader must be specified");
- }
-
- // Set properties
- this.classLoader = cl;
+ // Set
+ this.name = name;
}
-// //-------------------------------------------------------------------------------------||
-// // Required Implementations -----------------------------------------------------------||
-// //-------------------------------------------------------------------------------------||
-//
-// /**
-// * @see org.jboss.declarchive.api.Archive#addClass(java.lang.Class)
-// */
-// @Override
-// public T addClass(final Class<?> clazz) throws IllegalArgumentException
-// {
-// // Precondition check
-// if (clazz == null)
-// {
-// throw new IllegalArgumentException("Class must be specified");
-// }
-//
-// // Get the resource name of the class
-// final String name = this.getResourceNameOfClass(clazz);
-//
-// // Get the CL of the Class
-// final ClassLoader cl = clazz.getClassLoader();
-//
-// // Add it as a resource
-// if (log.isLoggable(Level.FINER))
-// {
-// log.log(Level.FINER, "Adding class as resource: " + clazz);
-// }
-// return this.addResource(name, cl);
-// }
-//
-// /**
-// * @see org.jboss.declarchive.api.Archive#addClasses(java.lang.Class<?>[])
-// */
-// @Override
-// public T addClasses(final Class<?>... classes) throws IllegalArgumentException
-// {
-// // Precondition check
-// if (classes == null || classes.length == 0)
-// {
-// throw new IllegalArgumentException("At least one class must be specified");
-// }
-//
-// // For each class
-// for (final Class<?> clazz : classes)
-// {
-// this.addClass(clazz);
-// }
-//
-// // Return
-// return this.covarientReturn();
-// }
-//
-// /**
-// * @see org.jboss.declarchive.api.Archive#addResource(java.lang.String)
-// */
-// @Override
-// public T addResource(final String name) throws IllegalArgumentException
-// {
-// return this.addResource(name, this.getClassLoader());
-// }
-//
-// /**
-// * @see org.jboss.declarchive.api.Archive#addResource(java.net.URL)
-// */
-// @Override
-// public T addResource(final URL location) throws IllegalArgumentException
-// {
-// // Delegate to the other implementation
-// return this.addResource(location, null);
-// }
-//
-// /**
-// * @see org.jboss.declarchive.api.Archive#addResource(java.lang.String, java.lang.ClassLoader)
-// */
-// @Override
-// public final T addResource(final String name, final ClassLoader cl) throws IllegalArgumentException
-// {
-// // Precondition check
-// if (name == null || name.length() == 0)
-// {
-// throw new IllegalArgumentException("name must be specified");
-// }
-// if (cl == null)
-// {
-// throw new IllegalArgumentException("ClassLoader must be specified");
-// }
-//
-// // Get the content of the resource
-// byte[] content = null;
-// try
-// {
-// content = this.getBytesOfResource(name, cl);
-// }
-// catch (final IOException ioe)
-// {
-// throw new RuntimeException("Could not add resource \"" + name + "\" to " + this, ioe);
-// }
-//
-// // Add
-// this.addContent(content, name);
-//
-// // Return
-// return this.covarientReturn();
-// }
-//
-// /**
-// * @see org.jboss.declarchive.api.Archive#addResource(java.net.URL, java.lang.String)
-// */
-// @Override
-// public T addResource(final URL location, final String newPath) throws IllegalArgumentException
-// {
-// // Precondition check
-// if (location == null)
-// {
-// throw new IllegalArgumentException("location must be specified");
-// }
-//
-// // Get the content of the location
-// byte[] content = null;
-// try
-// {
-// content = this.getBytesOfResource(location);
-// }
-// catch (final IOException ioe)
-// {
-// throw new RuntimeException("Could not add location \"" + location + "\" to " + this, ioe);
-// }
-//
-// // Adjust the path if not explicitly defined
-// String path = newPath;
-// if (path == null)
-// {
-// path = location.getPath();
-// if (log.isLoggable(Level.FINER))
-// {
-// log.log(Level.FINER, "Implicitly set new path to \"" + path + "\" while adding: " + location);
-// }
-// }
-//
-// // Add
-// this.addContent(content, path);
-//
-// // Return
-// return this.covarientReturn();
-// }
-
//-------------------------------------------------------------------------------------||
- // Contracts --------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
//-------------------------------------------------------------------------------------||
/**
- * Adds the specified content to the archive at the specified location
- *
- * @param content
- * @param location
- * @throws IllegalArgumentException
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#add(java.lang.String, org.jboss.declarchive.api.Asset)
*/
- protected abstract void addContent(final byte[] content, final String location) throws IllegalArgumentException;
+ @Override
+ public T add(final String target, final Asset asset) throws IllegalArgumentException
+ {
+ // Precondition checks
+ Validate.notNullOrEmpty(target, "target must be specified");
+ Validate.notNull(asset, "asset must be specified");
- /**
- * Returns the actual typed class for this instance, used in safe casting
- * for covarient return types
- *
- * @return
- */
- protected abstract Class<T> getActualClass();
+ // Make a Path from the target
+ final Path path = new BasicPath(target);
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
+ // Delegate
+ return this.add(path, asset);
+ }
/**
- * Provides typesafe covarient return of this instance
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Path, java.lang.String, org.jboss.declarchive.api.Asset)
*/
- protected final T covarientReturn()
+ @Override
+ public T add(final Path path, final String name, final Asset asset)
{
- try
- {
- return this.getActualClass().cast(this);
- }
- catch (final ClassCastException cce)
- {
- log.log(Level.SEVERE,
- "The class specified by getActualClass is not a valid assignment target for this instance;"
- + " developer error");
- throw cce;
- }
+ // Precondition checks
+ Validate.notNull(path, "No path was specified");
+ Validate.notNullOrEmpty(name, "No target name name was specified");
+ Validate.notNull(asset, "No asset was was specified");
+
+ // Make a relative path
+ final Path resolvedPath = new BasicPath(path, name);
+
+ // Delegate
+ return this.add(resolvedPath, asset);
}
/**
- * Returns the name of the class such that it may be accessed via ClassLoader.getResource()
- *
- * @param clazz The class
- * @throws IllegalArgumentException If the class was not specified
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#get(java.lang.String)
*/
- private String getResourceNameOfClass(final Class<?> clazz) throws IllegalArgumentException
+ @Override
+ public Asset get(final String path) throws AssetNotFoundException, IllegalArgumentException
{
- // Precondition check
- if (clazz == null)
- {
- throw new IllegalArgumentException("Class must be specified");
- }
+ // Precondition checks
+ Validate.notNullOrEmpty(path, "No path was specified");
- // Build the name
- final String fqn = clazz.getName();
- final String nameAsResourcePath = fqn.replace(DELIMITER_CLASS_NAME_PATH, DELIMITER_RESOURCE_PATH);
- final String resourceName = nameAsResourcePath + EXTENSION_CLASS;
+ // Make a Path
+ final Path realPath = new BasicPath(path);
- // Return
- return resourceName;
+ // Delegate
+ return get(realPath);
}
/**
- * Copies and returns the specified URL. Used
- * to ensure we don't export mutable URLs
- *
- * @param url
- * @return
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Path, org.jboss.declarchive.api.Archive)
*/
- protected final URL copyURL(final URL url)
+ @Override
+ public T add(final Path path, final Archive<?> archive)
{
- // If null, return
- if (url == null)
- {
- return url;
- }
+ // Precondition checks
+ Validate.notNull(path, "No path was specified");
+ Validate.notNull(archive, "No archive was specified");
- try
- {
- // Copy
- return new URL(url.toExternalForm());
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException("Error in copying URL", e);
- }
+ // Make a Path
+ final String archiveName = archive.getName();
+ final Path contentPath = new BasicPath(path, archiveName);
+
+ // Delegate
+ return addContents(contentPath, archive);
}
/**
- * Obtains the contents (bytes) of the specified location
- *
- * @param location
- * @return
- * @throws IOException
- * @throws IllegalArgumentException If the location is not specified
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#getName()
*/
- private byte[] getBytesOfResource(final URL location) throws IOException, IllegalArgumentException
+ public final String getName()
{
- // Precondition check
- if (location == null)
- {
- throw new IllegalArgumentException("location must be specified");
- }
-
- // Open a connection and read in all the bytes
- final URLConnection connection = location.openConnection();
- final int length = connection.getContentLength();
- assert length > -1 : "Content length is not known";
- final InputStream in = connection.getInputStream();
- final byte[] contents;
- try
- {
- contents = new byte[length];
- int offset = 0;
- while (offset < length)
- {
- final int readLength = length - offset;
- int bytesRead = in.read(contents, offset, readLength);
- if (bytesRead == -1)
- {
- break; // EOF
- }
- offset += bytesRead;
- }
- }
- finally
- {
- try
- {
- // Close up the stream
- in.close();
- }
- catch (final IOException ignore)
- {
-
- }
- }
-
- // Return the byte array
- if (log.isLoggable(Level.FINER))
- {
- log.log(Level.FINER, "Read " + length + " bytes for: " + location);
- }
- return contents;
+ return name;
}
/**
- * Obtains the contents (bytes) of the specified resource using the
- * specified ClassLoader
- *
- * @param name
- * @param cl
- * @return
- * @throws IOException
- * @throws IllegalArgumentException If the name or ClassLoader is not specified
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#addContents(org.jboss.declarchive.api.Archive)
*/
- private byte[] getBytesOfResource(final String name, final ClassLoader cl) throws IOException,
- IllegalArgumentException
+ @Override
+ public T addContents(final Archive<?> source) throws IllegalArgumentException
{
- // Precondition check
- if (name == null || name.length() == 0)
- {
- throw new IllegalArgumentException("name must be specified");
- }
- if (cl == null)
- {
- throw new IllegalArgumentException("ClassLoader must be specified");
- }
-
- // Get the URL
- final URL resourceUrl = this.getResourceUrl(name, cl);
-
- // Return
- return this.getBytesOfResource(resourceUrl);
+ return addContents(new BasicPath(), source);
}
/**
- * Obtains the URL of the resource with the requested name.
- * The search order is described by {@link ClassLoader#getResource(String)}
- *
- * @param name
- * @return
- * @throws IllegalArgumentException If name is not specified or could not be found,
- * or if the ClassLoader is not specified
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#addContents(org.jboss.declarchive.api.Path, org.jboss.declarchive.api.Archive)
*/
- private URL getResourceUrl(final String name, final ClassLoader cl) throws IllegalArgumentException
+ @Override
+ public T addContents(final Path path, final Archive<?> source) throws IllegalArgumentException
{
- // Precondition check
- if (name == null || name.length() == 0)
- {
- throw new IllegalArgumentException("name must be specified");
- }
- if (cl == null)
- {
- throw new IllegalArgumentException("ClassLoader must be specified");
- }
+ // Precondition checks
+ Validate.notNull(path, "No path was specified");
+ Validate.notNull(source, "No source archive was specified");
- // Find
- final URL url = cl.getResource(name);
+ // Get existing contents from source archive
+ final Map<Path, Asset> sourceContent = source.getContent();
+ Validate.notNull(sourceContent, "Source archive content can not be null.");
- // Ensure found
- if (url == null)
+ // Add each asset from the source archive
+ for (final Entry<Path, Asset> contentEntry : sourceContent.entrySet())
{
- throw new ResourceNotFoundException("Could not find resource with name \"" + name + "\" in: " + cl);
+ final Asset asset = contentEntry.getValue();
+ Path assetPath = contentEntry.getKey();
+ if (path != null)
+ {
+ assetPath = new BasicPath(path, assetPath);
+ }
+ // Delegate
+ add(assetPath, asset);
}
-
- // Return
- return url;
+ return covariantReturn();
}
//-------------------------------------------------------------------------------------||
- // Accessors / Mutators ---------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
/**
- * Returns the ClassLoader used to load classes
- * and resources into this virtual deployment
+ * Returns the actual typed class for this instance, used in safe casting
+ * for covariant return types
*
* @return
*/
- protected final ClassLoader getClassLoader()
+ protected abstract Class<T> getActualClass();
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Provides typesafe covariant return of this instance
+ */
+ protected final T covariantReturn()
{
- return this.classLoader;
+ try
+ {
+ return this.getActualClass().cast(this);
+ }
+ catch (final ClassCastException cce)
+ {
+ log.log(Level.SEVERE,
+ "The class specified by getActualClass is not a valid assignment target for this instance;"
+ + " developer error");
+ throw cce;
+ }
}
}
Modified: declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/MemoryMapArchiveBase.java
===================================================================
--- declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/MemoryMapArchiveBase.java 2009-08-24 18:51:35 UTC (rev 3481)
+++ declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/MemoryMapArchiveBase.java 2009-08-25 05:36:00 UTC (rev 3482)
@@ -21,17 +21,12 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
-import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
import java.util.logging.Logger;
import org.jboss.declarchive.api.Archive;
import org.jboss.declarchive.api.Asset;
-import org.jboss.declarchive.api.AssetNotFoundException;
import org.jboss.declarchive.api.Path;
-import org.jboss.declarchive.impl.base.path.BasicPath;
-import org.jboss.declarchive.spi.MemoryMapArchive;
/**
* MemoryMapArchiveBase
@@ -43,7 +38,7 @@
* @version $Revision: $
* @param <T>
*/
-public abstract class MemoryMapArchiveBase<T extends MemoryMapArchive> implements Archive<MemoryMapArchive>
+public abstract class MemoryMapArchiveBase<T extends Archive<T>> extends ArchiveBase<T> implements Archive<T>
{
//-------------------------------------------------------------------------------------||
@@ -64,11 +59,6 @@
*/
private final Map<Path, Asset> content = new ConcurrentHashMap<Path, Asset>();
- /**
- * The file name for this {@link Archive}.
- */
- private final String archiveName;
-
//-------------------------------------------------------------------------------------||
// Constructor ------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -93,12 +83,9 @@
*
* @param archiveName
*/
- public MemoryMapArchiveBase(String archiveName)
+ public MemoryMapArchiveBase(final String archiveName)
{
- super();
- Validate.notNull(archiveName, "Archive name is required");
-
- this.archiveName = archiveName;
+ super(archiveName);
}
//-------------------------------------------------------------------------------------||
@@ -106,15 +93,6 @@
//-------------------------------------------------------------------------------------||
/* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#getName()
- */
- @Override
- public String getName()
- {
- return archiveName;
- }
-
- /* (non-Javadoc)
* @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Path, org.jboss.declarchive.api.Asset[])
*/
@Override
@@ -128,29 +106,6 @@
}
/* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Path, java.lang.String, org.jboss.declarchive.api.Asset)
- */
- @Override
- public T add(Path path, String name, Asset asset)
- {
- Validate.notNull(path, "No path path was specified");
- Validate.notNull(name, "No asset name was specified");
- Validate.notNull(asset, "No asset was was specified");
-
- content.put(new BasicPath(path, name), asset);
- return covariantReturn();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#add(java.lang.String, org.jboss.declarchive.api.Asset)
- */
- @Override
- public T add(String name, Asset asset)
- {
- throw new UnsupportedOperationException("Remove when API updated");
- }
-
- /* (non-Javadoc)
* @see org.jboss.declarchive.api.Archive#contains(org.jboss.declarchive.api.Path)
*/
@Override
@@ -181,16 +136,6 @@
}
/* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#get(java.lang.String)
- */
- @Override
- public Asset get(String path) throws AssetNotFoundException, IllegalArgumentException
- {
- Validate.notNull(path, "No path was specified");
- return get(new BasicPath(path));
- }
-
- /* (non-Javadoc)
* @see org.jboss.declarchive.api.Archive#getContent()
*/
@Override
@@ -199,59 +144,6 @@
return Collections.unmodifiableMap(content);
}
- /*
- * (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Path, org.jboss.declarchive.api.Archive)
- */
- @Override
- public T add(Path path, Archive<?> archive)
- {
- Validate.notNull(path, "No path was specified");
- Validate.notNull(archive, "No archive was specified");
-
- final Path contentPath = new BasicPath(path, archive.getName());
-
- return addContents(contentPath, archive);
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#addContents(org.jboss.declarchive.api.Archive)
- */
- @Override
- public T addContents(Archive<?> source) throws IllegalArgumentException
- {
- return addContents(new BasicPath(""), source);
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#addContents(org.jboss.declarchive.api.Path, org.jboss.declarchive.api.Archive)
- */
- @Override
- public T addContents(Path path, Archive<?> source) throws IllegalArgumentException
- {
- Validate.notNull(path, "No path was specified");
- Validate.notNull(source, "No source archive was specified");
-
- // Get existing contents from source archive
- final Map<Path, Asset> sourceContent = source.getContent();
- Validate.notNull(sourceContent, "Source archive content can not be null.");
-
- // Add each asset from the source archive
- for (Entry<Path, Asset> contentEntry : sourceContent.entrySet())
- {
- final Asset asset = contentEntry.getValue();
- Path assetPath = contentEntry.getKey();
- if (path != null)
- {
- assetPath = new BasicPath(path, assetPath);
- }
- add(assetPath, asset);
- }
- return covariantReturn();
- }
-
/* (non-Javadoc)
* @see org.jboss.declarchive.api.Archive#toString(boolean)
*/
@@ -279,31 +171,4 @@
return toString(false);
}
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Provides typesafe covariant return of this instance
- */
- protected final T covariantReturn()
- {
- try
- {
- return getActualClass().cast(this);
- }
- catch (final ClassCastException cce)
- {
- log.log(Level.SEVERE,
- "The class specified by getActualClass is not a valid assignment target for this instance;"
- + " developer error");
- throw cce;
- }
- }
-
- /**
- *
- * @return actual MemoryMapArchive type
- */
- protected abstract Class<T> getActualClass();
}
Modified: declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/path/BasicPath.java
===================================================================
--- declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/path/BasicPath.java 2009-08-24 18:51:35 UTC (rev 3481)
+++ declarchive/trunk/impl-base/src/main/java/org/jboss/declarchive/impl/base/path/BasicPath.java 2009-08-25 05:36:00 UTC (rev 3482)
@@ -58,6 +58,14 @@
//-------------------------------------------------------------------------------------||
/**
+ * Creates a new Path representing the root context
+ */
+ public BasicPath()
+ {
+ this(null);
+ }
+
+ /**
* Creates a new Path with the specified context
*
* @param context The context which this path represents. Null or
Deleted: declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/MemoryArchiveImpl.java
===================================================================
--- declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/MemoryArchiveImpl.java 2009-08-24 18:51:35 UTC (rev 3481)
+++ declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/MemoryArchiveImpl.java 2009-08-25 05:36:00 UTC (rev 3482)
@@ -1,201 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.declarchive.impl.vfs;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.jboss.declarchive.spi.vfs.VfsArchive;
-import org.jboss.logging.Logger;
-import org.jboss.virtual.MemoryFileFactory;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * MemoryArchiveImpl
- *
- * Concrete implementation of a VFS-backed virtual archive which
- * stores contents in-memory
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class MemoryArchiveImpl
-{
-//
-// //-------------------------------------------------------------------------------------||
-// // Class Members ----------------------------------------------------------------------||
-// //-------------------------------------------------------------------------------------||
-//
-// /**
-// * Logger
-// */
-// private static final Logger log = Logger.getLogger(MemoryArchiveImpl.class);
-//
-// /**
-// * Protocol of VFS in-memory
-// */
-// private static final String PROTOCOL_VFS_MEMORY = "vfsmemory";
-//
-// /**
-// * Empty String
-// */
-// private static final String EMPTY_STRING = "";
-//
-// /**
-// * Separator
-// */
-// private static final char SEPARATOR = '/';
-//
-// //-------------------------------------------------------------------------------------||
-// // Constructors -----------------------------------------------------------------------||
-// //-------------------------------------------------------------------------------------||
-//
-// /**
-// * Constructor
-// *
-// * Creates a new instance using the Thread Context
-// * ClassLoader.
-// *
-// * @param name Unique name for the deployment
-// * @throws IllegalArgumentException If the name was not specified
-// */
-// public MemoryArchiveImpl(final String name) throws IllegalArgumentException
-// {
-// this(name, SecurityActions.getThreadContextClassLoader());
-// }
-//
-// /**
-// * Constructor
-// *
-// * @param name Unique name for the deployment
-// * @param cl ClassLoader to be used in loading resources and classes
-// * @throws IllegalArgumentException If the name or ClassLoader was not specified
-// */
-// public MemoryArchiveImpl(final String name, final ClassLoader cl) throws IllegalArgumentException
-// {
-// // Invoke super
-// super(cl);
-//
-// // Precondition Check
-// if (name == null || name.length() == 0)
-// {
-// throw new IllegalArgumentException("name must be specified");
-// }
-// if (cl == null)
-// {
-// throw new IllegalArgumentException("ClassLoader must be specified");
-// }
-//
-// // Create the root for the archive
-// VirtualFile file = null;
-// URL url = null;
-// try
-// {
-// final URL memoryRootUrl = new URL(PROTOCOL_VFS_MEMORY, name, EMPTY_STRING);
-// MemoryFileFactory.createRoot(memoryRootUrl);
-// final URL stubUrl = new URL(memoryRootUrl, name);
-// MemoryFileFactory.createDirectory(stubUrl);
-// url = stubUrl;
-// file = VFS.getRoot(memoryRootUrl);
-// }
-// catch (final IOException ioe)
-// {
-// throw new RuntimeException("Error in creating the root for virtual deployment \"" + name + "\"", ioe);
-// }
-//
-// // Set properties for the root
-// this.initialize(file, url);
-// }
-//
-// //-------------------------------------------------------------------------------------||
-// // Required Implementations -----------------------------------------------------------||
-// //-------------------------------------------------------------------------------------||
-//
-// /**
-// * Puts the specified content at the specified location as a memory file
-// * @param content
-// * @param location
-// * @throws IllegalArgumentException
-// */
-// void addContent(final byte[] content, final URL location) throws IllegalArgumentException
-// {
-// // Precondition check
-// if (content == null)
-// {
-// throw new IllegalArgumentException("content must be specified");
-// }
-// if (location == null)
-// {
-// throw new IllegalArgumentException("location must be specified");
-// }
-//
-// // Put the new memory file in place
-// MemoryFileFactory.putFile(location, content);
-// log.debug("Added: " + location);
-//
-// }
-//
-// /**
-// * @see org.jboss.declarchive.impl.base.ArchiveBase#addContent(byte[], java.lang.String)
-// */
-// @Override
-// protected void addContent(final byte[] content, final String location) throws IllegalArgumentException
-// {
-// // Precondition check
-// if (content == null)
-// {
-// throw new IllegalArgumentException("content must be specified");
-// }
-// if (location == null || location.length() == 0)
-// {
-// throw new IllegalArgumentException("location must be specified");
-// }
-//
-// // Get the root URL of the memory file
-// final URL rootUrl = this.getRootUrl();
-//
-// // Construct a new URL for this new memoryfile
-// URL url = null;
-// try
-// {
-// final StringBuilder sb = new StringBuilder();
-// sb.append(rootUrl.toExternalForm());
-// sb.append(SEPARATOR);
-// sb.append(location);
-// url = new URL(sb.toString());
-// }
-// catch (final MalformedURLException murle)
-// {
-// throw new RuntimeException("Could not form URL for new resource \"" + location + "\" in " + this, murle);
-// }
-//
-// // Add the content
-// this.addContent(content, url);
-// }
-//
-// /**
-// * @see org.jboss.declarchive.impl.base.ArchiveBase#getActualClass()
-// */
-// @Override
-// protected Class<VfsArchive> getActualClass()
-// {
-// return VfsArchive.class;
-// }
-
-}
Modified: declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/VfsArchiveBase.java
===================================================================
--- declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/VfsArchiveBase.java 2009-08-24 18:51:35 UTC (rev 3481)
+++ declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/VfsArchiveBase.java 2009-08-25 05:36:00 UTC (rev 3482)
@@ -17,6 +17,7 @@
package org.jboss.declarchive.impl.vfs;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.logging.Logger;
@@ -34,7 +35,7 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
-abstract class VfsArchiveBase extends ArchiveBase<VfsArchive>
+abstract class VfsArchiveBase extends ArchiveBase<VfsArchive> implements VfsArchive
{
//-------------------------------------------------------------------------------------||
@@ -70,41 +71,37 @@
//-------------------------------------------------------------------------------------||
/**
- * Constructor
+ * Creates a {@link VfsArchive} with the specified name
*
- * Creates a new instance with the specified root and rootURL
- *
- * @param root
- * @param rootUrl
- * @param cl
+ * @param name
*/
- public VfsArchiveBase(final ClassLoader cl)
+ protected VfsArchiveBase(final String name)
{
- // Invoke super
- super(cl);
+ super(name);
}
//-------------------------------------------------------------------------------------||
// Required Implementations -----------------------------------------------------------||
//-------------------------------------------------------------------------------------||
-//
-// /* (non-Javadoc)
-// * @see org.jboss.embedded.core.deployment.ExtensibleVirtualDeployment#toString(boolean)
-// */
-// @Override
-// public String toString(final boolean verbose)
-// {
-// // If we want verbose output
-// if (verbose)
-// {
-// // Describe the root
-// return this.describe(this.getRoot());
-// }
-//
-// // Fall back on toString
-// return this.toString();
-// }
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#toString(boolean)
+ */
+ @Override
+ public String toString(final boolean verbose)
+ {
+ // If we want verbose output
+ if (verbose)
+ {
+ // Describe the root
+ return this.describe(this.getRoot());
+ }
+
+ // Fall back on toString
+ return this.toString();
+ }
+
//-------------------------------------------------------------------------------------||
// Internal Helper Methods ------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -246,8 +243,16 @@
* state from mutation)
* @return
*/
- final URL getRootUrl()
+ protected final URL getRootUrl()
{
- return this.copyURL(this.rootUrl);
+ final String form = this.rootUrl.toExternalForm();
+ try
+ {
+ return new URL(form);
+ }
+ catch (final MalformedURLException murle)
+ {
+ throw new RuntimeException("Error in copying URL as new URL: " + form);
+ }
}
}
Copied: declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveImpl.java (from rev 3474, declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/MemoryArchiveImpl.java)
===================================================================
--- declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveImpl.java (rev 0)
+++ declarchive/trunk/impl-vfs/src/main/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveImpl.java 2009-08-25 05:36:00 UTC (rev 3482)
@@ -0,0 +1,295 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.declarchive.impl.vfs;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jboss.declarchive.api.Asset;
+import org.jboss.declarchive.api.AssetNotFoundException;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.impl.base.Validate;
+import org.jboss.declarchive.spi.vfs.VfsArchive;
+import org.jboss.virtual.MemoryFileFactory;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * VfsMemoryArchiveImpl
+ *
+ * Concrete implementation of a VFS-backed virtual archive which
+ * stores contents in-memory
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class VfsMemoryArchiveImpl extends VfsArchiveBase implements VfsArchive
+{
+
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Logger
+ */
+ private static final Logger log = Logger.getLogger(VfsMemoryArchiveImpl.class.getName());
+
+ /**
+ * Protocol of VFS in-memory
+ */
+ private static final String PROTOCOL_VFS_MEMORY = "vfsmemory";
+
+ /**
+ * Empty String
+ */
+ private static final String EMPTY_STRING = "";
+
+ /**
+ * Separator
+ */
+ private static final char SEPARATOR = '/';
+
+ //-------------------------------------------------------------------------------------||
+ // Constructors -----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * @param name Unique name for the deployment
+ * @param cl ClassLoader to be used in loading resources and classes
+ * @throws IllegalArgumentException If the name or ClassLoader was not specified
+ */
+ public VfsMemoryArchiveImpl(final String name) throws IllegalArgumentException
+ {
+ // Super impl
+ super(name);
+
+ // Precondition Check (also handled by super impls, but what the hell)
+ if (name == null || name.length() == 0)
+ {
+ throw new IllegalArgumentException("name must be specified");
+ }
+
+ // Create the root for the archive
+ VirtualFile file = null;
+ URL url = null;
+ try
+ {
+ final URL memoryRootUrl = new URL(PROTOCOL_VFS_MEMORY, name, EMPTY_STRING);
+ MemoryFileFactory.createRoot(memoryRootUrl);
+ final URL stubUrl = new URL(memoryRootUrl, name);
+ MemoryFileFactory.createDirectory(stubUrl);
+ url = stubUrl;
+ file = VFS.getRoot(memoryRootUrl);
+ }
+ catch (final IOException ioe)
+ {
+ throw new RuntimeException("Error in creating the root for virtual deployment \"" + name + "\"", ioe);
+ }
+
+ // Set properties for the root
+ this.initialize(file, url);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations -----------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * @see org.jboss.declarchive.impl.base.ArchiveBase#getActualClass()
+ */
+ @Override
+ protected Class<VfsArchive> getActualClass()
+ {
+ return VfsArchive.class;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Path, org.jboss.declarchive.api.Asset)
+ */
+ @Override
+ public VfsArchive add(final Path target, final Asset asset) throws IllegalArgumentException
+ {
+ // Precondition checks
+ Validate.notNull(target, "No target was specified");
+ Validate.notNull(asset, "No asset was was specified");
+
+ // Get a URL for the target
+ final URL url = this.urlFromPath(target);
+
+ // Get content as an array of bytes
+ final InputStream in = asset.getStream();
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
+ final int len = 1024;
+ final byte[] buffer = new byte[len];
+ try
+ {
+
+ while ((in.read(buffer) != -1))
+ {
+ out.write(buffer);
+ }
+ }
+ catch (final IOException ioe)
+ {
+ throw new RuntimeException("Error in adding asset to location: " + url.toExternalForm() + " in archive "
+ + this.getName(), ioe);
+ }
+ finally
+ {
+ try
+ {
+ in.close();
+ }
+ catch (final IOException ignore)
+ {
+
+ }
+ // We don't need to close the outstream, it's a byte array out
+ }
+
+ // Put the new memory file in place
+ final byte[] content = out.toByteArray();
+ MemoryFileFactory.putFile(url, content);
+ if (log.isLoggable(Level.FINE))
+ {
+ log.fine("Added: " + url.toExternalForm());
+ }
+
+ // Return
+ return this.covariantReturn();
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#contains(org.jboss.declarchive.api.Path)
+ */
+ //TODO Add support into VFS for this
+ @Override
+ public boolean contains(final Path path) throws IllegalArgumentException
+ {
+ // Precondition check
+ Validate.notNull(path, "No path was was specified");
+
+ // Get the String form of the Path
+ final URL url = this.urlFromPath(path);
+ final String pathString = url.toExternalForm();
+
+ // Determine if this path exists
+ final VFS vfs = MemoryFileFactory.find(pathString);
+ final boolean contains = vfs != null;
+ // return contains;
+ throw new UnsupportedOperationException("VFS " + MemoryFileFactory.class.getSimpleName()
+ + " currently does not back this operation.");
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#delete(org.jboss.declarchive.api.Path)
+ */
+ @Override
+ public boolean delete(final Path path) throws IllegalArgumentException
+ {
+ // Precondition check
+ Validate.notNull(path, "No path was specified");
+
+ // Get the URL form of the Path
+ final URL url = this.urlFromPath(path);
+
+ // Delete and return
+ final boolean deleted = MemoryFileFactory.delete(url);
+ if (log.isLoggable(Level.FINE))
+ {
+ log.fine("Removed: " + url + " from " + this);
+ }
+ return deleted;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#get(org.jboss.declarchive.api.Path)
+ */
+ //TODO Add support into VFS for this
+ @Override
+ public Asset get(final Path path) throws AssetNotFoundException, IllegalArgumentException
+ {
+ throw new UnsupportedOperationException("VFS " + MemoryFileFactory.class.getSimpleName()
+ + " currently does not back this operation.");
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.declarchive.api.Archive#getContent()
+ */
+ //TODO Add support into VFS for this
+ @Override
+ public Map<Path, Asset> getContent()
+ {
+ throw new UnsupportedOperationException("VFS " + MemoryFileFactory.class.getSimpleName()
+ + " currently does not back this operation.");
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains a URL internal to this archive from the
+ * provided path
+ *
+ * @param path
+ * @return
+ * @throws IllegalArgumentException
+ */
+ private URL urlFromPath(final Path path) throws IllegalArgumentException
+ {
+ // Precondition check
+ Validate.notNull(path, "No path was was specified");
+
+ // Get a URL for the target
+ final String targetString = path.get();
+ final URL rootUrl = this.getRootUrl();
+
+ // Construct a new URL for this new memoryfile
+ final URL url;
+ try
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(rootUrl.toExternalForm());
+ sb.append(SEPARATOR);
+ sb.append(targetString);
+ url = new URL(sb.toString());
+ }
+ catch (final MalformedURLException murle)
+ {
+ throw new RuntimeException("Could not form URL for Path \"" + targetString + "\" in " + this, murle);
+ }
+
+ // Return
+ return url;
+ }
+
+}
Modified: declarchive/trunk/impl-vfs/src/test/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveTestCase.java
===================================================================
--- declarchive/trunk/impl-vfs/src/test/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveTestCase.java 2009-08-24 18:51:35 UTC (rev 3481)
+++ declarchive/trunk/impl-vfs/src/test/java/org/jboss/declarchive/impl/vfs/VfsMemoryArchiveTestCase.java 2009-08-25 05:36:00 UTC (rev 3482)
@@ -21,10 +21,12 @@
*/
package org.jboss.declarchive.impl.vfs;
-import java.net.URL;
+import java.util.logging.Logger;
-import org.jboss.declarchive.api.Archive;
-import org.jboss.logging.Logger;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.impl.base.asset.ClassAsset;
+import org.jboss.declarchive.impl.base.path.BasicPath;
+import org.jboss.declarchive.spi.vfs.VfsArchive;
import org.jboss.virtual.VFS;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -38,6 +40,8 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
+//TODO Build upon a common test base just as the MemoryMap impl uses,
+// and swap in a method to get the VFS Memory Archive impl
public class VfsMemoryArchiveTestCase
{
@@ -48,33 +52,9 @@
/**
* Logger
*/
- private static final Logger log = Logger.getLogger(VfsMemoryArchiveTestCase.class);
+ private static final Logger log = Logger.getLogger(VfsMemoryArchiveTestCase.class.getName());
- /**
- * Path to "WEB-INF"
- */
- private static final String PATH_WEB_INF = "WEB-INF";
-
- /**
- * Filename of web.xml
- */
- private static final String FILENAME_WEB_XML = "web.xml";
-
- /**
- * Path, relative to the resources base, of a test XML file
- */
- private static final String PATH_SOMETHING_XML = "xml/something.xml";
-
- /**
- * Separator character within archives
- */
- private static final char SEPARATOR = '/';
-
//-------------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- //-------------------------------------------------------------------------------------||
// Lifecycle --------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -92,40 +72,31 @@
//-------------------------------------------------------------------------------------||
/**
- * Tests that a resource may be added to an archive from a given location,
- * and assigned a new path within the archive
+ * Used in building the impl, not a true test yet
*/
@Test
- public void testAddResourceExplicitPathNameMemory() throws Exception
+ //TODO Implement this test
+ public void testMuckingAroundPrototypesNotARealTestYet() throws Exception
{
-// // Log
-// log.info("testAddResourceExplicitPathNameMemory");
-//
-// // Get the base
-// final URL base = this.getBase();
-//
-// // Get the path to the test XML file
-// final URL location = new URL(base, PATH_SOMETHING_XML);
-//
-// // Define the new path
-// final String newPath = PATH_WEB_INF + SEPARATOR + FILENAME_WEB_XML;
-//
-// // Make a virtual archive
-// final Archive archive = new MemoryArchiveImpl("something.war").addResource(location, newPath);
-// log.info(archive.toString(true));
+ // Log
+ log.info("testMuckingAroundPrototypesNotARealTestYet");
- //TODO Actually test something when we have better hooks to examine archive contents
- }
+ // // Get the base
+ // final URL base = this.getBase();
+ //
+ // // Get the path to the test XML file
+ // final URL location = new URL(base, PATH_SOMETHING_XML);
+ //
+ // // Define the new path
+ // final String newPath = PATH_WEB_INF + SEPARATOR + FILENAME_WEB_XML;
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Obtains the test resources base
- */
- private URL getBase() throws Exception
- {
- return this.getClass().getProtectionDomain().getCodeSource().getLocation();
+ // Make a virtual archive
+ final VfsArchive archive = new VfsMemoryArchiveImpl("something.jar");
+ archive.add(new BasicPath("something"), new ClassAsset(this.getClass()));
+ final Path elsePath = new BasicPath("somethingelse");
+ archive.add(elsePath, new ClassAsset(VfsMemoryArchiveImpl.class));
+ log.info(archive.toString(true));
+ archive.delete(elsePath);
+ log.info(archive.toString(true));
}
}
More information about the jboss-svn-commits
mailing list