Class TypesKnowledge

java.lang.Object
org.gcube.informationsystem.types.knowledge.TypesKnowledge

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

    • 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.
    • modelKnowledge

      protected ModelKnowledge<Type,SchemaTypeInformation> modelKnowledge
      The model knowledge.
    • typesDiscoverer

      protected TypesDiscoverer<Type> typesDiscoverer
      The types discoverer.
  • Constructor Details

    • TypesKnowledge

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

    • 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.
    • getModelKnowledge

      public ModelKnowledge<Type,SchemaTypeInformation> getModelKnowledge()
      Returns the model knowledge.
      Returns:
      The model knowledge.
    • 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.