Update of 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher/cache
In directory james.mmbase.org:/tmp/cvs-serv16585

Modified Files:
        CacheFactory.java CacheFreshTask.java CacheInfo.java 
        DefaultCache.java ICache.java 
Log Message:
CMSC-899,Check and improve all lists according to guideline,add Javadoc comment


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher/cache
See also: http://www.mmbase.org/jira/browse/CMSC-899


Index: CacheFactory.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher/cache/CacheFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- CacheFactory.java   22 Sep 2008 10:52:27 -0000      1.6
+++ CacheFactory.java   23 Sep 2008 05:28:27 -0000      1.7
@@ -12,13 +12,9 @@
    private static final Log logger = LogFactory.getLog(CacheFactory.class);
 
    /**
-    * get caches'cahe
-    * 
-    * @param caches
-    *           f
-    * @return ICache
+    * @param caches this is a map
+    * @return interface 
     */
-
    public static ICache getCacheInstance(Class caches) {
       if (cache == null) {
          try {
@@ -46,7 +42,7 @@
    /**
     * getDefaultCache
     * 
-    * @param time
+    * @param time which control the life of cache
     * @return ICache
     */
    public static ICache getDefaultCache(long time) {


Index: CacheFreshTask.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher/cache/CacheFreshTask.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- CacheFreshTask.java 22 Sep 2008 10:52:27 -0000      1.5
+++ CacheFreshTask.java 23 Sep 2008 05:28:27 -0000      1.6
@@ -5,22 +5,28 @@
 import java.util.TimerTask;
 
 /**
- * @author nikko yin
+ * @author nikko
+ * 
  */
 public class CacheFreshTask extends TimerTask {
    private DefaultCache cache;
 
-   /* FreshTask */
+   /**
+    * @param cache this is a map info bean
+    */
    public CacheFreshTask(DefaultCache cache) {
       this.cache = cache;
    }
 
-   /* Start Thread */
+   /**
+    * Start Thread
+    * @see java.util.TimerTask#run()
+    */
    public void run() {
       synchronized (cache.getDatas()) {
-         Iterator<Map.Entry<String, CacheInfo>> iterator = 
cache.getDatas().entrySet().iterator();
+         Iterator < Map.Entry < String , CacheInfo > > iterator = 
cache.getDatas().entrySet().iterator();
          while (iterator.hasNext()) {
-            Map.Entry<String, CacheInfo> entry = iterator.next();
+            Map.Entry < String , CacheInfo > entry = iterator.next();
             CacheInfo ci = entry.getValue();
             if (ci.getTotalSeconds() != ICache.Forever) {
                ci.setSecondsRemain(ci.getSecondsRemain() - 1);


Index: CacheInfo.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher/cache/CacheInfo.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- CacheInfo.java      22 Sep 2008 10:52:27 -0000      1.5
+++ CacheInfo.java      23 Sep 2008 05:28:27 -0000      1.6
@@ -2,6 +2,7 @@
 
 /**
  * @author nikko yin
+ * CacheInfo is infoBean has getter and setter
  */
 public class CacheInfo {
 
@@ -9,33 +10,24 @@
    private long secondsRemain;
    private long cacheSeconds;
 
-   // construct CacheInfoBean
    public CacheInfo(Object obj, long cacheSeconds) {
       this.obj = obj;
       this.secondsRemain = cacheSeconds;
       this.cacheSeconds = cacheSeconds;
    }
 
-   // getObjInfoBean
    public Object getObj() {
       return obj;
    }
 
-   // getSecondsRemain
    public long getSecondsRemain() {
       return secondsRemain;
    }
 
-   // getTotalSeconds
    public long getTotalSeconds() {
       return cacheSeconds;
    }
 
-   /**
-    * setSecondsRemain
-    * 
-    * @param null
-    */
    public void setSecondsRemain(long secondsRemain) {
       this.secondsRemain = secondsRemain;
    }


Index: DefaultCache.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher/cache/DefaultCache.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- DefaultCache.java   22 Sep 2008 10:52:27 -0000      1.6
+++ DefaultCache.java   23 Sep 2008 05:28:27 -0000      1.7
@@ -8,40 +8,41 @@
 
 /**
  * @author nikko yin
+ * implement the interface ICache
  */
 public class DefaultCache implements ICache {
 
    private static final int FreshTimerIntervalSeconds = 1;
-   private Map<String, CacheInfo> datas;
+   private Map < String , CacheInfo > datas;
    private long time = 1800;
    private Timer timer;
 
+   /**
+    * synchronized cache when instance it
+    * flush when every second
+    */
    public DefaultCache() {
-      // synchronized cache when instance it
-      datas = Collections.synchronizedMap(new HashMap<String, CacheInfo>());
-      // flush cache
+      datas = Collections.synchronizedMap(new HashMap < String , CacheInfo > 
());
       TimerTask task = new CacheFreshTask(this);
       timer = new Timer("Cache_Timer", true);
-      // flush when every second
       timer.scheduleAtFixedRate(task, 1000, FreshTimerIntervalSeconds * 1000);
    }
 
-   // implement the interface
    public DefaultCache(long time) {
       this();
       this.time = time;
    }
 
-   // * add
+   /* add
+    * @see 
com.finalist.newsletter.publisher.cache.ICache#add(java.lang.Object, 
java.lang.Object)
+    */
    public void add(Object key, Object value) {
       add(key, value, time);
    }
 
-   /**
-    * add
-    * 
-    * @param Object ,
-    *           Object and long
+  
+   /* 
+    * @see 
com.finalist.newsletter.publisher.cache.ICache#add(java.lang.Object, 
java.lang.Object, long)
     */
    public void add(Object key, Object value, long slidingExpiration) {
       if (slidingExpiration != 0) {
@@ -50,16 +51,19 @@
       }
    }
 
-   // contains
+   /* contains
+    * @see 
com.finalist.newsletter.publisher.cache.ICache#contains(java.lang.Object)
+    */
    public boolean contains(Object key) {
-      if (datas.containsKey(key)) return true;
+      if (datas.containsKey(key)) {
+         return true;
+      }
       return false;
    }
 
-   /**
-    * get
-    * 
-    * @param Object
+   
+   /* 
+    * @see com.finalist.newsletter.publisher.cache.ICache#get(java.lang.Object)
     */
    public Object get(Object key) {
       if (datas.containsKey(key)) {
@@ -71,47 +75,29 @@
       return null;
    }
 
-   /**
-    * remove
-    * 
-    * @param Object
+   /* 
+    * @see 
com.finalist.newsletter.publisher.cache.ICache#remove(java.lang.Object)
     */
    public void remove(Object key) {
       datas.remove(key);
    }
 
-   /**
-    * removeAll
-    * 
-    * @param null
+   
+   /* 
+    * @see com.finalist.newsletter.publisher.cache.ICache#removeAll()
     */
    public void removeAll() {
    }
 
-   /**
-    * getTime
-    * 
-    * @param null
-    */
    public long getTime() {
       return time;
    }
 
-   /**
-    * setTime
-    * 
-    * @param time
-    */
    public void setTime(long time) {
       this.time = time;
    }
 
-   /**
-    * getDatas
-    * 
-    * @param null
-    */
-   public Map<String, CacheInfo> getDatas() {
+   public Map < String , CacheInfo > getDatas() {
       return datas;
    }
 }


Index: ICache.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-newsletter/src/java/com/finalist/newsletter/publisher/cache/ICache.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ICache.java 22 Sep 2008 10:52:27 -0000      1.2
+++ ICache.java 23 Sep 2008 05:28:27 -0000      1.3
@@ -1,18 +1,45 @@
 package com.finalist.newsletter.publisher.cache;
 
+/**
+ * @author nikko
+ * 
+ */
 public interface ICache {
    public static int Forever = -1;
 
+   /**
+    * @param key used to find value
+    * @param value store the infobean
+    */
    public void add(Object key, Object value);
 
+   /**
+    * @param key used to find value
+    * @param value store the infobean
+    * @param slidingExpiration the life of infobean
+    */
    public void add(Object key, Object value, long slidingExpiration);
 
+   /**
+    * @param key remove 
+    */
    public void remove(Object key);
 
+   /**
+    * remove all exited infobean in the cache
+    */
    public void removeAll();
 
+   /**
+    * @param key
+    * @return Object
+    */
    public Object get(Object key);
 
+   /**
+    * @param key
+    * @return boolean
+    */
    public boolean contains(Object key);
 
 }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to