|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.myfaces.trinidadinternal.util.TokenCache
public class TokenCache
A simple LRU tokenized cache. The cache is responsible for storing tokens, but the storage of the values referred to by those tokens is not handled by this class. Instead, the user of this class has to provide a Map instance to each call.
The design seems odd, but is intentional - this way, a session Map can be used directly as the storage target for values, while the TokenCache simply maintains the logic of which tokens should still be available. Storing values directly in the cache object (instead of directly on the session) causes HttpSession failover difficulties.
TokenCache also supports the concept of "pinning", whereby one token can be pinned to another. The pinned token will not be removed from the cache until all tokens that it is pinned to are also out of the cache.
| Field Summary | |
|---|---|
static char |
SEPARATOR_CHAR
Character guaranteed to not be used in tokens |
| Constructor Summary | |
|---|---|
TokenCache(int size)
Create a TokenCache that will store the last "size" entries. |
|
| Method Summary | ||
|---|---|---|
|
addNewEntry(V value,
java.util.Map<java.lang.String,V> targetStore)
Create a new token; and use that token to store a value into a target Map. |
|
|
addNewEntry(V value,
java.util.Map<java.lang.String,V> targetStore,
java.lang.String pinnedToken)
Create a new token; and use that token to store a value into a target Map. |
|
|
clear(java.util.Map<java.lang.String,V> targetStore)
Clear a cache, without resetting the token. |
|
static TokenCache |
getTokenCacheFromSession(javax.faces.context.ExternalContext extContext,
java.lang.String cacheName,
boolean createIfNeeded,
int defaultSize)
Gets a TokenCache from the session, creating it if needed. |
|
boolean |
isAvailable(java.lang.String token)
Returns true if an entry is still available. |
|
void |
reattachOwner(java.util.Map<java.lang.String,java.lang.Object> owner)
Reattaches the owner after Serialization since the owner might not be Serializable or it might not be a good idea to serialize the owner. |
|
|
removeOldEntry(java.lang.String token,
java.util.Map<java.lang.String,V> targetStore)
Removes a value from the cache. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char SEPARATOR_CHAR
| Constructor Detail |
|---|
public TokenCache(int size)
| Method Detail |
|---|
public static TokenCache getTokenCacheFromSession(javax.faces.context.ExternalContext extContext,
java.lang.String cacheName,
boolean createIfNeeded,
int defaultSize)
public void reattachOwner(java.util.Map<java.lang.String,java.lang.Object> owner)
owner -
java.lang.NullPointerException - if owner is null
public <V> java.lang.String addNewEntry(V value,
java.util.Map<java.lang.String,V> targetStore)
value - the value being added to the target storetargetStore - the map used for storing the value
public <V> java.lang.String addNewEntry(V value,
java.util.Map<java.lang.String,V> targetStore,
java.lang.String pinnedToken)
value - the value being added to the target storetargetStore - the map used for storing the valuepinnedToken - a token, that if still in the cache,
will not be freed until this current token is also freed
public boolean isAvailable(java.lang.String token)
public <V> V removeOldEntry(java.lang.String token,
java.util.Map<java.lang.String,V> targetStore)
public <V> void clear(java.util.Map<java.lang.String,V> targetStore)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||