Class InstanceCache


  • public abstract class InstanceCache
    extends java.lang.Object
    InstanceCache: cache data for a DataAccessUnit.
    Since:
    5.0
    • 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 for
                        BackingBeanContext 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 SystemException
        Initialize 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 key
        value - 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