Package com.illumon.iris.db.util.scripts
Class MultiScriptPathLoader<LOADER_TYPE extends ScriptPathLoader>
java.lang.Object
com.illumon.iris.db.util.scripts.MultiScriptPathLoader<LOADER_TYPE>
- All Implemented Interfaces:
ScriptPathLoader
public class MultiScriptPathLoader<LOADER_TYPE extends ScriptPathLoader>
extends Object
implements ScriptPathLoader
A
ScriptPathLoader
that will load paths from multiple underlying loaders.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Free resources associated with this loader.Gets the display paths available from this loader when it was in the specifiedstate
.getScriptBodyByDisplayPath
(String displayPath) getScriptBodyByDisplayPath
(String displayPath, ScriptPathLoaderState state) Get the specified script at the specified state.getScriptBodyByRelativePath
(String relativePath) getScriptBodyByRelativePath
(String relativePath, ScriptPathLoaderState state) Get the specified script at the specified state.getState()
Get the current state of thisScriptPathLoader
.void
lock()
Acquire a read lock.Create a stat object from the serialized JSON String provided byScriptPathLoaderState.encodeJSON()
void
refresh()
Refresh the loader internally.void
unlock()
Release a previously acquired read lock.
-
Constructor Details
-
MultiScriptPathLoader
-
-
Method Details
-
getLoaders
-
lock
public void lock()Description copied from interface:ScriptPathLoader
Acquire a read lock. Use before invoking any of the get* methods, and hold for as long as consistency is required for this loader.- Specified by:
lock
in interfaceScriptPathLoader
-
unlock
public void unlock()Description copied from interface:ScriptPathLoader
Release a previously acquired read lock.- Specified by:
unlock
in interfaceScriptPathLoader
-
getAvailableScriptDisplayPaths
- Specified by:
getAvailableScriptDisplayPaths
in interfaceScriptPathLoader
- Returns:
- The display paths currently available from this loader.
-
getScriptBodyByDisplayPath
- Specified by:
getScriptBodyByDisplayPath
in interfaceScriptPathLoader
- Parameters:
displayPath
- The display path to load a script for.- Returns:
- The body of the requested script.
- Throws:
IOException
- If a problem occurred reading the script body.
-
getScriptBodyByRelativePath
- Specified by:
getScriptBodyByRelativePath
in interfaceScriptPathLoader
- Parameters:
relativePath
- The relative path to load a script for.- Returns:
- The body of the requested script.
- Throws:
IOException
- If a problem occurred reading the script body.
-
getAvailableScriptDisplayPaths
Description copied from interface:ScriptPathLoader
Gets the display paths available from this loader when it was in the specifiedstate
.- Specified by:
getAvailableScriptDisplayPaths
in interfaceScriptPathLoader
- Parameters:
state
- The state of the loader to use when retrieving the list.- Returns:
- A list of all display paths available when the loader was in the specified state.
- Throws:
IOException
- If a problem occurred loading the script.
-
getScriptBodyByDisplayPath
public String getScriptBodyByDisplayPath(String displayPath, ScriptPathLoaderState state) throws IOException Description copied from interface:ScriptPathLoader
Get the specified script at the specified state.- Specified by:
getScriptBodyByDisplayPath
in interfaceScriptPathLoader
- Parameters:
displayPath
- The display path to the script.state
- The state of the loader.- Returns:
- The script at displayPath at the specified state.
- Throws:
IOException
- If a problem occurred loading the script.
-
getScriptBodyByRelativePath
public String getScriptBodyByRelativePath(String relativePath, ScriptPathLoaderState state) throws IOException Description copied from interface:ScriptPathLoader
Get the specified script at the specified state.- Specified by:
getScriptBodyByRelativePath
in interfaceScriptPathLoader
- Parameters:
relativePath
- The relative path to the script.state
- The state of the loader.- Returns:
- The script at relativePath at the specified state.
- Throws:
IOException
- If a problem occurred loading the script.
-
getState
Description copied from interface:ScriptPathLoader
Get the current state of thisScriptPathLoader
.- Specified by:
getState
in interfaceScriptPathLoader
- Returns:
- A
ScriptPathLoaderState
or null if this loader is stateless.
-
makeState
Description copied from interface:ScriptPathLoader
Create a stat object from the serialized JSON String provided byScriptPathLoaderState.encodeJSON()
- Specified by:
makeState
in interfaceScriptPathLoader
- Parameters:
stateJSON
- the JSON state- Returns:
- the deserialized object from the JSON state
-
refresh
public void refresh()Description copied from interface:ScriptPathLoader
Refresh the loader internally. Will respect existing read locks.- Specified by:
refresh
in interfaceScriptPathLoader
-
close
public void close()Description copied from interface:ScriptPathLoader
Free resources associated with this loader.- Specified by:
close
in interfaceScriptPathLoader
-