Package org.jboss.modules
Class ClassifyingModuleLoader
- java.lang.Object
-
- org.jboss.modules.ModuleLoader
-
- org.jboss.modules.ClassifyingModuleLoader
-
public final class ClassifyingModuleLoader extends ModuleLoader
A module loader which selects a delegate module loader based upon the prefix of the module name. Longer names are matched first always.- Author:
- David M. Lloyd
-
-
Field Summary
-
Fields inherited from class org.jboss.modules.ModuleLoader
NO_FINDERS
-
-
Constructor Summary
Constructors Constructor Description ClassifyingModuleLoader(java.lang.String name, java.util.Map<java.lang.String,ModuleLoader> delegates, ModuleLoader defaultLoader)Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ModuleSpecfindModule(java.lang.String name)Find a Module's specification in this ModuleLoader by its name.protected ModulepreloadModule(java.lang.String name)Preload a module based on an identifier.voidsetDelegates(java.util.Map<java.lang.String,ModuleLoader> delegates)Change the delegates map.java.lang.StringtoString()Get the string representation of this module loader.-
Methods inherited from class org.jboss.modules.ModuleLoader
findLoadedModuleLocal, findLoadedModuleLocal, findModule, forClass, forClassLoader, getDependencies, getFinders, getModuleDescription, installMBeanServer, iterateModules, iterateModules, loadModule, loadModule, loadModuleLocal, loadModuleLocal, preloadExportedModule, preloadExportedModule, preloadModule, preloadModule, preloadModule, refreshResourceLoaders, relink, setAndRefreshResourceLoaders, setAndRelinkDependencies, unloadModuleLocal, unloadModuleLocal
-
-
-
-
Constructor Detail
-
ClassifyingModuleLoader
public ClassifyingModuleLoader(java.lang.String name, java.util.Map<java.lang.String,ModuleLoader> delegates, ModuleLoader defaultLoader)Construct a new instance. The given delegates map is copied.- Parameters:
delegates- the default delegates map to usedefaultLoader- the default loader to use if no delegate mapping exists
-
-
Method Detail
-
preloadModule
protected Module preloadModule(java.lang.String name) throws ModuleLoadException
Preload a module based on an identifier. By default, delegation is only done for system and this method otherwise simply invokesModuleLoader.loadModuleLocal(String). A delegating module loader may delegate to the appropriate module loader based on loader-specific criteria (via theModuleLoader.preloadModule(String, ModuleLoader)method).- Overrides:
preloadModulein classModuleLoader- Parameters:
name- the module identifier- Returns:
- the load result, or
nullif the module is not found - Throws:
ModuleLoadException- if an error occurs
-
findModule
protected ModuleSpec findModule(java.lang.String name) throws ModuleLoadException
Find a Module's specification in this ModuleLoader by its name. This can be overriden by sub-classes to implement the Module loading strategy for this loader. The default implementation iterates the module finders provided during construction. If no module is found in this module loader with the given identifier, then this method should returnnull. If the module is found but some problem occurred (for example, a transitive dependency failed to load) then this method should throw aModuleLoadExceptionof the relevant type.- Overrides:
findModulein classModuleLoader- Parameters:
name- the module name- Returns:
- the module specification, or
nullif no module is found with the given identifier - Throws:
ModuleLoadException- if any problems occur finding the module
-
setDelegates
public void setDelegates(java.util.Map<java.lang.String,ModuleLoader> delegates)
Change the delegates map. A copy is made of the given map.- Parameters:
delegates- the new delegates map to use
-
toString
public java.lang.String toString()
Description copied from class:ModuleLoaderGet the string representation of this module loader.- Overrides:
toStringin classModuleLoader- Returns:
- the string representation
-
-