[jboss-svn-commits] JBoss Common SVN: r4264 - in shrinkwrap/trunk: impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Apr 17 11:29:01 EDT 2010
Author: aslak
Date: 2010-04-17 11:29:01 -0400 (Sat, 17 Apr 2010)
New Revision: 4264
Modified:
shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/EnterpriseContainer.java
shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/ManifestContainer.java
shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/ResourceContainer.java
shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/WebContainer.java
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/EnterpriseContainerBase.java
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/WebContainerBase.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicContainerTestBase.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicEnterpriseContainerTestBase.java
shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java
Log:
SHRINKWRAP-150 Added addXXX(Package, Resource). Adds resources from the specified package.
Modified: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/EnterpriseContainer.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/EnterpriseContainer.java 2010-04-16 16:11:08 UTC (rev 4263)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/EnterpriseContainer.java 2010-04-17 15:29:01 UTC (rev 4264)
@@ -249,6 +249,62 @@
T addApplicationResource(Asset resource, ArchivePath target) throws IllegalArgumentException;
/**
+ * Adds the resources inside the package as multiple resources to the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resources
+ * @param resourceNames The names of the resources inside resoucePackage
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if no resourceNames are specified or containing null
+ */
+ T addApplicationResources(Package resourcePackage, String... resourceNames) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource as a resource to the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resource
+ * @param resourceName The name of the resource inside resoucePackage
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if resourceName is null
+ */
+ T addApplicationResource(Package resourcePackage, String resourceName) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource as a resource to a specific path inside the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resource
+ * @param resourceName The name of the resource inside resoucePackage
+ * @param target The target location inside the container
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if resourceName is null
+ * @throws IllegalArgumentException if target is null
+ */
+ T addApplicationResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource as a resource to a specific path inside the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resource
+ * @param resourceName The name of the resource inside resoucePackage
+ * @param target The target location inside the container
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if resourceName is null
+ * @throws IllegalArgumentException if target is null
+ */
+ T addApplicationResource(Package resourcePackage, String resourceName, ArchivePath target) throws IllegalArgumentException;
+
+ /**
* Adds a archive to this {@link Archive}s module context.
* <br/><br/>
* The {@link Archive} name is used as path.
Modified: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/ManifestContainer.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/ManifestContainer.java 2010-04-16 16:11:08 UTC (rev 4263)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/ManifestContainer.java 2010-04-17 15:29:01 UTC (rev 4264)
@@ -211,8 +211,64 @@
* @throws IllegalArgumentException if target is null
*/
T addManifestResource(Asset resource, ArchivePath target) throws IllegalArgumentException;
+
+ /**
+ * Adds the resources inside the package as multiple resources to the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resources
+ * @param resourceNames The names of the resources inside resoucePackage
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if no resourceNames are specified or containing null
+ */
+ T addManifestResources(Package resourcePackage, String... resourceNames) throws IllegalArgumentException;
/**
+ * Adds the resource as a resource to the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resource
+ * @param resourceName The name of the resource inside resoucePackage
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if resourceName is null
+ */
+ T addManifestResource(Package resourcePackage, String resourceName) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource as a resource to a specific path inside the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resource
+ * @param resourceName The name of the resource inside resoucePackage
+ * @param target The target location inside the container
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if resourceName is null
+ * @throws IllegalArgumentException if target is null
+ */
+ T addManifestResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource as a resource to a specific path inside the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resource
+ * @param resourceName The name of the resource inside resoucePackage
+ * @param target The target location inside the container
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if resourceName is null
+ * @throws IllegalArgumentException if target is null
+ */
+ T addManifestResource(Package resourcePackage, String resourceName, ArchivePath target) throws IllegalArgumentException;
+
+ /**
* Adds a META-INF/services/ServiceInterfaceName {@link Asset} representing this service.
*
* Warning: this method does not add the specified classes to the archive.
Modified: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/ResourceContainer.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/ResourceContainer.java 2010-04-16 16:11:08 UTC (rev 4263)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/ResourceContainer.java 2010-04-17 15:29:01 UTC (rev 4264)
@@ -180,4 +180,60 @@
* @throws IllegalArgumentException if target is null
*/
T addResource(Asset resource, ArchivePath target) throws IllegalArgumentException;
+
+ /**
+ * Adds the resources inside the package as multiple resources to the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resources
+ * @param resourceNames The names of the resources inside resoucePackage
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if no resourceNames are specified or containing null
+ */
+ T addResources(Package resourcePackage, String... resourceNames) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource as a resource to the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resource
+ * @param resourceName The name of the resource inside resoucePackage
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if resourceName is null
+ */
+ T addResource(Package resourcePackage, String resourceName) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource as a resource to a specific path inside the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resource
+ * @param resourceName The name of the resource inside resoucePackage
+ * @param target The target location inside the container
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if resourceName is null
+ * @throws IllegalArgumentException if target is null
+ */
+ T addResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource as a resource to a specific path inside the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resource
+ * @param resourceName The name of the resource inside resoucePackage
+ * @param target The target location inside the container
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if resourceName is null
+ * @throws IllegalArgumentException if target is null
+ */
+ T addResource(Package resourcePackage, String resourceName, ArchivePath target) throws IllegalArgumentException;
}
Modified: shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/WebContainer.java
===================================================================
--- shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/WebContainer.java 2010-04-16 16:11:08 UTC (rev 4263)
+++ shrinkwrap/trunk/api/src/main/java/org/jboss/shrinkwrap/api/container/WebContainer.java 2010-04-17 15:29:01 UTC (rev 4264)
@@ -212,4 +212,60 @@
* @throws IllegalArgumentException if target is null
*/
T addWebResource(Asset resource, ArchivePath target) throws IllegalArgumentException;
+
+ /**
+ * Adds the resources inside the package as multiple resources to the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resources
+ * @param resourceNames The names of the resources inside resoucePackage
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if no resourceNames are specified or containing null
+ */
+ T addWebResources(Package resourcePackage, String... resourceNames) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource as a resource to the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resource
+ * @param resourceName The name of the resource inside resoucePackage
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if resourceName is null
+ */
+ T addWebResource(Package resourcePackage, String resourceName) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource as a resource to a specific path inside the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resource
+ * @param resourceName The name of the resource inside resoucePackage
+ * @param target The target location inside the container
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if resourceName is null
+ * @throws IllegalArgumentException if target is null
+ */
+ T addWebResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException;
+
+ /**
+ * Adds the resource as a resource to a specific path inside the container, returning the container itself.
+ * <br/><br/>
+ * The {@link ClassLoader} used to obtain the resource is up to the implementation.
+ *
+ * @param resourcePackage The package of the resource
+ * @param resourceName The name of the resource inside resoucePackage
+ * @param target The target location inside the container
+ * @return This virtual archive
+ * @throws IllegalArgumentException if resourcePackage is null
+ * @throws IllegalArgumentException if resourceName is null
+ * @throws IllegalArgumentException if target is null
+ */
+ T addWebResource(Package resourcePackage, String resourceName, ArchivePath target) throws IllegalArgumentException;
}
Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java 2010-04-16 16:11:08 UTC (rev 4263)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java 2010-04-17 15:29:01 UTC (rev 4264)
@@ -25,6 +25,7 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Asset;
import org.jboss.shrinkwrap.api.Filter;
import org.jboss.shrinkwrap.api.Filters;
@@ -501,7 +502,70 @@
return add(resource, location);
}
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResources(java.lang.Package, java.lang.String[])
+ */
@Override
+ public T addManifestResources(Package resourcePackage, String... resourceNames) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNullAndNoNullValues(resourceNames, "ResourceNames must be specified and can not container null values");
+ for(String resourceName : resourceNames)
+ {
+ addManifestResource(resourcePackage, resourceName);
+ }
+ return covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResource(java.lang.Package, java.lang.String)
+ */
+ @Override
+ public T addManifestResource(Package resourcePackage, String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+
+ String classloaderResourceName = AssetUtil.getClassLoaderResourceName(resourcePackage, resourceName);
+ ArchivePath target = ArchivePaths.create(classloaderResourceName);
+
+ return addManifestResource(resourcePackage, resourceName, target);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResource(java.lang.Package, java.lang.String, java.lang.String)
+ */
+ @Override
+ public T addManifestResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+ Validate.notNull(target, "Target must be specified");
+
+ return addManifestResource(resourcePackage, resourceName, ArchivePaths.create(target));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addManifestResource(java.lang.Package, java.lang.String, org.jboss.shrinkwrap.api.ArchivePath)
+ */
+ @Override
+ public T addManifestResource(Package resourcePackage, String resourceName, ArchivePath target) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+ Validate.notNull(target, "Target must be specified");
+
+ String classloaderResourceName = AssetUtil.getClassLoaderResourceName(resourcePackage, resourceName);
+ Asset resource = new ClassLoaderAsset(classloaderResourceName);
+
+ return addManifestResource(resource, target);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ManifestContainer#addServiceProvider(java.lang.Class, java.lang.Class<?>[])
+ */
+ @Override
public T addServiceProvider(Class<?> serviceInterface, Class<?>... serviceImpls) throws IllegalArgumentException
{
Validate.notNull(serviceInterface, "ServiceInterface must be specified");
@@ -654,6 +718,65 @@
return add(resource, location);
}
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ResourceContainer#addResources(java.lang.Package, java.lang.String[])
+ */
+ @Override
+ public T addResources(Package resourcePackage, String... resourceNames) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNullAndNoNullValues(resourceNames, "ResourceNames must be specified and can not container null values");
+ for(String resourceName : resourceNames)
+ {
+ addResource(resourcePackage, resourceName);
+ }
+ return covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ResourceContainer#addResource(java.lang.Package, java.lang.String)
+ */
+ @Override
+ public T addResource(Package resourcePackage, String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+
+ String classloaderResourceName = AssetUtil.getClassLoaderResourceName(resourcePackage, resourceName);
+ ArchivePath target = ArchivePaths.create(classloaderResourceName);
+
+ return addResource(resourcePackage, resourceName, target);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ResourceContainer#addResource(java.lang.Package, java.lang.String, java.lang.String)
+ */
+ @Override
+ public T addResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+ Validate.notNull(target, "Target must be specified");
+
+ return addResource(resourcePackage, resourceName, ArchivePaths.create(target));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ResourceContainer#addResource(java.lang.Package, java.lang.String, org.jboss.shrinkwrap.api.ArchivePath)
+ */
+ @Override
+ public T addResource(Package resourcePackage, String resourceName, ArchivePath target) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+ Validate.notNull(target, "Target must be specified");
+
+ String classloaderResourceName = AssetUtil.getClassLoaderResourceName(resourcePackage, resourceName);
+ Asset resource = new ClassLoaderAsset(classloaderResourceName);
+
+ return addResource(resource, target);
+ }
+
//-------------------------------------------------------------------------------------||
// Required Implementations - ClassContainer ------------------------------------------||
//-------------------------------------------------------------------------------------||
Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/EnterpriseContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/EnterpriseContainerBase.java 2010-04-16 16:11:08 UTC (rev 4263)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/EnterpriseContainerBase.java 2010-04-17 15:29:01 UTC (rev 4264)
@@ -20,6 +20,7 @@
import java.net.URL;
import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Asset;
import org.jboss.shrinkwrap.api.ArchivePath;
import org.jboss.shrinkwrap.api.container.EnterpriseContainer;
@@ -227,6 +228,65 @@
ArchivePath location = new BasicPath(getApplicationPath(), target);
return add(resource, location);
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResources(java.lang.Package, java.lang.String[])
+ */
+ @Override
+ public T addApplicationResources(Package resourcePackage, String... resourceNames) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNullAndNoNullValues(resourceNames, "ResourceNames must be specified and can not container null values");
+ for(String resourceName : resourceNames)
+ {
+ addApplicationResource(resourcePackage, resourceName);
+ }
+ return covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(java.lang.Package, java.lang.String)
+ */
+ @Override
+ public T addApplicationResource(Package resourcePackage, String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+
+ String classloaderResourceName = AssetUtil.getClassLoaderResourceName(resourcePackage, resourceName);
+ ArchivePath target = ArchivePaths.create(classloaderResourceName);
+
+ return addApplicationResource(resourcePackage, resourceName, target);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(java.lang.Package, java.lang.String, java.lang.String)
+ */
+ @Override
+ public T addApplicationResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+ Validate.notNull(target, "Target must be specified");
+
+ return addApplicationResource(resourcePackage, resourceName, ArchivePaths.create(target));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addApplicationResource(java.lang.Package, java.lang.String, org.jboss.shrinkwrap.api.ArchivePath)
+ */
+ @Override
+ public T addApplicationResource(Package resourcePackage, String resourceName, ArchivePath target) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+ Validate.notNull(target, "Target must be specified");
+
+ String classloaderResourceName = AssetUtil.getClassLoaderResourceName(resourcePackage, resourceName);
+ Asset resource = new ClassLoaderAsset(classloaderResourceName);
+
+ return addApplicationResource(resource, target);
+ }
//-------------------------------------------------------------------------------------||
// Required Implementations - EnterpriseContainer - Modules ---------------------------||
Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/WebContainerBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/WebContainerBase.java 2010-04-16 16:11:08 UTC (rev 4263)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/WebContainerBase.java 2010-04-17 15:29:01 UTC (rev 4264)
@@ -20,6 +20,7 @@
import java.net.URL;
import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Asset;
import org.jboss.shrinkwrap.api.ArchivePath;
import org.jboss.shrinkwrap.api.container.WebContainer;
@@ -231,4 +232,63 @@
ArchivePath location = new BasicPath(getWebPath(), target);
return add(resource, location);
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResources(java.lang.Package, java.lang.String[])
+ */
+ @Override
+ public T addWebResources(Package resourcePackage, String... resourceNames) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNullAndNoNullValues(resourceNames, "ResourceNames must be specified and can not container null values");
+ for(String resourceName : resourceNames)
+ {
+ addWebResource(resourcePackage, resourceName);
+ }
+ return covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(java.lang.Package, java.lang.String)
+ */
+ @Override
+ public T addWebResource(Package resourcePackage, String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+
+ String classloaderResourceName = AssetUtil.getClassLoaderResourceName(resourcePackage, resourceName);
+ ArchivePath target = ArchivePaths.create(classloaderResourceName);
+
+ return addWebResource(resourcePackage, resourceName, target);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(java.lang.Package, java.lang.String, java.lang.String)
+ */
+ @Override
+ public T addWebResource(Package resourcePackage, String resourceName, String target) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+ Validate.notNull(target, "Target must be specified");
+
+ return addWebResource(resourcePackage, resourceName, ArchivePaths.create(target));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(java.lang.Package, java.lang.String, org.jboss.shrinkwrap.api.ArchivePath)
+ */
+ @Override
+ public T addWebResource(Package resourcePackage, String resourceName, ArchivePath target) throws IllegalArgumentException
+ {
+ Validate.notNull(resourcePackage, "ResourcePackage must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+ Validate.notNull(target, "Target must be specified");
+
+ String classloaderResourceName = AssetUtil.getClassLoaderResourceName(resourcePackage, resourceName);
+ Asset resource = new ClassLoaderAsset(classloaderResourceName);
+
+ return addWebResource(resource, target);
+ }
}
Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicContainerTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicContainerTestBase.java 2010-04-16 16:11:08 UTC (rev 4263)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicContainerTestBase.java 2010-04-17 15:29:01 UTC (rev 4264)
@@ -23,6 +23,7 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Asset;
import org.jboss.shrinkwrap.api.Filter;
import org.jboss.shrinkwrap.api.container.ClassContainer;
@@ -279,6 +280,57 @@
getArchive().contains(testPath));
}
+ @Test
+ @ArchiveType(ManifestContainer.class)
+ public void testAddManifestPackage() throws Exception {
+ getManifestContainer().addManifestResource(AssetUtil.class.getPackage(), "Test.properties");
+
+ ArchivePath testPath = new BasicPath(getManifestPath(), NAME_TEST_PROPERTIES);
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(ManifestContainer.class)
+ public void testAddManifestPackages() throws Exception {
+ getManifestContainer().addManifestResources(AssetUtil.class.getPackage(), "Test.properties", "Test2.properties");
+
+ ArchivePath testPath = new BasicPath(getManifestPath(), NAME_TEST_PROPERTIES);
+ ArchivePath testPath2 = new BasicPath(getManifestPath(), NAME_TEST_PROPERTIES_2);
+
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ Assert.assertTrue(
+ "Archive should contain " + testPath2,
+ getArchive().contains(testPath2));
+ }
+
+ @Test
+ @ArchiveType(ManifestContainer.class)
+ public void testAddManifestPackageStringTarget() throws Exception {
+ getManifestContainer().addManifestResource(AssetUtil.class.getPackage(), "Test.properties", "Test.txt");
+
+ ArchivePath testPath = new BasicPath(getManifestPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(ManifestContainer.class)
+ public void testAddManifestPackagePathTarget() throws Exception {
+ ArchivePath targetPath = ArchivePaths.create("Test.txt");
+
+ getManifestContainer().addManifestResource(AssetUtil.class.getPackage(), "Test.properties", targetPath);
+
+ ArchivePath testPath = new BasicPath(getManifestPath(), targetPath);
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
//-------------------------------------------------------------------------------------||
// Test Implementations - ResourceContainer -------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -405,7 +457,60 @@
"Archive should contain " + testPath,
getArchive().contains(testPath));
}
+
+ @Test
+ @ArchiveType(ResourceContainer.class)
+ public void testAddResourcePackage() throws Exception {
+ getResourceContainer().addResource(AssetUtil.class.getPackage(), "Test.properties");
+
+ ArchivePath testPath = new BasicPath(getResourcePath(), NAME_TEST_PROPERTIES);
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(ResourceContainer.class)
+ public void testAddResourcePackages() throws Exception {
+ getResourceContainer().addResources(AssetUtil.class.getPackage(), "Test.properties", "Test2.properties");
+
+ ArchivePath testPath = new BasicPath(getResourcePath(), NAME_TEST_PROPERTIES);
+ ArchivePath testPath2 = new BasicPath(getResourcePath(), NAME_TEST_PROPERTIES_2);
+
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ Assert.assertTrue(
+ "Archive should contain " + testPath2,
+ getArchive().contains(testPath2));
+ }
+ @Test
+ @ArchiveType(ResourceContainer.class)
+ public void testAddResourcePackageStringTarget() throws Exception {
+
+ getResourceContainer().addResource(AssetUtil.class.getPackage(), "Test.properties", "Test.txt");
+
+ ArchivePath testPath = new BasicPath(getResourcePath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(ResourceContainer.class)
+ public void testAddResourcePackagePathTarget() throws Exception {
+
+ ArchivePath targetPath = ArchivePaths.create("Test.txt");
+
+ getResourceContainer().addResource(AssetUtil.class.getPackage(), "Test.properties", targetPath);
+
+ ArchivePath testPath = new BasicPath(getResourcePath(), targetPath);
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
//-------------------------------------------------------------------------------------||
// Test Implementations - ClassContainer ----------------------------------------------||
//-------------------------------------------------------------------------------------||
@@ -565,7 +670,7 @@
*/
@Test
@ArchiveType(ClassContainer.class)
- public void testAddPakcageRecursiveFiltered() throws Exception
+ public void testAddPackageRecursiveFiltered() throws Exception
{
getClassContainer().addPackages(true, new Filter<Class<?>>()
{
Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicEnterpriseContainerTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicEnterpriseContainerTestBase.java 2010-04-16 16:11:08 UTC (rev 4263)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicEnterpriseContainerTestBase.java 2010-04-17 15:29:01 UTC (rev 4264)
@@ -20,7 +20,9 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.container.EnterpriseContainer;
+import org.jboss.shrinkwrap.impl.base.asset.AssetUtil;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
import org.junit.Test;
@@ -207,6 +209,59 @@
@Test
@ArchiveType(EnterpriseContainer.class)
+ public void testAddAplicationResourcePackage() throws Exception {
+ getEnterpriseContainer().addApplicationResource(AssetUtil.class.getPackage(), "Test.properties");
+
+ ArchivePath testPath = new BasicPath(getApplicationPath(), NAME_TEST_PROPERTIES);
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationResourcePackages() throws Exception {
+ getEnterpriseContainer().addApplicationResources(AssetUtil.class.getPackage(), "Test.properties", "Test2.properties");
+
+ ArchivePath testPath = new BasicPath(getApplicationPath(), NAME_TEST_PROPERTIES);
+ ArchivePath testPath2 = new BasicPath(getApplicationPath(), NAME_TEST_PROPERTIES_2);
+
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ Assert.assertTrue(
+ "Archive should contain " + testPath2,
+ getArchive().contains(testPath2));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationResourcePackageStringTarget() throws Exception {
+
+ getEnterpriseContainer().addApplicationResource(AssetUtil.class.getPackage(), "Test.properties", "Test.txt");
+
+ ArchivePath testPath = new BasicPath(getApplicationPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
+ public void testAddApplicationResourcePackagePathTarget() throws Exception {
+
+ ArchivePath targetPath = ArchivePaths.create("Test.txt");
+
+ getEnterpriseContainer().addApplicationResource(AssetUtil.class.getPackage(), "Test.properties", targetPath);
+
+ ArchivePath testPath = new BasicPath(getApplicationPath(), targetPath);
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(EnterpriseContainer.class)
public void testAddModuleResource() throws Exception {
getEnterpriseContainer().addModule(NAME_TEST_PROPERTIES);
Modified: shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java 2010-04-16 16:11:08 UTC (rev 4263)
+++ shrinkwrap/trunk/impl-base/src/test/java/org/jboss/shrinkwrap/impl/base/test/DynamicWebContainerTestBase.java 2010-04-17 15:29:01 UTC (rev 4264)
@@ -20,7 +20,9 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.container.WebContainer;
+import org.jboss.shrinkwrap.impl.base.asset.AssetUtil;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
import org.junit.Test;
@@ -202,4 +204,57 @@
"Archive should contain " + testPath,
getArchive().contains(testPath));
}
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourcePackage() throws Exception {
+ getWebContainer().addWebResource(AssetUtil.class.getPackage(), "Test.properties");
+
+ ArchivePath testPath = new BasicPath(getWebPath(), NAME_TEST_PROPERTIES);
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourcePackages() throws Exception {
+ getWebContainer().addWebResources(AssetUtil.class.getPackage(), "Test.properties", "Test2.properties");
+
+ ArchivePath testPath = new BasicPath(getWebPath(), NAME_TEST_PROPERTIES);
+ ArchivePath testPath2 = new BasicPath(getWebPath(), NAME_TEST_PROPERTIES_2);
+
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ Assert.assertTrue(
+ "Archive should contain " + testPath2,
+ getArchive().contains(testPath2));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourcePackageStringTarget() throws Exception {
+
+ getWebContainer().addWebResource(AssetUtil.class.getPackage(), "Test.properties", "Test.txt");
+
+ ArchivePath testPath = new BasicPath(getWebPath(), "Test.txt");
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
+
+ @Test
+ @ArchiveType(WebContainer.class)
+ public void testAddWebResourcePackagePathTarget() throws Exception {
+
+ ArchivePath targetPath = ArchivePaths.create("Test.txt");
+
+ getWebContainer().addWebResource(AssetUtil.class.getPackage(), "Test.properties", targetPath);
+
+ ArchivePath testPath = new BasicPath(getWebPath(), targetPath);
+ Assert.assertTrue(
+ "Archive should contain " + testPath,
+ getArchive().contains(testPath));
+ }
}
More information about the jboss-svn-commits
mailing list