[jboss-svn-commits] JBoss Common SVN: r3589 - shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Oct 12 13:57:38 EDT 2009
Author: aslak
Date: 2009-10-12 13:57:38 -0400 (Mon, 12 Oct 2009)
New Revision: 3589
Modified:
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/EnterpriseContainerBase.java
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterContainerBase.java
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/WebContainerBase.java
Log:
SHRINKWRAP-51 Added File|URL|Asset overloading methods
Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java 2009-10-12 17:15:32 UTC (rev 3588)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java 2009-10-12 17:57:38 UTC (rev 3589)
@@ -16,10 +16,10 @@
*/
package org.jboss.shrinkwrap.impl.base;
+import java.io.File;
import java.net.URL;
import java.util.Map;
import java.util.Set;
-import java.util.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.Asset;
@@ -32,25 +32,27 @@
import org.jboss.shrinkwrap.impl.base.asset.AssetUtil;
import org.jboss.shrinkwrap.impl.base.asset.ClassAsset;
import org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.impl.base.asset.FileAsset;
import org.jboss.shrinkwrap.impl.base.asset.UrlAsset;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
/**
* ContainerBase
+ *
+ * Abstract class that helps implement the Archive, ManifestContainer, ResourceContainer, ClassContainer
+ * and LibraryContainer.
*
* @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
* @version $Revision: $
* @param <T>
*/
public abstract class ContainerBase<T extends Archive<T>> implements
- Archive<T>, ManifestContainer<T>, ResourceContainer<T>, ClassContainer<T>, LibraryContainer<T>
+ Archive<T>, ManifestContainer<T>, ResourceContainer<T>, ClassContainer<T>, LibraryContainer<T>
{
//-------------------------------------------------------------------------------------||
// Class Members ----------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
- private static final Logger log = Logger.getLogger(ContainerBase.class.getName());
-
//-------------------------------------------------------------------------------------||
// Instance Members -------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -83,26 +85,6 @@
//-------------------------------------------------------------------------------------||
/* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Resource[])
- */
-// @Override
-// public T add(Asset... assets)
-// {
-// archive.add(assets);
-// return covarientReturn();
-// }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Path, org.jboss.declarchive.api.Asset[])
- */
-// @Override
-// public T add(Path path, Asset... assets)
-// {
-// archive.add(path, assets);
-// return covarientReturn();
-// }
-
- /* (non-Javadoc)
* @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Path, org.jboss.declarchive.api.Archive)
*/
@Override
@@ -241,26 +223,118 @@
public final T setManifest(String resourceName)
{
Validate.notNull(resourceName, "ResourceName should be specified");
-
- return add(getManinfestPath(), "MANIFEST.MF", new ClassLoaderAsset(resourceName));
+ return setManifest(new ClassLoaderAsset(resourceName));
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#setManifest(java.io.File)
+ */
+ @Override
+ public T setManifest(File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource should be specified");
+ return setManifest(new FileAsset(resource));
+ }
/* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#setManifest(java.net.URL)
+ */
+ @Override
+ public T setManifest(URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource should be specified");
+ return setManifest(new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#setManifest(org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T setManifest(Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource should be specified");
+ return addManifestResource("MANIFEST.FM", resource);
+ }
+
+ /* (non-Javadoc)
* @see org.jboss.declarchive.api.container.ManifestContainer#addManifestResource(java.lang.String)
*/
@Override
public final T addManifestResource(String resourceName)
{
Validate.notNull(resourceName, "ResourceName should be specified");
+ return addManifestResource(resourceName, new ClassLoaderAsset(resourceName));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResource(java.io.File)
+ */
+ @Override
+ public T addManifestResource(File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource should be specified");
+ return addManifestResource(resource.getName(), new FileAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResource(java.net.URL)
+ */
+ @Override
+ public T addManifestResource(URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource should be specified");
+ return addManifestResource(AssetUtil.getFullPathForURLResource(resource), new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResource(java.lang.String, java.lang.String)
+ */
+ @Override
+ public T addManifestResource(String target, String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resourceName, "ResourceName should be specified");
+
+ return addManifestResource(target, new ClassLoaderAsset(resourceName));
+ }
- // create the Asset
- Asset asset = new ClassLoaderAsset(resourceName);
- // relocate the asset, sub path to the container.
- Path location = new BasicPath(getManinfestPath(), resourceName);
- return add(location, asset);
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResource(java.lang.String, java.io.File)
+ */
+ @Override
+ public T addManifestResource(String target, File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addManifestResource(target, new FileAsset(resource));
}
/* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResource(java.lang.String, java.net.URL)
+ */
+ @Override
+ public T addManifestResource(String target, URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addManifestResource(target, new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResource(java.lang.String, org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T addManifestResource(String target, Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addManifestResource(new BasicPath(target), resource);
+ }
+
+ /* (non-Javadoc)
* @see org.jboss.declarchive.api.container.ManifestContainer#addManifestResource(org.jboss.declarchive.api.Path, java.lang.String)
*/
@Override
@@ -269,9 +343,44 @@
Validate.notNull(target, "Target should be specified");
Validate.notNull(resourceName, "ResourceName should be specified");
- Asset asset = new ClassLoaderAsset(resourceName);
+ return addManifestResource(target, new ClassLoaderAsset(resourceName));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResource(org.jboss.shrinkwrap.api.Path, java.io.File)
+ */
+ @Override
+ public T addManifestResource(Path target, File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addManifestResource(target, new FileAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResource(org.jboss.shrinkwrap.api.Path, java.net.URL)
+ */
+ @Override
+ public T addManifestResource(Path target, URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addManifestResource(target, new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResource(org.jboss.shrinkwrap.api.Path, org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T addManifestResource(Path target, Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
Path location = new BasicPath(getManinfestPath(), target);
- return add(location, asset);
+ return add(location, resource);
}
//-------------------------------------------------------------------------------------||
@@ -293,27 +402,78 @@
public final T addResource(String resourceName) throws IllegalArgumentException
{
Validate.notNull(resourceName, "ResourceName should be specified");
-
- Asset asset = new ClassLoaderAsset(resourceName);
- Path location = new BasicPath(getResourcePath(), resourceName);
- return add(location, asset);
+ return addResource(resourceName, new ClassLoaderAsset(resourceName));
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.ResourceContainer#addResource(java.net.URL)
+ */
+ @Override
+ public final T addResource(File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource should be specified");
+ return addResource(resource.getName(), new FileAsset(resource));
+ }
/* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.ResourceContainer#addResource(java.net.URL)
+ */
+ @Override
+ public final T addResource(URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource should be specified");
+ return addResource(AssetUtil.getFullPathForURLResource(resource), new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
* @see org.jboss.declarchive.api.container.ResourceContainer#addResource(java.lang.String, java.lang.String)
*/
@Override
- public final T addResource(String resourceName, String newName) throws IllegalArgumentException
+ public final T addResource(String target, String resourceName) throws IllegalArgumentException
{
+ Validate.notNull(target, "Target should be specified");
Validate.notNull(resourceName, "ResourceName should be specified");
- Validate.notNull(newName, "NewName should be specified");
- Asset resource = new ClassLoaderAsset(resourceName);
- Path location = new BasicPath(getResourcePath(), AssetUtil.getPathForClassloaderResource(resourceName));
- return add(location, newName, resource);
- };
+ return addResource(target, new ClassLoaderAsset(resourceName));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ResourceContainer#addResource(java.lang.String, java.io.File)
+ */
+ @Override
+ public T addResource(String target, File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addResource(target, new FileAsset(resource));
+ }
/* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ResourceContainer#addResource(java.lang.String, java.net.URL)
+ */
+ @Override
+ public T addResource(String target, URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addResource(AssetUtil.getFullPathForURLResource(resource), new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ResourceContainer#addResource(java.lang.String, org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T addResource(String target, Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addResource(new BasicPath(target), resource);
+ }
+
+ /* (non-Javadoc)
* @see org.jboss.declarchive.api.container.ResourceContainer#addResource(org.jboss.declarchive.api.Path, java.lang.String)
*/
@Override
@@ -322,11 +482,9 @@
Validate.notNull(target, "Target should be specified");
Validate.notNull(resourceName, "ResourceName should be specified");
- Asset asset = new ClassLoaderAsset(resourceName);
- Path location = new BasicPath(getResourcePath(), target);
- return add(location, asset);
+ return addResource(target, new ClassLoaderAsset(resourceName));
}
-
+
/* (non-Javadoc)
* @see org.jboss.declarchive.api.container.ResourceContainer#addResource(org.jboss.declarchive.api.Path, java.lang.String, java.lang.ClassLoader)
*/
@@ -337,10 +495,20 @@
Validate.notNull(resourceName, "ResourceName should be specified");
Validate.notNull(classLoader, "ClassLoader should be specified");
- Asset asset = new ClassLoaderAsset(resourceName, classLoader);
- Path location = new BasicPath(getResourcePath(), target);
- return add(location, asset);
+ return addResource(target, new ClassLoaderAsset(resourceName, classLoader));
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ResourceContainer#addResource(org.jboss.shrinkwrap.api.Path, java.io.File)
+ */
+ @Override
+ public T addResource(Path target, File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addResource(target, new FileAsset(resource));
+ }
/* (non-Javadoc)
* @see org.jboss.declarchive.api.container.ResourceContainer#addResource(org.jboss.declarchive.api.Path, java.net.URL)
@@ -350,23 +518,21 @@
{
Validate.notNull(target, "Target should be specified");
Validate.notNull(resource, "Resource should be specified");
-
- Asset asset = new UrlAsset(resource);
- Path location = new BasicPath(getResourcePath(), target);
- return add(location, asset);
+
+ return addResource(target, new UrlAsset(resource));
}
/* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.ResourceContainer#addResource(java.net.URL)
+ * @see org.jboss.shrinkwrap.api.container.ResourceContainer#addResource(org.jboss.shrinkwrap.api.Path, org.jboss.shrinkwrap.api.Asset)
*/
@Override
- public T addResource(URL resource) throws IllegalArgumentException
+ public T addResource(Path target, Asset resource) throws IllegalArgumentException
{
- Validate.notNull(resource, "Location should be specified");
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
- Asset asset = new UrlAsset(resource);
- Path location = new BasicPath(getResourcePath(), AssetUtil.getFullPathForURLResource(resource));
- return add(location, asset);
+ Path location = new BasicPath(getResourcePath(), target);
+ return add(location, resource);
}
//-------------------------------------------------------------------------------------||
@@ -460,7 +626,6 @@
public T addLibrary(Archive<?> archive) throws IllegalArgumentException
{
Validate.notNull(archive, "Archive must be specified");
-
return add(getLibraryPath(), archive);
};
@@ -471,13 +636,78 @@
public T addLibrary(String resourceName) throws IllegalArgumentException
{
Validate.notNull(resourceName, "ResourceName must be specified");
+ return addLibrary(resourceName, new ClassLoaderAsset(resourceName));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(java.io.File)
+ */
+ @Override
+ public T addLibrary(File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource must be specified");
+ return addLibrary(resource.getName(), new FileAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(java.net.URL)
+ */
+ @Override
+ public T addLibrary(URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource must be specified");
+ return addLibrary(AssetUtil.getFullPathForURLResource(resource), new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(java.lang.String, java.lang.String)
+ */
+ @Override
+ public T addLibrary(String target, String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
- Asset asset = new ClassLoaderAsset(resourceName);
- Path location = new BasicPath(getLibraryPath(), resourceName);
- return add(location, asset);
+ return addLibrary(target, new ClassLoaderAsset(resourceName));
}
/* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(java.lang.String, java.io.File)
+ */
+ @Override
+ public T addLibrary(String target, File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addLibrary(target, new FileAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(java.lang.String, java.net.URL)
+ */
+ @Override
+ public T addLibrary(String target, URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addLibrary(target, new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(java.lang.String, org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T addLibrary(String target, Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addLibrary(new BasicPath(target), resource);
+ }
+
+ /* (non-Javadoc)
* @see org.jboss.declarchive.api.container.LibraryContainer#addLibrary(org.jboss.declarchive.api.Path, java.lang.String)
*/
@Override
@@ -486,9 +716,44 @@
Validate.notNull(target, "Target must be specified");
Validate.notNull(resourceName, "ResourceName must be specified");
- Asset asset = new ClassLoaderAsset(resourceName);
+ return addLibrary(target, new ClassLoaderAsset(resourceName));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(org.jboss.shrinkwrap.api.Path, java.io.File)
+ */
+ @Override
+ public T addLibrary(Path target, File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addLibrary(target, new FileAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(org.jboss.shrinkwrap.api.Path, java.net.URL)
+ */
+ @Override
+ public T addLibrary(Path target, URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addLibrary(target, new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addLibrary(org.jboss.shrinkwrap.api.Path, org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T addLibrary(Path target, Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
Path location = new BasicPath(getLibraryPath(), target);
- return add(location, asset);
+ return add(location, resource);
}
//-------------------------------------------------------------------------------------||
Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/EnterpriseContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/EnterpriseContainerBase.java 2009-10-12 17:15:32 UTC (rev 3588)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/EnterpriseContainerBase.java 2009-10-12 17:57:38 UTC (rev 3589)
@@ -16,7 +16,8 @@
*/
package org.jboss.shrinkwrap.impl.base;
-import java.util.logging.Logger;
+import java.io.File;
+import java.net.URL;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.Asset;
@@ -24,6 +25,8 @@
import org.jboss.shrinkwrap.api.container.EnterpriseContainer;
import org.jboss.shrinkwrap.impl.base.asset.AssetUtil;
import org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.impl.base.asset.FileAsset;
+import org.jboss.shrinkwrap.impl.base.asset.UrlAsset;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
/**
@@ -44,8 +47,6 @@
// Class Members ----------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
- private static final Logger log = Logger.getLogger(EnterpriseContainerBase.class.getName());
-
//-------------------------------------------------------------------------------------||
// Constructor ------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -74,10 +75,121 @@
public T setApplicationXML(String resourceName) throws IllegalArgumentException
{
Validate.notNull(resourceName, "ResourceName must be specified");
- return add(getApplicationPath(), "application.xml", new ClassLoaderAsset(resourceName));
+ return setApplicationXML(new ClassLoaderAsset(resourceName));
}
/* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#setApplicationXML(java.io.File)
+ */
+ @Override
+ public T setApplicationXML(File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource must be specified");
+ return setApplicationXML(new FileAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#setApplicationXML(java.net.URL)
+ */
+ @Override
+ public T setApplicationXML(URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource must be specified");
+ return setApplicationXML(new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#setApplicationXML(org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T setApplicationXML(Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource must be specified");
+ return addApplicationResource("application.xml", resource);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.EnterpriseContainer#addApplicationResource(java.lang.String)
+ */
+ @Override
+ public T addApplicationResource(String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(resourceName, "ResourceName must be specified");
+
+ return addApplicationResource(resourceName, new ClassLoaderAsset(resourceName));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(java.io.File)
+ */
+ @Override
+ public T addApplicationResource(File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addApplicationResource(resource.getName(), new FileAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(java.net.URL)
+ */
+ @Override
+ public T addApplicationResource(URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addApplicationResource(AssetUtil.getFullPathForURLResource(resource), new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(java.lang.String, java.lang.String)
+ */
+ @Override
+ public T addApplicationResource(String target, String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+
+ return addApplicationResource(target, new ClassLoaderAsset(resourceName));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(java.lang.String, java.io.File)
+ */
+ @Override
+ public T addApplicationResource(String target, File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addApplicationResource(target, new FileAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(java.lang.String, java.net.URL)
+ */
+ @Override
+ public T addApplicationResource(String target, URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addApplicationResource(target, new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(java.lang.String, org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T addApplicationResource(String target, Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addApplicationResource(new BasicPath(target), resource);
+ }
+
+ /* (non-Javadoc)
* @see org.jboss.declarchive.api.container.EnterpriseContainer#addApplicationResource(org.jboss.declarchive.api.Path, java.lang.String)
*/
@Override
@@ -86,25 +198,49 @@
Validate.notNull(target, "Target must be specified");
Validate.notNull(resourceName, "ResourceName must be specified");
- Asset asset = new ClassLoaderAsset(resourceName);
- Path location = new BasicPath(getApplicationPath(), target);
- return add(location, asset);
+ return addApplicationResource(target, new ClassLoaderAsset(resourceName));
}
/* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.EnterpriseContainer#addApplicationResource(java.lang.String)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(org.jboss.shrinkwrap.api.Path, java.io.File)
*/
@Override
- public T addApplicationResource(String resourceName) throws IllegalArgumentException
+ public T addApplicationResource(Path target, File resource) throws IllegalArgumentException
{
- Validate.notNull(resourceName, "ResourceName must be specified");
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resource, "Resource must be specified");
- Asset asset = new ClassLoaderAsset(resourceName);
- Path location = new BasicPath(getApplicationPath(), resourceName);
- return add(location, asset);
+ return addApplicationResource(target, new FileAsset(resource));
}
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(org.jboss.shrinkwrap.api.Path, java.net.URL)
+ */
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(org.jboss.shrinkwrap.api.Path, java.net.URL)
+ */
+ @Override
+ public T addApplicationResource(Path target, URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addApplicationResource(target, new UrlAsset(resource));
+ }
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(org.jboss.shrinkwrap.api.Path, org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T addApplicationResource(Path target, Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ Path location = new BasicPath(getApplicationPath(), target);
+ return add(location, resource);
+ }
+
//-------------------------------------------------------------------------------------||
// Required Implementations - EnterpriseContainer - Modules ---------------------------||
//-------------------------------------------------------------------------------------||
@@ -125,8 +261,7 @@
{
Validate.notNull(archive, "Archive must be specified");
- Path location = getModulePath();
- return add(location, archive);
+ return add(getModulePath(), archive);
}
/* (non-Javadoc)
@@ -141,4 +276,30 @@
Path location = new BasicPath(getModulePath(), AssetUtil.getNameForClassloaderResource(resourceName));
return add(location, asset);
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(java.io.File)
+ */
+ @Override
+ public T addModule(File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource must be specified");
+
+ Asset asset = new FileAsset(resource);
+ Path location = new BasicPath(getModulePath(), resource.getName());
+ return add(location, asset);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(java.net.URL)
+ */
+ @Override
+ public T addModule(URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource must be specified");
+
+ Asset asset = new UrlAsset(resource);
+ Path location = new BasicPath(getModulePath(), AssetUtil.getFullPathForURLResource(resource));
+ return add(location, asset);
+ }
}
Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterContainerBase.java 2009-10-12 17:15:32 UTC (rev 3588)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterContainerBase.java 2009-10-12 17:57:38 UTC (rev 3589)
@@ -16,11 +16,16 @@
*/
package org.jboss.shrinkwrap.impl.base;
-import java.util.logging.Logger;
+import java.io.File;
+import java.net.URL;
import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.Asset;
import org.jboss.shrinkwrap.api.container.ResourceAdapterContainer;
import org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.impl.base.asset.FileAsset;
+import org.jboss.shrinkwrap.impl.base.asset.UrlAsset;
+import org.jboss.shrinkwrap.impl.base.path.BasicPath;
/**
* ResourceAdapterContainerBase
@@ -29,6 +34,7 @@
* Used by specs that extends the ResourceAdapter.
*
* @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
* @version $Revision: $
* @param <T>
*/
@@ -37,12 +43,6 @@
ResourceAdapterContainer<T>
{
//-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(ResourceAdapterContainerBase.class.getName());
-
- //-------------------------------------------------------------------------------------||
// Constructor ------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -62,7 +62,29 @@
public T setResourceAdapterXML(String resourceName) throws IllegalArgumentException
{
Validate.notNull(resourceName, "ResourceName must be specified");
- return add(getManinfestPath(), "ra.xml", new ClassLoaderAsset(resourceName));
+ return setResourceAdapterXML(new ClassLoaderAsset(resourceName));
+
}
+
+ @Override
+ public T setResourceAdapterXML(File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource must be specified");
+ return setResourceAdapterXML(new FileAsset(resource));
+ }
+
+ @Override
+ public T setResourceAdapterXML(URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource must be specified");
+ return setResourceAdapterXML(new UrlAsset(resource));
+ }
+
+ @Override
+ public T setResourceAdapterXML(Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource must be specified");
+ return addResource(new BasicPath(getResourcePath(), "ra.xml"), resource);
+ }
}
Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/WebContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/WebContainerBase.java 2009-10-12 17:15:32 UTC (rev 3588)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/WebContainerBase.java 2009-10-12 17:57:38 UTC (rev 3589)
@@ -16,13 +16,17 @@
*/
package org.jboss.shrinkwrap.impl.base;
-import java.util.logging.Logger;
+import java.io.File;
+import java.net.URL;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.Asset;
import org.jboss.shrinkwrap.api.Path;
import org.jboss.shrinkwrap.api.container.WebContainer;
+import org.jboss.shrinkwrap.impl.base.asset.AssetUtil;
import org.jboss.shrinkwrap.impl.base.asset.ClassLoaderAsset;
+import org.jboss.shrinkwrap.impl.base.asset.FileAsset;
+import org.jboss.shrinkwrap.impl.base.asset.UrlAsset;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
/**
@@ -42,10 +46,12 @@
//-------------------------------------------------------------------------------------||
// Class Members ----------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
-
- private static final Logger log = Logger.getLogger(WebContainerBase.class.getName());
//-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ //-------------------------------------------------------------------------------------||
// Constructor ------------------------------------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -73,10 +79,121 @@
public T setWebXML(String resourceName) throws IllegalArgumentException
{
Validate.notNull(resourceName, "ResourceName should be specified");
- return add(getWebPath(), "web.xml", new ClassLoaderAsset(resourceName));
+ return setWebXML(new ClassLoaderAsset(resourceName));
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#setWebXML(java.io.File)
+ */
+ @Override
+ public T setWebXML(File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource should be specified");
+ return setWebXML(new FileAsset(resource));
+ }
/* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#setWebXML(java.net.URL)
+ */
+ @Override
+ public T setWebXML(URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource should be specified");
+ return setWebXML(new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#setWebXML(org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T setWebXML(Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource should be specified");
+ return addWebResource("web.xml", resource);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.WebContainer#addWebResource(java.lang.String)
+ */
+ @Override
+ public T addWebResource(String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(resourceName, "ResourceName should be specified");
+
+ return addWebResource(AssetUtil.getNameForClassloaderResource(resourceName), new ClassLoaderAsset(resourceName));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(java.io.File)
+ */
+ @Override
+ public T addWebResource(File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addWebResource(resource.getName(), new FileAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(java.net.URL)
+ */
+ @Override
+ public T addWebResource(URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addWebResource(AssetUtil.getFullPathForURLResource(resource), new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(java.lang.String, java.lang.String)
+ */
+ @Override
+ public T addWebResource(String target, String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resourceName, "ResourceName should be specified");
+
+ return addWebResource(new BasicPath(target), new ClassLoaderAsset(resourceName));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(java.lang.String, java.io.File)
+ */
+ @Override
+ public T addWebResource(String target, File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addWebResource(new BasicPath(target), new FileAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(java.lang.String, java.net.URL)
+ */
+ @Override
+ public T addWebResource(String target, URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addWebResource(new BasicPath(target), new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(java.lang.String, org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T addWebResource(String target, Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addWebResource(new BasicPath(target), resource);
+ }
+
+ /* (non-Javadoc)
* @see org.jboss.declarchive.api.container.WebContainer#addWebResource(org.jboss.declarchive.api.Path, java.lang.String)
*/
@Override
@@ -85,22 +202,43 @@
Validate.notNull(target, "Target should be specified");
Validate.notNull(resourceName, "ResourceName should be specified");
- Asset asset = new ClassLoaderAsset(resourceName);
- Path location = new BasicPath(getWebPath(), target);
- return add(location, asset);
+ return addWebResource(target, new ClassLoaderAsset(resourceName));
}
/* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.WebContainer#addWebResource(java.lang.String)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(org.jboss.shrinkwrap.api.Path, java.io.File)
*/
@Override
- public T addWebResource(String resourceName) throws IllegalArgumentException
+ public T addWebResource(Path target, File resource) throws IllegalArgumentException
{
- Validate.notNull(resourceName, "ResourceName should be specified");
-
- Asset asset = new ClassLoaderAsset(resourceName);
- Path location = new BasicPath(getWebPath(), resourceName);
- return add(location, asset);
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addWebResource(target, new FileAsset(resource));
}
-
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(org.jboss.shrinkwrap.api.Path, java.net.URL)
+ */
+ @Override
+ public T addWebResource(Path target, URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addWebResource(target, new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(org.jboss.shrinkwrap.api.Path, org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T addWebResource(Path target, Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ Path location = new BasicPath(getWebPath(), target);
+ return add(location, resource);
+ }
}
More information about the jboss-svn-commits
mailing list