@groovy.util.logging.Slf4j @groovy.transform.CompileStatic class GormRegistry extends java.lang.Object
A registry of GORM API objects. This registry is used to decouple the API objects from the static state in GormEnhancer. It implements an O(M+N) memory strategy where: M = Number of Entities N = Number of Connections (Tenants)
| Type | Name and description |
|---|---|
java.util.Set<Datastore> |
allDatastores |
GormApiResolver |
apiResolver |
java.util.Map<java.lang.String, Datastore> |
datastoresByQualifier |
java.util.Map<java.lang.Class, Datastore> |
datastoresByType |
GormInstanceApiRegistry |
instanceApiRegistry |
GormStaticApiRegistry |
staticApiRegistry |
GormValidationApiRegistry |
validationApiRegistry |
| Constructor and description |
|---|
GormRegistry() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
DatastoreResolver |
createClassDatastoreResolver(java.lang.Class cls, java.lang.String qualifier)Create a DatastoreResolver for a class and optional qualifier. |
|
java.util.List<FinderMethod> |
createDynamicFinders(Datastore targetDatastore)Creates dynamic finders for the default datastore |
|
java.util.List<FinderMethod> |
createDynamicFinders(DatastoreResolver resolver, MappingContext mappingContext)Creates dynamic finders using the given resolver and mapping context. |
|
GormInstanceApi |
createInstanceApi(java.lang.Class cls, Datastore datastore, boolean failOnError, boolean markDirty)Create a GormInstanceApi instance. |
|
GormStaticApi |
createStaticApi(java.lang.Class cls, Datastore datastore, java.lang.String qualifier)Create a GormStaticApi instance. |
|
GormValidationApi |
createValidationApi(java.lang.Class cls, Datastore datastore)Create a GormValidationApi instance. |
|
static Datastore |
findDatastore(java.lang.Class entity) |
|
static Datastore |
findDatastore(java.lang.Class entity, java.lang.String qualifier) |
<D> |
static GormInstanceApi<D> |
findInstanceApi(java.lang.Class<D> entity) |
<D> |
static GormInstanceApi<D> |
findInstanceApi(java.lang.Class<D> entity, java.lang.String qualifier) |
|
PlatformTransactionManager |
findSingleTransactionManager()Finds a single transaction manager if only one datastore is registered. |
|
PlatformTransactionManager |
findSingleTransactionManager(java.lang.String qualifier)Finds a single transaction manager for a specific qualifier. |
<D> |
static GormStaticApi<D> |
findStaticApi(java.lang.Class<D> entity) |
<D> |
static GormStaticApi<D> |
findStaticApi(java.lang.Class<D> entity, java.lang.String qualifier) |
|
PlatformTransactionManager |
findTransactionManager(java.lang.Class entityClass, java.lang.String qualifier)Finds a transaction manager for a specific entity class and qualifier. |
|
PlatformTransactionManager |
findTransactionManager(java.lang.Class entityClass)Finds a transaction manager for a specific entity class. |
<D> |
static GormValidationApi<D> |
findValidationApi(java.lang.Class<D> entity) |
<D> |
static GormValidationApi<D> |
findValidationApi(java.lang.Class<D> entity, java.lang.String qualifier) |
|
GormApiFactory |
getApiFactory(Datastore datastore) |
|
Datastore |
getDatastore(java.lang.String qualifier)Finds a datastore for a specific qualifier (connection name). |
|
Datastore |
getDatastore(java.lang.Class entityClass)Finds a datastore for a specific entity class. |
|
Datastore |
getDatastore(java.lang.Class entityClass, java.lang.String qualifier)Finds a datastore for a specific entity class and qualifier. |
|
Datastore |
getDatastore(java.lang.String className, java.lang.String qualifier)Finds a datastore for an entity class name and qualifier. |
|
Datastore |
getDatastoreByString(java.lang.String className, java.lang.String qualifier)Internal method to avoid ambiguity. |
|
Datastore |
getDatastoreDirect(java.lang.String normalizedClassName, java.lang.String normalizedQualifier)Internal method to avoid redundant normalization. |
|
Datastore |
getDefaultDatastore()
|
|
static GormRegistry |
getInstance() |
|
GormInstanceApi |
getInstanceApi(java.lang.Class entityClass) |
|
GormInstanceApi |
getInstanceApi(java.lang.Class entityClass, java.lang.String qualifier) |
|
GormInstanceApi |
getInstanceApi(java.lang.String className) |
|
GormInstanceApi |
getInstanceApi(java.lang.String className, java.lang.String qualifier) |
|
GormStaticApi |
getStaticApi(java.lang.Class entityClass) |
|
GormStaticApi |
getStaticApi(java.lang.Class entityClass, java.lang.String qualifier) |
|
GormStaticApi |
getStaticApi(java.lang.String className) |
|
GormStaticApi |
getStaticApi(java.lang.String className, java.lang.String qualifier) |
|
GormValidationApi |
getValidationApi(java.lang.Class entityClass) |
|
GormValidationApi |
getValidationApi(java.lang.Class entityClass, java.lang.String qualifier) |
|
GormValidationApi |
getValidationApi(java.lang.String className) |
|
GormValidationApi |
getValidationApi(java.lang.String className, java.lang.String qualifier) |
|
void |
initializeDatastore(Datastore datastore)Initializes a datastore, registering its type and default qualifier. |
|
void |
initializeDatastore(java.lang.Object datastore, java.lang.String defaultQualifier)Initialize a datastore with GORM. |
|
boolean |
isDatastoreRegisteredForEntity(java.lang.String className, Datastore datastore)Checks if a specific datastore is explicitly registered for an entity. |
|
java.lang.String |
normalizeEntityKey(java.lang.Object entityKey) |
|
java.lang.String |
normalizeEntityKeyFromClass(java.lang.Class entityClass)
|
|
java.lang.String |
normalizeQualifier(java.lang.String qualifier) |
|
java.lang.String |
normalizeQualifierByString(java.lang.String qualifier)
|
|
void |
registerApi(java.lang.String className, GormStaticApi staticApi, GormInstanceApi instanceApi, GormValidationApi validationApi)Registers GORM APIs for an entity. |
|
void |
registerApiFactory(java.lang.Class datastoreType, GormApiFactory factory)Registers a custom GormApiFactory for a specific datastore type. |
|
void |
registerDatastore(java.lang.String qualifier, Datastore datastore)Registers a datastore for a qualifier. |
|
void |
registerDatastore(Datastore datastore)Registers a datastore. |
|
void |
registerDatastoreByQualifier(java.lang.String qualifier, Datastore datastore)Registers a datastore by qualifier only, without adding it to the global type-based discovery. |
|
void |
registerDatastoreByType(Datastore datastore)Registers a datastore by its type. |
|
void |
registerEntity(PersistentEntity persistentEntity, GormEnhancer enhancer)Register a persistent entity with GORM, orchestrating API and datastore registration. |
|
void |
registerEntityApis(java.lang.String className, GormStaticApi staticApi, GormInstanceApi instanceApi, GormValidationApi validationApi)Register API objects for a persistent entity. |
|
void |
registerEntityApis(java.lang.Class cls, GormStaticApi staticApi, GormInstanceApi instanceApi, GormValidationApi validationApi)Register API objects for a persistent entity. |
|
void |
registerEntityDatastore(java.lang.String className, java.lang.String qualifier, Datastore datastore)Registers an entity-specific datastore override. |
|
void |
registerEntityDatastores(java.lang.String className, java.lang.Object datastore, java.util.List<java.lang.String> connectionSourceNames, java.lang.Object entity)Register datastores for a persistent entity across multiple connection sources. |
|
void |
removeConstraints()De-registers the old Grails 2 'unique' constraint, if present. |
|
void |
removeDatastore(Datastore datastore)Completely removes a datastore from the registry. |
|
void |
removeDatastoreByType(java.lang.Class datastoreType)Removes a datastore from discovery by its class type. |
|
void |
removeDatastoreByType(Datastore datastore)Removes a datastore from discovery by its instance type. |
|
void |
removeDatastoreFromDiscovery(Datastore datastore)Removes a datastore from global discovery (allDatastores and datastoresByType) but keeps it in datastoresByQualifier. |
|
void |
removeEntityDatastore(java.lang.String className, Datastore datastore)Removes a datastore for a specific entity. |
|
static void |
reset()Resets the registry. |
|
GormInstanceApi |
resolveInstanceApi(java.lang.Class entityClass) |
|
GormInstanceApi |
resolveInstanceApi(java.lang.Class entityClass, java.lang.String qualifier) |
|
GormStaticApi |
resolveStaticApi(java.lang.Class entityClass) |
|
GormStaticApi |
resolveStaticApi(java.lang.Class entityClass, java.lang.String qualifier) |
|
GormValidationApi |
resolveValidationApi(java.lang.Class entityClass)Resolves the validation API for the given entity class. |
|
GormValidationApi |
resolveValidationApi(java.lang.Class entityClass, java.lang.String qualifier)Resolves the validation API for the given entity class and qualifier. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
Create a DatastoreResolver for a class and optional qualifier.
Creates dynamic finders for the default datastore
Creates dynamic finders using the given resolver and mapping context.
resolver - The datastore resolvermappingContext - The mapping contextCreate a GormInstanceApi instance. Uses a bound resolver (always returns the given datastore) at registration time so that tenant-resolving DatastoreResolvers are not invoked before any tenant context is active.
Create a GormStaticApi instance. Uses a bound resolver (always returns the given datastore) at registration time so that tenant-resolving DatastoreResolvers are not invoked before any tenant context is active.
Create a GormValidationApi instance. Uses a bound resolver (always returns the given datastore) at registration time so that tenant-resolving DatastoreResolvers are not invoked before any tenant context is active.
Finds a single transaction manager if only one datastore is registered. Nominally unused, but invoked at compile-time by transactional AST transformations.
Finds a single transaction manager for a specific qualifier. Nominally unused, but invoked at compile-time by transactional AST transformations.
Finds a transaction manager for a specific entity class and qualifier. Nominally unused, but invoked at compile-time by transactional/service AST transformations.
Finds a transaction manager for a specific entity class. Nominally unused, but invoked at compile-time by transactional/service AST transformations.
Finds a datastore for a specific qualifier (connection name).
Finds a datastore for a specific entity class. Part of the public API for external integrations and manual datastore lookup.
Finds a datastore for a specific entity class and qualifier.
Finds a datastore for an entity class name and qualifier.
Internal method to avoid ambiguity.
Internal method to avoid redundant normalization.
Initializes a datastore, registering its type and default qualifier.
Initialize a datastore with GORM. Orchestrates datastore registration. Constraint registration is handled by GormEnhancer.registerConstraints; entity-specific registration is still handled by GormEnhancer.
datastore - The datastore to initializedefaultQualifier - The default connection source qualifierChecks if a specific datastore is explicitly registered for an entity.
normalizeEntityKey(Class).normalizeQualifier(String).Registers GORM APIs for an entity.
Registers a custom GormApiFactory for a specific datastore type. Nominally unused within the core mapping module, but invoked dynamically by external datastore implementations (e.g. Hibernate, MongoDB) to customize API generation.
Registers a datastore for a qualifier. (O(N) part)
Registers a datastore.
Registers a datastore by qualifier only, without adding it to the global type-based discovery.
Registers a datastore by its type. Nominally unused in core mapping runtime code, but used by test suites and external integrations.
Register a persistent entity with GORM, orchestrating API and datastore registration. This delegates to a GormEnhancer for creating the API instances.
entity - The persistent entity to registerenhancer - The GormEnhancer that provides API creationRegister API objects for a persistent entity. Creates and registers StaticApi, InstanceApi, and ValidationApi for the given entity. Part of the public API for external plugins and test environments.
className - The entity class namestaticApi - The static API implementationinstanceApi - The instance API implementationvalidationApi - The validation API implementationRegister API objects for a persistent entity. Part of the public API for external plugins and test environments.
Registers an entity-specific datastore override.
Register datastores for a persistent entity across multiple connection sources. Handles entity-specific datastore mappings for multi-tenant and multi-datasource scenarios.
className - The entity class namedatastore - The datastore to registerconnectionSourceNames - The connection source names to register the datastore forentity - The persistent entity (for entity-specific qualifier resolution) De-registers the old Grails 2 'unique' constraint, if present.
Mirrors GormEnhancer.registerConstraints's reflective, soft-dependency
lookup - a no-op outside a Grails 2 environment. Not scoped to a specific datastore (the
underlying constraint registry this clears is global), so takes no parameters, same as the
original. Lives here, not on GormEnhancer, because removeDatastore(Datastore)
already owns every other piece of teardown for a datastore going away (API deregistration,
datastore mapping cleanup, metaclass cleanup); constraint removal is one more.
Completely removes a datastore from the registry.
Removes a datastore from discovery by its class type. Nominally unused in core mapping runtime code, but used by testing frameworks to clean up dynamic datastores.
Removes a datastore from discovery by its instance type. Nominally unused in core mapping runtime code, but used by testing frameworks to clean up dynamic datastores.
Removes a datastore from global discovery (allDatastores and datastoresByType) but keeps it in datastoresByQualifier. Nominally unused in core mapping runtime code, but used by test suites to verify multi-datastore isolation.
Removes a datastore for a specific entity.
Resets the registry. Nominally unused in core mapping runtime code, but heavily used by testing frameworks to reset state between spec executions.
Resolves the validation API for the given entity class. Nominally unused in core mapping runtime code, but invoked at compile-time by GORM's AST transformations.
Resolves the validation API for the given entity class and qualifier. Nominally unused in core mapping runtime code, but invoked at compile-time by GORM's AST transformations.