@groovy.transform.CompileStatic abstract class AbstractDatastoreInitializer extends java.lang.Object implements ResourceLoaderAware
Abstract class for datastore initializers to implement
| Modifiers | Name | Description |
|---|---|---|
static class |
AbstractDatastoreInitializer.GrailsBeanBuilderInit |
|
static class |
AbstractDatastoreInitializer.GroovyBeanReaderInit |
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
ENTITY_CLASS_RESOURCE_PATTERN |
|
static java.lang.String |
OSIV_CLASS_NAME |
|
static java.lang.String |
TRANSACTION_MANAGER_BEAN |
|
static java.lang.String |
WEB_APPLICATION_CONTEXT_CLASS_NAME |
|
protected java.lang.ClassLoader |
classLoader |
|
protected boolean |
secondaryDatastore |
| Type | Name and description |
|---|---|
PropertyResolver |
configuration |
java.lang.Object |
originalConfiguration |
java.util.Collection<java.lang.String> |
packages |
java.util.Collection<java.lang.Class> |
persistentClasses |
boolean |
registerApplicationIfNotPresent |
PathMatchingResourcePatternResolver |
resourcePatternResolver |
| Constructor and description |
|---|
AbstractDatastoreInitializer() |
AbstractDatastoreInitializer(java.lang.ClassLoader classLoader, java.lang.String[] packages) |
AbstractDatastoreInitializer(java.lang.String[] packages) |
AbstractDatastoreInitializer(java.util.Collection<java.lang.Class> persistentClasses) |
AbstractDatastoreInitializer(java.lang.Class[] persistentClasses) |
AbstractDatastoreInitializer(PropertyResolver configuration, java.util.Collection<java.lang.Class> persistentClasses) |
AbstractDatastoreInitializer(PropertyResolver configuration, java.lang.Class[] persistentClasses) |
AbstractDatastoreInitializer(PropertyResolver configuration, java.lang.String[] packages) |
AbstractDatastoreInitializer(java.util.Map configuration, java.util.Collection<java.lang.Class> persistentClasses) |
AbstractDatastoreInitializer(java.util.Map configuration, java.lang.Class[] persistentClasses) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected java.util.Collection<java.lang.Class> |
collectMappedClasses(java.lang.String datastoreType)The classes this datastore maps. |
|
protected java.lang.Object |
configurationReference(BeanDefinitionRegistry registry)What a bean definition should hold in place of the configuration itself. |
|
ApplicationContext |
configure()Configures for an existing Mongo instance |
|
void |
configureForBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry)Configures an existing BeanDefinitionRegistry |
|
protected boolean |
containsRegisteredBean(java.lang.Object builder, BeanDefinitionRegistry registry, java.lang.String beanName) |
|
ApplicationEventPublisher |
findEventPublisher(BeanDefinitionRegistry beanDefinitionRegistry)Finds the event publisher to use |
|
protected java.lang.Class<? extends ApplicationEventPublisher> |
findEventPublisherClass(BeanDefinitionRegistry beanDefinitionRegistry)Finds the publisher class a datastore definition should name, in place of a publisher itself. |
|
MessageSource |
findMessageSource(BeanDefinitionRegistry beanDefinitionRegistry)Finds the message source to use |
|
groovy.lang.Closure |
getAdditionalBeansConfiguration(BeanDefinitionRegistry registry, java.lang.String type)Internal method aiding in datastore configuration. |
|
abstract groovy.lang.Closure |
getBeanDefinitions(BeanDefinitionRegistry beanDefinitionRegistry) |
|
groovy.lang.Closure |
getCommonConfiguration(BeanDefinitionRegistry registry, java.lang.String type) |
|
protected java.lang.Class |
getGrailsApplicationClass() |
|
protected java.lang.Class |
getGrailsValidatorClass() |
|
protected abstract java.lang.Class<AbstractDatastorePersistenceContextInterceptor> |
getPersistenceInterceptorClass()
|
|
protected boolean |
isGrailsPresent() |
|
protected boolean |
isMappedClass(java.lang.String datastoreType, java.lang.Class cls) |
|
protected boolean |
isWebApplicationRegistry(BeanDefinitionRegistry registry)Determines whether the given registry belongs to a web application. |
|
protected java.util.Map<java.lang.String, java.lang.Class<?>> |
loadDataServices(java.lang.String secondaryDatastore) |
|
protected java.lang.Class[] |
mappedClasses(java.lang.String datastoreType)The classes this datastore maps, as the array its constructor takes. |
|
protected void |
scanForPersistentClasses() |
|
void |
setResourceLoader(ResourceLoader resourceLoader) |
|
void |
setSecondaryDatastore(boolean secondaryDatastore)Whether this datastore is secondary to another primary datastore (example the SQL DB) |
| 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) |
The classes this datastore maps.
datastoreType - the datastore the classes are being collected forWhat a bean definition should hold in place of the configuration itself.
A definition holding the resolver is a definition holding everything the resolver can reach, and generating code for such a definition writes those values out: an environment carries the machine's own variables, so the generated source ends up containing the environment of whatever machine built it, along with whatever was in it -- credentials among them -- and the application then reads its settings from there rather than from where it runs.
So while code is being generated, and only then, the context's environment is named instead, which leaves the lookup to be made where the application runs. Every other time the resolver is held as it always was, which matters for a datastore brought up on its own: its configuration is whatever the caller passed and there is no environment holding it.
Configures for an existing Mongo instance
mongo - The instance of MongoConfigures an existing BeanDefinitionRegistry
beanDefinitionRegistry - The BeanDefinitionRegistry to configureFinds the event publisher to use
beanDefinitionRegistry - The event publisherFinds the publisher class a datastore definition should name, in place of a publisher itself.
The same choice findEventPublisher makes -- one that publishes through the surrounding context, or the one that publishes nowhere -- but left to the container to build. A definition holding an already-constructed publisher is a definition that cannot be generated ahead of time: generating one means writing out what it holds, and a publisher bound to a running context is not something there is any way to write down.
beanDefinitionRegistry - the registry the definitions are being contributed toFinds the message source to use
beanDefinitionRegistry - The registryInternal method aiding in datastore configuration.
registry - The BeanDefinitionRegistrytype - The type of the datastore
Determines whether the given registry belongs to a web application. The presence of the
dispatcherServlet bean definition is only a reliable signal after Spring Boot
auto-configuration has been processed; Grails plugin bean definitions register before
that, so the type of the registry (the web application context itself) is checked as well.
registry - The bean definition registryThe classes this datastore maps, as the array its constructor takes.
The array type is what makes this survive ahead-of-time processing. A datastore takes its
classes as a variable-argument parameter, so the constructor argument the generator writes out
is looked up by that parameter's type when the bean is rebuilt. A collection does not answer to
Class[], so the lookup misses it and the argument is resolved as a dependency instead,
which for an array type means every Class bean in the context: none. The datastore is
then built mapping nothing, and the first call on a domain class reports that it is not one.
Kept apart from collectMappedClasses rather than folded into it, because that one is the seam a datastore outside this repository overrides to say which classes are its own. Changing what it returns would leave such an override no longer overriding anything, and silently unasked.
datastoreType - the datastore the classes are being collected forWhether this datastore is secondary to another primary datastore (example the SQL DB)