ShrinkWrap Aggregator and Build Parent 1.0.0-cr-1

org.jboss.shrinkwrap.impl.base
Class ServiceExtensionLoader

java.lang.Object
  extended by 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 of ExtensionLoader is not provided to the ConfigurationBuilder and the ConfigurationBuilder.build() method is invoked. If the ConfigurationBuilder doesn't provide any ClassLoader, ConfigurationBuilder.build() defaults to a one-element collection holding the TCCL. The classLoaders are 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 in cache.

Version:
$Revision: $
Author:
Aslak Knutsen, Ken Gullaksen

Constructor Summary
ServiceExtensionLoader(Iterable<ClassLoader> classLoaders)
          Creates a new instance, using the specified ClassLoaders to create extensions
 
Method Summary
<T extends Assignable>
ServiceExtensionLoader
addOverride(Class<T> extensionClass, Class<? extends T> extensionImplClass)
          Add a Override to the normal Extension loading.
<T extends Archive<T>>
ArchiveFormat
getArchiveFormatFromExtensionMapping(Class<T> type)
          Gets the ArchiveFormat for the given type from the extensionMapping
<T extends Assignable>
String
getExtensionFromExtensionMapping(Class<T> type)
          Gets the extension for the given type from the extensionMapping
 boolean isOverriden(Class<?> extensionClass)
          Check to see if a specific extension interface is beeing overloaded
<T extends Assignable>
T
load(Class<T> extensionClass, Archive<?> baseArchive)
          Load a Extension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceExtensionLoader

public ServiceExtensionLoader(Iterable<ClassLoader> classLoaders)
                       throws IllegalArgumentException
Creates a new instance, using the specified ClassLoaders to create extensions

Parameters:
classLoaders -
Throws:
IllegalArgumentException - If the ClassLoader is not specified
Method Detail

load

public <T extends Assignable> T load(Class<T> extensionClass,
                                     Archive<?> baseArchive)
                          throws UnknownExtensionTypeException
Load a Extension.

Specified by:
load in interface ExtensionLoader
Parameters:
extensionClass - The Extension interface
baseArchive - 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:
addOverride in interface ExtensionLoader
Type Parameters:
T - The type of Extension
Parameters:
extensionClass - The Extension interface class
extensionImplClass - 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:
getExtensionFromExtensionMapping in interface ExtensionLoader
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 the ArchiveFormat for the given type from the extensionMapping

Specified by:
getArchiveFormatFromExtensionMapping in interface ExtensionLoader
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

ShrinkWrap Aggregator and Build Parent 1.0.0-cr-1

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.