[jboss-svn-commits] JBoss Common SVN: r3661 - 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
Wed Nov 11 05:14:43 EST 2009
Author: aslak
Date: 2009-11-11 05:14:41 -0500 (Wed, 11 Nov 2009)
New Revision: 3661
Added:
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/
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/ResourceAdapterContainerBase.java
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/WebContainerBase.java
Removed:
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
Modified:
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/EnterpriseArchiveImpl.java
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/JavaArchiveImpl.java
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/ResourceAdapterArchiveImpl.java
shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/WebArchiveImpl.java
Log:
SHRINKWRAP-69 Moved *ContainerBase classes down to impl.base.container package
Deleted: 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-11-11 10:01:28 UTC (rev 3660)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ContainerBase.java 2009-11-11 10:14:41 UTC (rev 3661)
@@ -1,755 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.shrinkwrap.impl.base;
-
-import java.io.File;
-import java.net.URL;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.Asset;
-import org.jboss.shrinkwrap.api.Path;
-import org.jboss.shrinkwrap.api.container.ClassContainer;
-import org.jboss.shrinkwrap.api.container.LibraryContainer;
-import org.jboss.shrinkwrap.api.container.ManifestContainer;
-import org.jboss.shrinkwrap.api.container.ResourceContainer;
-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>> extends SpecializedBase implements
- Archive<T>, ManifestContainer<T>, ResourceContainer<T>, ClassContainer<T>, LibraryContainer<T>
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- //-------------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * The backing storage engine.
- */
- private final Archive<?> archive;
-
- /**
- * The exposed archive type.
- */
- private final Class<T> actualType;
-
- //-------------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- protected ContainerBase(Class<T> actualType, Archive<?> archive)
- {
- Validate.notNull(actualType, "ActualType should be specified");
- Validate.notNull(archive, "Archive should be specified");
-
- this.actualType = actualType;
- this.archive = archive;
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations - Archive Delegation --------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Path, org.jboss.declarchive.api.Archive)
- */
- @Override
- public T add(Path path, Archive<?> archive)
- {
- this.archive.add(path, archive);
- 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 target, Asset asset) throws IllegalArgumentException
- {
- archive.add(target, asset);
- return covarientReturn();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Path, java.lang.String, org.jboss.declarchive.api.Asset)
- */
- @Override
- public T add(Path path, String name, Asset asset)
- {
- archive.add(path, name, asset);
- return covarientReturn();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#merge(org.jboss.declarchive.api.Archive)
- */
- @Override
- public T merge(Archive<?> source) throws IllegalArgumentException
- {
- archive.merge(source);
- return covarientReturn();
- }
-
- @Override
- public T merge(Path path, Archive<?> source) throws IllegalArgumentException
- {
- archive.merge(path, source);
- return covarientReturn();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#add(java.lang.String, org.jboss.declarchive.api.Asset)
- */
- @Override
- public T add(String name, Asset asset)
- {
- archive.add(name, asset);
- return covarientReturn();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#contains(org.jboss.declarchive.api.Path)
- */
- @Override
- public boolean contains(Path path)
- {
- return archive.contains(path);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#delete(org.jboss.declarchive.api.Path)
- */
- @Override
- public boolean delete(Path path)
- {
- return archive.delete(path);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#get(org.jboss.declarchive.api.Path)
- */
- @Override
- public Asset get(Path path)
- {
- return archive.get(path);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#get(java.lang.String)
- */
- @Override
- public Asset get(String path) throws IllegalArgumentException
- {
- return archive.get(path);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#getContent()
- */
- @Override
- public Map<Path, Asset> getContent()
- {
- return archive.getContent();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#getName()
- */
- @Override
- public String getName()
- {
- return archive.getName();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.Archive#toString(boolean)
- */
- @Override
- public String toString(boolean verbose)
- {
- return archive.toString(verbose);
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations - SpecializedBase -----------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /* (non-Javadoc)
- * @see org.jboss.shrinkwrap.impl.base.SpecializedBase#getArchive()
- */
- @Override
- protected Archive<?> getArchive()
- {
- return archive;
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations - ManifestContainer ---------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Should be implemented to set the path for Manifest related
- * resources.
- *
- * @return Base Path for the ManifestContainer resources
- */
- protected abstract Path getManinfestPath();
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.ManifestContainer#setManifest(java.lang.String)
- */
- @Override
- public final T setManifest(String resourceName)
- {
- Validate.notNull(resourceName, "ResourceName should be specified");
- 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.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));
- }
-
- /* (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
- public T addManifestResource(Path 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));
- }
-
- /* (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, resource);
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations - ResourceContainer ---------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Should be implemented to set the path for Resource related
- * resources.
- *
- * @return Base Path for the ResourceContainer resources
- */
- protected abstract Path getResourcePath();
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.ResourceContainer#addResource(java.lang.String)
- */
- @Override
- public final T addResource(String resourceName) throws IllegalArgumentException
- {
- Validate.notNull(resourceName, "ResourceName should be specified");
- 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.lang.String, java.lang.String)
- */
- @Override
- public final T addResource(String target, String resourceName) throws IllegalArgumentException
- {
- Validate.notNull(target, "Target should be specified");
- Validate.notNull(resourceName, "ResourceName should be specified");
-
- 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(target, 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
- public T addResource(Path target, String resourceName) throws IllegalArgumentException
- {
- Validate.notNull(target, "Target should be specified");
- Validate.notNull(resourceName, "ResourceName should be specified");
-
- 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)
- */
- @Override
- public T addResource(Path target, String resourceName, ClassLoader classLoader) throws IllegalArgumentException
- {
- Validate.notNull(target, "Target should be specified");
- Validate.notNull(resourceName, "ResourceName should be specified");
- Validate.notNull(classLoader, "ClassLoader should be specified");
-
- 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)
- */
- @Override
- public T addResource(Path target, URL resource) throws IllegalArgumentException
- {
- Validate.notNull(target, "Target should be specified");
- Validate.notNull(resource, "Resource should be specified");
-
- return addResource(target, new UrlAsset(resource));
- }
-
- /* (non-Javadoc)
- * @see org.jboss.shrinkwrap.api.container.ResourceContainer#addResource(org.jboss.shrinkwrap.api.Path, org.jboss.shrinkwrap.api.Asset)
- */
- @Override
- public T addResource(Path target, Asset resource) throws IllegalArgumentException
- {
- Validate.notNull(target, "Target should be specified");
- Validate.notNull(resource, "Resource should be specified");
-
- Path location = new BasicPath(getResourcePath(), target);
- return add(location, resource);
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations - ClassContainer ------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Should be implemented to set the path for Class related
- * resources.
- *
- * @return Base Path for the ClassContainer resources
- */
- protected abstract Path getClassesPath();
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.ClassContainer#addClass(java.lang.Class)
- */
- @Override
- public T addClass(Class<?> clazz) throws IllegalArgumentException
- {
- Validate.notNull(clazz, "Clazz must be specified");
-
- return addClasses(clazz);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.ClassContainer#addClasses(java.lang.Class<?>[])
- */
- public T addClasses(Class<?>... classes) throws IllegalArgumentException
- {
- Validate.notNull(classes, "Classes must be specified");
-
- for(Class<?> clazz : classes)
- {
- Asset resource = new ClassAsset(clazz);
- Path location = new BasicPath(getClassesPath(), AssetUtil.getFullPathForClassResource(clazz));
- add(location, resource);
- }
- return covarientReturn();
- };
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.ClassContainer#addPackage(java.lang.Package)
- */
- @Override
- public T addPackage(Package pack) throws IllegalArgumentException
- {
- Validate.notNull(pack, "Pack must be specified");
-
- return addPackages(false, pack);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.ClassContainer#addPackages(boolean, java.lang.Package[])
- */
- @Override
- public T addPackages(boolean recursive, Package... packages) throws IllegalArgumentException
- {
- Validate.notNull(packages, "Packages must be specified");
-
- for(Package pack : packages)
- {
- URLPackageScanner scanner = new URLPackageScanner(
- pack, recursive, Thread.currentThread().getContextClassLoader());
- Set<Class<?>> classes = scanner.getClasses();
- for(Class<?> clazz : classes)
- {
- Asset asset = new ClassAsset(clazz);
- Path location = new BasicPath(getClassesPath(), AssetUtil.getFullPathForClassResource(clazz));
- add(location, asset);
- }
- }
- return covarientReturn();
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations - LibraryContainer ----------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Should be implemented to set the path for Library related
- * resources.
- *
- * @return Base Path for the LibraryContainer resources
- */
- protected abstract Path getLibraryPath();
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.LibraryContainer#addLibrary(org.jboss.declarchive.api.Archive)
- */
- public T addLibrary(Archive<?> archive) throws IllegalArgumentException
- {
- Validate.notNull(archive, "Archive must be specified");
- return add(getLibraryPath(), archive);
- };
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.LibraryContainer#addLibrary(java.lang.String)
- */
- @Override
- 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.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");
-
- 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
- public T addLibrary(Path target, String resourceName) throws IllegalArgumentException
- {
- Validate.notNull(target, "Target must be specified");
- Validate.notNull(resourceName, "ResourceName must be specified");
-
- 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, resource);
- }
-
- //-------------------------------------------------------------------------------------||
- // Internal Helper Methods ------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- protected T covarientReturn()
- {
- return getActualClass().cast(this);
- }
-
- protected Class<T> getActualClass()
- {
- return this.actualType;
- }
-
-}
Deleted: 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-11-11 10:01:28 UTC (rev 3660)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/EnterpriseContainerBase.java 2009-11-11 10:14:41 UTC (rev 3661)
@@ -1,357 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.shrinkwrap.impl.base;
-
-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.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;
-
-/**
- * EnterpriseContainerSupport
- *
- * Abstract class that helps implement the EnterpriseContainer.
- * Used by specs that extends the EnterpriseContainer.
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- * @param <T>
- */
-public abstract class EnterpriseContainerBase<T extends Archive<T>>
- extends ContainerBase<T>
- implements EnterpriseContainer<T>
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- //-------------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- protected EnterpriseContainerBase(Class<T> actualType, Archive<?> archive)
- {
- super(actualType, archive);
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations - EnterpriseContainer - Resources -------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Should be implemented to set the path for Application related
- * resources.
- *
- * @return Base Path for the EnterpriseContainer application resources
- */
- protected abstract Path getApplicationPath();
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.EnterpriseContainer#setApplicationXML(java.lang.String)
- */
- @Override
- public T setApplicationXML(String resourceName) throws IllegalArgumentException
- {
- Validate.notNull(resourceName, "ResourceName must be specified");
- 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.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
- public T addApplicationResource(Path 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(org.jboss.shrinkwrap.api.Path, java.io.File)
- */
- @Override
- public T addApplicationResource(Path 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(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 ---------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Should be implemented to set the path for Module related
- * resources.
- *
- * @return Base Path for the EnterpriseContainer module resources
- */
- protected abstract Path getModulePath();
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.EnterpriseContainer#addModule(org.jboss.declarchive.api.Archive)
- */
- @Override
- public T addModule(Archive<?> archive) throws IllegalArgumentException
- {
- Validate.notNull(archive, "Archive must be specified");
-
- return add(getModulePath(), archive);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.EnterpriseContainer#addModule(java.lang.String)
- */
- @Override
- public T addModule(String resourceName)
- {
- Validate.notNull(resourceName, "ResourceName must be specified");
-
- Path location = new BasicPath(AssetUtil.getNameForClassloaderResource(resourceName));
- return addModule(location, resourceName);
- }
-
- /* (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");
-
- Path location = new BasicPath(resource.getName());
- return addModule(location, resource);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(org.jboss.shrinkwrap.api.Path, java.io.File)
- */
- @Override
- public T addModule(final Path targetPath, final File resource) throws IllegalArgumentException
- {
- Validate.notNull(targetPath, "Target Path must be specified");
- Validate.notNull(resource, "Resource must be specified");
-
- final Asset asset = new FileAsset(resource);
- final Path location = new BasicPath(getModulePath(), targetPath);
- return add(location, asset);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(org.jboss.shrinkwrap.api.Path, java.lang.String)
- */
- @Override
- public T addModule(final Path targetPath, final String resourceName) throws IllegalArgumentException
- {
- Validate.notNull(targetPath, "Target Path must be specified");
- Validate.notNull(resourceName, "ResourceName must be specified");
-
- final Asset asset = new ClassLoaderAsset(resourceName);
- final Path location = new BasicPath(getModulePath(), targetPath);
- return add(location, asset);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(org.jboss.shrinkwrap.api.Path, java.net.URL)
- */
- @Override
- public T addModule(final Path targetPath, final URL resource) throws IllegalArgumentException
- {
- Validate.notNull(targetPath, "Target Path must be specified");
- Validate.notNull(resource, "Resource must be specified");
-
- Asset asset = new UrlAsset(resource);
- Path location = new BasicPath(getModulePath(),targetPath);
- return add(location, asset);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(java.lang.String, java.io.File)
- */
- @Override
- public T addModule(final String targetPath, final File resource) throws IllegalArgumentException
- {
- Validate.notNull(targetPath, "Target Path must be specified");
- Validate.notNull(resource, "Resource must be specified");
-
- return addModule(new BasicPath(targetPath), resource);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(java.lang.String, java.lang.String)
- */
- @Override
- public T addModule(final String targetPath, final String resourceName) throws IllegalArgumentException
- {
- Validate.notNull(targetPath, "Target Path must be specified");
- Validate.notNull(resourceName, "Resource must be specified");
-
- return addModule(new BasicPath(targetPath), resourceName);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(java.lang.String, java.net.URL)
- */
- @Override
- public T addModule(final String targetPath, final URL resource) throws IllegalArgumentException
- {
- Validate.notNull(targetPath, "Target Path must be specified");
- Validate.notNull(resource, "Resource must be specified");
-
- return addModule(new BasicPath(targetPath), resource);
- }
-}
Deleted: 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-11-11 10:01:28 UTC (rev 3660)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/ResourceAdapterContainerBase.java 2009-11-11 10:14:41 UTC (rev 3661)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.shrinkwrap.impl.base;
-
-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
- *
- * Abstract class that helps implement the ResourceAdapter.
- * 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>
- */
-public abstract class ResourceAdapterContainerBase<T extends Archive<T>> extends ContainerBase<T>
- implements
- ResourceAdapterContainer<T>
-{
- //-------------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- protected ResourceAdapterContainerBase(Class<T> actualType, Archive<?> archive)
- {
- super(actualType, archive);
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations - ResourceAdapterContainer - Resources --------------------||
- //-------------------------------------------------------------------------------------||
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.RContainer#setApplicationXML(java.lang.String)
- */
- @Override
- public T setResourceAdapterXML(String resourceName) throws IllegalArgumentException
- {
- Validate.notNull(resourceName, "ResourceName must be specified");
- 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);
- }
-
-}
Deleted: 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-11-11 10:01:28 UTC (rev 3660)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/WebContainerBase.java 2009-11-11 10:14:41 UTC (rev 3661)
@@ -1,233 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.shrinkwrap.impl.base;
-
-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;
-
-/**
- * WebContainerBase
- *
- * Abstract class that helps implement the WebContainer.
- * Used by specs that extends the WebContainer.
- *
- * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
- * @version $Revision: $
- * @param <T>
- */
-public abstract class WebContainerBase<T extends Archive<T>>
- extends ContainerBase<T>
- implements WebContainer<T>
-{
- //-------------------------------------------------------------------------------------||
- // Class Members ----------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- //-------------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- //-------------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- protected WebContainerBase(Class<T> actualType, Archive<?> archive)
- {
- super(actualType, archive);
- }
-
- //-------------------------------------------------------------------------------------||
- // Required Implementations - WebContainer --------------------------------------------||
- //-------------------------------------------------------------------------------------||
-
- /**
- * Should be implemented to set the path for Manifest related
- * resources.
- *
- * @return Base Path for the ManifestContainer resources
- */
- protected abstract Path getWebPath();
-
- /* (non-Javadoc)
- * @see org.jboss.declarchive.api.container.WebContainer#setWebXML(java.lang.String)
- */
- @Override
- public T setWebXML(String resourceName) throws IllegalArgumentException
- {
- Validate.notNull(resourceName, "ResourceName should be specified");
- 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.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
- public T addWebResource(Path target, String resourceName) throws IllegalArgumentException
- {
- Validate.notNull(target, "Target should be specified");
- Validate.notNull(resourceName, "ResourceName should be specified");
-
- return addWebResource(target, new ClassLoaderAsset(resourceName));
- }
-
- /* (non-Javadoc)
- * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(org.jboss.shrinkwrap.api.Path, java.io.File)
- */
- @Override
- public T addWebResource(Path target, File resource) throws IllegalArgumentException
- {
- 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);
- }
-}
Copied: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java (from rev 3645, 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/container/ContainerBase.java (rev 0)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ContainerBase.java 2009-11-11 10:14:41 UTC (rev 3661)
@@ -0,0 +1,758 @@
+/*
+ * 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.shrinkwrap.impl.base.container;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.Asset;
+import org.jboss.shrinkwrap.api.Path;
+import org.jboss.shrinkwrap.api.container.ClassContainer;
+import org.jboss.shrinkwrap.api.container.LibraryContainer;
+import org.jboss.shrinkwrap.api.container.ManifestContainer;
+import org.jboss.shrinkwrap.api.container.ResourceContainer;
+import org.jboss.shrinkwrap.impl.base.SpecializedBase;
+import org.jboss.shrinkwrap.impl.base.URLPackageScanner;
+import org.jboss.shrinkwrap.impl.base.Validate;
+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>> extends SpecializedBase implements
+ Archive<T>, ManifestContainer<T>, ResourceContainer<T>, ClassContainer<T>, LibraryContainer<T>
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * The backing storage engine.
+ */
+ private final Archive<?> archive;
+
+ /**
+ * The exposed archive type.
+ */
+ private final Class<T> actualType;
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ protected ContainerBase(Class<T> actualType, Archive<?> archive)
+ {
+ Validate.notNull(actualType, "ActualType should be specified");
+ Validate.notNull(archive, "Archive should be specified");
+
+ this.actualType = actualType;
+ this.archive = archive;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations - Archive Delegation --------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Path, org.jboss.declarchive.api.Archive)
+ */
+ @Override
+ public T add(Path path, Archive<?> archive)
+ {
+ this.archive.add(path, archive);
+ 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 target, Asset asset) throws IllegalArgumentException
+ {
+ archive.add(target, asset);
+ return covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.Archive#add(org.jboss.declarchive.api.Path, java.lang.String, org.jboss.declarchive.api.Asset)
+ */
+ @Override
+ public T add(Path path, String name, Asset asset)
+ {
+ archive.add(path, name, asset);
+ return covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.Archive#merge(org.jboss.declarchive.api.Archive)
+ */
+ @Override
+ public T merge(Archive<?> source) throws IllegalArgumentException
+ {
+ archive.merge(source);
+ return covarientReturn();
+ }
+
+ @Override
+ public T merge(Path path, Archive<?> source) throws IllegalArgumentException
+ {
+ archive.merge(path, source);
+ return covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.Archive#add(java.lang.String, org.jboss.declarchive.api.Asset)
+ */
+ @Override
+ public T add(String name, Asset asset)
+ {
+ archive.add(name, asset);
+ return covarientReturn();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.Archive#contains(org.jboss.declarchive.api.Path)
+ */
+ @Override
+ public boolean contains(Path path)
+ {
+ return archive.contains(path);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.Archive#delete(org.jboss.declarchive.api.Path)
+ */
+ @Override
+ public boolean delete(Path path)
+ {
+ return archive.delete(path);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.Archive#get(org.jboss.declarchive.api.Path)
+ */
+ @Override
+ public Asset get(Path path)
+ {
+ return archive.get(path);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.Archive#get(java.lang.String)
+ */
+ @Override
+ public Asset get(String path) throws IllegalArgumentException
+ {
+ return archive.get(path);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.Archive#getContent()
+ */
+ @Override
+ public Map<Path, Asset> getContent()
+ {
+ return archive.getContent();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.Archive#getName()
+ */
+ @Override
+ public String getName()
+ {
+ return archive.getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.Archive#toString(boolean)
+ */
+ @Override
+ public String toString(boolean verbose)
+ {
+ return archive.toString(verbose);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations - SpecializedBase -----------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.impl.base.SpecializedBase#getArchive()
+ */
+ @Override
+ protected Archive<?> getArchive()
+ {
+ return archive;
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations - ManifestContainer ---------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Should be implemented to set the path for Manifest related
+ * resources.
+ *
+ * @return Base Path for the ManifestContainer resources
+ */
+ protected abstract Path getManinfestPath();
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.ManifestContainer#setManifest(java.lang.String)
+ */
+ @Override
+ public final T setManifest(String resourceName)
+ {
+ Validate.notNull(resourceName, "ResourceName should be specified");
+ 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.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));
+ }
+
+ /* (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
+ public T addManifestResource(Path 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));
+ }
+
+ /* (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, resource);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations - ResourceContainer ---------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Should be implemented to set the path for Resource related
+ * resources.
+ *
+ * @return Base Path for the ResourceContainer resources
+ */
+ protected abstract Path getResourcePath();
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.ResourceContainer#addResource(java.lang.String)
+ */
+ @Override
+ public final T addResource(String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(resourceName, "ResourceName should be specified");
+ 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.lang.String, java.lang.String)
+ */
+ @Override
+ public final T addResource(String target, String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resourceName, "ResourceName should be specified");
+
+ 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(target, 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
+ public T addResource(Path target, String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resourceName, "ResourceName should be specified");
+
+ 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)
+ */
+ @Override
+ public T addResource(Path target, String resourceName, ClassLoader classLoader) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resourceName, "ResourceName should be specified");
+ Validate.notNull(classLoader, "ClassLoader should be specified");
+
+ 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)
+ */
+ @Override
+ public T addResource(Path target, URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ return addResource(target, new UrlAsset(resource));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.ResourceContainer#addResource(org.jboss.shrinkwrap.api.Path, org.jboss.shrinkwrap.api.Asset)
+ */
+ @Override
+ public T addResource(Path target, Asset resource) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resource, "Resource should be specified");
+
+ Path location = new BasicPath(getResourcePath(), target);
+ return add(location, resource);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations - ClassContainer ------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Should be implemented to set the path for Class related
+ * resources.
+ *
+ * @return Base Path for the ClassContainer resources
+ */
+ protected abstract Path getClassesPath();
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.ClassContainer#addClass(java.lang.Class)
+ */
+ @Override
+ public T addClass(Class<?> clazz) throws IllegalArgumentException
+ {
+ Validate.notNull(clazz, "Clazz must be specified");
+
+ return addClasses(clazz);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.ClassContainer#addClasses(java.lang.Class<?>[])
+ */
+ public T addClasses(Class<?>... classes) throws IllegalArgumentException
+ {
+ Validate.notNull(classes, "Classes must be specified");
+
+ for(Class<?> clazz : classes)
+ {
+ Asset resource = new ClassAsset(clazz);
+ Path location = new BasicPath(getClassesPath(), AssetUtil.getFullPathForClassResource(clazz));
+ add(location, resource);
+ }
+ return covarientReturn();
+ };
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.ClassContainer#addPackage(java.lang.Package)
+ */
+ @Override
+ public T addPackage(Package pack) throws IllegalArgumentException
+ {
+ Validate.notNull(pack, "Pack must be specified");
+
+ return addPackages(false, pack);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.ClassContainer#addPackages(boolean, java.lang.Package[])
+ */
+ @Override
+ public T addPackages(boolean recursive, Package... packages) throws IllegalArgumentException
+ {
+ Validate.notNull(packages, "Packages must be specified");
+
+ for(Package pack : packages)
+ {
+ URLPackageScanner scanner = new URLPackageScanner(
+ pack, recursive, Thread.currentThread().getContextClassLoader());
+ Set<Class<?>> classes = scanner.getClasses();
+ for(Class<?> clazz : classes)
+ {
+ Asset asset = new ClassAsset(clazz);
+ Path location = new BasicPath(getClassesPath(), AssetUtil.getFullPathForClassResource(clazz));
+ add(location, asset);
+ }
+ }
+ return covarientReturn();
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations - LibraryContainer ----------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Should be implemented to set the path for Library related
+ * resources.
+ *
+ * @return Base Path for the LibraryContainer resources
+ */
+ protected abstract Path getLibraryPath();
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.LibraryContainer#addLibrary(org.jboss.declarchive.api.Archive)
+ */
+ public T addLibrary(Archive<?> archive) throws IllegalArgumentException
+ {
+ Validate.notNull(archive, "Archive must be specified");
+ return add(getLibraryPath(), archive);
+ };
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.LibraryContainer#addLibrary(java.lang.String)
+ */
+ @Override
+ 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.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");
+
+ 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
+ public T addLibrary(Path target, String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+
+ 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, resource);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ protected T covarientReturn()
+ {
+ return getActualClass().cast(this);
+ }
+
+ protected Class<T> getActualClass()
+ {
+ return this.actualType;
+ }
+
+}
Copied: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/EnterpriseContainerBase.java (from rev 3659, 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/container/EnterpriseContainerBase.java (rev 0)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/EnterpriseContainerBase.java 2009-11-11 10:14:41 UTC (rev 3661)
@@ -0,0 +1,358 @@
+/*
+ * 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.shrinkwrap.impl.base.container;
+
+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.EnterpriseContainer;
+import org.jboss.shrinkwrap.impl.base.Validate;
+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;
+
+/**
+ * EnterpriseContainerSupport
+ *
+ * Abstract class that helps implement the EnterpriseContainer.
+ * Used by specs that extends the EnterpriseContainer.
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ * @param <T>
+ */
+public abstract class EnterpriseContainerBase<T extends Archive<T>>
+ extends ContainerBase<T>
+ implements EnterpriseContainer<T>
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ protected EnterpriseContainerBase(Class<T> actualType, Archive<?> archive)
+ {
+ super(actualType, archive);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations - EnterpriseContainer - Resources -------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Should be implemented to set the path for Application related
+ * resources.
+ *
+ * @return Base Path for the EnterpriseContainer application resources
+ */
+ protected abstract Path getApplicationPath();
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.EnterpriseContainer#setApplicationXML(java.lang.String)
+ */
+ @Override
+ public T setApplicationXML(String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(resourceName, "ResourceName must be specified");
+ 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.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
+ public T addApplicationResource(Path 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(org.jboss.shrinkwrap.api.Path, java.io.File)
+ */
+ @Override
+ public T addApplicationResource(Path 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(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 ---------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Should be implemented to set the path for Module related
+ * resources.
+ *
+ * @return Base Path for the EnterpriseContainer module resources
+ */
+ protected abstract Path getModulePath();
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.EnterpriseContainer#addModule(org.jboss.declarchive.api.Archive)
+ */
+ @Override
+ public T addModule(Archive<?> archive) throws IllegalArgumentException
+ {
+ Validate.notNull(archive, "Archive must be specified");
+
+ return add(getModulePath(), archive);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.EnterpriseContainer#addModule(java.lang.String)
+ */
+ @Override
+ public T addModule(String resourceName)
+ {
+ Validate.notNull(resourceName, "ResourceName must be specified");
+
+ Path location = new BasicPath(AssetUtil.getNameForClassloaderResource(resourceName));
+ return addModule(location, resourceName);
+ }
+
+ /* (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");
+
+ Path location = new BasicPath(resource.getName());
+ return addModule(location, resource);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(org.jboss.shrinkwrap.api.Path, java.io.File)
+ */
+ @Override
+ public T addModule(final Path targetPath, final File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(targetPath, "Target Path must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ final Asset asset = new FileAsset(resource);
+ final Path location = new BasicPath(getModulePath(), targetPath);
+ return add(location, asset);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(org.jboss.shrinkwrap.api.Path, java.lang.String)
+ */
+ @Override
+ public T addModule(final Path targetPath, final String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(targetPath, "Target Path must be specified");
+ Validate.notNull(resourceName, "ResourceName must be specified");
+
+ final Asset asset = new ClassLoaderAsset(resourceName);
+ final Path location = new BasicPath(getModulePath(), targetPath);
+ return add(location, asset);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(org.jboss.shrinkwrap.api.Path, java.net.URL)
+ */
+ @Override
+ public T addModule(final Path targetPath, final URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(targetPath, "Target Path must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ Asset asset = new UrlAsset(resource);
+ Path location = new BasicPath(getModulePath(),targetPath);
+ return add(location, asset);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(java.lang.String, java.io.File)
+ */
+ @Override
+ public T addModule(final String targetPath, final File resource) throws IllegalArgumentException
+ {
+ Validate.notNull(targetPath, "Target Path must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addModule(new BasicPath(targetPath), resource);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(java.lang.String, java.lang.String)
+ */
+ @Override
+ public T addModule(final String targetPath, final String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(targetPath, "Target Path must be specified");
+ Validate.notNull(resourceName, "Resource must be specified");
+
+ return addModule(new BasicPath(targetPath), resourceName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.EnterpriseContainer#addModule(java.lang.String, java.net.URL)
+ */
+ @Override
+ public T addModule(final String targetPath, final URL resource) throws IllegalArgumentException
+ {
+ Validate.notNull(targetPath, "Target Path must be specified");
+ Validate.notNull(resource, "Resource must be specified");
+
+ return addModule(new BasicPath(targetPath), resource);
+ }
+}
Copied: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ResourceAdapterContainerBase.java (from rev 3600, 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/container/ResourceAdapterContainerBase.java (rev 0)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/ResourceAdapterContainerBase.java 2009-11-11 10:14:41 UTC (rev 3661)
@@ -0,0 +1,91 @@
+/*
+ * 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.shrinkwrap.impl.base.container;
+
+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.Validate;
+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
+ *
+ * Abstract class that helps implement the ResourceAdapter.
+ * 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>
+ */
+public abstract class ResourceAdapterContainerBase<T extends Archive<T>> extends ContainerBase<T>
+ implements
+ ResourceAdapterContainer<T>
+{
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ protected ResourceAdapterContainerBase(Class<T> actualType, Archive<?> archive)
+ {
+ super(actualType, archive);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations - ResourceAdapterContainer - Resources --------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.RContainer#setApplicationXML(java.lang.String)
+ */
+ @Override
+ public T setResourceAdapterXML(String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(resourceName, "ResourceName must be specified");
+ 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);
+ }
+
+}
Copied: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/WebContainerBase.java (from rev 3600, 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/container/WebContainerBase.java (rev 0)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/container/WebContainerBase.java 2009-11-11 10:14:41 UTC (rev 3661)
@@ -0,0 +1,234 @@
+/*
+ * 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.shrinkwrap.impl.base.container;
+
+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.Validate;
+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;
+
+/**
+ * WebContainerBase
+ *
+ * Abstract class that helps implement the WebContainer.
+ * Used by specs that extends the WebContainer.
+ *
+ * @author <a href="mailto:aslak at conduct.no">Aslak Knutsen</a>
+ * @version $Revision: $
+ * @param <T>
+ */
+public abstract class WebContainerBase<T extends Archive<T>>
+ extends ContainerBase<T>
+ implements WebContainer<T>
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ //-------------------------------------------------------------------------------------||
+ // Constructor ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ protected WebContainerBase(Class<T> actualType, Archive<?> archive)
+ {
+ super(actualType, archive);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Required Implementations - WebContainer --------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Should be implemented to set the path for Manifest related
+ * resources.
+ *
+ * @return Base Path for the ManifestContainer resources
+ */
+ protected abstract Path getWebPath();
+
+ /* (non-Javadoc)
+ * @see org.jboss.declarchive.api.container.WebContainer#setWebXML(java.lang.String)
+ */
+ @Override
+ public T setWebXML(String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(resourceName, "ResourceName should be specified");
+ 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.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
+ public T addWebResource(Path target, String resourceName) throws IllegalArgumentException
+ {
+ Validate.notNull(target, "Target should be specified");
+ Validate.notNull(resourceName, "ResourceName should be specified");
+
+ return addWebResource(target, new ClassLoaderAsset(resourceName));
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.shrinkwrap.api.container.WebContainer#addWebResource(org.jboss.shrinkwrap.api.Path, java.io.File)
+ */
+ @Override
+ public T addWebResource(Path target, File resource) throws IllegalArgumentException
+ {
+ 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);
+ }
+}
Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/EnterpriseArchiveImpl.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/EnterpriseArchiveImpl.java 2009-11-11 10:01:28 UTC (rev 3660)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/EnterpriseArchiveImpl.java 2009-11-11 10:14:41 UTC (rev 3661)
@@ -21,7 +21,7 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.Path;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
-import org.jboss.shrinkwrap.impl.base.EnterpriseContainerBase;
+import org.jboss.shrinkwrap.impl.base.container.EnterpriseContainerBase;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
/**
Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/JavaArchiveImpl.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/JavaArchiveImpl.java 2009-11-11 10:01:28 UTC (rev 3660)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/JavaArchiveImpl.java 2009-11-11 10:14:41 UTC (rev 3661)
@@ -21,7 +21,7 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.Path;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.jboss.shrinkwrap.impl.base.ContainerBase;
+import org.jboss.shrinkwrap.impl.base.container.ContainerBase;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
/**
Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/ResourceAdapterArchiveImpl.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/ResourceAdapterArchiveImpl.java 2009-11-11 10:01:28 UTC (rev 3660)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/ResourceAdapterArchiveImpl.java 2009-11-11 10:14:41 UTC (rev 3661)
@@ -21,7 +21,7 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.Path;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
-import org.jboss.shrinkwrap.impl.base.ResourceAdapterContainerBase;
+import org.jboss.shrinkwrap.impl.base.container.ResourceAdapterContainerBase;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
/**
Modified: shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/WebArchiveImpl.java
===================================================================
--- shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/WebArchiveImpl.java 2009-11-11 10:01:28 UTC (rev 3660)
+++ shrinkwrap/trunk/impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/spec/WebArchiveImpl.java 2009-11-11 10:14:41 UTC (rev 3661)
@@ -21,7 +21,7 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.Path;
import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.impl.base.WebContainerBase;
+import org.jboss.shrinkwrap.impl.base.container.WebContainerBase;
import org.jboss.shrinkwrap.impl.base.path.BasicPath;
/**
More information about the jboss-svn-commits
mailing list