Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 2013-2014 sagyf Yang. The Four Group.
   */
  
  package com.github.sog.controller.flash;
  
 

.

Author(s):
sagyf yang
Version:
1.0 2014-03-27 11:48
Since:
JDK 1.6
 
 public class EhCacheFlashManager implements FlashManager {

    
falsh 存放在cache中的值。
 
     private final String flashCacheName;

    
 
     private ReentrantLock lock = new ReentrantLock();

    
构造函数

Parameters:
flashCacheName ehcache 中的key值。
 
     public EhCacheFlashManager(String flashCacheName) {
         if (StringKit.isBlank(flashCacheName)) {
             throw new IllegalArgumentException("flashCacheName can not be blank.");
         }
         this. = flashCacheName;
     }
 
     @Override
     public void setFlash(HttpSession sessionString curActionString keyObject value) {
         String sessionKey = session.getId();
         sessionKey = sessionKey + curAction.replace("/""_");
         try {
             .lock();
             ConcurrentHashMap<StringObjectmap;
             Object obj = CacheKit.get(sessionKey);
             if (obj != null) {
                 map = (ConcurrentHashMap<StringObject>) obj;
             } else {
                 map = new ConcurrentHashMap<StringObject>();
                 CacheKit.put(sessionKeymap);
             }
             map.put(keyvalue);
         } finally {
             .unlock();
         }
     }
 
     @Override
     public void updateFlashKey(HttpSession sessionString curActionString nextAction) {
         String sessionKey = session.getId();
         String oldKey = sessionKey + curAction.replace("/""_");
         String newkey = sessionKey + nextAction.replace("/""_");
         try {
             .lock();
             Object obj = CacheKit.get(oldKey);
             if (obj != null) {
                 CacheKit.remove(oldKey);
                 CacheKit.put(newkeyobj);
             }
         } finally {
             .unlock();
         }
     }
 
     @Override
     public ConcurrentHashMap<StringObjectgetFlash(HttpSession sessionString curAction) {
         String sessionKey = session.getId();
         String sessionActionKey = sessionKey + curAction.replace("/""_");
         ConcurrentHashMap<StringObjectmap = null;
         try {
             .lock();
             Object obj = CacheKit.get(sessionActionKey);
             if (obj != null) {
                 map = (ConcurrentHashMap<StringObject>) obj;
                 CacheKit.remove(sessionActionKey);
             }
         } finally {
             .unlock();
        }
        return map;
    }
New to GrepCode? Check out our FAQ X