org.opensubsystems.core.util
Class CallContext

java.lang.Object
  extended by org.opensubsystems.core.util.CallContext

public class CallContext
extends java.lang.Object

This class encapsulate context in which certain (method) call execution is made. This class establishes that every call is made in the context of user and domain where the user belongs. This class is independent from the security implementation, therefore it doesn't refer to any specific security package. Overriden class actually implement concept of users and domains as proposed in this class.

Version:
$Id: CallContext.java,v 1.5 2007/01/07 06:14:00 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
Initial revision

Constructor Summary
CallContext()
          Default constructor.
 
Method Summary
 java.util.Map getCache(java.lang.String strCacheKey)
          Get custom cache for given key.
 int getCurrentDomainId()
          Get curent domain ID, which can be used to limit current user or session to access only data in this domain.
 java.lang.String getCurrentSession()
          Get identification of current session, which is jus a unique string which can identify the each individual session established between client and application.
 java.security.Principal getCurrentUser()
          Get identification of current user.
 int getCurrentUserId()
          Get curent user ID.
static CallContext getInstance()
          Get the default instance.
 Messages getMessages()
          Get messages to display to user for current call.
 void reset()
          Removes context (all information) for current call from stack.
 void resetCache()
          Removes all cached items for current custom cache.
 void resetCurrentUserAndSession()
          Removes who is the current user session for this call context from stack.
 void resetMessages()
          Removes all messages for current call.
protected  void setCache(java.util.Map cache)
          Set custom cache for this call context
 void setCurrentUserAndSession(java.security.Principal user, java.lang.String session)
          Set who is the current user and session for this call context.
static void setInstance(CallContext defaultInstance)
          Set the default instance.
protected  void setMessages(Messages msgs)
          Set the error or information message object to collect messages to display to user for current call
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CallContext

public CallContext()
Default constructor.

Method Detail

getInstance

public static CallContext getInstance()
Get the default instance.

Returns:
CallContext

setInstance

public static void setInstance(CallContext defaultInstance)
Set the default instance. This instance will be returned by getInstance method until it is changed.

Parameters:
defaultInstance - - new default instance
See Also:
getInstance()

getCurrentUser

public java.security.Principal getCurrentUser()
Get identification of current user.

Returns:
Principal - current user identification or null if not known

getCurrentSession

public java.lang.String getCurrentSession()
Get identification of current session, which is jus a unique string which can identify the each individual session established between client and application.

Returns:
String - current session identification or null if not known

getCurrentUserId

public int getCurrentUserId()
Get curent user ID.

Returns:
int - current user ID

setCurrentUserAndSession

public void setCurrentUserAndSession(java.security.Principal user,
                                     java.lang.String session)
Set who is the current user and session for this call context. Values are stored in stack.

Parameters:
user - - information about user who is making the call.
session - - information about session in whic user is making the call.

resetCurrentUserAndSession

public void resetCurrentUserAndSession()
Removes who is the current user session for this call context from stack. After this call, the current user and session will be null.


getCurrentDomainId

public int getCurrentDomainId()
Get curent domain ID, which can be used to limit current user or session to access only data in this domain. Domain is just partition to which data might be allocated.

Returns:
int - current domain ID

getMessages

public Messages getMessages()
Get messages to display to user for current call.

Returns:
Messages - error or information messages to display to user related to current call, never null

setMessages

protected void setMessages(Messages msgs)
Set the error or information message object to collect messages to display to user for current call

Parameters:
msgs - - messages for current call

resetMessages

public void resetMessages()
Removes all messages for current call. After this call, there won't be any error or information messages to display to the user.


getCache

public java.util.Map getCache(java.lang.String strCacheKey)
Get custom cache for given key.

Parameters:
strCacheKey - - key for which to get cache
Returns:
Map - cache registered under given key. This will always return Map and never null.

setCache

protected void setCache(java.util.Map cache)
Set custom cache for this call context

Parameters:
cache - - cache for current call context

resetCache

public void resetCache()
Removes all cached items for current custom cache.


reset

public void reset()
Removes context (all information) for current call from stack.



Copyright © 2003 - 2006 OpenSubsystems s.r.o.