org.codehaus.groovy.grails.context.support
Class PluginAwareResourceBundleMessageSource

java.lang.Object
  extended by org.springframework.context.support.MessageSourceSupport
      extended by org.springframework.context.support.AbstractMessageSource
          extended by org.springframework.context.support.ReloadableResourceBundleMessageSource
              extended by org.codehaus.groovy.grails.context.support.PluginAwareResourceBundleMessageSource
All Implemented Interfaces:
PluginManagerAware, GrailsApplicationAware, InitializingBean, HierarchicalMessageSource, MessageSource, ResourceLoaderAware

public class PluginAwareResourceBundleMessageSource
extends ReloadableResourceBundleMessageSource
implements GrailsApplicationAware, PluginManagerAware, InitializingBean

A ReloadableResourceBundleMessageSource that is capable of loading message sources from plugins

Since:
1.1

Created: Feb 6, 2009

Author:
Graeme Rocher

Nested Class Summary
 
Nested classes/interfaces inherited from class org.springframework.context.support.ReloadableResourceBundleMessageSource
ReloadableResourceBundleMessageSource.PropertiesHolder
 
Field Summary
protected  GrailsApplication application
           
protected  List<String> pluginBaseNames
           
protected  GrailsPluginManager pluginManager
           
 
Fields inherited from class org.springframework.context.support.MessageSourceSupport
logger
 
Constructor Summary
PluginAwareResourceBundleMessageSource()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  ReloadableResourceBundleMessageSource.PropertiesHolder getMergedPluginProperties(Locale locale)
          Get a PropertiesHolder that contains the actually visible properties for a Locale, after merging all specified resource bundles.
 List<String> getPluginBaseNames()
           
protected  Resource[] getPluginBundles(String pluginName)
           
protected  MessageFormat resolveCode(String code, Locale locale)
           
protected  MessageFormat resolveCodeFromPlugins(String code, Locale locale)
          Attempts to resolve a MessageFormat for the code from the list of plugin base names
protected  String resolveCodeWithoutArguments(String code, Locale locale)
           
protected  String resolveCodeWithoutArgumentsFromPlugins(String code, Locale locale)
          Attempts to resolve a String for the code from the list of plugin base names
 void setCacheSeconds(int cacheSeconds)
           
 void setGrailsApplication(GrailsApplication grailsApplication)
          This method is called by the ApplicationContext that loads the Grails application.
 void setPluginBaseNames(List<String> pluginBaseNames)
           
 void setPluginManager(GrailsPluginManager pluginManager)
          Sets the plug-in manager on this instance
 void setResourceLoader(ResourceLoader resourceLoader)
           
 
Methods inherited from class org.springframework.context.support.ReloadableResourceBundleMessageSource
calculateAllFilenames, calculateFilenamesForLocale, clearCache, clearCacheIncludingAncestors, getMergedProperties, getProperties, loadProperties, refreshProperties, setBasename, setBasenames, setDefaultEncoding, setFallbackToSystemLocale, setFileEncodings, setPropertiesPersister, toString
 
Methods inherited from class org.springframework.context.support.AbstractMessageSource
getDefaultMessage, getMessage, getMessage, getMessage, getMessageFromParent, getMessageInternal, getParentMessageSource, isUseCodeAsDefaultMessage, renderDefaultMessage, resolveArguments, setParentMessageSource, setUseCodeAsDefaultMessage
 
Methods inherited from class org.springframework.context.support.MessageSourceSupport
createMessageFormat, formatMessage, isAlwaysUseMessageFormat, setAlwaysUseMessageFormat
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

application

protected GrailsApplication application

pluginManager

protected GrailsPluginManager pluginManager

pluginBaseNames

protected List<String> pluginBaseNames
Constructor Detail

PluginAwareResourceBundleMessageSource

public PluginAwareResourceBundleMessageSource()
Method Detail

getPluginBaseNames

public List<String> getPluginBaseNames()

setPluginBaseNames

public void setPluginBaseNames(List<String> pluginBaseNames)

setGrailsApplication

public void setGrailsApplication(GrailsApplication grailsApplication)
Description copied from interface: GrailsApplicationAware

This method is called by the ApplicationContext that loads the Grails application. The GrailsApplication instance that represents the loaded Grails application is injected.

Specified by:
setGrailsApplication in interface GrailsApplicationAware
Parameters:
grailsApplication - the GrailsApplication object that represents this Grails application

setPluginManager

public void setPluginManager(GrailsPluginManager pluginManager)
Description copied from interface: PluginManagerAware
Sets the plug-in manager on this instance

Specified by:
setPluginManager in interface PluginManagerAware
Parameters:
pluginManager - The PluginManager

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

getPluginBundles

protected Resource[] getPluginBundles(String pluginName)

resolveCodeWithoutArguments

protected String resolveCodeWithoutArguments(String code,
                                             Locale locale)
Overrides:
resolveCodeWithoutArguments in class ReloadableResourceBundleMessageSource

resolveCode

protected MessageFormat resolveCode(String code,
                                    Locale locale)
Overrides:
resolveCode in class ReloadableResourceBundleMessageSource

getMergedPluginProperties

protected ReloadableResourceBundleMessageSource.PropertiesHolder getMergedPluginProperties(Locale locale)
Get a PropertiesHolder that contains the actually visible properties for a Locale, after merging all specified resource bundles. Either fetches the holder from the cache or freshly loads it.

Only used when caching resource bundle contents forever, i.e. with cacheSeconds < 0. Therefore, merged properties are always cached forever.


setCacheSeconds

public void setCacheSeconds(int cacheSeconds)
Overrides:
setCacheSeconds in class ReloadableResourceBundleMessageSource

resolveCodeWithoutArgumentsFromPlugins

protected String resolveCodeWithoutArgumentsFromPlugins(String code,
                                                        Locale locale)
Attempts to resolve a String for the code from the list of plugin base names

Parameters:
code - The code
locale - The locale
Returns:
a MessageFormat

resolveCodeFromPlugins

protected MessageFormat resolveCodeFromPlugins(String code,
                                               Locale locale)
Attempts to resolve a MessageFormat for the code from the list of plugin base names

Parameters:
code - The code
locale - The locale
Returns:
a MessageFormat

setResourceLoader

public void setResourceLoader(ResourceLoader resourceLoader)
Specified by:
setResourceLoader in interface ResourceLoaderAware
Overrides:
setResourceLoader in class ReloadableResourceBundleMessageSource


Copyright (c) 2005-2009 The Grails project