Class TypesKnowledge
java.lang.Object
org.gcube.informationsystem.types.knowledge.TypesKnowledge
Manages the knowledge about types.
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CalendarThe creation time.static final longThe default expiring timeout.protected CalendarThe expiring time.intThe expiring timeout.protected booleanA flag indicating whether the knowledge has been initialized.protected ModelKnowledge<Type,SchemaTypeInformation> The model knowledge.protected TypesDiscoverer<Type>The types discoverer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddTypeIfInitialized(Type type) Adds a Type to the current model knowledge only when that knowledge has already been initialized.voiddiscover()This method does nothing if TypesDiscoverer was not set.static TypesKnowledgeReturns the singleton instance of this class.Returns the model knowledge.Returns the types discoverer.protected voidinit(boolean forceReinitialization) Initializes the knowledge.voidInvalidates the current knowledge without triggering discovery.voidrenew()Forces reinitialization of the ModelKnowledge.voidsetExpiringTimeout(int expiringTimeout) Sets the expiring timeout.voidsetTypesDiscoverer(TypesDiscoverer<Type> typesDiscoverer) Sets the types discoverer.
-
Field Details
-
DEFAULT_EXPIRING_TIMEOUT
public static final long DEFAULT_EXPIRING_TIMEOUTThe default expiring timeout. -
initialized
protected volatile boolean initializedA flag indicating whether the knowledge has been initialized. -
expiringTimeout
public int expiringTimeoutThe expiring timeout. -
creationTime
The creation time. -
expiringTime
The expiring time. -
modelKnowledge
The model knowledge. -
typesDiscoverer
The types discoverer.
-
-
Constructor Details
-
TypesKnowledge
public TypesKnowledge()Constructs a newTypesKnowledge.
-
-
Method Details
-
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
Returns the types discoverer.- Returns:
- The types discoverer.
-
setTypesDiscoverer
Sets the types discoverer.- Parameters:
typesDiscoverer- The types discoverer.
-
getModelKnowledge
Returns the model knowledge.- Returns:
- The model knowledge.
-
addTypeIfInitialized
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:
truewhen the initialized knowledge was updated,falsewhen 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.
-