@@ -0,0 +1,2034 @@
+package com.neucrack.tool;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Date;%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Apublic class Session %7B%0A%09static private HashMap%3CObject, Object%3E mAttribute = new HashMap%3CObject, Object%3E();//%C2%BC%D6%B5%0A%09static private Map%3CObject,Long%3E mTime = new HashMap%3CObject, Long%3E();//%C2%BC%CA%B1%0A%09static private ArrayList%3CObject%3E mKeys= new ArrayList%3CObject%3E();%0A%09static private long mMaxInactiveInterval = 7776000;//%C3%B3%CA%B1%CA%B1 90(7776000s)%0A%09static private long mAutoClearInterval = 7776000;//%D4%B6%CA%A7%D0%A7session%0A%09%0A%0A%09public Session() %7B%0A%09%09mMaxInactiveInterval = 1800000;//30%0A%09%09mAutoClearInterval = mMaxInactiveInterval;%0A%09%7D%0A%0A%09static public Object getAttribute(Object key) %7B%0A%09%09if(!mAttribute.containsKey(key))%0A%09%09%09return null;%0A%09%09if(System.currentTimeMillis() - mTime.get(key) %3E mMaxInactiveInterval)%0A%09%09%09return null;%0A%09%09return mAttribute.get(key);%0A%09%7D%0A%0A%09static public Object setAttribute(Object key, Object value) %7B%0A%09%09mTime.put(key, System.currentTimeMillis());%0A%09%09mKeys.add(key);%0A%09%09return mAttribute.put(key, value);%0A%09%09%09%0A%09%7D%0A%09static public void invalidate() %7B%0A%09%09mAttribute.clear();%0A%09%7D%0A%0A%09static public long getMaxInactiveInterval() %7B%0A%09%09return mMaxInactiveInterval;%0A%09%7D%0A%0A%09static public void setMaxInactiveInterval(long maxInactiveInterval) %7B%0A%09%09mMaxInactiveInterval = maxInactiveInterval;%0A%09%7D%0A%09%0A%09static public long getmAutoClearInterval() %7B%0A%09%09return mAutoClearInterval;%0A%09%7D%0A%0A%09static public void setmAutoClearInterval(long mAutoClearInterval) %7B%0A%09%09mAutoClearInterval = mAutoClearInterval;%0A%09%7D%0A%0A%09public void EnableAutoClear() %7B%0A%09%09AutoClear autoClear = new AutoClear();%0A%09%09autoClear.start();%0A%09%7D%0A%09private class AutoClear extends Thread%7B%0A%0A%09%09@Override%0A%09%09public void run() %7B%0A%09%09%09super.run();%0A%09%09%09while(true)%7B%0A%09%09%09%09for(int i=0;i%3CmAttribute.size();++i)%7B%0A%09%09%09%09%09if(System.currentTimeMillis() - mTime.get(mKeys.get(i)) %3E mMaxInactiveInterval)%0A%09%09%09%09%09%09mAttribute.remove(mKeys.get(i));%0A%09%09%09%09%7D%0A%09%09%09%09try %7B%0A%09%09%09%09%09Thread.sleep(mAutoClearInterval);%0A%09%09%09%09%7D catch (InterruptedException e) %7B%0A%09%09%09%09%09// TODO Auto-generated catch block%0A%09%09%09%09%09e.printStackTrace();%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%7D%0A%09%0A%7D%0A

add session class to save user sign in infomation