Class TypesKnowledge


  • public class TypesKnowledge
    extends Object
    Manages the knowledge about types.
    Author:
    Luca Frosini (ISTI - CNR)
    • Field Detail

      • DEFAULT_EXPIRING_TIMEOUT

        public static final long DEFAULT_EXPIRING_TIMEOUT
        The default expiring timeout.
      • initialized

        protected volatile boolean initialized
        A flag indicating whether the knowledge has been initialized.
      • expiringTimeout

        public int expiringTimeout
        The expiring timeout.
      • creationTime

        protected Calendar creationTime
        The creation time.
      • expiringTime

        protected Calendar expiringTime
        The expiring time.
    • Constructor Detail

      • TypesKnowledge

        public TypesKnowledge()
        Constructs a new TypesKnowledge.
    • Method Detail

      • getInstance

        public static TypesKnowledge getInstance()
        Returns the singleton instance of this class.
        Returns:
        The singleton instance.
      • setExpiringTimeout

        public void setExpiringTimeout​(int expiringTimeout)
        Sets the expiring timeout.
        Parameters:
        expiringTimeout - The expiring timeout in milliseconds.
      • getTypesDiscoverer

        public TypesDiscoverer<Type> getTypesDiscoverer()
        Returns the types discoverer.
        Returns:
        The types discoverer.
      • setTypesDiscoverer

        public void setTypesDiscoverer​(TypesDiscoverer<Type> typesDiscoverer)
        Sets the types discoverer.
        Parameters:
        typesDiscoverer - The types discoverer.
      • addTypeIfInitialized

        public boolean addTypeIfInitialized​(Type type)
        Adds a Type to the current model knowledge only when that knowledge has already been initialized. This avoids triggering a complete discovery merely to update an otherwise unused cache after a successful remote mutation.
        Parameters:
        type - the Type to add
        Returns:
        true when the initialized knowledge was updated, false when no initialized knowledge exists yet
      • invalidate

        public void invalidate()
        Invalidates the current knowledge without triggering discovery. The next access rebuilds the complete snapshot through the configured discoverer.
      • init

        protected void init​(boolean forceReinitialization)
        Initializes the knowledge.
        Parameters:
        forceReinitialization - A flag indicating whether to force reinitialization.
      • discover

        public void discover()
        This method does nothing if TypesDiscoverer was not set. Otherwise, it initializes the ModelKnowledge if it was not already initialized. To enforce rediscovery, use the renew method.
      • renew

        public void renew()
        Forces reinitialization of the ModelKnowledge.