File tree Expand file tree Collapse file tree 3 files changed +30
-4
lines changed
src/java/org/codehaus/groovy/grails Expand file tree Collapse file tree 3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,9 @@ import org.apache.commons.lang.StringUtils
2323import org.apache.commons.logging.LogFactory
2424
2525import org.codehaus.groovy.grails.context.support.PluginAwareResourceBundleMessageSource
26+ import org.codehaus.groovy.grails.web.context.GrailsConfigUtils ;
2627import org.codehaus.groovy.grails.web.i18n.ParamsAwareLocaleChangeInterceptor
28+ import org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateEngine
2729
2830import org.springframework.core.io.ContextResource
2931import org.springframework.context.support.ReloadableResourceBundleMessageSource
@@ -93,8 +95,13 @@ class I18nGrailsPlugin {
9395 basenames = baseNames. toArray()
9496 fallbackToSystemLocale = false
9597 pluginManager = manager
96- if (Environment . current. isReloadEnabled()) {
97- cacheSeconds = 5
98+ if (Environment . current. isReloadEnabled() || GrailsConfigUtils . isConfigTrue(application, GroovyPagesTemplateEngine . CONFIG_PROPERTY_GSP_ENABLE_RELOAD )) {
99+ def cacheSecondsSetting = application?. flatConfig?. get(' grails.i18n.cache.seconds' )
100+ if (cacheSecondsSetting != null ) {
101+ cacheSeconds = cacheSecondsSetting as Integer
102+ } else {
103+ cacheSeconds = 5
104+ }
98105 }
99106 }
100107
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import org.codehaus.groovy.grails.commons.GrailsTagLibClass
2929import org.codehaus.groovy.grails.commons.TagLibArtefactHandler
3030import org.codehaus.groovy.grails.plugins.GrailsPluginManager
3131import org.codehaus.groovy.grails.plugins.web.taglib.*
32+ import org.codehaus.groovy.grails.web.context.GrailsConfigUtils ;
3233import org.codehaus.groovy.grails.web.filters.JavascriptLibraryFilters
3334import org.codehaus.groovy.grails.web.pages.*
3435import org.codehaus.groovy.grails.web.pages.ext.jsp.TagLibraryResolver
@@ -91,8 +92,7 @@ class GroovyPagesGrailsPlugin {
9192 boolean developmentMode = ! application. warDeployed
9293 Environment env = Environment . current
9394 boolean enableReload = env. isReloadEnabled() ||
94- application?. flatConfig?. get(GroovyPagesTemplateEngine . CONFIG_PROPERTY_GSP_ENABLE_RELOAD ) == true ||
95- Boolean . getBoolean(GroovyPagesTemplateEngine . CONFIG_PROPERTY_GSP_ENABLE_RELOAD ) ||
95+ GrailsConfigUtils . isConfigTrue(application, GroovyPagesTemplateEngine . CONFIG_PROPERTY_GSP_ENABLE_RELOAD ) ||
9696 (developmentMode && env == Environment . DEVELOPMENT )
9797 boolean warDeployedWithReload = application. warDeployed && enableReload
9898 boolean enableCacheResources = ! (application?. flatConfig?. get(GroovyPagesTemplateEngine . CONFIG_PROPERTY_DISABLE_CACHING_RESOURCES ) == true )
Original file line number Diff line number Diff line change 2828import org .codehaus .groovy .grails .commons .spring .GrailsRuntimeConfigurator ;
2929import org .codehaus .groovy .grails .plugins .GrailsPluginManager ;
3030import org .codehaus .groovy .grails .support .PersistenceContextInterceptor ;
31+ import org .codehaus .groovy .runtime .typehandling .DefaultTypeTransformation ;
3132import org .springframework .beans .BeanUtils ;
3233import org .springframework .beans .factory .config .AutowireCapableBeanFactory ;
3334import org .springframework .context .ApplicationContext ;
@@ -166,4 +167,22 @@ public static GrailsRuntimeConfigurator determineGrailsRuntimeConfiguratorFromSe
166167
167168 return configurator ;
168169 }
170+
171+ /**
172+ * Checks if a Config parameter is true or a System property with the same name is true
173+ *
174+ *
175+ * @param application
176+ * @param propertyName
177+ * @return
178+ */
179+ public static boolean isConfigTrue (GrailsApplication application , String propertyName ) {
180+ return ((application != null && application .getFlatConfig () != null && DefaultTypeTransformation .castToBoolean (application .getFlatConfig ().get (propertyName ))) ||
181+ Boolean .getBoolean (propertyName ));
182+ }
183+
184+ // support GrailsApplication mocking, see ControllersGrailsPluginTests
185+ public static boolean isConfigTrue (Object application , String propertyName ) {
186+ return false ;
187+ }
169188}
You can’t perform that action at this time.
0 commit comments