|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts.util.MessageResources
jp.terasoluna.fw.web.struts.action.GlobalMessageResources
public final class GlobalMessageResources
Class that generates application message resources and system message resources.
As per the Struts specifications, message resource definition is independent for each module
Hence, the message resources common to all modules cannot be uniquely defined.
TERASOLUNA provides the method of using the application messages and system messages that are common to all modules.
This class retains system (framework) message resources and application message resources.
This class can be referred by using any of the message resource class provided by TERASOLUNA
framework.
Application message resources are by default fetched from application message resource definition file.
The default file name of application message resource definition file is set to the application-messages.properties.
For changing the file name, do the following settings in system settings property file (system.properties)
with the following key.
application.messages=sample1-messages
.properties extension should always be removed from the file name which is set in application.messages.
.properties should always be removed.
add.message.file.1=app1-message
add.message.file.2=app2-message
Since the suffix of the property key is a serial number starting with "1", if the serial number is broken in between,
read operation of the external file is terminated.
DBMessageResourcesFactory
,
DBMessageResources
,
PropertyMessageResourcesExFactory
,
PropertyMessageResourcesEx
,
Serialized FormField Summary | |
---|---|
private static java.lang.String |
ADD_MESSAGES_FILE
External message file which is specified in the root message file and which is used for adding the message resources. |
private static java.lang.String |
APPLICATION_CONFIG_KEY
Application message resource name which is specified in system.properties . |
private static java.lang.String |
DEFAULT_APPLICATION_MESSAGE
Default application message resource name. |
private java.util.Map<java.lang.String,java.lang.String> |
fwMessages
Retains messages of the framework. |
private static GlobalMessageResources |
globalMessageResources
Singleton object. |
private java.util.Map<java.lang.String,java.lang.String> |
globalMessages
Retains the messages that are unique to the system. |
private static org.apache.commons.logging.Log |
log
Log class. |
private static long |
serialVersionUID
Serial version ID |
private static java.lang.String |
SYSTEM_MESSAGE
Framework message resource name. |
Fields inherited from class org.apache.struts.util.MessageResources |
---|
config, defaultFactory, defaultLocale, factory, formats, returnNull |
Constructor Summary | |
---|---|
private |
GlobalMessageResources(org.apache.struts.util.MessageResourcesFactory factory,
java.lang.String config)
Generates GlobalMessageResources as per the specified parameter. |
Method Summary | |
---|---|
private void |
applicationInit()
 Loads application message resource file and fetches message resources. |
private java.util.Map<java.lang.String,java.lang.String> |
getAddApplicationMap(java.util.Properties prop,
java.lang.String rootProperty)
Fetches the list of external message resource file from the application root message and fetches the actual messages. Returns empty map even if the external file does not exist. When the name of root file and name of file to be loaded matches, it escapes from infinite loop and skips the read operation. |
static GlobalMessageResources |
getInstance()
Returns singleton instance of this class. |
java.lang.String |
getMessage(java.util.Locale locale,
java.lang.String key)
Returns messages. The priority sequence for fetching the messages, is as follows. Application message resources and System message resources |
private java.util.Map<java.lang.String,java.lang.String> |
getRootApplicationMap(java.util.Properties prop)
Returns the message list map which is specified in root message file of application. Returns empty map even if the message list does not exist. |
private void |
globalInit()
Refills the map by reading the property file. |
Methods inherited from class org.apache.struts.util.MessageResources |
---|
escape, getConfig, getFactory, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessage, getMessageResources, getReturnNull, isEscape, isPresent, isPresent, localeKey, log, log, messageKey, messageKey, setEscape, setReturnNull |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private static org.apache.commons.logging.Log log
private java.util.Map<java.lang.String,java.lang.String> fwMessages
private java.util.Map<java.lang.String,java.lang.String> globalMessages
private static final java.lang.String SYSTEM_MESSAGE
private static final java.lang.String DEFAULT_APPLICATION_MESSAGE
private static final java.lang.String APPLICATION_CONFIG_KEY
system.properties
.
private static final java.lang.String ADD_MESSAGES_FILE
private static GlobalMessageResources globalMessageResources
Constructor Detail |
---|
private GlobalMessageResources(org.apache.struts.util.MessageResourcesFactory factory, java.lang.String config)
GlobalMessageResources
as per the specified parameter.
factory
- Message resource factoryconfig
- Paaremeter set in this MessageResource
Method Detail |
---|
public static GlobalMessageResources getInstance()
private void globalInit()
private void applicationInit()
private java.util.Map<java.lang.String,java.lang.String> getRootApplicationMap(java.util.Properties prop)
prop
- Root property file
private java.util.Map<java.lang.String,java.lang.String> getAddApplicationMap(java.util.Properties prop, java.lang.String rootProperty)
prop
- Root property filerootProperty
- Root property file name
public java.lang.String getMessage(java.util.Locale locale, java.lang.String key)
getMessage
in class org.apache.struts.util.MessageResources
locale
- Locale objectkey
- Message resource key
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |