com.openexchange.mail
Class MailSessionCache

java.lang.Object
  extended by com.openexchange.mail.MailSessionCache

public final class MailSessionCache
extends java.lang.Object

MailSessionCache - The main session-bound cache for mail module.

Author:
Thorben Betten

Method Summary
 void clear()
          Clears this cache.
 boolean containsParameter(int accountId, java.lang.String parameterName)
          Checks if a parameter is associated with given account ID and parameter name.
static void dropInstance(com.openexchange.session.Session session)
          Drops the session-bound mail cache.
static MailSessionCache getInstance(com.openexchange.session.Session session)
          Gets the session-bound mail cache.
<T> T
getParameter(int accountId, java.lang.String parameterName)
          Gets the parameter associated with given account ID and parameter name.
 void putParameter(int accountId, java.lang.String parameterName, java.lang.Object parameterValue)
          Puts parameter into this cache.
 java.lang.Object putParameterIfAbsent(int accountId, java.lang.String parameterName, java.lang.Object parameterValue)
          (Atomically) Puts parameter into this cache only if no other parameter is associated with given account ID and parameter name.
 void removeAccountParameters(int accountId)
          Removes the parameters associated with given account ID
 java.lang.Object removeParameter(int accountId, java.lang.String parameterName)
          Removes the parameter associated with given account ID and parameter name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static MailSessionCache getInstance(com.openexchange.session.Session session)
Gets the session-bound mail cache.

Parameters:
session - The session whose mail cache shall be returned
Returns:
The session-bound mail cache.

dropInstance

public static void dropInstance(com.openexchange.session.Session session)
Drops the session-bound mail cache.

Parameters:
session - The session whose mail cache shall be dropped

getParameter

public <T> T getParameter(int accountId,
                          java.lang.String parameterName)
Gets the parameter associated with given account ID and parameter name.

Parameters:
accountId - The account ID
parameterName - The parameter name
clazz - The parameter value's class
Returns:
The parameter or null

containsParameter

public boolean containsParameter(int accountId,
                                 java.lang.String parameterName)
Checks if a parameter is associated with given account ID and parameter name.

Parameters:
accountId - The account ID
parameterName - The parameter name
Returns:
true if a parameter is associated with given account ID and parameter name; otherwise false

putParameter

public void putParameter(int accountId,
                         java.lang.String parameterName,
                         java.lang.Object parameterValue)
Puts parameter into this cache. A null value removes the parameter.

Parameters:
accountId - The account ID
parameterName - The parameter name
parameterValue - The parameter value

putParameterIfAbsent

public java.lang.Object putParameterIfAbsent(int accountId,
                                             java.lang.String parameterName,
                                             java.lang.Object parameterValue)
(Atomically) Puts parameter into this cache only if no other parameter is associated with given account ID and parameter name. A null value removes the parameter.

Parameters:
accountId - The account ID
parameterName - The parameter name
parameterValue - The parameter value
Returns:
The parameter value previously associated with given account ID and parameter name

removeParameter

public java.lang.Object removeParameter(int accountId,
                                        java.lang.String parameterName)
Removes the parameter associated with given account ID and parameter name.

Parameters:
accountId - The account ID
parameterName - The parameter name
Returns:
The parameter previously associated with given account ID and parameter name or null

removeAccountParameters

public void removeAccountParameters(int accountId)
Removes the parameters associated with given account ID

Parameters:
accountId - The account ID

clear

public void clear()
Clears this cache.