net.sf.mmm.util.nls.api
Class NlsAccess

java.lang.Object
  extended by net.sf.mmm.util.nls.api.NlsAccess

public final class NlsAccess
extends Object

This is an ugly static accessor for the NlsMessageFactory used to create instances of NlsMessage and allowing to exchange the default implementation.

Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
private static NlsMessageFactory factory
           
private static NlsTemplateResolver templateResolver
           
 
Constructor Summary
private NlsAccess()
          The constructor.
 
Method Summary
static NlsMessageFactory getFactory()
          This method gets the NlsMessageFactory used to create instances of NlsMessage.
static NlsTemplateResolver getTemplateResolver()
          This method gets the default NlsTemplateResolver.
static void setFactory(NlsMessageFactory instance)
          This method sets (overrides) the NlsMessageFactory.
static void setTemplateResolver(NlsTemplateResolver templateResolver)
          This method sets (overrides) the default NlsTemplateResolver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

private static NlsMessageFactory factory
See Also:
getFactory()

templateResolver

private static NlsTemplateResolver templateResolver
See Also:
getTemplateResolver()
Constructor Detail

NlsAccess

private NlsAccess()
The constructor.

Method Detail

getFactory

public static NlsMessageFactory getFactory()
This method gets the NlsMessageFactory used to create instances of NlsMessage.

Returns:
the factory instance.

setFactory

public static void setFactory(NlsMessageFactory instance)
This method sets (overrides) the NlsMessageFactory. This allows to exchange the NlsMessageFactory and thereby the implementation of NlsMessage.
The desired behavior of a universal translator can depend from the situation where it is used. E.g. a client application could use the "default locale" to choose the destination language. In a multi-user server application a ThreadLocal may be used to retrieve the appropriate locale.
WARNING:
This is only a back-door for simple applications or test situations. Please try to avoid using this feature as well as NlsMessage.getLocalizedMessage() and solve this issue with IoC strategies (using non-final static fields like here is evil).
ATTENTION:
No synchronization is performed setting the factory instance. This assumes that an assignment is an atomic operation in the JVM you are using. Additionally this method should only be invoked in the initialization phase of your application.

Parameters:
instance - the factory-instance to use.

getTemplateResolver

public static NlsTemplateResolver getTemplateResolver()
This method gets the default NlsTemplateResolver.

Returns:
the default NlsTemplateResolver.
Since:
2.0.0

setTemplateResolver

public static void setTemplateResolver(NlsTemplateResolver templateResolver)
This method sets (overrides) the default NlsTemplateResolver. WARNING:
This is only a back-door for simple applications or test situations. Please try to avoid using this feature and solve this issue with IoC strategies (using non-final static fields like here is evil).
ATTENTION:
No synchronization is performed setting the instance. This assumes that an assignment is an atomic operation in the JVM you are using. Additionally this method should only be invoked in the initialization phase of your application.

Parameters:
templateResolver - is the NlsTemplateResolver to use by default.
Since:
2.0.0


Copyright © 2001-2010 mmm-Team. All Rights Reserved.