org.silverpeas.notification.message
Class MessageManager

java.lang.Object
  extended by org.silverpeas.notification.message.MessageManager

public class MessageManager
extends Object

This manager provides tools to register and restitute volatile messages (info, success or error) to the user (on screen).

It works for now with Thread Cache Service, and several steps have to be performed : - use the initialize function in order to render accessible message tools provided - user message tools in treatment when necessary - use the destroy function in order to clear all message data attached to the thread

A typical initialization/destruction in a the service method of a HttpServlet : protected void service(HttpHttpServletResponse response) { MessageManager.initialize(); try { ... } finally { MessageManager.destroy(); ... } }

A typical use anywhere in treatments : if ([test of functionnal information is not ok]) { MessageMessager.addError(bundle.getMessage("err.label", params)); }

User: Yohann Chastagnier Date: 07/11/13


Constructor Summary
MessageManager()
           
 
Method Summary
static Message addError(String message)
          Add an error message.
protected static Message addError(String registredKey, String message)
          Add an error message.
static Message addInfo(String message)
          Add an info message.
protected static Message addInfo(String registredKey, String message)
          Add an info message.
static void addListener(MessageListener listener)
          Adding a message listener
protected static void addListener(String registredKey, MessageListener listener)
          Adding a message listener
static Message addSevere(String message)
          Add an severe message.
protected static Message addSevere(String registredKey, String message)
          Add an severe message.
static Message addSuccess(String message)
          Add a success message.
protected static Message addSuccess(String registredKey, String message)
          Add a success message.
static Message addWarning(String message)
          Add an warning message.
protected static Message addWarning(String registredKey, String message)
          Add an warning message.
static void clear(String registredKey)
          Remove out of the cache the message container referenced by the given key
static void destroy()
          Clear out the thread cache the registred key referenced.
static String getLanguage()
          Getting language
protected static String getLanguage(String registredKey)
          Getting language
static MessageContainer getMessageContainer(String registredKey)
          Gets the message container.
static String getRegistredKey()
          Get the key that permits to get the MessageContainer registred for the thread.
static ResourceLocator getResourceLocator(String propertyFileBaseName)
          Gets the resource locator from the given property file and by taking into account of the current known language.
protected static ResourceLocator getResourceLocator(String registredKey, String propertyFileBaseName, String language)
          Gets the resource locator from the given property file and given language.
static String initialize()
          Initialize the manager in order to be used everywhere in treatments.
static void setLanguage(String language)
          Setting a language
protected static void setLanguage(String registredKey, String language)
          Setting a language
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageManager

public MessageManager()
Method Detail

initialize

public static String initialize()
Initialize the manager in order to be used everywhere in treatments.


destroy

public static void destroy()
Clear out the thread cache the registred key referenced.


addListener

public static void addListener(MessageListener listener)
Adding a message listener

Parameters:
listener -

addListener

protected static void addListener(String registredKey,
                                  MessageListener listener)
Adding a message listener

Parameters:
listener -

setLanguage

public static void setLanguage(String language)
Setting a language

Parameters:
language -

getLanguage

public static String getLanguage()
Getting language

Returns:

setLanguage

protected static void setLanguage(String registredKey,
                                  String language)
Setting a language

Parameters:
language -

getLanguage

protected static String getLanguage(String registredKey)
Getting language

Returns:

clear

public static void clear(String registredKey)
Remove out of the cache the message container referenced by the given key


getRegistredKey

public static String getRegistredKey()
Get the key that permits to get the MessageContainer registred for the thread.


getResourceLocator

public static ResourceLocator getResourceLocator(String propertyFileBaseName)
Gets the resource locator from the given property file and by taking into account of the current known language.

Parameters:
propertyFileBaseName -
Returns:

getResourceLocator

protected static ResourceLocator getResourceLocator(String registredKey,
                                                    String propertyFileBaseName,
                                                    String language)
Gets the resource locator from the given property file and given language.

Parameters:
propertyFileBaseName -
language -
Returns:

getMessageContainer

public static MessageContainer getMessageContainer(String registredKey)
Gets the message container.

Returns:

addError

public static Message addError(String message)
Add an error message. If a message already exists, HTML newline is added between the existent message and the given one

Parameters:
message -
Returns:
the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).

addError

protected static Message addError(String registredKey,
                                  String message)
Add an error message. If a message already exists, HTML newline is added between the existent message and the given one

Parameters:
message -
Returns:
the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).

addSevere

public static Message addSevere(String message)
Add an severe message. If a message already exists, HTML newline is added between the existent message and the given one

Parameters:
message -
Returns:
the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).

addSevere

protected static Message addSevere(String registredKey,
                                   String message)
Add an severe message. If a message already exists, HTML newline is added between the existent message and the given one

Parameters:
message -
Returns:
the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).

addWarning

public static Message addWarning(String message)
Add an warning message. If a message already exists, HTML newline is added between the existent message and the given one

Parameters:
message -
Returns:
the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).

addWarning

protected static Message addWarning(String registredKey,
                                    String message)
Add an warning message. If a message already exists, HTML newline is added between the existent message and the given one

Parameters:
message -
Returns:
the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).

addSuccess

public static Message addSuccess(String message)
Add a success message. If a message already exists, HTML newline is added between the existent message and the given one

Parameters:
message -
Returns:
the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).

addSuccess

protected static Message addSuccess(String registredKey,
                                    String message)
Add a success message. If a message already exists, HTML newline is added between the existent message and the given one

Parameters:
message -
Returns:
the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).

addInfo

public static Message addInfo(String message)
Add an info message. If a message already exists, HTML newline is added between the existent message and the given one

Parameters:
message -
Returns:
the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).

addInfo

protected static Message addInfo(String registredKey,
                                 String message)
Add an info message. If a message already exists, HTML newline is added between the existent message and the given one

Parameters:
message -
Returns:
the instance of the created message. Some parameters of this instance can be overridden (the display live time for example).


Copyright © 2016 Silverpeas. All Rights Reserved.