Package jadex.model.impl
Class AbstractModelLoader
java.lang.Object
jadex.model.impl.AbstractModelLoader
Loader for managing models, loaded from disc and kept in cache.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassStore an exception during loading in cache. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String[]The supported file extensions (if any).static final Map<Class<? extends jadex.core.impl.Component>, AbstractModelLoader> protected jadex.collection.LRU<jadex.common.Tuple, ICacheableModel> The model cache (filename/imports -> loaded model).protected Map<String, ICacheableModel> The registered models (filename -> loaded model). -
Constructor Summary
ConstructorsConstructorDescriptionAbstractModelLoader(String[] extensions) Create a model loader.AbstractModelLoader(String[] extensions, int cachesize) Create a model loader. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddLoader(Class<? extends jadex.core.impl.Component> type, AbstractModelLoader loader) voidClears the model cache.voidderegisterModel(String key) Deregister a model.protected abstract ICacheableModeldoLoadModel(String name, Object pojo, String[] imports, ClassLoader classloader, jadex.common.ResourceInfo info) Load a model.getCachedModel(String name, String extension, String[] imports, Object clkey) Get a cached model.static AbstractModelLoaderprotected jadex.common.ResourceInfogetResourceInfo(String name, String[] imports, ClassLoader classloader) Find the file for a given name using any supported extension.protected jadex.common.ResourceInfogetResourceInfo(String name, String extension, String[] imports, ClassLoader classloader) Find the file for a given name.jadex.common.ResourceInfogetResourceInfo0(String name, String[] imports, ClassLoader classloader) Find the file for a given name using any supported extension.loadModel(String name, Object pojo, String[] imports, Object clkey, ClassLoader classloader, Object context) Load a model.loadModel(String name, Object pojo, String extension, String[] imports, Object clkey, ClassLoader classloader) Load a model with a required extension.voidregisterModel(String key, ICacheableModel model) Register a model.voidupdateCachedModel(Runnable update)
-
Field Details
-
extensions
The supported file extensions (if any). -
modelcache
The model cache (filename/imports -> loaded model). -
registered
The registered models (filename -> loaded model). -
loaders
-
-
Constructor Details
-
AbstractModelLoader
Create a model loader.- Parameters:
extensions- The supported file extensions by order of importance.
-
AbstractModelLoader
Create a model loader.- Parameters:
extensions- The supported file extensions by order of importance.
-
-
Method Details
-
doLoadModel
protected abstract ICacheableModel doLoadModel(String name, Object pojo, String[] imports, ClassLoader classloader, jadex.common.ResourceInfo info) throws Exception Load a model.- Parameters:
name- The original name (i.e. not filename).info- The resource info.- Throws:
Exception
-
getResourceInfo
protected jadex.common.ResourceInfo getResourceInfo(String name, String[] imports, ClassLoader classloader) throws Exception Find the file for a given name using any supported extension.- Parameters:
name- The filename or logical name (resolved via imports and extensions).imports- The imports, if any.- Returns:
- The resource info identifying the file.
- Throws:
Exception- when the file could not be found.
-
getResourceInfo0
public jadex.common.ResourceInfo getResourceInfo0(String name, String[] imports, ClassLoader classloader) Find the file for a given name using any supported extension.- Parameters:
name- The filename or logical name (resolved via imports and extensions).imports- The imports, if any.- Returns:
- The resource info identifying the file or null.
-
getResourceInfo
protected jadex.common.ResourceInfo getResourceInfo(String name, String extension, String[] imports, ClassLoader classloader) throws Exception Find the file for a given name.- Parameters:
name- The filename or logical name (resolved via imports and extension).extension- The required extension.imports- The imports, if any.- Returns:
- The resource info identifying the file.
- Throws:
Exception
-
getCachedModel
public ICacheableModel getCachedModel(String name, String extension, String[] imports, Object clkey) throws Exception Get a cached model.- Parameters:
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.- Returns:
- null, when model not found or not yet loaded.
- Throws:
Exception
-
loadModel
public ICacheableModel loadModel(String name, Object pojo, String[] imports, Object clkey, ClassLoader classloader, Object context) throws Exception Load a model.- Parameters:
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.- Throws:
Exception
-
loadModel
public ICacheableModel loadModel(String name, Object pojo, String extension, String[] imports, Object clkey, ClassLoader classloader) throws Exception Load a model with a required extension.- Parameters:
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.- Throws:
Exception
-
updateCachedModel
-
registerModel
Register a model. -
deregisterModel
Deregister a model. -
clearModelCache
public void clearModelCache()Clears the model cache. -
getLoader
-
addLoader
public static void addLoader(Class<? extends jadex.core.impl.Component> type, AbstractModelLoader loader)
-