@groovy.util.logging.Slf4j @groovy.transform.CompileStatic @org.springframework.boot.autoconfigure.AutoConfiguration @org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty(name: grails.cache.enabled, matchIfMissing: true) class CacheGrailsPlugin extends Plugin
Configures the cache plugin.
Every bean is contributed as auto-configuration so that one supplied by the application or
another plugin — for example a cache-provider plugin's grailsCacheManager — makes the
default back off cleanly instead of triggering a bean-definition override. The whole set is gated
on grails.cache.enabled, which is compared against the literal true/false
and defaults to enabled.
Having this jar on the classpath is therefore sufficient for the cache beans, the way it is for
an ordinary Boot starter. The deleted GrailsCacheAutoConfiguration additionally carried
@ConditionalOnBean(CachePluginConfiguration), which kept it in lockstep with the plugin
descriptor: the descriptor's registrar contributed that bean, so the auto-configuration backed off
when the plugin was not active. That gate cannot be restated here, because
grailsCacheConfiguration is now declared in this same beans block and the
condition would be gating on a bean this class itself contributes. The plugin declares no
profiles or environments, so it is active wherever its jar is - which is what makes
dropping the gate a rename of the mechanism rather than a change in which applications get the
beans. Anything that later makes the descriptor conditionally inactive would need a different
anchor for it.
| Type | Name and description |
|---|---|
java.lang.Object |
authorEmail |
java.lang.Object |
beans |
java.lang.Object |
description |
java.lang.Object |
grailsVersion |
java.lang.Object |
loadAfter |
java.lang.Object |
observe |
java.lang.Object |
pluginExcludes |
| Properties inherited from class | Properties |
|---|---|
class Plugin |
applicationContext, artefacts, environment, grailsApplication, plugin, pluginManager |
| Constructor and description |
|---|
CacheGrailsPlugin() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
void |
doWithApplicationContext()Keyed on whether the beans were actually registered, rather than on a second reading of grails.cache.enabled. |
| Methods inherited from class | Name |
|---|---|
class Plugin |
beanRegistrar, beans, doWithApplicationContext, doWithDynamicMethods, doWithSpring, doWithSpring, getApplicationContext, getConfig, getManager, onChange, onConfigChange, onShutdown, onStartup, setApplicationContext |
Keyed on whether the beans were actually registered, rather than on a second reading of
grails.cache.enabled. The two disagree: @ConditionalOnBooleanProperty compares
the literal strings true/false, while config.getProperty(..., Boolean)
also accepts yes/on/1 - so on grails.cache.enabled=yes this
hook believed caching was on and asked for a bean the condition had just declined to register,
failing startup. Asking the context what exists cannot drift from the condition that decided it.