Package com.znize.platform.model
Class InstanceCache
- java.lang.Object
-
- com.znize.platform.model.InstanceCache
-
public abstract class InstanceCache extends java.lang.ObjectInstanceCache: cache data for a DataAccessUnit.- Since:
- 5.0
-
-
Field Summary
Fields Modifier and Type Field Description protected DataAccessUnitdataAccessUnitThe name of the instance
-
Constructor Summary
Constructors Modifier Constructor Description protectedInstanceCache(DataAccessUnit dataAccessUnit)Constructor with instance name
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(java.lang.String key)Does this cache contain the key? This cache keeps a map of key/value pairs.abstract java.util.PropertiesgetConfigProperties()Get instance configuration propertiesDataAccessUnitgetDataAccessUnit()Get the dataAccessUnit of this cache.static InstanceCachegetInstanceCache()Get the InstanceCache for the current bound instanceType or instance.static InstanceCachegetInstanceCache(DataAccessUnit dataAccessUnit)Get the InstanceCache for the system or subsystem instance<T extends PersistenceEntity>
TgetSingularEntity(java.lang.Class<T> entityType, BackingBeanContext context)Get the singular entity of the entity type.static InstanceCachegetSystemInstanceCache()Get the InstanceCache for the system instance.java.lang.ObjectgetValue(java.lang.String key)Get the value for the key.protected voidinit()Initialize cache after this instance is created.static voidremove(DataAccessUnit dataAccessUnit)Remove the cache for the DataAccessUnitvoidremoveValue(java.lang.String key)Remove the key.<T extends PersistenceEntity>
voidsetSingularEntity(java.lang.Class<T> entityType, T entity, boolean initialized)Set the singular in this instance cache when the entity in persistence is changed.voidsetValue(java.lang.String key, java.lang.Object value)Set the value for the key.
-
-
-
Field Detail
-
dataAccessUnit
protected DataAccessUnit dataAccessUnit
The name of the instance
-
-
Constructor Detail
-
InstanceCache
protected InstanceCache(DataAccessUnit dataAccessUnit)
Constructor with instance name- Parameters:
dataAccessUnit- instanceType or instance
-
-
Method Detail
-
getInstanceCache
public static InstanceCache getInstanceCache()
Get the InstanceCache for the current bound instanceType or instance.- Returns:
- InstanceCache instance
- Since:
- 5.7
-
getSystemInstanceCache
public static InstanceCache getSystemInstanceCache()
Get the InstanceCache for the system instance. It is short form forBackingBeanContext context = BackingBeanContext.getInstance(); InstanceCache.getInstance(context.getSystemInstance());- Returns:
- InstanceCache instance
-
getInstanceCache
public static InstanceCache getInstanceCache(DataAccessUnit dataAccessUnit)
Get the InstanceCache for the system or subsystem instance- Parameters:
dataAccessUnit- instanceType or instance- Returns:
- InstanceCache instance
-
init
protected void init() throws SystemExceptionInitialize cache after this instance is created.- Throws:
SystemException- throw if an error occurs
-
getDataAccessUnit
public DataAccessUnit getDataAccessUnit()
Get the dataAccessUnit of this cache.- Returns:
- DataAccessUnit object
- Since:
- 5.13
-
getSingularEntity
public <T extends PersistenceEntity> T getSingularEntity(java.lang.Class<T> entityType, BackingBeanContext context)
Get the singular entity of the entity type. Load from persistence if not cached.- Parameters:
entityType- entityType. If the type of the entity implements a PersistenceEntity subclass interface, the entityType must be the interface implemented.- Returns:
- entity. return null if not found.
- Since:
- 5.13
-
setSingularEntity
public <T extends PersistenceEntity> void setSingularEntity(java.lang.Class<T> entityType, T entity, boolean initialized)
Set the singular in this instance cache when the entity in persistence is changed.- Parameters:
entityType- entityType. If the type of the entity implements a PersistenceEntity subclass interface, the entityType must be the interface implemented.entity- the singular entity to be cached.initialized- whether the entity is initialized and do not need to fetch it from persistence- Since:
- 5.13
-
getValue
public java.lang.Object getValue(java.lang.String key)
Get the value for the key. This cache keeps a map of key/value pairs.- Parameters:
key- a key- Returns:
- value
-
setValue
public void setValue(java.lang.String key, java.lang.Object value)Set the value for the key. This cache keeps a map of key/value pairs.- Parameters:
key- a keyvalue- the value for the key
-
removeValue
public void removeValue(java.lang.String key)
Remove the key. This cache keeps a map of key/value pairs.- Parameters:
key- a key
-
containsKey
public boolean containsKey(java.lang.String key)
Does this cache contain the key? This cache keeps a map of key/value pairs.- Parameters:
key- a key- Returns:
- true if containing the key, false otherwise.
-
remove
public static void remove(DataAccessUnit dataAccessUnit)
Remove the cache for the DataAccessUnit- Parameters:
dataAccessUnit- instanceType or instance
-
getConfigProperties
public abstract java.util.Properties getConfigProperties()
Get instance configuration properties- Returns:
- name/value pairs
- Since:
- 5.7
-
-