public abstract class AbstractModelLoader
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
AbstractModelLoader.BrokenModel
Store an exception during loading in cache.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.String[] |
extensions
The supported file extensions (if any).
|
protected LRU<Tuple,ICacheableModel> |
modelcache
The model cache (filename/imports -> loaded model).
|
protected java.util.Map<java.lang.String,ICacheableModel> |
registered
The registered models (filename -> loaded model).
|
Constructor and Description |
---|
AbstractModelLoader(java.lang.String[] extensions)
Create a model loader.
|
AbstractModelLoader(java.lang.String[] extensions,
int cachesize)
Create a model loader.
|
Modifier and Type | Method and Description |
---|---|
void |
clearModelCache()
Clears the model cache.
|
void |
deregisterModel(java.lang.String key)
Deregister a model.
|
protected abstract ICacheableModel |
doLoadModel(java.lang.String name,
java.lang.String[] imports,
ResourceInfo info,
java.lang.ClassLoader classloader,
java.lang.Object context)
Load a model.
|
ICacheableModel |
getCachedModel(java.lang.String name,
java.lang.String extension,
java.lang.String[] imports,
java.lang.Object clkey)
Get a cached model.
|
protected ResourceInfo |
getResourceInfo(java.lang.String name,
java.lang.String[] imports,
java.lang.ClassLoader classloader)
Find the file for a given name using any supported extension.
|
protected ResourceInfo |
getResourceInfo(java.lang.String name,
java.lang.String extension,
java.lang.String[] imports,
java.lang.ClassLoader classloader)
Find the file for a given name.
|
protected ResourceInfo |
getResourceInfo0(java.lang.String name,
java.lang.String[] imports,
java.lang.ClassLoader classloader)
Find the file for a given name using any supported extension.
|
ICacheableModel |
loadModel(java.lang.String name,
java.lang.String[] imports,
java.lang.Object clkey,
java.lang.ClassLoader classloader,
java.lang.Object context)
Load a model.
|
ICacheableModel |
loadModel(java.lang.String name,
java.lang.String extension,
java.lang.String[] imports,
java.lang.Object clkey,
java.lang.ClassLoader classloader,
java.lang.Object context)
Load a model with a required extension.
|
void |
registerModel(java.lang.String key,
ICacheableModel model)
Register a model.
|
protected java.lang.String[] extensions
protected LRU<Tuple,ICacheableModel> modelcache
protected java.util.Map<java.lang.String,ICacheableModel> registered
public AbstractModelLoader(java.lang.String[] extensions)
extensions
- The supported file extensions by order of importance.public AbstractModelLoader(java.lang.String[] extensions, int cachesize)
extensions
- The supported file extensions by order of importance.protected abstract ICacheableModel doLoadModel(java.lang.String name, java.lang.String[] imports, ResourceInfo info, java.lang.ClassLoader classloader, java.lang.Object context) throws java.lang.Exception
name
- The original name (i.e. not filename).info
- The resource info.java.lang.Exception
protected ResourceInfo getResourceInfo(java.lang.String name, java.lang.String[] imports, java.lang.ClassLoader classloader) throws java.lang.Exception
name
- The filename or logical name (resolved via imports and extensions).imports
- The imports, if any.java.lang.Exception
- when the file could not be found.protected ResourceInfo getResourceInfo0(java.lang.String name, java.lang.String[] imports, java.lang.ClassLoader classloader)
name
- The filename or logical name (resolved via imports and extensions).imports
- The imports, if any.protected ResourceInfo getResourceInfo(java.lang.String name, java.lang.String extension, java.lang.String[] imports, java.lang.ClassLoader classloader) throws java.lang.Exception
name
- The filename or logical name (resolved via imports and extension).extension
- The required extension.imports
- The imports, if any.java.lang.Exception
public ICacheableModel getCachedModel(java.lang.String name, java.lang.String extension, java.lang.String[] imports, java.lang.Object clkey) throws java.lang.Exception
name
- The name of the model (file name or logical name).extension
- The specific extension to look for.imports
- The imports to use when resolving logical names.clkey
- The class loader key to allow caching by e.g. RID.java.lang.Exception
public ICacheableModel loadModel(java.lang.String name, java.lang.String[] imports, java.lang.Object clkey, java.lang.ClassLoader classloader, java.lang.Object context) throws java.lang.Exception
name
- The name of the model (file name or logical name).imports
- The imports to use when resolving logical names.clkey
- The class loader key to allow caching by e.g. RID.java.lang.Exception
public ICacheableModel loadModel(java.lang.String name, java.lang.String extension, java.lang.String[] imports, java.lang.Object clkey, java.lang.ClassLoader classloader, java.lang.Object context) throws java.lang.Exception
name
- The name of the model (file name or logical name).extension
- The specific extension to look for.imports
- The imports to use when resolving logical names.clkey
- The class loader key to allow caching by e.g. RID.java.lang.Exception
public void registerModel(java.lang.String key, ICacheableModel model)
public void deregisterModel(java.lang.String key)
public void clearModelCache()