org.araneaframework.framework.filter
Class StandardLocalizationFilterService

java.lang.Object
  extended by org.araneaframework.core.BaseComponent
      extended by org.araneaframework.core.BaseService
          extended by org.araneaframework.framework.core.BaseFilterService
              extended by org.araneaframework.framework.filter.StandardLocalizationFilterService
All Implemented Interfaces:
Serializable, Component, FilterService, LocalizationContext, Service
Direct Known Subclasses:
SpringLocalizationFilterService

public class StandardLocalizationFilterService
extends BaseFilterService
implements LocalizationContext

Enriches the environment with an implementation of the LocalizationContext. Children can use it and thus provide Locale specific content.

Author:
"Toomas Römer" , Jevgeni Kabanov (ekabanov at araneaframework dot org)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseService
BaseService.ServiceImpl
 
Nested classes/interfaces inherited from class org.araneaframework.core.BaseComponent
BaseComponent.ComponentImpl
 
Nested classes/interfaces inherited from interface org.araneaframework.framework.LocalizationContext
LocalizationContext.LocaleChangeListener
 
Nested classes/interfaces inherited from interface org.araneaframework.Service
Service.Interface
 
Field Summary
 
Fields inherited from class org.araneaframework.framework.core.BaseFilterService
childService
 
Fields inherited from class org.araneaframework.core.BaseService
currentInputData, currentOutputData
 
Constructor Summary
StandardLocalizationFilterService()
           
 
Method Summary
 void addLocaleChangeListener(LocalizationContext.LocaleChangeListener listener)
           
protected  Environment getChildEnvironment()
          Returns the Environment of this service by default.
 Locale getLocale()
          Returns the current session locale.
 String getMessage(String code, Object[] args)
          Localizes the code and uses it to format the message with the passed arguments.
 String getMessage(String code, Object[] args, String defaultMessage)
          Localizes the code and uses it to format the message with the passed arguments.
 ResourceBundle getResourceBundle()
          Returns a resource bundle corresponding to the current locale.
 ResourceBundle getResourceBundle(Locale locale)
          Gets a resource bundle using the specified resource bundle name and current locale and the ClassLoaders provided by the ClassLoaderUtil.
protected  void init()
          Init callback.
 String localize(String key)
          Localizes a string returning one that corresponds to the current locale.
protected  void notifyLocaleChangeListeners(Locale oldLocale, Locale newLocale)
           
 boolean removeLocaleChangeListener(LocalizationContext.LocaleChangeListener listener)
           
 void setLanguageName(String languageName)
          Set the name of the language, it must be a valid ISO Language Code.
 void setLocale(Locale currentLocale)
          Sets the current session locale.
 void setResourceBundleName(String resourceBundleName)
          Sets the name of the resource bundle.
 
Methods inherited from class org.araneaframework.framework.core.BaseFilterService
action, destroy, propagate, setChildService
 
Methods inherited from class org.araneaframework.core.BaseService
_getService, getInputData, getOutputData, handleServiceException
 
Methods inherited from class org.araneaframework.core.BaseComponent
_addComponent, _addComponent, _checkCall, _disableComponent, _enableComponent, _endCall, _endWaitingCall, _getChildren, _getComponent, _getDisabledChildren, _propagate, _relocateComponent, _removeComponent, _setEnvironment, _setScope, _startCall, _startWaitingCall, _strictCheckCall, _strictStartCall, _waitNoCall, disable, enable, getEnvironment, getScope, handleException, isAlive, isDead, isInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.araneaframework.Service
_getService
 
Methods inherited from interface org.araneaframework.Component
_getComponent, getEnvironment, getScope, isAlive
 

Constructor Detail

StandardLocalizationFilterService

public StandardLocalizationFilterService()
Method Detail

setLanguageName

public void setLanguageName(String languageName)
Set the name of the language, it must be a valid ISO Language Code. See the language name in Locale. This method should only be used when country and variant are not important at all, otherwise setLocale(Locale) must be used.


setResourceBundleName

public void setResourceBundleName(String resourceBundleName)
Sets the name of the resource bundle.

Parameters:
resourceBundleName -

getLocale

public Locale getLocale()
Description copied from interface: LocalizationContext
Returns the current session locale.

Specified by:
getLocale in interface LocalizationContext

setLocale

public void setLocale(Locale currentLocale)
Description copied from interface: LocalizationContext
Sets the current session locale.

Specified by:
setLocale in interface LocalizationContext

getChildEnvironment

protected Environment getChildEnvironment()
Description copied from class: BaseFilterService
Returns the Environment of this service by default. The child is initilized with this method. Meant for overriding.

Overrides:
getChildEnvironment in class BaseFilterService

getResourceBundle

public ResourceBundle getResourceBundle()
Description copied from interface: LocalizationContext
Returns a resource bundle corresponding to the current locale.

Specified by:
getResourceBundle in interface LocalizationContext

init

protected void init()
             throws Exception
Description copied from class: BaseComponent
Init callback. Gets called when the component is initilized.

Overrides:
init in class BaseFilterService
Throws:
Exception - Any runtime exception that may occur.

getResourceBundle

public ResourceBundle getResourceBundle(Locale locale)
Gets a resource bundle using the specified resource bundle name and current locale and the ClassLoaders provided by the ClassLoaderUtil.

Specified by:
getResourceBundle in interface LocalizationContext

localize

public String localize(String key)
Description copied from interface: LocalizationContext
Localizes a string returning one that corresponds to the current locale.

Specified by:
localize in interface LocalizationContext

getMessage

public String getMessage(String code,
                         Object[] args)
Description copied from interface: LocalizationContext
Localizes the code and uses it to format the message with the passed arguments. The format of the localized message should be acceptable by java.text.MessageFormat.

Specified by:
getMessage in interface LocalizationContext

getMessage

public String getMessage(String code,
                         Object[] args,
                         String defaultMessage)
Description copied from interface: LocalizationContext
Localizes the code and uses it to format the message with the passed arguments. The format of the localized message should be acceptable by java.text.MessageFormat. If the localized message cannot be resolved uses defaultMessage instead.

Specified by:
getMessage in interface LocalizationContext

addLocaleChangeListener

public void addLocaleChangeListener(LocalizationContext.LocaleChangeListener listener)
Specified by:
addLocaleChangeListener in interface LocalizationContext
Since:
1.1

removeLocaleChangeListener

public boolean removeLocaleChangeListener(LocalizationContext.LocaleChangeListener listener)
Specified by:
removeLocaleChangeListener in interface LocalizationContext
Since:
1.1

notifyLocaleChangeListeners

protected void notifyLocaleChangeListeners(Locale oldLocale,
                                           Locale newLocale)
Since:
1.1