Index: impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/ClassloaderResourceTestCase.java
===================================================================
--- impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/ClassloaderResourceTestCase.java	(revision 3449)
+++ impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/ClassloaderResourceTestCase.java	(working copy)
@@ -20,7 +20,7 @@
 
 import junit.framework.Assert;
 
-import org.jboss.declarchive.spi.Resource;
+import org.jboss.declarchive.api.Resource;
 import org.junit.Test;
 
 /**
Index: impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/FileResourceTestCase.java
===================================================================
--- impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/FileResourceTestCase.java	(revision 3449)
+++ impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/FileResourceTestCase.java	(working copy)
@@ -21,7 +21,7 @@
 
 import junit.framework.Assert;
 
-import org.jboss.declarchive.spi.Resource;
+import org.jboss.declarchive.api.Resource;
 import org.junit.Test;
 
 /**
Index: impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/URLResourceTestCase.java
===================================================================
--- impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/URLResourceTestCase.java	(revision 3449)
+++ impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/URLResourceTestCase.java	(working copy)
@@ -20,7 +20,7 @@
 
 import junit.framework.Assert;
 
-import org.jboss.declarchive.spi.Resource;
+import org.jboss.declarchive.api.Resource;
 import org.junit.Test;
 
 /**
Index: impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/ClassResourceTestCase.java
===================================================================
--- impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/ClassResourceTestCase.java	(revision 3449)
+++ impl-base/src/test/java/org/jboss/declarchive/impl/base/resource/ClassResourceTestCase.java	(working copy)
@@ -18,7 +18,7 @@
 
 import java.io.InputStream;
 
-import org.jboss.declarchive.spi.Resource;
+import org.jboss.declarchive.api.Resource;
 import org.junit.Assert;
 import org.junit.Test;
 
Index: impl-base/src/test/java/org/jboss/declarchive/impl/base/path/PathTestCase.java
===================================================================
--- impl-base/src/test/java/org/jboss/declarchive/impl/base/path/PathTestCase.java	(revision 0)
+++ impl-base/src/test/java/org/jboss/declarchive/impl/base/path/PathTestCase.java	(revision 0)
@@ -0,0 +1,102 @@
+/*
+ * 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.base.path;
+
+import junit.framework.Assert;
+
+import org.jboss.declarchive.api.Path;
+import org.junit.Test;
+
+
+public class PathTestCase
+{
+
+   @Test
+   public void shouldResolveBasePathWithNoPrefixPostfix() throws Exception 
+   {
+      testBasePath(new BasePath("WEB-INF"));
+   }
+
+   @Test
+   public void shouldResolveBasePathWithNoPrefix() throws Exception 
+   {
+      testBasePath(new BasePath("WEB-INF/"));
+   }
+
+   @Test
+   public void shouldResolveBasePathWithNoPostfix() throws Exception 
+   {
+      testBasePath(new BasePath("/WEB-INF"));
+   }
+
+   @Test
+   public void shouldResolveBasePathWithPrefixPostfix() throws Exception 
+   {
+      testBasePath(new BasePath("/WEB-INF/"));
+   }
+   
+   @Test
+   public void shouldResolveRelativePathWithNoPrefixPostfix() throws Exception 
+   {
+      testRelativePath(
+            new RelativePath(
+                  new BasePath("WEB-INF"), 
+                  "classes"));
+   }
+
+   @Test
+   public void shouldResolveRelativePathWithNoPrefix() throws Exception 
+   {
+      testRelativePath(
+            new RelativePath(
+                  new BasePath("WEB-INF"), 
+                  "classes/"));
+   }
+   
+   @Test
+   public void shouldResolveRelativePathWithNoPostfix() throws Exception 
+   {
+      testRelativePath(
+            new RelativePath(
+                  new BasePath("WEB-INF"), 
+                  "/classes"));
+   }
+
+   @Test
+   public void shouldResolveRelativePathWithPrefixPostfix() throws Exception 
+   {
+      testRelativePath(
+            new RelativePath(
+                  new BasePath("WEB-INF"), 
+                  "/classes/"));
+   }
+   
+   private void testRelativePath(Path path) throws Exception {
+      Assert.assertEquals(
+            "Should resolve realtive path",
+           "/WEB-INF/classes/", path.get());
+     
+   }
+   
+   private void testBasePath(Path path) 
+   {
+      Assert.assertEquals(
+            "Should resolve a absolute path to root",
+            "/WEB-INF/", path.get());
+   }
+}
Index: impl-base/src/test/java/org/jboss/declarchive/impl/base/jar/ArchiveProxyTestCase.java
===================================================================
--- impl-base/src/test/java/org/jboss/declarchive/impl/base/jar/ArchiveProxyTestCase.java	(revision 0)
+++ impl-base/src/test/java/org/jboss/declarchive/impl/base/jar/ArchiveProxyTestCase.java	(revision 0)
@@ -0,0 +1,62 @@
+/*
+ * 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.base.jar;
+
+import org.jboss.declarchive.api.jar.WebArchive;
+import org.jboss.declarchive.impl.base.path.BasePath;
+import org.jboss.declarchive.impl.base.path.ResourcePath;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * ArchiveProxyTestCase
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class ArchiveProxyTestCase
+{
+   private WebArchive archive;
+   
+   @Before 
+   public void createArchive() throws Exception {
+      MockArchive<WebArchive> backingArchive = new MockArchive<WebArchive>();
+      archive = ArchiveProxy.createWebArchive(backingArchive);
+   }
+   
+   @After
+   public void printArchive() throws Exception {
+      System.out.println(archive.toString(true));   
+   }
+   
+   @Test
+   public void shouldBeAbleToAssambleProxy() throws Exception {
+      archive
+         .setManifest("org/jboss/declarchive/impl/base/resource/Test.properties")
+         .setWebXML("org/jboss/declarchive/impl/base/resource/Test.properties");
+      
+      Assert.assertTrue(
+            archive.contains(
+                  new ResourcePath(
+                        new BasePath("/WEB-INF/"), 
+                        "web.xml")));
+   }
+   
+}
Index: impl-base/src/test/java/org/jboss/declarchive/impl/base/jar/ArchiveProxy.java
===================================================================
--- impl-base/src/test/java/org/jboss/declarchive/impl/base/jar/ArchiveProxy.java	(revision 0)
+++ impl-base/src/test/java/org/jboss/declarchive/impl/base/jar/ArchiveProxy.java	(revision 0)
@@ -0,0 +1,136 @@
+/*
+ * 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.base.jar;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.jar.WebArchive;
+import org.jboss.declarchive.impl.base.container.ArchiveContainerBase;
+import org.jboss.declarchive.impl.base.container.ManifestContainerBase;
+import org.jboss.declarchive.impl.base.container.WebContainerBase;
+import org.jboss.declarchive.impl.base.path.BasePath;
+
+/**
+ * ArchiveProxy
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class ArchiveProxy
+{
+
+   public static WebArchive createWebArchive(Archive<WebArchive> archive) 
+      throws Exception
+   {
+      Map<Path, Class<?>> handlers = new HashMap<Path, Class<?>>();
+      handlers.put(
+            new BasePath("META-INF"), 
+            ManifestContainerBase.class);
+      handlers.put(
+            new BasePath("WEB-INF"), 
+            WebContainerBase.class);
+      
+      return createProxy(WebArchive.class, handlers, archive);
+   }
+   
+   @SuppressWarnings("unchecked")
+   public static <T extends Archive<T>> T createProxy(
+         Class<T> clazz, Map<Path, Class<?>> handlers, Archive<T> archive) 
+      throws Exception 
+   {
+      T proxy = (T)Proxy.newProxyInstance(
+            Thread.currentThread().getContextClassLoader(),
+            new Class[]{clazz, Handler.class},
+            new ArchiveInvocationHandler());
+      
+      Archive<T> archiveContainer = (Archive<T>)createNewInstnace(
+            new BasePath("/"), clazz, ArchiveContainerBase.class, archive);
+      
+      Map<Class<?>, Object> initializedHandlers = initializeHandlers(clazz, proxy, handlers);
+      initializedHandlers.put(Archive.class, archiveContainer);
+      
+      ((Handler)proxy).setHandlers(initializedHandlers);
+      return proxy;
+   }
+   
+   private static <T extends Archive<T>> Map<Class<?>, Object> initializeHandlers(
+         Class<T> clazz, T proxy, Map<Path, Class<?>> handlers)
+         throws Exception
+   {
+      Map<Class<?>, Object> initHandlers = new HashMap<Class<?>, Object>();
+      for(Map.Entry<Path, Class<?>> handlerEntry : handlers.entrySet())
+      {
+         Object instance = createNewInstnace(handlerEntry.getKey(), clazz, handlerEntry.getValue(), proxy);
+         initHandlers.put(
+               handlerEntry.getValue().getInterfaces()[0], 
+               instance);
+      }
+      return initHandlers;
+   }
+
+   private static <T extends Archive<T>> Object createNewInstnace(Path path, Class<T> clazz, Class<?> base, Archive<T> archive) 
+      throws Exception
+   {
+      for(Constructor<?> constructor : base.getConstructors()) {
+         System.out.println(constructor.toGenericString());
+         return constructor.newInstance(path, archive);
+      }
+      return null;
+   }
+   
+   public static interface Handler {
+      void setHandlers(Map<Class<?>, Object> handlers);
+   }
+   
+   public static class ArchiveInvocationHandler implements InvocationHandler, Handler 
+   {
+      private Map<Class<?>, Object> handlers;
+      
+      public ArchiveInvocationHandler()
+      {
+      }
+      
+      @Override
+      public void setHandlers(Map<Class<?>, Object> handlers)
+      {
+         this.handlers = handlers;
+      }
+      
+      @Override
+      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+      {
+         if(Handler.class == method.getDeclaringClass()) {
+            this.setHandlers((Map<Class<?>, Object>)args[0]);
+            return null;
+         }
+         Object handler = handlers.get(method.getDeclaringClass());
+         Object returnValue = method.invoke(handler, args);
+         if(method.getReturnType() == Archive.class) {
+            return proxy;
+         }
+         return returnValue;
+      }
+   }
+}
Index: impl-base/src/test/java/org/jboss/declarchive/impl/base/jar/MockArchive.java
===================================================================
--- impl-base/src/test/java/org/jboss/declarchive/impl/base/jar/MockArchive.java	(revision 0)
+++ impl-base/src/test/java/org/jboss/declarchive/impl/base/jar/MockArchive.java	(revision 0)
@@ -0,0 +1,133 @@
+/*
+ * 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.base.jar;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.Resource;
+import org.jboss.declarchive.impl.base.path.ResourcePath;
+
+/**
+ * MockArchive
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ * @param <T>
+ */
+public class MockArchive<T extends Archive<T>> implements Archive<T>
+{
+   private Map<String, Resource> content;
+   
+   public MockArchive()
+   {
+      this.content = new HashMap<String, Resource>();
+   }
+   
+   @Override
+   public String getName()
+   {
+      return "MockArchive";
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Override
+   public T add(Resource... resources)
+   {
+      for(Resource resource : resources) {
+         add(resource.getDefaultPath(), resource.getDefaultName(), resource);
+      }
+      return (T)this;
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Override
+   public T add(Path path, Resource... resources)
+   {
+      for(Resource resource : resources) 
+      {
+         add(path, resource.getDefaultName(), resource);
+      }
+      return (T)this;
+   }
+
+   @SuppressWarnings("unchecked")
+   @Override
+   public T add(Path path, String name, Resource resource)
+   {
+      content.put(new ResourcePath(path, name).get(), resource);
+      return (T)this;
+   }
+
+   @SuppressWarnings("unchecked")
+   @Override
+   public T add(String name, Resource resource)
+   {
+      add(resource.getDefaultPath(), name, resource);
+      return (T)this;
+   }
+
+   @Override
+   public boolean contains(Path path)
+   {
+      return content.containsKey(path.get());
+   }
+
+   @Override
+   public boolean delete(Path path)
+   {
+      return content.remove(path.get()) != null;
+   }
+
+   @Override
+   public Resource get(Path path)
+   {
+      return content.get(path.get());
+   }
+
+   @Override
+   public Map<Path, Resource> getContent()
+   {
+      throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
+   }
+
+   @Override
+   public String toString(boolean verbose)
+   {
+      StringBuilder sb = new StringBuilder();
+      List<String> keys = new ArrayList<String>(content.keySet());
+      Collections.sort(keys);
+      
+      for(String key : keys) 
+      {
+         sb.append(key).append('\n');
+      }
+      return sb.toString();
+   }
+   
+   @Override
+   public String toString()
+   {
+      return toString(false);
+   }
+}
Index: impl-base/src/test/java/org/jboss/declarchive/impl/base/jar/WebArchiveImplTestCase.java
===================================================================
--- impl-base/src/test/java/org/jboss/declarchive/impl/base/jar/WebArchiveImplTestCase.java	(revision 0)
+++ impl-base/src/test/java/org/jboss/declarchive/impl/base/jar/WebArchiveImplTestCase.java	(revision 0)
@@ -0,0 +1,58 @@
+package org.jboss.declarchive.impl.base.jar;
+
+import junit.framework.Assert;
+
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.jar.WebArchive;
+import org.jboss.declarchive.impl.base.path.BasePath;
+import org.jboss.declarchive.impl.base.path.ResourcePath;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+
+/**
+ * Test case to ensure that the WebArchiveImpl follow the 
+ * java Web Archive specification structure.
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class WebArchiveImplTestCase
+{
+   private Path webinfPath = new BasePath("WEB-INF");
+   
+   private WebArchive archive;
+   
+   
+   @Before
+   public void createWebArchive() throws Exception {
+      archive = new WebArchiveImpl(new MockArchive<WebArchive>());
+   }
+
+   @After
+   public void displayArchive() throws Exception {
+      System.out.println("Archive:\n" + archive.toString(true));
+   }
+   
+   @Test
+   public void shouldPlaceWebXMLInWebInf() throws Exception 
+   {
+      archive.setWebXML("org/jboss/declarchive/impl/base/resource/Test.properties");
+      Assert.assertTrue(
+            "web.xml should be located in /WEB-INF/web.xml",
+            archive.contains(new ResourcePath(webinfPath, "web.xml")));
+   }
+
+   @Test
+   public void shouldPlaceLibrariesInWebInf() throws Exception 
+   {
+      
+   }
+
+   @Test
+   public void shouldPlaceClassesInWebInf() throws Exception 
+   {
+      
+   }
+}
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/container/ArchiveContainerBase.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/container/ArchiveContainerBase.java	(revision 0)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/container/ArchiveContainerBase.java	(revision 0)
@@ -0,0 +1,132 @@
+/*
+ * 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.base.container;
+
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.Resource;
+
+/**
+ * ArchiveContainerBase
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ * @param <T>
+ */
+public class ArchiveContainerBase<T extends Archive<T>> implements Archive<T>
+{
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(ArchiveContainerBase.class.getName());
+
+   //-------------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Backing archive for this Container
+    */
+   private final T archive;
+   private final Path basePath;
+   
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   public ArchiveContainerBase(final Path basePath, final T archive)
+   {
+      this.basePath = basePath;
+      this.archive = archive;
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   @Override
+   public String getName()
+   {
+      return archive.getName();
+   }
+
+   @Override
+   public T add(Path path, Resource... resources)
+   {
+      archive.add(path, resources);
+      return (T)this;
+   }
+   
+   @Override
+   public T add(Path path, String name, Resource resource)
+   {
+      archive.add(path, name, resource);
+      return (T)this;
+   }
+   
+   @Override
+   public T add(Resource... resources)
+   {
+      archive.add(resources);
+      return (T)this;
+   }
+   
+   @Override
+   public T add(String name, Resource resource)
+   {
+      archive.add(name, resource);
+      return (T)this;
+   }
+   
+   @Override
+   public boolean contains(Path path)
+   {
+      return archive.contains(path);
+   }
+   
+   @Override
+   public boolean delete(Path path)
+   {
+      return archive.delete(path);
+   }
+   
+   @Override
+   public Resource get(Path path)
+   {
+      return archive.get(path);
+   }
+   
+   @Override
+   public Map<Path, Resource> getContent()
+   {
+      return archive.getContent();
+   }
+   
+   @Override
+   public String toString(boolean verbose)
+   {
+      return archive.toString(verbose);
+   }
+}
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/container/ManifestContainerBase.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/container/ManifestContainerBase.java	(revision 0)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/container/ManifestContainerBase.java	(revision 0)
@@ -0,0 +1,95 @@
+/*
+ * 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.base.container;
+
+import java.util.logging.Logger;
+
+
+import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.container.ManifestContainer;
+import org.jboss.declarchive.impl.base.resource.ClassloaderResource;
+
+/**
+ * ManifestContainerBase
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ * @param <T>
+ */
+public class ManifestContainerBase<T extends Archive<T>> implements ManifestContainer<T>
+{
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(ManifestContainerBase.class.getName());
+
+   //-------------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Backing archive for this Container
+    */
+   private final T archive;
+   private final Path basePath;
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   public ManifestContainerBase(final Path basePath, final T archive)
+   {
+      this.basePath = basePath;
+      this.archive = archive;
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   @Override
+   public T addManifestResource(final String resourceName)
+   {
+      return archive.add(basePath, new ClassloaderResource(resourceName));
+   }
+
+   @Override
+   public T addManifestResource(final String resourceName, final String newName)
+   {
+      return archive.add(basePath, newName, new ClassloaderResource(resourceName));
+   }
+
+   @Override
+   public T setManifest(final String resourceName)
+   {
+      return archive.add(basePath, "MANIFEST.MF", new ClassloaderResource(resourceName));
+   }
+   
+   //-------------------------------------------------------------------------------------||
+   // Contracts --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   //-------------------------------------------------------------------------------------||
+   // Internal Helper Methods ------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+}
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/container/ThreadContextClassLoaderResourceContainer.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/container/ThreadContextClassLoaderResourceContainer.java	(revision 0)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/container/ThreadContextClassLoaderResourceContainer.java	(revision 0)
@@ -0,0 +1,63 @@
+/*
+ * 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.base.container;
+
+import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.container.ResourceContainer;
+
+/**
+ * ThreadContextClassLoaderResourceContainer
+ * 
+ * A {@link ResourceContainer} which uses the Thread Context ClassLoader
+ * to load requested resources.
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ThreadContextClassLoaderResourceContainer<T extends Archive<T>> extends ResourceContainerBase<T>
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Creates a new Resource Container targeted to 
+    * the specified archive
+    * 
+    * @param archive
+    * @throws IllegalArgumentException If the archive is not specified
+    */
+   public ThreadContextClassLoaderResourceContainer(final T archive)
+   {
+      // Super
+      super(archive);
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * @see org.jboss.declarchive.impl.base.container.ResourceContainerBase#getClassLoader()
+    */
+   @Override
+   ClassLoader getClassLoader()
+   {
+      return SecurityActions.getThreadContextClassLoader();
+   }
+}
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/container/ResourceContainerBase.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/container/ResourceContainerBase.java	(revision 0)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/container/ResourceContainerBase.java	(revision 0)
@@ -0,0 +1,191 @@
+/*
+ * 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.base.container;
+
+import java.util.logging.Logger;
+
+import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.Resource;
+import org.jboss.declarchive.api.container.ResourceContainer;
+import org.jboss.declarchive.impl.base.path.BasePath;
+import org.jboss.declarchive.impl.base.resource.ClassloaderResource;
+
+/**
+ * ResourceContainerBase
+ * 
+ * A {@link ResourceContainer} which uses the Thread Context ClassLoader
+ * to load requested resources.
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+abstract class ResourceContainerBase<T extends Archive<T>> implements ResourceContainer<T>
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(ResourceContainerBase.class.getName());
+
+   //-------------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Backing archive for this Container
+    */
+   private final T archive;
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Creates a new Resource Container targeted to 
+    * the specified archive
+    * 
+    * @param archive
+    * @throws IllegalArgumentException If the archive is not specified
+    */
+   public ResourceContainerBase(final T archive)
+   {
+      // Precondition check
+      if (archive == null)
+      {
+         throw new IllegalArgumentException("archive must be specified");
+      }
+
+      // Set properties
+      this.archive = archive;
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * @see org.jboss.declarchive.api.container.ResourceContainer#addResource(java.lang.String)
+    */
+   @Override
+   public T addResource(final String name) throws IllegalArgumentException
+   {
+      // Make a resource
+      final Resource resource = this.getResource(name);
+
+      // Make a Path
+      final Path path = resource.getDefaultPath();
+
+      // Return
+      return this.addResource(resource, path);
+   }
+
+   /**
+    * @see org.jboss.declarchive.api.container.ResourceContainer#addResource(java.lang.String, java.lang.String)
+    */
+   @Override
+   public T addResource(final String name, final String locationWithinContainer) throws IllegalArgumentException
+   {
+      // Make a resource
+      final Resource resource = this.getResource(name);
+
+      // Make a Path using the explicit location
+      final Path path = new BasePath(locationWithinContainer);
+
+      // Return
+      return this.addResource(resource, path);
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Contracts --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the ClassLoader used to look up resources 
+    */
+   abstract ClassLoader getClassLoader();
+
+   //-------------------------------------------------------------------------------------||
+   // Internal Helper Methods ------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Adds the specified resource to the specified path
+    * 
+    * @param resource
+    * @param path
+    * @throws IllegalArgumentException If either the resource or path is not specified
+    */
+   private T addResource(final Resource resource, final Path path) throws IllegalArgumentException
+   {
+      // Precondition checks
+      if (resource == null)
+      {
+         throw new IllegalArgumentException("resource must be specified");
+      }
+      if (path == null)
+      {
+         throw new IllegalArgumentException("path must be specified");
+      }
+
+      // Get Archive
+      final T archive = this.getArchive();
+
+      // Add
+      archive.add(path, resource);
+
+      // Return
+      return archive;
+   }
+
+   /**
+    * Obtains a resource from the specified name
+    * 
+    * @param name
+    * @return
+    * @throws IllegalArgumentException If the name is not specified
+    */
+   private Resource getResource(final String name)
+   {
+      // Precondition checks
+      if (name == null || name.length() == 0)
+      {
+         throw new IllegalArgumentException("name must be specified");
+      }
+
+      // Get the CL
+      final ClassLoader cl = this.getClassLoader();
+
+      // Make a resource
+      final Resource resource = new ClassloaderResource(name, cl);
+
+      // Return
+      return resource;
+   }
+
+   /**
+    * @return the archive
+    */
+   private final T getArchive()
+   {
+      return archive;
+   }
+}
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/container/SecurityActions.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/container/SecurityActions.java	(revision 0)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/container/SecurityActions.java	(revision 0)
@@ -0,0 +1,63 @@
+/*
+ * 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.base.container;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * SecurityActions
+ * 
+ * A set of privileged actions that are not to leak out
+ * of this package 
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+class SecurityActions
+{
+
+   //-------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------||
+
+   /**
+    * No external instantiation
+    */
+   private SecurityActions()
+   {
+
+   }
+
+   //-------------------------------------------------------------------------------||
+   // Utility Methods --------------------------------------------------------------||
+   //-------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the Thread Context ClassLoader
+    */
+   static ClassLoader getThreadContextClassLoader()
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+      {
+         public ClassLoader run()
+         {
+            return Thread.currentThread().getContextClassLoader();
+         }
+      });
+   }
+}
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/container/WebContainerBase.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/container/WebContainerBase.java	(revision 0)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/container/WebContainerBase.java	(revision 0)
@@ -0,0 +1,72 @@
+/*
+ * 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.base.container;
+
+import java.util.logging.Logger;
+
+import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.container.WebContainer;
+import org.jboss.declarchive.impl.base.resource.ClassloaderResource;
+
+/**
+ * WebContainerBase
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ * @param <T>
+ */
+public class WebContainerBase<T extends Archive<T>> implements WebContainer<T>
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(WebContainerBase.class.getName());
+
+   //-------------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Backing archive for this Container
+    */
+   private final T archive;
+   private final Path basePath;
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   public WebContainerBase(final Path basePath, final T archive)
+   {
+      this.basePath = basePath;
+      this.archive = archive;
+   }
+   
+   @Override
+   public T setWebXML(String resourceName)
+   {
+      return archive.add(basePath, "web.xml", new ClassloaderResource(resourceName));
+   }
+   
+}
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/ClassloaderResource.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/ClassloaderResource.java	(revision 3449)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/ClassloaderResource.java	(working copy)
@@ -19,7 +19,9 @@
 import java.io.InputStream;
 import java.net.URL;
 
-import org.jboss.declarchive.spi.Resource;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.Resource;
+import org.jboss.declarchive.impl.base.path.BasePath;
 
 /**
  * Loads the content of any resource located in the Classloader.
@@ -82,6 +84,14 @@
    {
       return extractFileName(classLoader.getResource(resourceName));
    }
+   
+   @Override
+   public Path getDefaultPath()
+   {
+      // TODO Auto-generated method stub
+      //return new BasePath(extractFileName(classLoader.getResource(resourceName)));
+      throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
+   }
 
    /**
     * Opens up the given resource as a stream.
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/FileResource.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/FileResource.java	(revision 3449)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/FileResource.java	(working copy)
@@ -21,7 +21,9 @@
 import java.io.FileNotFoundException;
 import java.io.InputStream;
 
-import org.jboss.declarchive.spi.Resource;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.Resource;
+import org.jboss.declarchive.impl.base.path.BasePath;
 
 /**
  * Loads any File.
@@ -62,6 +64,14 @@
    {
       return file.getName();
    }
+   
+   @Override
+   public Path getDefaultPath()
+   {
+      // TODO Auto-generated method stub
+      //return new BasePath(file.getName());
+      throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
+   }
 
    /**
     * Opens a new FileInputStream for the given File.
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/URLResource.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/URLResource.java	(revision 3449)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/URLResource.java	(working copy)
@@ -19,7 +19,9 @@
 import java.io.InputStream;
 import java.net.URL;
 
-import org.jboss.declarchive.spi.Resource;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.Resource;
+import org.jboss.declarchive.impl.base.path.BasePath;
 
 /**
  * Loads the content of any URL supported by the runtime.
@@ -56,6 +58,14 @@
       return extractFileName(url);
    }
 
+   @Override
+   public Path getDefaultPath()
+   {
+      // TODO Auto-generated method stub
+      //return new BasePath(extractFileName(url));
+      throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
+   }
+   
    /**
     * Open the URL stream.
     * 
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/ClassResource.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/ClassResource.java	(revision 3449)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/resource/ClassResource.java	(working copy)
@@ -18,7 +18,9 @@
 
 import java.io.InputStream;
 
-import org.jboss.declarchive.spi.Resource;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.Resource;
+import org.jboss.declarchive.impl.base.path.BasePath;
 
 /**
  * Loads the given class using the class's ClassLoader.
@@ -69,6 +71,14 @@
    {
       return getResourceNameOfClass(clazz);
    }
+   
+   @Override
+   public Path getDefaultPath()
+   {
+      // TODO Auto-generated method stub
+      //return new BasePath(getResourceNameOfClass(clazz));
+      throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
+   }
 
    /**
     * Converts the Class name into a Resource URL and uses the 
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/ArchiveBase.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/ArchiveBase.java	(revision 3449)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/ArchiveBase.java	(working copy)
@@ -25,6 +25,9 @@
 import java.util.logging.Logger;
 
 import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.Resource;
+import org.jboss.declarchive.api.container.ResourceContainer;
 
 /**
  * ArchiveBase
@@ -34,7 +37,7 @@
  * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
  * @version $Revision: $
  */
-public abstract class ArchiveBase<T extends Archive<?>> implements Archive<T>
+public abstract class ArchiveBase<T extends Archive<T>> implements Archive<T>, ResourceContainer<T>
 {
 
    //-------------------------------------------------------------------------------------||
@@ -260,6 +263,26 @@
       return this.covarientReturn();
    }
 
+   /**
+    * @see org.jboss.declarchive.api.container.ResourceContainer#addResource(java.lang.String, java.lang.String)
+    */
+   @Override
+   public T addResource(final String name, final String locationWithinContainer) throws IllegalArgumentException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   /**
+    * @see org.jboss.declarchive.api.Archive#addResource(org.jboss.declarchive.api.Resource, org.jboss.declarchive.api.Path)
+    */
+   @Override
+   public T addResource(final Resource resource, final Path path) throws IllegalArgumentException
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
    //-------------------------------------------------------------------------------------||
    // Contracts --------------------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/jar/WebArchiveImpl.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/jar/WebArchiveImpl.java	(revision 0)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/jar/WebArchiveImpl.java	(revision 0)
@@ -0,0 +1,182 @@
+/*
+ * 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.base.jar;
+
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.Resource;
+import org.jboss.declarchive.api.container.ManifestContainer;
+import org.jboss.declarchive.api.jar.WebArchive;
+import org.jboss.declarchive.impl.base.container.ManifestContainerBase;
+import org.jboss.declarchive.impl.base.path.BasePath;
+import org.jboss.declarchive.impl.base.path.RelativePath;
+import org.jboss.declarchive.impl.base.resource.ClassloaderResource;
+
+/**
+ * WebArchiveImpl
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class WebArchiveImpl implements WebArchive 
+{
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(JavaArchiveImpl.class.getName());
+
+   //-------------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   private static final Path PATH_WEB_INF = new BasePath("WEB-INF"); 
+   private static final Path PATH_META_INF = new BasePath("META-INF"); 
+   private static final Path PATH_CLASSES = new RelativePath(PATH_WEB_INF, "classes");
+   private static final Path PATH_LIBRARY = new RelativePath(PATH_WEB_INF, "lib");
+   
+   /**
+    * Underlying delegate
+    */
+   private final Archive<?> delegate;
+
+   private final ManifestContainer<WebArchive> manifest;
+   
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   public WebArchiveImpl(final Archive<?> delegate)
+   {
+      // Precondition check
+      if (delegate == null)
+      {
+         throw new IllegalArgumentException("delegate must be specified");
+      }
+
+      // Set properties
+      this.delegate = delegate;
+
+      this.manifest = new ManifestContainerBase<WebArchive>(PATH_META_INF, this);
+      
+      // Log
+      log.fine("Created new Java Archive from backing delegate: " + delegate);
+   }
+   
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   @Override
+   public String getName()
+   {
+      return delegate.getName();
+   }
+   
+   @Override
+   public WebArchive setWebXML(String resourceName)
+   {
+      this.delegate.add(PATH_WEB_INF, "web.xml", new ClassloaderResource(resourceName));
+      return this;
+   }
+   
+   @Override
+   public WebArchive add(Resource... resources)
+   {
+      this.delegate.add(resources);
+      return this;
+   }
+
+   @Override
+   public WebArchive add(Path path, Resource... resources)
+   {
+      this.delegate.add(path, resources);
+      return this;
+   }
+
+   @Override
+   public WebArchive add(Path path, String name, Resource resource)
+   {
+      this.delegate.add(path, name, resource);
+      return this;
+   }
+
+   @Override
+   public WebArchive add(String name, Resource resource)
+   {
+      this.delegate.add(name, resource);
+      return this;
+   }
+
+   @Override
+   public boolean contains(Path path)
+   {
+      return this.delegate.contains(path);
+   }
+
+   @Override
+   public boolean delete(Path path)
+   {
+      return this.delegate.delete(path);
+   }
+
+   @Override
+   public Resource get(Path path)
+   {
+      return this.delegate.get(path);
+   }
+
+   @Override
+   public Map<Path, Resource> getContent()
+   {
+      return delegate.getContent();
+   }
+
+   @Override
+   public String toString(boolean verbose)
+   {
+      return delegate.toString(verbose);
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations - Delegation ----------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+   
+   @Override
+   public WebArchive setManifest(String resourceName)
+   {
+      return manifest.addManifestResource(resourceName);
+   }
+   
+   @Override
+   public WebArchive addManifestResource(String resourceName)
+   {
+      return manifest.addManifestResource(resourceName);
+   }
+   
+   @Override
+   public WebArchive addManifestResource(String resourceName, String newName)
+   {
+      return manifest.addManifestResource(resourceName, newName);
+   }
+}
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/jar/JavaArchiveImpl.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/jar/JavaArchiveImpl.java	(revision 3449)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/jar/JavaArchiveImpl.java	(working copy)
@@ -22,6 +22,8 @@
 import java.util.logging.Logger;
 
 import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.Path;
+import org.jboss.declarchive.api.Resource;
 import org.jboss.declarchive.api.jar.JavaArchive;
 
 /**
@@ -89,7 +91,13 @@
    //-------------------------------------------------------------------------------------||
    // Required Implementations -----------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
-
+   
+   @Override
+   public String getName()
+   {
+      return delegate.getName();
+   }
+   
    /**
     * @param clazz
     * @return
@@ -165,6 +173,27 @@
    }
 
    /**
+    * @see org.jboss.declarchive.api.Archive#addResource(org.jboss.declarchive.api.Resource, org.jboss.declarchive.api.Path)
+    */
+   @Override
+   public JavaArchive addResource(final Resource resource, final Path path) throws IllegalArgumentException
+   {
+      delegate.addResource(resource, path);
+      return this;
+   }
+
+   /**
+    * @see org.jboss.declarchive.api.container.ResourceContainer#addResource(java.lang.String, java.lang.String)
+    */
+   @Override
+   public JavaArchive addResource(final String name, final String locationWithinContainer)
+         throws IllegalArgumentException
+   {
+      //TODO Impl
+      throw new RuntimeException("Not Implemented");
+   }
+
+   /**
     * @param verbose
     * @return
     * @see org.jboss.declarchive.api.Archive#toString(boolean)
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/path/ResourcePath.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/path/ResourcePath.java	(revision 0)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/path/ResourcePath.java	(revision 0)
@@ -0,0 +1,37 @@
+/*
+ * 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.base.path;
+
+import org.jboss.declarchive.api.Path;
+
+public class ResourcePath extends PrefixPath
+{
+   private Path basePath;
+
+   public ResourcePath(Path basePath, String resourceName)
+   {
+      super(resourceName);
+      this.basePath = basePath;
+   }
+   
+   @Override
+   String getPrefix()
+   {
+      return basePath.get();
+   }
+}
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/path/BasePath.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/path/BasePath.java	(revision 0)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/path/BasePath.java	(revision 0)
@@ -0,0 +1,68 @@
+/*
+ * 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.base.path;
+
+import org.jboss.declarchive.api.Path;
+
+/**
+ * BasePath
+ * 
+ * A {@link Path} which has no namespace and is relative to the
+ * root.
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class BasePath extends PrefixPath
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   private static final String PREFIX = null;
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Creates a new Path representing the specified
+    * context.  Null or blank may be used to 
+    * denote the root.
+    * 
+    * @param context
+    */
+   public BasePath(final String context)
+   {
+      super(PathUtil.fixBasePath(context));
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * @see org.jboss.declarchive.impl.base.path.PrefixPath#getPrefix()
+    */
+   @Override
+   String getPrefix()
+   {
+      return PREFIX;
+   }
+}
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/path/RelativePath.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/path/RelativePath.java	(revision 0)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/path/RelativePath.java	(revision 0)
@@ -0,0 +1,44 @@
+/*
+ * 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.base.path;
+
+import org.jboss.declarchive.api.Path;
+
+/**
+ * RelativePath
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class RelativePath extends PrefixPath
+{
+   private Path basePath;
+   
+   public RelativePath(Path basePath, String context)
+   {
+      super(PathUtil.fixRelativePath(context));
+      this.basePath = basePath;
+   }
+   
+   @Override
+   String getPrefix()
+   {
+      return basePath.get();
+   }
+   
+}
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/path/PrefixPath.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/path/PrefixPath.java	(revision 0)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/path/PrefixPath.java	(revision 0)
@@ -0,0 +1,93 @@
+/*
+ * 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.base.path;
+
+import org.jboss.declarchive.api.Path;
+
+/**
+ * PrefixPath
+ * 
+ * A Path which may be optionally prefixed with some common
+ * namespace
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+abstract class PrefixPath implements Path
+{
+
+   //-------------------------------------------------------------------------------------||
+   // Class Members ----------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Empty String
+    */
+   private static final String EMPTY_STRING = "";
+
+   //-------------------------------------------------------------------------------------||
+   // Instance Members -------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * The context which this path represents
+    */
+   private final String context;
+
+   //-------------------------------------------------------------------------------------||
+   // Constructor ------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Creates a new Path with the specified Prefix and context
+    * 
+    * @param prefix The prefix to prepend to every context returned
+    * in {@link PrefixPath#get()}.  May be null or blank
+    * @param context The context which this path represents.  Null or 
+    * blank represents the root.
+    */
+   PrefixPath(final String context)
+   {
+      this.context = context;
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Required Implementations -----------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * @see org.jboss.declarchive.api.Path#get()
+    */
+   @Override
+   public String get()
+   {
+      // Return the prefix plus the context
+      final String prefix = this.getPrefix();
+      final String prefixToUse = prefix == null ? EMPTY_STRING : prefix;
+      final String resolvedContext = prefixToUse + context;
+      return resolvedContext;
+   }
+
+   //-------------------------------------------------------------------------------------||
+   // Contracts --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Obtains the prefix to prepend to all path contexts
+    */
+   abstract String getPrefix();
+}
Index: impl-base/src/main/java/org/jboss/declarchive/impl/base/path/PathUtil.java
===================================================================
--- impl-base/src/main/java/org/jboss/declarchive/impl/base/path/PathUtil.java	(revision 0)
+++ impl-base/src/main/java/org/jboss/declarchive/impl/base/path/PathUtil.java	(revision 0)
@@ -0,0 +1,76 @@
+/*
+ * 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.base.path;
+
+/**
+ * PathUtil
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public class PathUtil
+{
+
+   private PathUtil() {}
+   
+   public static String fixRelativePath(String path) 
+   {
+      if(path == null) 
+      {
+         return path;
+      }
+      String removedPrefix = removePrefix(path);
+      String addedPostfix = addPostfix(removedPrefix);
+
+      return addedPostfix;
+   }
+   
+   public static String fixBasePath(String path) 
+   {
+      if(path == null) 
+      {
+         return path;
+      }
+      String prefixedPath = addPrefix(path);
+      String prePostfixedPath = addPostfix(prefixedPath);
+      
+      return prePostfixedPath;
+   }
+
+   private static String removePrefix(String path) {
+      if(path.charAt(0) == '/') {
+         return path.substring(1);
+      }
+      return path;
+   }
+   
+   private static String addPostfix(String path) {
+      if(path.charAt(path.length()-1) != '/') {
+         return path + '/';
+      }
+      return path;
+   }
+
+   private static String addPrefix(String path) {
+      if(path.charAt(0) != '/') {
+         return '/' + path;
+      }
+      return path;
+   }
+   
+}
Index: api/src/main/java/org/jboss/declarchive/api/Archive.java
===================================================================
--- api/src/main/java/org/jboss/declarchive/api/Archive.java	(revision 3449)
+++ api/src/main/java/org/jboss/declarchive/api/Archive.java	(working copy)
@@ -16,7 +16,7 @@
  */
 package org.jboss.declarchive.api;
 
-import java.net.URL;
+import java.util.Map;
 
 /**
  * Archive
@@ -25,6 +25,7 @@
  * be constructed declaratively / programmatically.
  *
  * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
  * @version $Revision: $
  */
 public interface Archive<T extends Archive<?>>
@@ -33,70 +34,25 @@
    // Contracts --------------------------------------------------------------------------||
    //-------------------------------------------------------------------------------------||
 
-   /**
-    * Adds the specified Class to the archive
-    * 
-    * @param The class to add
-    * @return This virtual deployment
-    * @throws IllegalArgumentException If no class was specified
-    */
-   T addClass(Class<?> clazz) throws IllegalArgumentException;
+   String getName();
+   
+   T add(Resource... resources);
 
-   /**
-    * Adds the specified Classes to the archive.  
-    * 
-    * @param classes
-    * @return This virtual deployment
-    * @throws IllegalArgumentException If no classes were specified
-    */
-   T addClasses(Class<?>... classes) throws IllegalArgumentException;
+   T add(Path path, Resource... resources);
 
-   /**
-    * Adds the resource with the specified name to the 
-    * deployment.  The resource name must be visible to the ClassLoader
-    * of the archive
-    * 
-    * @param name
-    * @return
-    * @throws IllegalArgumentException If the name was not specified
-    */
-   T addResource(String name) throws IllegalArgumentException;
+   T add(Path path, String name, Resource resource);
+   
+   T add(String name, Resource resource);
+   
+   Resource get(Path path);
+   
+   boolean contains(Path path);
 
-   /**
-    * Adds the specified resource to the archive, using the specified ClassLoader
-    * to load the resource
-    * 
-    * @param name
-    * @param cl
-    * @return
-    * @throws IllegalArgumentException If either the name or ClassLoader is not specified
-    */
-   T addResource(String name, ClassLoader cl) throws IllegalArgumentException;
+   boolean delete(Path path);
+   
+   Map<Path, Resource> getContent();
 
    /**
-    * Adds the resource located at the specified URL to the archive.  The
-    * location within the archive will be equal to the path portion of the 
-    * specified URL.
-    * 
-    * @param location
-    * @return
-    * @throws IllegalArgumentException If the location is not specified
-    */
-   T addResource(URL location) throws IllegalArgumentException;
-
-   /**
-    * Adds the resource located at the specified URL to
-    * the archive at the specified path.
-    * 
-    * @param location
-    * @param newPath The new path to assign, or null if 
-    *   the path portion of the location should be used
-    * @return
-    * @throws IllegalArgumentException If the location is not specified 
-    */
-   T addResource(URL location, String newPath) throws IllegalArgumentException;
-
-   /**
     * Returns a multiline "ls -l"-equse output of the contents of
     * this deployment and (recursively) its children if the verbosity 
     * flag is set to "true".  Otherwise the no-arg version is invoked
Index: api/src/main/java/org/jboss/declarchive/api/container/WebContainer.java
===================================================================
--- api/src/main/java/org/jboss/declarchive/api/container/WebContainer.java	(revision 0)
+++ api/src/main/java/org/jboss/declarchive/api/container/WebContainer.java	(revision 0)
@@ -0,0 +1,36 @@
+/*
+ * 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.api.container;
+
+import org.jboss.declarchive.api.Archive;
+
+/**
+ * WebContainer
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ * @param <T>
+ */
+public interface WebContainer<T extends Archive<T>>
+{
+   //-------------------------------------------------------------------------------------||
+   // Contracts --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   T setWebXML(String resourceName);
+}
Index: api/src/main/java/org/jboss/declarchive/api/container/LibraryContainer.java
===================================================================
--- api/src/main/java/org/jboss/declarchive/api/container/LibraryContainer.java	(revision 0)
+++ api/src/main/java/org/jboss/declarchive/api/container/LibraryContainer.java	(revision 0)
@@ -0,0 +1,36 @@
+/*
+ * 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.api.container;
+
+import org.jboss.declarchive.api.Archive;
+
+/**
+ * LibraryContainer
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public interface LibraryContainer<T extends Archive<T>>
+{
+   //-------------------------------------------------------------------------------------||
+   // Contracts --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   T addLibrary(String resourceName);
+   T addLibrary(String resourceName, String newName);
+   T addLibrary(Archive<?> archive);
+}
Index: api/src/main/java/org/jboss/declarchive/api/container/ClassContainer.java
===================================================================
--- api/src/main/java/org/jboss/declarchive/api/container/ClassContainer.java	(revision 0)
+++ api/src/main/java/org/jboss/declarchive/api/container/ClassContainer.java	(revision 0)
@@ -0,0 +1,60 @@
+/*
+ * 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.api.container;
+
+import org.jboss.declarchive.api.Archive;
+
+/**
+ * ClassContainer
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public interface ClassContainer<T extends Archive<T>>
+{
+   //-------------------------------------------------------------------------------------||
+   // Contracts --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Adds the specified Class to the archive
+    * 
+    * @param The class to add
+    * @return This virtual deployment
+    * @throws IllegalArgumentException If no class was specified
+    */
+   T addClass(Class<?> clazz) throws IllegalArgumentException;
+
+   /**
+    * Adds the specified Classes to the archive.  
+    * 
+    * @param classes
+    * @return This virtual archive
+    * @throws IllegalArgumentException If no classes were specified
+    */
+   T addClasses(Class<?>... clazz) throws IllegalArgumentException;
+
+   
+   /**
+    * Adds a whole Package to the archive.
+    * 
+    * @param packages
+    * @return This virtual archive
+    * @throws IllegalArgumentException If no packages were specified
+    */
+   T addPackages(Package... packages) throws IllegalArgumentException;
+}
Index: api/src/main/java/org/jboss/declarchive/api/container/ManifestContainer.java
===================================================================
--- api/src/main/java/org/jboss/declarchive/api/container/ManifestContainer.java	(revision 0)
+++ api/src/main/java/org/jboss/declarchive/api/container/ManifestContainer.java	(revision 0)
@@ -0,0 +1,30 @@
+/*
+ * 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.api.container;
+
+import org.jboss.declarchive.api.Archive;
+
+public interface ManifestContainer<T extends Archive<T>>
+{
+   //-------------------------------------------------------------------------------------||
+   // Contracts --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   T setManifest(String resourceName);
+   T addManifestResource(String resourceName);
+   T addManifestResource(String resourceName, String newName);
+}
Index: api/src/main/java/org/jboss/declarchive/api/container/ResourceContainer.java
===================================================================
--- api/src/main/java/org/jboss/declarchive/api/container/ResourceContainer.java	(revision 0)
+++ api/src/main/java/org/jboss/declarchive/api/container/ResourceContainer.java	(revision 0)
@@ -0,0 +1,111 @@
+/*
+ * 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.api.container;
+
+import org.jboss.declarchive.api.Archive;
+
+/**
+ * ResourceContainer
+ * 
+ * Defines the contract for a component capable of storing 
+ * a series of ClassLoader resources
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public interface ResourceContainer<T extends Archive<T>>
+{
+   //-------------------------------------------------------------------------------------||
+   // Contracts --------------------------------------------------------------------------||
+   //-------------------------------------------------------------------------------------||
+
+   /**
+    * Adds the resource with the specified name
+    * to the container, returning the container itself.
+    * The ClassLoader used to obtain the resource is up to
+    * the implementation.  The resource will be placed into 
+    * the Container under the same context from which it was retrieved.
+    * For instance a name of "META-INF/resource.xml" will be placed
+    * at the same location within the Container.
+    * 
+    * @param name Name of the ClassLoader resource to add
+    * @throws IllegalArgumentException If the name is not specified
+    */
+   T addResource(String name) throws IllegalArgumentException;
+
+   /**
+    * Adds the resource with the specified name
+    * to the container, returning the container itself.
+    * The ClassLoader used to obtain the resource is up to
+    * the implementation.  The resource will be placed into 
+    * the Container under the same context specified by
+    * "locationWithinContainer"
+    * 
+    * @param name Name of the ClassLoader resource to add
+    * @param locationWithinContainer Context within the Container
+    *       under which to place the resource
+    * @throws IllegalArgumentException If the name or location is not specified
+    */
+   T addResource(String name, String locationWithinContainer) throws IllegalArgumentException;
+
+   /**
+    * Adds the specified resource to the archive at the specified Path
+    * 
+    * @param resource
+    * @param path
+    * @return
+    * @throws IllegalArgumentException If either the resource or path is
+    * unspecified
+    */
+   //T addResource(Resource resource, Path path) throws IllegalArgumentException;
+
+   /**
+    * Adds the specified resource to the archive, using the specified ClassLoader
+    * to load the resource
+    * 
+    * @param name
+    * @param cl
+    * @return
+    * @throws IllegalArgumentException If either the name or ClassLoader is not specified
+    */
+   //T addResource(String name, ClassLoader cl) throws IllegalArgumentException;
+
+   /**
+    * Adds the resource located at the specified URL to the archive.  The
+    * location within the archive will be equal to the path portion of the 
+    * specified URL.
+    * 
+    * @param location
+    * @return
+    * @throws IllegalArgumentException If the location is not specified
+    */
+   //T addResource(URL location) throws IllegalArgumentException;
+
+   /**
+    * Adds the resource located at the specified URL to
+    * the archive at the specified path.
+    * 
+    * @param location
+    * @param newPath The new path to assign, or null if 
+    *   the path portion of the location should be used
+    * @return
+    * @throws IllegalArgumentException If the location is not specified 
+    */
+   //T addResource(URL location, String newPath) throws IllegalArgumentException;
+   
+}
Index: api/src/main/java/org/jboss/declarchive/api/Resource.java
===================================================================
--- api/src/main/java/org/jboss/declarchive/api/Resource.java	(revision 0)
+++ api/src/main/java/org/jboss/declarchive/api/Resource.java	(revision 0)
@@ -0,0 +1,56 @@
+/*
+ * 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.api;
+
+import java.io.InputStream;
+
+/**
+ * Represents a Class, file, or any other collection
+ * of bytes stored under some context within an {@link Archive} 
+ * 
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ */
+public interface Resource
+{
+
+   /**
+    * Get the default name for this resource, which will 
+    * be the name under with the resource is placed into
+    * an archive unless explicitly specified otherwise.
+    * 
+    * @return A name for this Resource
+    */
+   String getDefaultName();
+
+   /**
+    * Get the default path for this resource, which will 
+    * be the context under with the resource is placed into
+    * an archive unless explicitly specified otherwise.
+    * 
+    * @return A path for this Resource
+    */
+   Path getDefaultPath();
+
+   /**
+    * Get a open stream for the resource content.
+    * The caller is responsible for closing the stream. 
+    * 
+    * @return A new open inputstream for each call.
+    */
+   InputStream getStream();
+}
Index: api/src/main/java/org/jboss/declarchive/api/ArchiveFactory.java
===================================================================
--- api/src/main/java/org/jboss/declarchive/api/ArchiveFactory.java	(revision 0)
+++ api/src/main/java/org/jboss/declarchive/api/ArchiveFactory.java	(revision 0)
@@ -0,0 +1,104 @@
+package org.jboss.declarchive.api;
+
+import java.lang.reflect.Constructor;
+import java.util.logging.Logger;
+
+public class ArchiveFactory
+{
+   /**
+    * Logger
+    */
+   private static final Logger log = Logger.getLogger(ArchiveFactory.class.getName());
+
+   private static final Class<?>[] ARCHIVE_IMPL_CONSTRUCTOR_ARGUMENTS = new Class[]{String.class};
+   
+   private ArchiveFactory() {  }
+   
+   public static Archive createTmpArchive(String name) 
+   {
+      Class<? extends Archive> implClass = null;
+      try 
+      {
+         implClass = getClass("org.jboss.declarchive.impl.jdkfile.TempFileArchiveImpl")
+            .asSubclass(Archive.class);
+      } 
+      catch (ClassNotFoundException e) 
+      {
+         throw new RuntimeException(
+               "Declarative Archives implementation \"JDK File\" not in classpath", 
+               e);
+      }
+      return createArchive(
+            name, 
+            Archive.class, 
+            implClass);
+   }
+   
+   public static Archive createVirtualArchive(String name) 
+   {
+      Class<? extends Archive> implClass = null;
+      try 
+      {
+         implClass = getClass("org.jboss.declarchive.impl.vfs.MemoryArchiveImpl")
+            .asSubclass(Archive.class);
+      } 
+      catch (ClassNotFoundException e) 
+      {
+         throw new RuntimeException(
+               "Declarative Archives implementation \"Virtual File System\" not in classpath", 
+               e);
+      }
+      return createArchive(
+            name, 
+            Archive.class,
+            implClass);
+   }
+
+   public static <T extends Archive> T createArchive(final String name, final Class<T> archiveType, final Class<? extends T> archiveImpl) 
+   {
+      if(archiveType == null) {
+         throw new IllegalArgumentException("ArchiveType can not be null");
+      }
+      if(archiveImpl == null) {
+         throw new IllegalArgumentException("ArchiveImpl can not be null");
+      }
+      
+      Constructor<?> implConstructor = findConstructor(archiveImpl, ARCHIVE_IMPL_CONSTRUCTOR_ARGUMENTS); 
+      
+      Object archive = null;
+      try 
+      {
+         archive = implConstructor.newInstance(name);
+      } 
+      catch (Exception e) {
+         throw new RuntimeException("Error in creating new " + archiveImpl.getName(), e);
+      }
+      
+      return archiveType.cast(archive);
+   }
+   
+   private static Constructor<?> findConstructor(final Class<?> implClass, final Class<?>[] arguments) 
+   {
+      try 
+      {
+         return SecurityActions.getConstructor(implClass, arguments);
+      } 
+      catch (NoSuchMethodException e) 
+      {
+         throw new RuntimeException("Could not find constructor to be used in factory creation of a new "
+               + Archive.class.getSimpleName(), e);
+      }
+   }
+   
+   /**
+    * Obtains the class with the specified name from the TCCL
+    *  
+    * @param className
+    * @return
+    */
+   static Class<?> getClass(final String className) throws ClassNotFoundException
+   {
+      final ClassLoader cl = SecurityActions.getThreadContextClassLoader();
+      return Class.forName(className, false, cl);
+   }
+}
Index: api/src/main/java/org/jboss/declarchive/api/jar/WebArchive.java
===================================================================
--- api/src/main/java/org/jboss/declarchive/api/jar/WebArchive.java	(revision 0)
+++ api/src/main/java/org/jboss/declarchive/api/jar/WebArchive.java	(revision 0)
@@ -0,0 +1,31 @@
+/*
+ * 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.api.jar;
+
+import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.container.ManifestContainer;
+import org.jboss.declarchive.api.container.WebContainer;
+
+/**
+ * WebArchive
+ *
+ * @author <a href="mailto:aslak@conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ */
+public interface WebArchive extends Archive<WebArchive>, ManifestContainer<WebArchive>, WebContainer<WebArchive>
+{
+}
Index: api/src/main/java/org/jboss/declarchive/api/jar/JavaArchive.java
===================================================================
--- api/src/main/java/org/jboss/declarchive/api/jar/JavaArchive.java	(revision 3449)
+++ api/src/main/java/org/jboss/declarchive/api/jar/JavaArchive.java	(working copy)
@@ -20,6 +20,7 @@
 import java.net.URL;
 
 import org.jboss.declarchive.api.Archive;
+import org.jboss.declarchive.api.container.ResourceContainer;
 
 /**
  * JavaArchive
@@ -31,7 +32,7 @@
  * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
  * @version $Revision: $
  */
-public interface JavaArchive extends Archive<JavaArchive>
+public interface JavaArchive extends Archive<JavaArchive>, ResourceContainer<JavaArchive>
 {
 
    //-------------------------------------------------------------------------------------||
Index: api/src/main/java/org/jboss/declarchive/api/Path.java
===================================================================
--- api/src/main/java/org/jboss/declarchive/api/Path.java	(revision 0)
+++ api/src/main/java/org/jboss/declarchive/api/Path.java	(revision 0)
@@ -0,0 +1,36 @@
+/*
+ * 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.api;
+
+/**
+ * Path
+ * 
+ * Represents a target context within an {@link Archive} under
+ * which a {@link Resource} may be found.
+ *
+ * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface Path
+{
+   /**
+    * Obtains the context which this Path represents
+    * 
+    * @return
+    */
+   String get();
+}
