nl.gx.webmanager.springmvc
Class ThreadLocalMessageSource

java.lang.Object
  extended by nl.gx.webmanager.springmvc.ThreadLocalMessageSource
All Implemented Interfaces:
org.springframework.context.MessageSource, org.springframework.context.ResourceLoaderAware

public class ThreadLocalMessageSource
extends java.lang.Object
implements org.springframework.context.MessageSource, org.springframework.context.ResourceLoaderAware

This class is a wrapper for the messageSource as used in WebManager. It produces a ReloadableResourceBundleMessageSource that is saved in a threadsafe way to prevent mix-up with threads that use the messageSource bean simultaneously.

Since:
WebManager 9.13.1
Author:
wouterr

Constructor Summary
ThreadLocalMessageSource()
           
 
Method Summary
 void cleanUp()
          Destroys the existing instance of the ReloadableResourceBundleMessageSource on the current ThreadLocal
 void clearCache()
          Cleares the cached ReloadableResourceBundleMessageSource by calling the clearCahce method on the instantiated bean or creates a new ReloadableResourceBundleMessageSource when no bean is available.
 java.lang.String getBasename()
          Retrieves the basename.
 java.lang.String getMessage(org.springframework.context.MessageSourceResolvable resolvable, java.util.Locale locale)
          
 java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.util.Locale locale)
          
 java.lang.String getMessage(java.lang.String code, java.lang.Object[] args, java.lang.String defaultMessage, java.util.Locale locale)
          
 void initialize()
          Initializes the bean.
 void setBasename(java.lang.String basename)
          Sets the basename.
 void setBasenames(java.lang.String[] basenames)
          Sets the basenames of the ReloadableResourceBundleMessageSource.
 void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadLocalMessageSource

public ThreadLocalMessageSource()
Method Detail

getMessage

public java.lang.String getMessage(org.springframework.context.MessageSourceResolvable resolvable,
                                   java.util.Locale locale)
                            throws org.springframework.context.NoSuchMessageException

Specified by:
getMessage in interface org.springframework.context.MessageSource
Throws:
org.springframework.context.NoSuchMessageException

getMessage

public java.lang.String getMessage(java.lang.String code,
                                   java.lang.Object[] args,
                                   java.util.Locale locale)
                            throws org.springframework.context.NoSuchMessageException

Specified by:
getMessage in interface org.springframework.context.MessageSource
Throws:
org.springframework.context.NoSuchMessageException

getMessage

public java.lang.String getMessage(java.lang.String code,
                                   java.lang.Object[] args,
                                   java.lang.String defaultMessage,
                                   java.util.Locale locale)

Specified by:
getMessage in interface org.springframework.context.MessageSource

setBasename

public void setBasename(java.lang.String basename)
Sets the basename.

Parameters:
the - basename to set

getBasename

public java.lang.String getBasename()
Retrieves the basename.

Returns:
the basename

setBasenames

public void setBasenames(java.lang.String[] basenames)
Sets the basenames of the ReloadableResourceBundleMessageSource.

Parameters:
basenames - Array of strings

clearCache

public void clearCache()
Cleares the cached ReloadableResourceBundleMessageSource by calling the clearCahce method on the instantiated bean or creates a new ReloadableResourceBundleMessageSource when no bean is available.


initialize

public void initialize()
Initializes the bean. Creates a new ReloadableResourceBundleMessageSource with a basename and ResourceLoader.


cleanUp

public void cleanUp()
Destroys the existing instance of the ReloadableResourceBundleMessageSource on the current ThreadLocal


setResourceLoader

public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)

Specified by:
setResourceLoader in interface org.springframework.context.ResourceLoaderAware


Copyright © 2007-2011 GX Software BV. All Rights Reserved.