public class ScriptModuleLoader
extends java.lang.Object
ScriptCompilerPluginSpec
.Modifier and Type | Class and Description |
---|---|
static class |
ScriptModuleLoader.Builder
Builder used to constract a
ScriptModuleLoader |
Modifier and Type | Field and Description |
---|---|
protected java.lang.ClassLoader |
appClassLoader |
protected java.util.Set<java.lang.String> |
appPackagePaths |
protected java.nio.file.Path |
compilationRootDir |
protected java.util.Map<java.lang.String,java.lang.ClassLoader> |
compilerClassLoaders |
protected java.util.List<ScriptArchiveCompiler> |
compilers |
protected JBossModuleLoader |
jbossModuleLoader |
protected java.util.Set<ScriptModuleListener> |
listeners |
protected java.util.Map<ModuleId,ScriptModule> |
loadedScriptModules
Map of script ModuleId to the loaded ScriptModules
|
protected java.util.Set<ScriptCompilerPluginSpec> |
pluginSpecs |
Modifier | Constructor and Description |
---|---|
protected |
ScriptModuleLoader(java.util.Set<ScriptCompilerPluginSpec> pluginSpecs,
java.lang.ClassLoader appClassLoader,
java.util.Set<java.lang.String> appPackagePaths,
java.util.Set<ScriptModuleListener> listeners,
java.nio.file.Path compilationRootDir) |
Modifier and Type | Method and Description |
---|---|
void |
addCompilerPlugin(ScriptCompilerPluginSpec pluginSpec)
Add a language plugin to this module
|
void |
addListeners(java.util.Set<ScriptModuleListener> listeners)
Add listeners to this module loader.
|
protected void |
compileModule(org.jboss.modules.Module module,
java.nio.file.Path moduleCompilationRoot)
Compiles and links the scripts within the module by locating the correct compiler
and delegating the compilation.
|
protected org.jboss.modules.ModuleSpec |
createModuleSpec(ScriptArchive archive,
org.jboss.modules.ModuleIdentifier moduleId,
java.util.Map<ModuleId,org.jboss.modules.ModuleIdentifier> moduleIdMap,
java.nio.file.Path moduleCompilationRoot)
Create a JBoss module spec for an about to be created script module.
|
protected java.util.List<ScriptArchiveCompiler> |
findCompilers(ScriptArchive archive)
Select a set of compilers to compile this archive.
|
java.util.Map<ModuleId,ScriptModule> |
getAllScriptModules()
Get a view of the loaded script modules
|
java.lang.ClassLoader |
getCompilerPluginClassLoader(java.lang.String pluginModuleId) |
ScriptModule |
getScriptModule(ModuleId scriptModuleId) |
ScriptModule |
getScriptModule(java.lang.String scriptModuleId) |
protected void |
notifyArchiveRejected(ScriptArchive scriptArchive,
ArchiveRejectedReason reason,
java.lang.Throwable cause)
Notify listeners that a script archive was rejected by this loader
|
protected void |
notifyModuleUpdate(ScriptModule newModule,
ScriptModule oldModule)
Convenience method to notify the listeners that there was an update to the script module
|
void |
removeScriptModule(ModuleId scriptModuleId)
Remove a module from being served by this instance.
|
void |
updateScriptArchives(java.util.Set<? extends ScriptArchive> candidateArchives)
Add or update the existing
ScriptModule s with the given script archives. |
protected final java.util.Map<ModuleId,ScriptModule> loadedScriptModules
protected final java.util.Map<java.lang.String,java.lang.ClassLoader> compilerClassLoaders
protected final java.util.Set<ScriptCompilerPluginSpec> pluginSpecs
protected final java.lang.ClassLoader appClassLoader
protected final java.util.Set<java.lang.String> appPackagePaths
protected final java.util.List<ScriptArchiveCompiler> compilers
protected final java.nio.file.Path compilationRootDir
protected final java.util.Set<ScriptModuleListener> listeners
protected final JBossModuleLoader jbossModuleLoader
protected ScriptModuleLoader(java.util.Set<ScriptCompilerPluginSpec> pluginSpecs, java.lang.ClassLoader appClassLoader, java.util.Set<java.lang.String> appPackagePaths, java.util.Set<ScriptModuleListener> listeners, java.nio.file.Path compilationRootDir) throws org.jboss.modules.ModuleLoadException
org.jboss.modules.ModuleLoadException
public void updateScriptArchives(java.util.Set<? extends ScriptArchive> candidateArchives)
ScriptModule
s with the given script archives.
This method will convert the archives to modules and then compile + link them in to the
dependency graph. It will then recursively re-link any modules depending on the new modules.
If this loader already contains an old version of the module, it will be unloaded on
successful compile of the new module.candidateArchives
- archives to load or updateprotected org.jboss.modules.ModuleSpec createModuleSpec(ScriptArchive archive, org.jboss.modules.ModuleIdentifier moduleId, java.util.Map<ModuleId,org.jboss.modules.ModuleIdentifier> moduleIdMap, java.nio.file.Path moduleCompilationRoot) throws org.jboss.modules.ModuleLoadException
archive
- the script archive being converted to a module.moduleId
- the JBoss module identifier.moduleIdMap
- a map of loaded script module IDs to jboss module identifiersmoduleCompilationRoot
- a path to a directory that will hold compiled classes for this module.org.jboss.modules.ModuleLoadException
protected void compileModule(org.jboss.modules.Module module, java.nio.file.Path moduleCompilationRoot) throws ScriptCompilationException, java.io.IOException
module
- module to be compiledmoduleCompilationRoot
- the directory to store compiled classes in.ScriptCompilationException
java.io.IOException
public void addCompilerPlugin(ScriptCompilerPluginSpec pluginSpec) throws org.jboss.modules.ModuleLoadException
pluginSpec
- org.jboss.modules.ModuleLoadException
public void removeScriptModule(ModuleId scriptModuleId)
@Nullable public ScriptModule getScriptModule(java.lang.String scriptModuleId)
@Nullable public java.lang.ClassLoader getCompilerPluginClassLoader(java.lang.String pluginModuleId)
@Nullable public ScriptModule getScriptModule(ModuleId scriptModuleId)
public java.util.Map<ModuleId,ScriptModule> getAllScriptModules()
public void addListeners(java.util.Set<ScriptModuleListener> listeners)
listeners
- listeners to addprotected java.util.List<ScriptArchiveCompiler> findCompilers(ScriptArchive archive)
protected void notifyModuleUpdate(@Nullable ScriptModule newModule, @Nullable ScriptModule oldModule)
newModule
- newly loaded moduleoldModule
- module that was displaced by the new moduleprotected void notifyArchiveRejected(ScriptArchive scriptArchive, ArchiveRejectedReason reason, @Nullable java.lang.Throwable cause)
scriptArchive
- archive that was rejectedreason
- reason it was rejectedcause
- underlying exception which triggered the rejection