org.jboss.shrinkwrap.api.container
Interface ClassContainer<T extends Archive<T>>

All Superinterfaces:
ResourceContainer<T>
All Known Subinterfaces:
JavaArchive, ServiceProviderContainer<T>, WebArchive

public interface ClassContainer<T extends Archive<T>>
extends ResourceContainer<T>

Defines the contract for a component capable of storing Java Classes.

The actual path to the Class resources within the Archive is up to the implementations/specifications.

Version:
$Revision: $
Author:
Aslak Knutsen

Method Summary
 T addClass(Class<?> clazz)
          Adds the Class, and all member (inner) Classes to the Archive.
 T addClass(String fullyQualifiedClassName)
          Adds the Class, and all member (inner) Classes, with the specified fully-qualified name, loaded by the Thread Context ClassLoader, to the Archive.
 T addClass(String fullyQualifiedClassName, ClassLoader cl)
          Adds the Class, and all member (inner) @link{Class}es, with the specified fully-qualified name, loaded by the specified ClassLoader, to the Archive.
 T addClasses(Class<?>... classes)
          Adds the Classes, and all member (inner) Classes to the Archive.
 T addDefaultPackage()
          Adds all classes in the default Package to the Archive.
 T addPackage(Package pack)
          Adds all classes in the specified Package to the Archive.
 T addPackage(String pack)
          Adds all classes in the specified Package to the Archive.
 T addPackages(boolean recursive, Filter<ArchivePath> filter, Package... packages)
          Adds all classes accepted by the filter in the specified Packages to the Archive.
 T addPackages(boolean recursive, Filter<ArchivePath> filter, String... packages)
          Adds all classes accepted by the filter in the specified Packages to the Archive.
 T addPackages(boolean recursive, Package... packages)
          Adds all classes in the specified Packages to the Archive.
 T addPackages(boolean recursive, String... packages)
          Adds all classes in the specified Packages to the Archive.
 
Methods inherited from interface org.jboss.shrinkwrap.api.container.ResourceContainer
addAsResource, addAsResource, addAsResource, addAsResource, addAsResource, addAsResource, addAsResource, addAsResource, addAsResource, addAsResource, addAsResource, addAsResource, addAsResource, addAsResource, addAsResources
 

Method Detail

addClass

T addClass(Class<?> clazz)
                              throws IllegalArgumentException
Adds the Class, and all member (inner) Classes to the Archive.

Parameters:
class - The class to add to the Archive
Returns:
This archive
Throws:
IllegalArgumentException - If no class were specified

addClass

T addClass(String fullyQualifiedClassName)
                              throws IllegalArgumentException
Adds the Class, and all member (inner) Classes, with the specified fully-qualified name, loaded by the Thread Context ClassLoader, to the Archive.

Parameters:
fullyQualifiedClassName - The name of the Class to add
Returns:
This archive
Throws:
IllegalArgumentException - If no class name was specified
IllegalArgumentException - If the Class could not be loaded

addClass

T addClass(String fullyQualifiedClassName,
           ClassLoader cl)
                              throws IllegalArgumentException
Adds the Class, and all member (inner) @link{Class}es, with the specified fully-qualified name, loaded by the specified ClassLoader, to the Archive.

Parameters:
fullyQualifiedClassName - The name of the Class to add
cl - The ClassLoader used to load the Class
Returns:
This archive
Throws:
IllegalArgumentException - If no class name was specified
IllegalArgumentException - If no ClassLoader was specified
IllegalArgumentException - If the Class could not be loaded by the target ClassLoader

addClasses

T addClasses(Class<?>... classes)
                                throws IllegalArgumentException
Adds the Classes, and all member (inner) Classes to the Archive.

Parameters:
classes - The classes to add to the Archive
Returns:
This archive
Throws:
IllegalArgumentException - If no classes were specified

addPackage

T addPackage(Package pack)
                                throws IllegalArgumentException
Adds all classes in the specified Package to the Archive.
SubPackages are excluded.

Parameters:
pack - The Package to add
Returns:
This virtual archive
Throws:
IllegalArgumentException - If no package were specified
See Also:
addPackages(boolean, Package...)

addDefaultPackage

T addDefaultPackage()
Adds all classes in the default Package to the Archive.
SubPackages are excluded.

Returns:
This virtual archive

addPackages

T addPackages(boolean recursive,
              Package... packages)
                                 throws IllegalArgumentException
Adds all classes in the specified Packages to the Archive.

Parameters:
recursive - Should the sub packages be added
packages - All the packages to add
Returns:
This virtual archive
Throws:
IllegalArgumentException - If no packages were specified
See Also:
addPackages(boolean, Filter, Package...)

addPackages

T addPackages(boolean recursive,
              Filter<ArchivePath> filter,
              Package... packages)
                                 throws IllegalArgumentException
Adds all classes accepted by the filter in the specified Packages to the Archive.
The ArchivePath returned to the filter is the ArchivePath of the class, not the final location.
package.MyClass = /package/MyClass.class
not: package.MyClass = /WEB-INF/classes/package/MyClass.class

Parameters:
recursive - Should the sub packages be added
filter - filter out specific classes
packages - All the packages to add
Returns:
This virtual archive
Throws:
IllegalArgumentException - If no packages were specified

addPackage

T addPackage(String pack)
                                throws IllegalArgumentException
Adds all classes in the specified Package to the Archive.
SubPackages are excluded.

Parameters:
pack - Package to add represented by a String ("my/package")
Returns:
This virtual archive
Throws:
IllegalArgumentException - If no package were specified
See Also:
addPackages(boolean, Package...)

addPackages

T addPackages(boolean recursive,
              String... packages)
                                 throws IllegalArgumentException
Adds all classes in the specified Packages to the Archive.

Parameters:
recursive - Should the sub packages be added
packages - All the packages to add represented by a String ("my/package")
Returns:
This virtual archive
Throws:
IllegalArgumentException - If no packages were specified
See Also:
addPackages(boolean, Filter, Package...)

addPackages

T addPackages(boolean recursive,
              Filter<ArchivePath> filter,
              String... packages)
                                 throws IllegalArgumentException
Adds all classes accepted by the filter in the specified Packages to the Archive.
The ArchivePath returned to the filter is the ArchivePath of the class, not the final location.
package.MyClass = /package/MyClass.class
not: package.MyClass = /WEB-INF/classes/package/MyClass.class

Parameters:
recursive - Should the sub packages be added
filter - filter out specific classes
packages - All the packages to add represented by a String ("my/package")
Returns:
This virtual archive
Throws:
IllegalArgumentException - If no packages were specified


Copyright © 2012 JBoss by Red Hat. All Rights Reserved.