Package org.openbravo.service.web
Class UserContextCache
- java.lang.Object
-
- org.openbravo.service.web.UserContextCache
-
- All Implemented Interfaces:
OBProvidable
,OBSingleton
public class UserContextCache extends Object implements OBSingleton
The main purpose of the user context cache is to support session-less http requests without a large performance hit. With a session-less http request every request needs to log in. This can be comparatively heavy as for each request a newOBContext
is created.The user context cache takes care of storing a cache of user contexts (on user id) which are re-used when a web-service call is done. Note that the OBContext which is cached can be re-used by multiple threads at the same time.
- Author:
- mtaal
- See Also:
OBContext
-
-
Constructor Summary
Constructors Constructor Description UserContextCache()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description OBContext
getCreateOBContext(String userId)
Searches the ContextCache for an OBContext.OBContext
getCreateOBContext(String userId, String roleId, String orgId)
Searches the ContextCache for an OBContext.static UserContextCache
getInstance()
void
invalidate()
InvalidatesUserContextCache
.static void
setInstance(UserContextCache instance)
-
-
-
Method Detail
-
getInstance
public static UserContextCache getInstance()
-
setInstance
public static void setInstance(UserContextCache instance)
-
getCreateOBContext
public OBContext getCreateOBContext(String userId)
Searches the ContextCache for an OBContext. If none is found a new one is created and placed in the cache.- Parameters:
userId
- the user for which an OBContext is required- Returns:
- the OBContext object
- See Also:
OBContext
-
getCreateOBContext
public OBContext getCreateOBContext(String userId, String roleId, String orgId)
Searches the ContextCache for an OBContext. If none is found a new one is created and placed in the cache.- Parameters:
userId
- the user for which an OBContext is requiredroleId
- the role id of the userorgId
- the org id of the user- Returns:
- the OBContext object
- See Also:
OBContext
-
invalidate
public void invalidate()
InvalidatesUserContextCache
.
-
-