Package io.jmix.search.index.mapping
Class IndexConfigurationManager
java.lang.Object
io.jmix.search.index.mapping.IndexConfigurationManager
@Component("search_IndexConfigurationManager")
public class IndexConfigurationManager
extends Object
The
IndexConfigurationManager class provides functionality for managing
index configurations within an application. It allows for retrieving, creating,
and refreshing index definitions, as well as for determining the involvement of
entities in the indexing process.
This class is responsible for ensuring index configuration consistency and providing metadata about entities and their relationships in the indexing context.
Main Responsibilities
- Managing index definitions and their lifecycle
- Retrieving index configurations by entity or index name
- Determining the extent to which entities are indexed
- Providing metadata on dependencies between entities in the indexing process
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AnnotatedIndexDefinitionProcessorprotected final StampedLockprotected final IndexConfigurationManager.Registry -
Constructor Summary
ConstructorsConstructorDescriptionIndexConfigurationManager(JmixModulesClasspathScanner classpathScanner, AnnotatedIndexDefinitionProcessor indexDefinitionProcessor, InstanceNameProvider instanceNameProvider, IndexDefinitionDetector indexDefinitionDetector, MetadataTools metadataTools) -
Method Summary
Modifier and TypeMethodDescriptionGets allIndexConfigurationregistered in applicationgetDependenciesMetaDataForDelete(Class<?> deletedEntityClass) Gets metadata of entities dependent on the deleted main entity.getDependenciesMetaDataForUpdate(Class<?> entityClass, Set<String> changedProperties) Gets metadata of entities dependent on the updated main entity and its changed properties.getIndexConfigurationByEntityName(String entityName) GetsIndexConfigurationregistered for provided entity name.getIndexConfigurationByEntityNameOpt(String entityName) Gets optionalIndexConfigurationregistered for provided entity name.getIndexConfigurationByIndexName(String indexName) GetsIndexConfigurationregistered for provided index name.getIndexConfigurationByIndexNameOpt(String indexName) Gets optionalIndexConfigurationregistered for provided index name.getLocalPropertyNamesAffectedByUpdate(Class<?> entityClass) Gets local property names of the provided entity involved into the index update processprotected voidInitializes the index definitions by creating and registering them.booleanisAffectedEntityClass(Class<?> entityClass) Checks if the provided entity is involved in the index process directly or as a part of another entity.booleanisDirectlyIndexed(String entityName) Checks if the provided entity is declared to be indexed directly (not as a part of another entity).protected <T> ToptimisticRead(Supplier<T> supplier) Executes the given supplier function in a read-safe manner using an optimistic read lock, ensuring the consistency of the read operation.protected <T> Optional<T>optimisticReadOpt(Supplier<T> supplier) Executes the given supplier function using an optimistic read lock and wraps the result in anOptional.voidRefreshes and recreates the index definitions by creating and registering them.protected voidreplaceConfigurations(List<IndexConfiguration> configurations) Replaces the current index configurations with the provided list of new configurations.
-
Field Details
-
registry
-
indexDefinitionProcessor
-
classNames
-
lock
-
-
Constructor Details
-
IndexConfigurationManager
@Autowired public IndexConfigurationManager(JmixModulesClasspathScanner classpathScanner, AnnotatedIndexDefinitionProcessor indexDefinitionProcessor, InstanceNameProvider instanceNameProvider, IndexDefinitionDetector indexDefinitionDetector, MetadataTools metadataTools)
-
-
Method Details
-
refreshIndexDefinitions
public void refreshIndexDefinitions()Refreshes and recreates the index definitions by creating and registering them.This method ensures that the current index configurations are updated to reflect any changes in the index definitions within the application.
This refreshing also takes into account any changes in the dynamic attributes metadata if the Dynamic attributes add-on is used in the project.
-
getAllIndexConfigurations
Gets allIndexConfigurationregistered in application- Returns:
- all
IndexConfiguration
-
getIndexConfigurationByEntityName
GetsIndexConfigurationregistered for provided entity name. ThrowsIllegalArgumentExceptionif there is no configuration for provided entity name.- Parameters:
entityName- entity name.- Returns:
IndexConfiguration
-
getIndexConfigurationByEntityNameOpt
Gets optionalIndexConfigurationregistered for provided entity name.- Parameters:
entityName- entity name- Returns:
- optional
IndexConfiguration
-
getIndexConfigurationByIndexName
GetsIndexConfigurationregistered for provided index name. ThrowsIllegalArgumentExceptionif there is no configuration for provided index name.- Parameters:
indexName- index name- Returns:
IndexConfiguration
-
getIndexConfigurationByIndexNameOpt
Gets optionalIndexConfigurationregistered for provided index name.- Parameters:
indexName- index name- Returns:
- optional
IndexConfiguration
-
getAllIndexedEntities
-
isDirectlyIndexed
Checks if the provided entity is declared to be indexed directly (not as a part of another entity).- Parameters:
entityName- entity name- Returns:
- true if the entity is indexed, false otherwise
-
isAffectedEntityClass
Checks if the provided entity is involved in the index process directly or as a part of another entity.- Parameters:
entityClass- entity java class- Returns:
- true if the entity is involved in the index process, false otherwise
-
getLocalPropertyNamesAffectedByUpdate
Gets local property names of the provided entity involved into the index update process- Parameters:
entityClass- entity class- Returns:
- set of property names
-
getDependenciesMetaDataForUpdate
public Map<MetaClass,Set<MetaPropertyPath>> getDependenciesMetaDataForUpdate(Class<?> entityClass, Set<String> changedProperties) Gets metadata of entities dependent on the updated main entity and its changed properties.- Parameters:
entityClass- java class of the main entitychangedProperties- changed property of the main entity- Returns:
- dependent entities grouped by their
MetaClass. For every meta class group there are set of properties representing dependency-to-main references
-
getDependenciesMetaDataForDelete
public Map<MetaClass,Set<MetaPropertyPath>> getDependenciesMetaDataForDelete(Class<?> deletedEntityClass) Gets metadata of entities dependent on the deleted main entity.- Parameters:
deletedEntityClass- java class of the main entity- Returns:
- dependent entities grouped by their
MetaClass. For every meta class group there are set of properties representing dependency-to-main references
-
initializeIndexDefinitions
protected void initializeIndexDefinitions()Initializes the index definitions by creating and registering them.The method ensures that the current index configurations are updated to match the definitions specified by the provided class names.
-
replaceConfigurations
Replaces the current index configurations with the provided list of new configurations.- Parameters:
configurations- the list ofIndexConfigurationobjects to be set in the registry
-
optimisticReadOpt
Executes the given supplier function using an optimistic read lock and wraps the result in anOptional. -
optimisticRead
Executes the given supplier function in a read-safe manner using an optimistic read lock, ensuring the consistency of the read operation. If the optimistic lock fails validation, a fallback using a read lock is performed.- Type Parameters:
T- the type of the result provided by the supplier- Parameters:
supplier- the supplier function to execute within the optimistic read lock- Returns:
- the result of the supplier's execution
-