org.araneaframework.integration.spring
Class SpringLocalizationFilterService

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
                  extended by org.araneaframework.integration.spring.SpringLocalizationFilterService
All Implemented Interfaces:
Serializable, Component, FilterService, LocalizationContext, SpringLocalizationContext, Service

public class SpringLocalizationFilterService
extends StandardLocalizationFilterService
implements SpringLocalizationContext

Provides the SpringLocalizationContext and LocalizationContext implementation that uses the MessageSource of the Spring framework. It is mainly targeted for projects that also use the Spring framework IoC container, and want to let the latter handle message context configuration. This service, however, helps to use the same message context in Aranea.

This filter service is accessible from the Environment by key SpringLocalizationContext.class.

To enable this service instead of the StandardLocalizationFilterService, one must define (to override the default solution) it in aranea-conf.xml:


   <bean id="araneaLocalizationFilter" singleton="false"
       class="org.araneaframework.integration.spring.SpringLocalizationFilterService">
     <property name="languageName" value="de" />
   </bean>
 

Author:
Rein Raudjärv
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
SpringLocalizationFilterService()
           
 
Method Summary
protected  Environment getChildEnvironment()
          Returns the Environment of this service by default.
 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.
 MessageSource getMessageSource()
          Provides access to the MessageSource from the Spring framework.
 ResourceBundle getResourceBundle(Locale locale)
          Gets a resource bundle using the specified resource bundle name and current locale and the ClassLoaders provided by the ClassLoaderUtil.
 String localize(String key)
          Localizes a string returning one that corresponds to the current locale.
 
Methods inherited from class org.araneaframework.framework.filter.StandardLocalizationFilterService
addLocaleChangeListener, getLocale, getResourceBundle, init, notifyLocaleChangeListeners, removeLocaleChangeListener, setLanguageName, setLocale, setResourceBundleName
 
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.framework.LocalizationContext
addLocaleChangeListener, getLocale, getResourceBundle, removeLocaleChangeListener, setLocale
 
Methods inherited from interface org.araneaframework.Service
_getService
 
Methods inherited from interface org.araneaframework.Component
_getComponent, getEnvironment, getScope, isAlive
 

Constructor Detail

SpringLocalizationFilterService

public SpringLocalizationFilterService()
Method Detail

getMessageSource

public MessageSource getMessageSource()
Description copied from interface: SpringLocalizationContext
Provides access to the MessageSource from the Spring framework.

Specified by:
getMessageSource in interface SpringLocalizationContext
Returns:
the MessageSource from the Spring framework.

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
Overrides:
getMessage in class StandardLocalizationFilterService

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
Overrides:
getMessage in class StandardLocalizationFilterService

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 StandardLocalizationFilterService

getResourceBundle

public ResourceBundle getResourceBundle(Locale locale)
Description copied from class: StandardLocalizationFilterService
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
Overrides:
getResourceBundle in class StandardLocalizationFilterService

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
Overrides:
localize in class StandardLocalizationFilterService