Package org.jboss.shrinkwrap.impl.base
Class ServiceExtensionLoader
- java.lang.Object
-
- org.jboss.shrinkwrap.impl.base.ServiceExtensionLoader
-
- All Implemented Interfaces:
ExtensionLoader
public class ServiceExtensionLoader extends Object implements ExtensionLoader
ServiceExtensionLoader This class is the default strategy to load extensions when an instance ofExtensionLoaderis not provided to theConfigurationBuilderand theConfigurationBuilder.build()method is invoked. If theConfigurationBuilderdoesn't provide anyClassLoader,ConfigurationBuilder.build()defaults to a one-element collection holding the TCCL. TheclassLoadersare used to find the provider-configuration file for the extension to be loaded in META-INF/services/. This provider-configuration file is used to make an instance of the SPI implementation and cached incache.- Version:
- $Revision: $
- Author:
- Aslak Knutsen, Ken Gullaksen
-
-
Constructor Summary
Constructors Constructor Description ServiceExtensionLoader(Iterable<ClassLoader> classLoaders)Creates a new instance, using the specifiedClassLoaders to create extensions
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends Assignable>
ServiceExtensionLoaderaddOverride(Class<T> extensionClass, Class<? extends T> extensionImplClass)Add a Override to the normal Extension loading.<T extends Archive<T>>
ArchiveFormatgetArchiveFormatFromExtensionMapping(Class<T> type)Gets theArchiveFormatfor the given type from the extensionMapping<T extends Assignable>
StringgetExtensionFromExtensionMapping(Class<T> type)Gets the extension for the given type from the extensionMappingbooleanisOverriden(Class<?> extensionClass)Check to see if a specific extension interface is beeing overloaded<T extends Assignable>
Tload(Class<T> extensionClass, Archive<?> baseArchive)Load a Extension.
-
-
-
Constructor Detail
-
ServiceExtensionLoader
public ServiceExtensionLoader(Iterable<ClassLoader> classLoaders) throws IllegalArgumentException
Creates a new instance, using the specifiedClassLoaders to create extensions- Parameters:
classLoaders-- Throws:
IllegalArgumentException- If theClassLoaderis not specified
-
-
Method Detail
-
load
public <T extends Assignable> T load(Class<T> extensionClass, Archive<?> baseArchive) throws UnknownExtensionTypeException
Load a Extension.- Specified by:
loadin interfaceExtensionLoader- Parameters:
extensionClass- The Extension interfacebaseArchive- The base archive to use- Returns:
- a
- Throws:
UnknownExtensionTypeException- See Also:
ExtensionLoader.load(java.lang.Class, org.jboss.shrinkwrap.api.Archive)
-
addOverride
public <T extends Assignable> ServiceExtensionLoader addOverride(Class<T> extensionClass, Class<? extends T> extensionImplClass)
Add a Override to the normal Extension loading. If a specific class is found to be overridden, the class will not be loaded using the normal strategy.- Specified by:
addOverridein interfaceExtensionLoader- Type Parameters:
T- The type of Extension- Parameters:
extensionClass- The Extension interface classextensionImplClass- The Extension implementation class- Returns:
- this ExtensionLoader
- See Also:
ExtensionLoader.addOverride(java.lang.Class, java.lang.Class)
-
getExtensionFromExtensionMapping
public <T extends Assignable> String getExtensionFromExtensionMapping(Class<T> type)
Gets the extension for the given type from the extensionMapping- Specified by:
getExtensionFromExtensionMappingin interfaceExtensionLoader- Type Parameters:
T- The type of Extension- Parameters:
type- The Extension interface class- Returns:
- the filename extension
- See Also:
ExtensionLoader.getExtensionFromExtensionMapping(java.lang.Class)
-
getArchiveFormatFromExtensionMapping
public <T extends Archive<T>> ArchiveFormat getArchiveFormatFromExtensionMapping(Class<T> type)
Gets theArchiveFormatfor the given type from the extensionMapping- Specified by:
getArchiveFormatFromExtensionMappingin interfaceExtensionLoader- Type Parameters:
T- The type of Extension- Parameters:
type- The Extension interface class- Returns:
- the archive format
- See Also:
ExtensionLoader.getArchiveFormatFromExtensionMapping(java.lang.Class)
-
isOverriden
public boolean isOverriden(Class<?> extensionClass)
Check to see if a specific extension interface is beeing overloaded- Parameters:
extensionClass- The ExtensionType interface class- Returns:
- true if found
-
-