[jboss-svn-commits] JBL Code SVN: r14598 - in labs/shotoku/trunk: shotoku-base/src/java/org/jboss/shotoku/cache and 10 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Aug 26 11:05:14 EDT 2007


Author: adamw
Date: 2007-08-26 11:05:13 -0400 (Sun, 26 Aug 2007)
New Revision: 14598

Added:
   labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheItemInject.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItem.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItemDataSource.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItemOperations.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItemUser.java
Removed:
   labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheItem.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItem.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemDataSource.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemOperations.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemUser.java
Modified:
   labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java
   labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCacheItem.java
   labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/AdminBean.java
   labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/CacheItemBean.java
   labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/MonitorBean.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UpdateThreadData.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/DummyRenewableCacheService.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/RenewableCacheServiceMBean.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlert.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/DummyRenewableCacheMonitorService.java
   labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/RenewableCacheMonitorServiceMBean.java
   labs/shotoku/trunk/shotoku-cache/cache-service/src/java/org/jboss/shotoku/cache/service/RenewableCacheService.java
   labs/shotoku/trunk/shotoku-cache/cache-service/src/java/org/jboss/shotoku/cache/service/monitor/RenewableCacheMonitorService.java
   labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestCacheItem.java
   labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestCacheItem2.java
   labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestCacheItem3.java
   labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestServlet.java
   labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptorImpl.java
   labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/service/FeedsServiceImpl.java
   labs/shotoku/trunk/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java
Log:
Refactoring

Modified: labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java
===================================================================
--- labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -25,8 +25,8 @@
 import org.jboss.aop.Bind;
 import org.jboss.aop.joinpoint.*;
 import org.jboss.aop.advice.Scope;
-import org.jboss.shotoku.cache.RenewableCacheItem;
-import org.jboss.shotoku.cache.RenewableCacheItemUser;
+import org.jboss.shotoku.cache.CacheItem;
+import org.jboss.shotoku.cache.CacheItemUser;
 
 /**
  * @author Adam Warski (adamw at aster.pl)
@@ -34,10 +34,10 @@
 @Aspect(scope=Scope.PER_JOINPOINT)
 public class CacheInjectAspect {
     private final static Object synchronizer = new Object();
-    private RenewableCacheItemUser<?,?> sci;
+    private CacheItemUser<?,?> sci;
 
-    private CacheItem getCurrentAnnotation(FieldInvocation invocation) {
-        CacheItem current = invocation.getField().getAnnotation(CacheItem.class);
+    private CacheItemInject getCurrentAnnotation(FieldInvocation invocation) {
+    	CacheItemInject current = invocation.getField().getAnnotation(CacheItemInject.class);
         if (current == null)
             throw new RuntimeException("This aspect should be used only with " +
                     "@CacheItem!");
@@ -51,9 +51,9 @@
         if (sci == null) {
             synchronized(synchronizer) {
                 if (sci == null) {
-                    CacheItem ci = getCurrentAnnotation(invocation);
+                	CacheItemInject ci = getCurrentAnnotation(invocation);
 
-                    sci = RenewableCacheItem.create(ci.dataSource().newInstance(), null, null, ci.interval());
+                    sci = CacheItem.create(ci.dataSource().newInstance(), null, null, ci.interval());
                 }
             }
         }

Deleted: labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheItem.java
===================================================================
--- labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheItem.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheItem.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.shotoku.aop;
-
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-import org.jboss.shotoku.cache.RenewableCacheItemDataSource;
-
-/**
- * @author Adam Warski (adamw at aster.pl)
- */
- at Target({ElementType.FIELD})
- at Retention(RetentionPolicy.RUNTIME)
-public @interface CacheItem {
-    long interval()     default 0;
-    Class<? extends RenewableCacheItemDataSource<?,?>> dataSource();
-}

Copied: labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheItemInject.java (from rev 14597, labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheItem.java)
===================================================================
--- labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheItemInject.java	                        (rev 0)
+++ labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheItemInject.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.shotoku.aop;
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import org.jboss.shotoku.cache.CacheItemDataSource;
+
+/**
+ * @author Adam Warski (adamw at aster.pl)
+ */
+ at Target({ElementType.FIELD})
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface CacheItemInject {
+    long interval()     default 0;
+    Class<? extends CacheItemDataSource<?,?>> dataSource();
+}

Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCacheItem.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCacheItem.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCacheItem.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -36,7 +36,7 @@
  * @param <T> Type of the object that will be stored in the cache.
  * @author Adam Warski (adamw at aster.pl)
  */
-public abstract class ShotokuCacheItem<K, T> implements RenewableCacheItemDataSource<K, T> {
+public abstract class ShotokuCacheItem<K, T> implements CacheItemDataSource<K, T> {
     private final Map<K, ContentManager> cmForKeys = new HashMap<K, ContentManager>();
 
     /**

Modified: labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/AdminBean.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/AdminBean.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/AdminBean.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -10,7 +10,7 @@
 import javax.faces.context.FacesContext;
 import javax.servlet.http.HttpServletRequest;
 
-import org.jboss.shotoku.cache.RenewableCacheItemOperations;
+import org.jboss.shotoku.cache.CacheItemOperations;
 import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
 import org.jboss.shotoku.cache.service.RenewableCacheStatistics;
 import org.jboss.shotoku.tools.CacheTools;
@@ -78,7 +78,7 @@
 		if (cacheItems == null) {
 			cacheItems = new ArrayList<CacheItemBean>();
 			
-			for (RenewableCacheItemOperations<?,?> cacheItemData : getService().getCacheItemsOperations()) {
+			for (CacheItemOperations<?,?> cacheItemData : getService().getCacheItemsOperations()) {
 				CacheItemBean cacheItemBean = new CacheItemBean(cacheItemData, getService(), this);
 				cacheItems.add(cacheItemBean);
 			}

Modified: labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/CacheItemBean.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/CacheItemBean.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/CacheItemBean.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -6,12 +6,12 @@
 import java.util.Map;
 
 import org.jboss.cache.CacheException;
-import org.jboss.shotoku.cache.RenewableCacheItemOperations;
+import org.jboss.shotoku.cache.CacheItemOperations;
 import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
 import org.jboss.shotoku.cache.service.monitor.CacheAlert;
 
 public class CacheItemBean {
-	private RenewableCacheItemOperations<?,?> cacheItem;
+	private CacheItemOperations<?,?> cacheItem;
 	private List<? extends Object> keysDuringUpdate;
 	private List<? extends Object> keysNotDuringUpdate;
 	private Map<Object, Long> keysUpdatesAgo;
@@ -22,7 +22,7 @@
 	
 	private AdminBean adminBean;
 	
-	public CacheItemBean(RenewableCacheItemOperations<?,?> cacheItem, RenewableCacheServiceMBean service, AdminBean adminBean) {
+	public CacheItemBean(CacheItemOperations<?,?> cacheItem, RenewableCacheServiceMBean service, AdminBean adminBean) {
 		this.cacheItem = cacheItem;
 		this.service = service;
 		

Modified: labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/MonitorBean.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/MonitorBean.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-admin/src/java/org/jboss/shotoku/cache/admin/MonitorBean.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -3,7 +3,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.jboss.shotoku.cache.RenewableCacheItemOperations;
+import org.jboss.shotoku.cache.CacheItemOperations;
 import org.jboss.shotoku.cache.service.monitor.DummyRenewableCacheMonitorService;
 import org.jboss.shotoku.cache.service.monitor.RenewableCacheMonitorServiceMBean;
 import org.jboss.shotoku.tools.CacheTools;
@@ -51,7 +51,7 @@
     public List<String> getCurrentAlerts() {
     	if (currentAlerts == null) {
     		currentAlerts = new ArrayList<String>();
-    		for (RenewableCacheItemOperations<?,?> rcid : getMonitor().getCacheItemsWithAlerts()) {
+    		for (CacheItemOperations<?,?> rcid : getMonitor().getCacheItemsWithAlerts()) {
     			currentAlerts.add(rcid.getName());
     		}
     	}

Added: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItem.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItem.java	                        (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItem.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -0,0 +1,380 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.shotoku.cache;
+
+import org.apache.log4j.Logger;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.shotoku.tools.CacheTools;
+import org.jboss.shotoku.tools.ConcurrentSet;
+import org.jboss.shotoku.tools.ConcurrentHashSet;
+import org.jboss.shotoku.cache.service.DummyRenewableCacheService;
+import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
+
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Extend this class if you want to store objects in a cache that
+ * will be updated on a regular intervals of time, by a service daemon
+ * thread. All data is held in one node of a {@link org.jboss.cache.TreeCache}.
+ * If a key is requested for the first time, it is initialized with the
+ * {@link #init(Object)} method. Later, the {@link #update(Object, Object)} method
+ * is called to (possibly) update the currently held value.
+ * 
+ * The cache item will be auto-registered in the service upon construction 
+ * --- so take care when constructing objects of this class. When you want to
+ * remove all keys, from the TreeCache node, that are handled by this cache item,
+ * simply call the {@link #unregister()} method.
+ * 
+ * @param <K> Type of the key of the objects held in cache. The keys
+ * should bahave well as map keys (most probably, the hashCode() and
+ * equals() methods should be overriden).
+ * 
+ * @param <T> Type of the objects that will be stored in the cache.
+ * 
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ */
+public class CacheItem<K, T> implements CacheItemOperations<K, T> {
+	private final Logger log = Logger.getLogger(CacheItem.class);
+	
+	private CacheItemDataSource<K, T> dataSource;
+	
+    private Fqn fqn;
+    private long interval;
+    private String mbeanName;
+    private int id;
+    
+    private ConcurrentMap<K, Long> keysUpdates;
+    /**
+     * Double-update-start prevention: if a key is already in that set, it won't be updated.
+     */
+    private ConcurrentSet<K> keysInUpdate;
+    /**
+     * Information: update methods of which keys are currently executed. Doesn't have to 
+     * coincide with <code>keysInUpdate</code>, as the execution of the update methods for
+     * some keys may be waiting in a queue.
+     */
+    private ConcurrentSet<K> keysDuringUpdate;
+    /**
+     * Exceptions whih occured on last update of keys.
+     */
+    private ConcurrentMap<K, Throwable> keysExceptions;
+    
+    private RenewableCacheServiceMBean service;
+
+    private CacheItem(CacheItemDataSource<K, T> dataSource, Fqn fqn, String mbeanName, long interval) {
+    	this.dataSource = dataSource;
+    	
+    	if (mbeanName == null) {
+    		mbeanName = CacheTools.DEFAULT_RENEWABLE_CACHE_MBEAN;
+    	}
+    	
+    	this.mbeanName = mbeanName;
+    	
+    	this.interval = interval;
+    	
+        keysUpdates = new ConcurrentHashMap<K, Long>();
+        keysDuringUpdate = new ConcurrentHashSet<K>();
+        keysInUpdate = new ConcurrentHashSet<K>();
+        keysExceptions = new ConcurrentHashMap<K, Throwable>();
+    	
+        id = CacheTools.getNextId();
+        
+    	register();
+        
+    	if (fqn == null) {
+    		this.fqn = service.generateNextFqn();
+    	} else {
+    		this.fqn = fqn;
+    	}
+    }
+    
+    /**
+     * Creates and registeres a new cache item, with default parameter values (see
+     * {@link #RenewableCacheItem(Fqn, String, long, long)}): the fqn will be auto-generated,
+     * a default cache mbean name will be used, update will happen on each service thread
+     * update and there will be no limit on the length of a key update.
+     */
+    public static <K,T> CacheItemUser<K,T> create(CacheItemDataSource<K,T> dataSource) {
+    	return create(dataSource, null, null, 0);
+    }
+    
+    /**
+     * Creates and registeres a new cache item.
+     *
+     * @param fqn An fqn of the node in TreeCache, where data should be held. If it is null,
+     * a unique fqn will be auto-generated for this cache item.
+     * 
+     * @param mbeanName A name of an {@link RenewableCacheServiceMBean} mbean, which
+     * should be used to perform cache operations. This mbeans holds a reference
+     * to a {@link org.jboss.cache.TreeCache}. If it is null, a default mbean
+     * name will be used.
+     * 
+     * @param interval Interval at which the update operation will be executed.
+     * Effectively, the interval will be rounded to the nearest multiplicity of
+     * the service update thread interval. The interval should be given in milliseconds.
+     * If it is 0, the {@link #update()} method will be executed on every service
+     * thread update.
+     */
+    public static <K,T> CacheItemUser<K,T> create(CacheItemDataSource<K,T> dataSource,
+    		Fqn fqn, String mbeanName, long interval) {
+    	return new CacheItem<K, T>(dataSource, fqn, mbeanName, interval);
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.jboss.shotoku.cache.CacheItemUser#register()
+     */
+    public synchronized void register() {
+			synchronized (keysUpdates) {
+				synchronized (keysDuringUpdate) {
+					keysUpdates.clear();
+					keysDuringUpdate.clear();
+					
+					try {
+						service = (RenewableCacheServiceMBean) 
+							CacheTools.getService(mbeanName, RenewableCacheServiceMBean.class);
+					} catch (Exception e) {
+						log.error("No RenewableCacheService bound to "
+								+ mbeanName + " in cache item "
+								+ getName() + "!");
+						return;
+					}
+
+					service.register(this);
+				}
+			}
+	}
+
+    /*
+     * (non-Javadoc)
+     * @see org.jboss.shotoku.cache.CacheItemUser#unregister()
+     */
+    public synchronized void unregister() {
+        try {
+        	RenewableCacheServiceMBean oldService = service;
+        	service = new DummyRenewableCacheService();
+        	
+			oldService.unregister(this);
+		} catch (CacheException e) {
+			log.error("Error while unregistering a cache item " + this.getClass() + ".", e);
+		}
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.jboss.shotoku.cache.CacheItemUser#getFqn()
+     */
+    public Fqn getFqn() {
+		return fqn;
+	}
+
+    /*
+     * (non-Javadoc)
+     * @see org.jboss.shotoku.cache.CacheItemUser#getInterval()
+     */
+	public synchronized long getInterval() {
+		return interval;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.jboss.shotoku.cache.CacheItemUser#setInterval(long)
+	 */
+	public synchronized void setInterval(long interval) {
+		this.interval = interval;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.jboss.shotoku.cache.CacheItemUser#getMbeanName()
+	 */
+	public String getMbeanName() {
+		return mbeanName;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.jboss.shotoku.cache.CacheItemUser#getKeysDuringUpdate()
+	 */
+	public ConcurrentSet<K> getKeysDuringUpdate() {
+		return keysDuringUpdate;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.jboss.shotoku.cache.CacheItemUser#getKeysUpdates()
+	 */
+	public ConcurrentMap<K, Long> getKeysUpdates() {
+		return keysUpdates;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.jboss.shotoku.cache.CacheItemUser#getKeysExceptions()
+	 */
+	public ConcurrentMap<K, Throwable> getKeysExceptions() {
+		return keysExceptions;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * @see org.jboss.shotoku.cache.CacheItemUser#getId()
+	 */
+	public int getId() {
+		return id;
+	}
+    
+    /*
+     * (non-Javadoc)
+     * @see org.jboss.shotoku.cache.CacheItemUser#getInfo()
+     */
+    public String getInfo() {
+    	return dataSource.getInfo();
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.jboss.shotoku.cache.CacheItemUser#getName()
+     */
+    public String getName() {
+    	return dataSource.getClass().getName();
+    }
+
+	/**
+     * Binds the given key with the given object in the associated TreeCache
+     * node. Should be only called
+     * from the {@link #update(Object, Object)} method to put new values in the
+     * cache (if not called during an update, this method has no effect).
+     * @param key Key of the object.
+     * @param object Object that should be bound.
+     */
+    private synchronized final void put(K key, T object) { 
+        if (!keysDuringUpdate.contains(key)) {
+            return;
+        }
+        
+        try {
+			service.put(fqn, key, object);
+		} catch (CacheException e) {
+			log.error("Error while putting a value for key \"" + key + "\" in cache item " + this.getClass() + ".", e);
+		}
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.jboss.shotoku.cache.CacheItemUser#get(java.lang.Object)
+     */
+    @SuppressWarnings("unchecked")
+	public final T get(K key) {
+    	if (!keysUpdates.containsKey(key)) {
+			synchronized (this) {
+				if (!keysUpdates.containsKey(key)) {
+					T ret = dataSource.init(key);
+					try {
+						service.put(fqn, key, ret);
+					} catch (CacheException e) {
+						log.error("Error while putting a value for key \""
+								+ key + "\" in cache item " + this.getClass()
+								+ ".", e);
+						return null;
+					}
+
+					// We have to initialize a new object.
+					keysUpdates.put(key, System.currentTimeMillis());
+
+					return ret;
+				}
+			}
+		}
+
+        try {
+			return (T) service.get(fqn, key);
+		} catch (CacheException e) {
+			log.error("Error while getting a value for key \"" + key + "\" in cache item " + this.getClass() + ".", e);
+			return null;
+		}
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.jboss.shotoku.cache.CacheItemOperations#update()
+     */
+    public void update() {
+        long now = Calendar.getInstance().getTimeInMillis();
+        
+        for (final K key : keysUpdates.keySet()) {
+            if (now - keysUpdates.get(key) >= interval) {
+                if (keysInUpdate.add(key)) {
+                    service.addUpdateThreadData(new UpdateThreadData<K, T>(key, this) {
+                        public void execute() {
+                        	keysUpdates.put(key, System.currentTimeMillis());
+                        	keysDuringUpdate.add(key);
+                        	
+                            try {
+                                ValueChange<T> change = dataSource.update(key, get(key));
+                                if (change.hasValue()) {
+                                	put(key, change.getValue());
+                                }
+                            } finally {
+                            	keysInUpdate.remove(key);
+                            	keysDuringUpdate.remove(key);
+                            }
+                        }
+                    });
+                }
+            }
+        }
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.jboss.shotoku.cache.CacheItemUser#resetKey(java.lang.Object)
+     */
+    public void resetKey(Object key) {
+    	keysInUpdate.remove(key);
+    	keysDuringUpdate.remove(key);
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.jboss.shotoku.cache.CacheItemOperations#reportUpdateOk(java.lang.Object)
+     */
+    public void reportUpdateOk(K key) {
+		
+	}
+
+    /*
+     * (non-Javadoc)
+     * @see org.jboss.shotoku.cache.CacheItemOperations#reportUpdateWithException(java.lang.Object, java.lang.Throwable)
+     */
+	public void reportUpdateWithException(K key, Throwable t) {
+		if (keysExceptions.put(key, t) == null) {
+			// There was no exception before.
+			log.error("Update of cache item " + getName() + " for key " + key + " threw an exception. Suppressing " +
+					"subsequent exceptions.", t);
+		}
+	}
+}

Added: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItemDataSource.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItemDataSource.java	                        (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItemDataSource.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.shotoku.cache;
+
+import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
+
+/**
+ * Basic interface when using a renewable cache item --- defines methods, which
+ * are used to determine what values should be put to the cache. The {@link #init(Object)} method
+ * is called when a user demands a value for a key that hasn't been accessed before.
+ * That value is then placed in the cache, and updated periodically in the background,
+ * using the {@link #update(Object, Object)} method. How often the updates happen,
+ * depends on the settings of the {@link RenewableCacheServiceMBean} and on
+ * settings passed when creating the cache item
+ * ({@link CacheItem#create(RenewableCacheItemDataSource, org.jboss.cache.Fqn, String, long)}).
+ * @param <K> Type of keys in the cache. The keys
+ * should bahave well as map keys (most probably, the hashCode() and
+ * equals() methods should be overriden).
+ * @param <T> Type of the values bound to the keys in the cache.
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ */
+public interface CacheItemDataSource<K, T> {
+	/**
+     * Called by the service periodically to update the object held in the
+     * cache, bound to the given key. The value current held in the cache can be changed or not.
+     * @param key Key of the object to update.
+     * @param currentObject Current value held in the cache.
+     * @return Can return either:
+     * <ul>
+     * <li>{@link ValueChange#noChange()} to indicate that the value currently held in the cache
+     * shouldn't be changed.</li>
+     * <li>{@link ValueChange#changeTo(Object)} to bind a new value to the given key in
+     * the cache.</li>
+     * </ul>
+     */
+    public ValueChange<T> update(K key, T currentObject);
+
+    /**
+     * Called when the user demands an object which hasn't been accessed
+     * before, and thus, which hasn't been yet initialized. 
+     * @param key Key of the object to initialize.
+     * @return Initial value of an object with the given key.
+     */
+    public T init(K key);
+    
+    /**
+     * 
+     * @return Additional information about this data source, which is visible for example
+     * in the cache administration web application. Has no influence on the behaviour or
+     * content of the cache.
+     */
+    public String getInfo();
+}

Added: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItemOperations.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItemOperations.java	                        (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItemOperations.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.shotoku.cache;
+
+/**
+ * Operations on a cache item that shouldn't be visible to the user --- mainly
+ * the {@link #update()} method.
+ * @param <K> Type of the keys in the cache.
+ * @param <T> Type of the values bound to the keys in the cache.
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ */
+public interface CacheItemOperations<K,T> extends CacheItemUser<K,T> {
+	/**
+     * Called by the service update thread to update all keys and associated values.
+     * You shouldn't call it from inside your code.
+     */
+    public void update();
+	
+	/**
+	 * Reports that an update of a key ended wihtout any exceptions.
+	 * @param key Key which has been updated.
+	 */
+	public void reportUpdateOk(K key);
+	
+	/**
+	 * Reports that an update of a key ended with an exception.
+	 * @param key Key which has been updated.
+	 * @param t Exception which was thrown during the update.
+	 */
+	public void reportUpdateWithException(K key, Throwable t);
+}

Added: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItemUser.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItemUser.java	                        (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/CacheItemUser.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -0,0 +1,146 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+package org.jboss.shotoku.cache;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.cache.Fqn;
+import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
+
+/**
+ * An interface presented to the user of the cache item. Its main function is
+ * to retrieve values from the cache, but also to get configuration information and
+ * information about the current state of keys (their last updates, etc) handeled
+ * by this cache item.
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ *
+ * @param <K> Type of the keys in the cache.
+ * @param <T> Type of the values bound to the keys in the cache.
+ */
+public interface CacheItemUser<K, T> {
+	/**
+	 * Resets the given key, that is, it's update status. Hence, if a thread updating a key
+	 * locks for some reason, it is possible to resume updates of this key. Use with caution.
+	 * @param key Key, which update status should be reset.
+	 */
+	public void resetKey(Object key);
+	
+	/**
+     * Gets an object that is bound to the given key in the associated
+     * TreeCache node.
+     * If this object is not in the cache, it will be initialized (using the
+     * {@link CacheItemDataSource#init(Object)} method of a data source
+     * that was passed to {@link CacheItem#create(CacheItemDataSource)}).
+     * @param key Key of the object to get.
+     * @return Value of the object.
+     */
+	public T get(K key);
+	
+	/**
+     * Registers this cache item in the service. This method is automatically called
+     * when creating the cache item (using {@link CacheItem#create(CacheItemDataSource)}),
+     * so you will only need to use it if you previously
+     * manually unregistered the cache item using {@link #unregister()}.
+     */
+    public void register();
+    
+    /**
+     * Removes all keys handled by this cache item from the associated TreeCache node and
+     * stops updates on this cache item.
+     */
+    public void unregister();
+    
+	/**
+	 * 
+	 * @return A fqn of a TreeCache node associated with this cache item. This is a node in which
+	 * data will be kept.
+	 */
+	public Fqn getFqn();
+	
+	/**
+	 * 
+	 * @return Interval at which updates of keys will be executed.
+     * Effectively, the interval will be rounded to the nearest multiplicity of
+     * the service update thread interval. The interval should be given in milliseconds.
+     * If it is 0, the {@link CacheItemDataSource#update(Object, Object)} method will
+     * be executed on every service thread update (for every key).
+	 */
+	public long getInterval();
+	
+	/**
+	 * 
+	 * @param interval Interval at which the update operation will be executed.
+     * Effectively, the interval will be rounded to the nearest multiplicity of
+     * the service update thread interval. The interval should be given in milliseconds.
+     * If it is 0, the {@link CacheItemDataSource#update(Object, Object)} method will
+     * be executed on every service thread update (for every key).
+	 */
+	public void setInterval(long interval);
+	
+	/**
+	 * 
+	 * @return Name of an mbean implementing the {@link RenewableCacheServiceMBean} interface, associated
+	 * with this cache item.
+	 */
+	public String getMbeanName();
+	
+	/**
+	 * 
+	 * @return A unique id of this instance of cache item.
+	 */
+	public int getId();
+	
+	/**
+	 * 
+	 * @return Additional information about the state of a data source for this cache item. Returns
+	 * {@link CacheItemDataSource#getInfo()}.
+	 */
+	public String getInfo();
+	
+	/**
+	 * 
+	 * @return Name of this {@link CacheItem} --- the fully qualified name of the class
+	 * implementing {@link CacheItemDataSource}.
+	 */
+	public String getName();
+    
+	/**
+	 * 
+	 * @return A map of keys, which are handeled by this cache item, and corresponding last
+	 * update times.
+	 */
+	public Map<K, Long> getKeysUpdates();
+	
+	/**
+	 * 
+	 * @return A set of keys, which are currently being updated.
+	 */
+	public Set<K> getKeysDuringUpdate();
+	
+	/**
+	 * 
+	 * @return A map of keys, in which an exception occured during an update.
+	 */
+	public Map<K, Throwable> getKeysExceptions();
+}

Deleted: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItem.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItem.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItem.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -1,380 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
- ******************************************************************************/
-package org.jboss.shotoku.cache;
-
-import org.apache.log4j.Logger;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
-import org.jboss.shotoku.tools.CacheTools;
-import org.jboss.shotoku.tools.ConcurrentSet;
-import org.jboss.shotoku.tools.ConcurrentHashSet;
-import org.jboss.shotoku.cache.service.DummyRenewableCacheService;
-import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * Extend this class if you want to store objects in a cache that
- * will be updated on a regular intervals of time, by a service daemon
- * thread. All data is held in one node of a {@link org.jboss.cache.TreeCache}.
- * If a key is requested for the first time, it is initialized with the
- * {@link #init(Object)} method. Later, the {@link #update(Object, Object)} method
- * is called to (possibly) update the currently held value.
- * 
- * The cache item will be auto-registered in the service upon construction 
- * --- so take care when constructing objects of this class. When you want to
- * remove all keys, from the TreeCache node, that are handled by this cache item,
- * simply call the {@link #unregister()} method.
- * 
- * @param <K> Type of the key of the objects held in cache. The keys
- * should bahave well as map keys (most probably, the hashCode() and
- * equals() methods should be overriden).
- * 
- * @param <T> Type of the objects that will be stored in the cache.
- * 
- * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
- */
-public class RenewableCacheItem<K, T> implements RenewableCacheItemOperations<K, T> {
-	private final Logger log = Logger.getLogger(RenewableCacheItem.class);
-	
-	private RenewableCacheItemDataSource<K, T> dataSource;
-	
-    private Fqn fqn;
-    private long interval;
-    private String mbeanName;
-    private int id;
-    
-    private ConcurrentMap<K, Long> keysUpdates;
-    /**
-     * Double-update-start prevention: if a key is already in that set, it won't be updated.
-     */
-    private ConcurrentSet<K> keysInUpdate;
-    /**
-     * Information: update methods of which keys are currently executed. Doesn't have to 
-     * coincide with <code>keysInUpdate</code>, as the execution of the update methods for
-     * some keys may be waiting in a queue.
-     */
-    private ConcurrentSet<K> keysDuringUpdate;
-    /**
-     * Exceptions whih occured on last update of keys.
-     */
-    private ConcurrentMap<K, Throwable> keysExceptions;
-    
-    private RenewableCacheServiceMBean service;
-
-    private RenewableCacheItem(RenewableCacheItemDataSource<K, T> dataSource, Fqn fqn, String mbeanName, long interval) {
-    	this.dataSource = dataSource;
-    	
-    	if (mbeanName == null) {
-    		mbeanName = CacheTools.DEFAULT_RENEWABLE_CACHE_MBEAN;
-    	}
-    	
-    	this.mbeanName = mbeanName;
-    	
-    	this.interval = interval;
-    	
-        keysUpdates = new ConcurrentHashMap<K, Long>();
-        keysDuringUpdate = new ConcurrentHashSet<K>();
-        keysInUpdate = new ConcurrentHashSet<K>();
-        keysExceptions = new ConcurrentHashMap<K, Throwable>();
-    	
-        id = CacheTools.getNextId();
-        
-    	register();
-        
-    	if (fqn == null) {
-    		this.fqn = service.generateNextFqn();
-    	} else {
-    		this.fqn = fqn;
-    	}
-    }
-    
-    /**
-     * Creates and registeres a new cache item, with default parameter values (see
-     * {@link #RenewableCacheItem(Fqn, String, long, long)}): the fqn will be auto-generated,
-     * a default cache mbean name will be used, update will happen on each service thread
-     * update and there will be no limit on the length of a key update.
-     */
-    public static <K,T> RenewableCacheItemUser<K,T> create(RenewableCacheItemDataSource<K,T> dataSource) {
-    	return create(dataSource, null, null, 0);
-    }
-    
-    /**
-     * Creates and registeres a new cache item.
-     *
-     * @param fqn An fqn of the node in TreeCache, where data should be held. If it is null,
-     * a unique fqn will be auto-generated for this cache item.
-     * 
-     * @param mbeanName A name of an {@link RenewableCacheServiceMBean} mbean, which
-     * should be used to perform cache operations. This mbeans holds a reference
-     * to a {@link org.jboss.cache.TreeCache}. If it is null, a default mbean
-     * name will be used.
-     * 
-     * @param interval Interval at which the update operation will be executed.
-     * Effectively, the interval will be rounded to the nearest multiplicity of
-     * the service update thread interval. The interval should be given in milliseconds.
-     * If it is 0, the {@link #update()} method will be executed on every service
-     * thread update.
-     */
-    public static <K,T> RenewableCacheItemUser<K,T> create(RenewableCacheItemDataSource<K,T> dataSource,
-    		Fqn fqn, String mbeanName, long interval) {
-    	return new RenewableCacheItem<K, T>(dataSource, fqn, mbeanName, interval);
-    }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.jboss.shotoku.cache.RenewableCacheItemUser#register()
-     */
-    public synchronized void register() {
-			synchronized (keysUpdates) {
-				synchronized (keysDuringUpdate) {
-					keysUpdates.clear();
-					keysDuringUpdate.clear();
-					
-					try {
-						service = (RenewableCacheServiceMBean) 
-							CacheTools.getService(mbeanName, RenewableCacheServiceMBean.class);
-					} catch (Exception e) {
-						log.error("No RenewableCacheService bound to "
-								+ mbeanName + " in cache item "
-								+ getName() + "!");
-						return;
-					}
-
-					service.register(this);
-				}
-			}
-	}
-
-    /*
-     * (non-Javadoc)
-     * @see org.jboss.shotoku.cache.RenewableCacheItemUser#unregister()
-     */
-    public synchronized void unregister() {
-        try {
-        	RenewableCacheServiceMBean oldService = service;
-        	service = new DummyRenewableCacheService();
-        	
-			oldService.unregister(this);
-		} catch (CacheException e) {
-			log.error("Error while unregistering a cache item " + this.getClass() + ".", e);
-		}
-    }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.jboss.shotoku.cache.RenewableCacheItemConfiguration#getFqn()
-     */
-    public Fqn getFqn() {
-		return fqn;
-	}
-
-    /*
-     * (non-Javadoc)
-     * @see org.jboss.shotoku.cache.RenewableCacheItemConfiguration#getInterval()
-     */
-	public synchronized long getInterval() {
-		return interval;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.jboss.shotoku.cache.RenewableCacheItemConfiguration#setInterval(long)
-	 */
-	public synchronized void setInterval(long interval) {
-		this.interval = interval;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.jboss.shotoku.cache.RenewableCacheItemConfiguration#getMbeanName()
-	 */
-	public String getMbeanName() {
-		return mbeanName;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.jboss.shotoku.cache.RenewableCacheItemConfiguration#getKeysDuringUpdate()
-	 */
-	public ConcurrentSet<K> getKeysDuringUpdate() {
-		return keysDuringUpdate;
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * @see org.jboss.shotoku.cache.RenewableCacheItemConfiguration#getKeysUpdates()
-	 */
-	public ConcurrentMap<K, Long> getKeysUpdates() {
-		return keysUpdates;
-	}
-	
-	/*
-	 * (non-Javadoc)
-	 * @see org.jboss.shotoku.cache.RenewableCacheItemOperations#getKeysExceptions()
-	 */
-	public ConcurrentMap<K, Throwable> getKeysExceptions() {
-		return keysExceptions;
-	}
-	
-	/*
-	 * (non-Javadoc)
-	 * @see org.jboss.shotoku.cache.RenewableCacheItemOperations#getId()
-	 */
-	public int getId() {
-		return id;
-	}
-    
-    /*
-     * (non-Javadoc)
-     * @see org.jboss.shotoku.cache.RenewableCacheItemData#getInfo()
-     */
-    public String getInfo() {
-    	return dataSource.getInfo();
-    }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.jboss.shotoku.cache.RenewableCacheItemData#getName()
-     */
-    public String getName() {
-    	return dataSource.getClass().getName();
-    }
-
-	/**
-     * Binds the given key with the given object in the associated TreeCache
-     * node. Should be only called
-     * from the {@link #update(Object, Object)} method to put new values in the
-     * cache (if not called during an update, this method has no effect).
-     * @param key Key of the object.
-     * @param object Object that should be bound.
-     */
-    private synchronized final void put(K key, T object) { 
-        if (!keysDuringUpdate.contains(key)) {
-            return;
-        }
-        
-        try {
-			service.put(fqn, key, object);
-		} catch (CacheException e) {
-			log.error("Error while putting a value for key \"" + key + "\" in cache item " + this.getClass() + ".", e);
-		}
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see org.jboss.shotoku.cache.RenewableCacheItemUser#get(java.lang.Object)
-     */
-    @SuppressWarnings("unchecked")
-	public final T get(K key) {
-    	if (!keysUpdates.containsKey(key)) {
-			synchronized (this) {
-				if (!keysUpdates.containsKey(key)) {
-					T ret = dataSource.init(key);
-					try {
-						service.put(fqn, key, ret);
-					} catch (CacheException e) {
-						log.error("Error while putting a value for key \""
-								+ key + "\" in cache item " + this.getClass()
-								+ ".", e);
-						return null;
-					}
-
-					// We have to initialize a new object.
-					keysUpdates.put(key, System.currentTimeMillis());
-
-					return ret;
-				}
-			}
-		}
-
-        try {
-			return (T) service.get(fqn, key);
-		} catch (CacheException e) {
-			log.error("Error while getting a value for key \"" + key + "\" in cache item " + this.getClass() + ".", e);
-			return null;
-		}
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see org.jboss.shotoku.cache.RenewableCacheItemOperations#update()
-     */
-    public void update() {
-        long now = Calendar.getInstance().getTimeInMillis();
-        
-        for (final K key : keysUpdates.keySet()) {
-            if (now - keysUpdates.get(key) >= interval) {
-                if (keysInUpdate.add(key)) {
-                    service.addUpdateThreadData(new UpdateThreadData<K, T>(key, this) {
-                        public void execute() {
-                        	keysUpdates.put(key, System.currentTimeMillis());
-                        	keysDuringUpdate.add(key);
-                        	
-                            try {
-                                ValueChange<T> change = dataSource.update(key, get(key));
-                                if (change.hasValue()) {
-                                	put(key, change.getValue());
-                                }
-                            } finally {
-                            	keysInUpdate.remove(key);
-                            	keysDuringUpdate.remove(key);
-                            }
-                        }
-                    });
-                }
-            }
-        }
-    }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.jboss.shotoku.cache.RenewableCacheItemData#resetKey(java.lang.Object)
-     */
-    public void resetKey(Object key) {
-    	keysInUpdate.remove(key);
-    	keysDuringUpdate.remove(key);
-    }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.jboss.shotoku.cache.RenewableCacheItemOperations#reportUpdateOk(java.lang.Object)
-     */
-    public void reportUpdateOk(K key) {
-		
-	}
-
-    /*
-     * (non-Javadoc)
-     * @see org.jboss.shotoku.cache.RenewableCacheItemOperations#reportUpdateWithException(java.lang.Object, java.lang.Throwable)
-     */
-	public void reportUpdateWithException(K key, Throwable t) {
-		if (keysExceptions.put(key, t) == null) {
-			// There was no exception before.
-			log.error("Update of cache item " + getName() + " for key " + key + " threw an exception. Suppressing " +
-					"subsequent exceptions.", t);
-		}
-	}
-}

Deleted: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemDataSource.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemDataSource.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemDataSource.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -1,73 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
- ******************************************************************************/
-package org.jboss.shotoku.cache;
-
-import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
-
-/**
- * Basic interface when using a renewable cache item --- defines methods, which
- * are used to determine what values should be put to the cache. The {@link #init(Object)} method
- * is called when a user demands a value for a key that hasn't been accessed before.
- * That value is then placed in the cache, and updated periodically in the background,
- * using the {@link #update(Object, Object)} method. How often the updates happen,
- * depends on the settings of the {@link RenewableCacheServiceMBean} and on
- * settings passed when creating the cache item
- * ({@link RenewableCacheItem#create(RenewableCacheItemDataSource, org.jboss.cache.Fqn, String, long)}).
- * @param <K> Type of keys in the cache. The keys
- * should bahave well as map keys (most probably, the hashCode() and
- * equals() methods should be overriden).
- * @param <T> Type of the values bound to the keys in the cache.
- * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
- */
-public interface RenewableCacheItemDataSource<K, T> {
-	/**
-     * Called by the service periodically to update the object held in the
-     * cache, bound to the given key. The value current held in the cache can be changed or not.
-     * @param key Key of the object to update.
-     * @param currentObject Current value held in the cache.
-     * @return Can return either:
-     * <ul>
-     * <li>{@link ValueChange#noChange()} to indicate that the value currently held in the cache
-     * shouldn't be changed.</li>
-     * <li>{@link ValueChange#changeTo(Object)} to bind a new value to the given key in
-     * the cache.</li>
-     * </ul>
-     */
-    public ValueChange<T> update(K key, T currentObject);
-
-    /**
-     * Called when the user demands an object which hasn't been accessed
-     * before, and thus, which hasn't been yet initialized. 
-     * @param key Key of the object to initialize.
-     * @return Initial value of an object with the given key.
-     */
-    public T init(K key);
-    
-    /**
-     * 
-     * @return Additional information about this data source, which is visible for example
-     * in the cache administration web application. Has no influence on the behaviour or
-     * content of the cache.
-     */
-    public String getInfo();
-}

Deleted: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemOperations.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemOperations.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemOperations.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -1,51 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
- ******************************************************************************/
-package org.jboss.shotoku.cache;
-
-/**
- * Operations on a cache item that shouldn't be visible to the user --- mainly
- * the {@link #update()} method.
- * @param <K> Type of the keys in the cache.
- * @param <T> Type of the values bound to the keys in the cache.
- * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
- */
-public interface RenewableCacheItemOperations<K,T> extends RenewableCacheItemUser<K,T> {
-	/**
-     * Called by the service update thread to update all keys and associated values.
-     * You shouldn't call it from inside your code.
-     */
-    public void update();
-	
-	/**
-	 * Reports that an update of a key ended wihtout any exceptions.
-	 * @param key Key which has been updated.
-	 */
-	public void reportUpdateOk(K key);
-	
-	/**
-	 * Reports that an update of a key ended with an exception.
-	 * @param key Key which has been updated.
-	 * @param t Exception which was thrown during the update.
-	 */
-	public void reportUpdateWithException(K key, Throwable t);
-}

Deleted: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemUser.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemUser.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemUser.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -1,146 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * This is free software; you can redistribute it and/or modify it            *
- * under the terms of the GNU Lesser General Public License as                *
- * published by the Free Software Foundation; either version 2.1 of           *
- * the License, or (at your option) any later version.                        *
- *                                                                            *
- * This software is distributed in the hope that it will be useful,           *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
- * Lesser General Public License for more details.                            *
- *                                                                            *
- * You should have received a copy of the GNU Lesser General Public           *
- * License along with this software; if not, write to the Free                *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
- ******************************************************************************/
-package org.jboss.shotoku.cache;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.cache.Fqn;
-import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
-
-/**
- * An interface presented to the user of the cache item. Its main function is
- * to retrieve values from the cache, but also to get configuration information and
- * information about the current state of keys (their last updates, etc) handeled
- * by this cache item.
- * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
- *
- * @param <K> Type of the keys in the cache.
- * @param <T> Type of the values bound to the keys in the cache.
- */
-public interface RenewableCacheItemUser<K, T> {
-	/**
-	 * Resets the given key, that is, it's update status. Hence, if a thread updating a key
-	 * locks for some reason, it is possible to resume updates of this key. Use with caution.
-	 * @param key Key, which update status should be reset.
-	 */
-	public void resetKey(Object key);
-	
-	/**
-     * Gets an object that is bound to the given key in the associated
-     * TreeCache node.
-     * If this object is not in the cache, it will be initialized (using the
-     * {@link RenewableCacheItemDataSource#init(Object)} method of a data source
-     * that was passed to {@link RenewableCacheItem#create(RenewableCacheItemDataSource)}).
-     * @param key Key of the object to get.
-     * @return Value of the object.
-     */
-	public T get(K key);
-	
-	/**
-     * Registers this cache item in the service. This method is automatically called
-     * when creating the cache item (using {@link RenewableCacheItem#create(RenewableCacheItemDataSource)}),
-     * so you will only need to use it if you previously
-     * manually unregistered the cache item using {@link #unregister()}.
-     */
-    public void register();
-    
-    /**
-     * Removes all keys handled by this cache item from the associated TreeCache node and
-     * stops updates on this cache item.
-     */
-    public void unregister();
-    
-	/**
-	 * 
-	 * @return A fqn of a TreeCache node associated with this cache item. This is a node in which
-	 * data will be kept.
-	 */
-	public Fqn getFqn();
-	
-	/**
-	 * 
-	 * @return Interval at which updates of keys will be executed.
-     * Effectively, the interval will be rounded to the nearest multiplicity of
-     * the service update thread interval. The interval should be given in milliseconds.
-     * If it is 0, the {@link RenewableCacheItemDataSource#update(Object, Object)} method will
-     * be executed on every service thread update (for every key).
-	 */
-	public long getInterval();
-	
-	/**
-	 * 
-	 * @param interval Interval at which the update operation will be executed.
-     * Effectively, the interval will be rounded to the nearest multiplicity of
-     * the service update thread interval. The interval should be given in milliseconds.
-     * If it is 0, the {@link RenewableCacheItemDataSource#update(Object, Object)} method will
-     * be executed on every service thread update (for every key).
-	 */
-	public void setInterval(long interval);
-	
-	/**
-	 * 
-	 * @return Name of an mbean implementing the {@link RenewableCacheServiceMBean} interface, associated
-	 * with this cache item.
-	 */
-	public String getMbeanName();
-	
-	/**
-	 * 
-	 * @return A unique id of this instance of cache item.
-	 */
-	public int getId();
-	
-	/**
-	 * 
-	 * @return Additional information about the state of a data source for this cache item. Returns
-	 * {@link RenewableCacheItemDataSource#getInfo()}.
-	 */
-	public String getInfo();
-	
-	/**
-	 * 
-	 * @return Name of this {@link RenewableCacheItem} --- the fully qualified name of the class
-	 * implementing {@link RenewableCacheItemDataSource}.
-	 */
-	public String getName();
-    
-	/**
-	 * 
-	 * @return A map of keys, which are handeled by this cache item, and corresponding last
-	 * update times.
-	 */
-	public Map<K, Long> getKeysUpdates();
-	
-	/**
-	 * 
-	 * @return A set of keys, which are currently being updated.
-	 */
-	public Set<K> getKeysDuringUpdate();
-	
-	/**
-	 * 
-	 * @return A map of keys, in which an exception occured during an update.
-	 */
-	public Map<K, Throwable> getKeysExceptions();
-}

Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UpdateThreadData.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UpdateThreadData.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UpdateThreadData.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -31,9 +31,9 @@
 	private long createTime;
 	
 	private K key;
-	private RenewableCacheItemOperations<K, T> cacheItem;
+	private CacheItemOperations<K, T> cacheItem;
 	
-    public UpdateThreadData(K key, RenewableCacheItemOperations<K, T> cacheItem) {
+    public UpdateThreadData(K key, CacheItemOperations<K, T> cacheItem) {
 		createTime = System.currentTimeMillis();
 		
 		this.key = key;

Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/DummyRenewableCacheService.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/DummyRenewableCacheService.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/DummyRenewableCacheService.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -6,7 +6,7 @@
 import org.jboss.cache.CacheException;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.TreeCacheMBean;
-import org.jboss.shotoku.cache.RenewableCacheItemOperations;
+import org.jboss.shotoku.cache.CacheItemOperations;
 import org.jboss.shotoku.cache.UpdateThreadData;
 
 /**
@@ -57,7 +57,7 @@
 	public void put(Fqn fqn, Object key, Object o) throws CacheException {
 	}
 
-	public void register(RenewableCacheItemOperations<?,?> cacheItem) {
+	public void register(CacheItemOperations<?,?> cacheItem) {
 	}
 
 	public void remove(Fqn fqn, Object key) throws CacheException {
@@ -81,13 +81,13 @@
 	public void stop() {
 	}
 
-	public void unregister(RenewableCacheItemOperations<?,?> cacheItem) throws CacheException {
+	public void unregister(CacheItemOperations<?,?> cacheItem) throws CacheException {
 	}
 
 	public void update() {
 	}
 
-	public Set<? extends RenewableCacheItemOperations<?,?>> getCacheItemsOperations() {
+	public Set<? extends CacheItemOperations<?,?>> getCacheItemsOperations() {
 		return null;
 	}
 

Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/RenewableCacheServiceMBean.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/RenewableCacheServiceMBean.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/RenewableCacheServiceMBean.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -27,7 +27,7 @@
 import org.jboss.cache.CacheException;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.TreeCacheMBean;
-import org.jboss.shotoku.cache.RenewableCacheItemOperations;
+import org.jboss.shotoku.cache.CacheItemOperations;
 import org.jboss.shotoku.cache.UpdateThreadData;
 
 /**
@@ -39,8 +39,8 @@
     public void put(Fqn fqn, Object key, Object o) throws CacheException;
     public void remove(Fqn fqn, Object key) throws CacheException;
     
-    public void register(RenewableCacheItemOperations<?,?> cacheItem);
-    public void unregister(RenewableCacheItemOperations<?,?> cacheItem) throws CacheException;
+    public void register(CacheItemOperations<?,?> cacheItem);
+    public void unregister(CacheItemOperations<?,?> cacheItem) throws CacheException;
 
     public Fqn generateNextFqn();
 
@@ -69,7 +69,7 @@
     public int getIdleThreadCount();
     public int getBusyThreadCount();
     
-    public Set<? extends RenewableCacheItemOperations<?, ?>> getCacheItemsOperations();
+    public Set<? extends CacheItemOperations<?, ?>> getCacheItemsOperations();
     
     public void update();
     

Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlert.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlert.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/CacheAlert.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -1,6 +1,6 @@
 package org.jboss.shotoku.cache.service.monitor;
 
-import org.jboss.shotoku.cache.RenewableCacheItem;
+import org.jboss.shotoku.cache.CacheItem;
 
 /**
  * Information about probably incorrect behaviour of cache items, collected
@@ -30,7 +30,7 @@
 	public String getCause();
 	/**
 	 * 
-	 * @return {@link RenewableCacheItem} key, for which the incorrect behaviour occured.
+	 * @return {@link CacheItem} key, for which the incorrect behaviour occured.
 	 */
 	public Object getKey();
 }

Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/DummyRenewableCacheMonitorService.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/DummyRenewableCacheMonitorService.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/DummyRenewableCacheMonitorService.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -4,7 +4,7 @@
 import java.util.List;
 import java.util.Set;
 
-import org.jboss.shotoku.cache.RenewableCacheItemOperations;
+import org.jboss.shotoku.cache.CacheItemOperations;
 import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
 
 public class DummyRenewableCacheMonitorService implements RenewableCacheMonitorServiceMBean {
@@ -12,12 +12,12 @@
 	
 	}
 
-	public List<CacheAlert> getAlertsForCacheItem(RenewableCacheItemOperations<?,?> rcid) {
+	public List<CacheAlert> getAlertsForCacheItem(CacheItemOperations<?,?> rcid) {
 		return null;
 	}
 
-	public Set<RenewableCacheItemOperations<?,?>> getCacheItemsWithAlerts() {
-		return new HashSet<RenewableCacheItemOperations<?,?>>();
+	public Set<CacheItemOperations<?,?>> getCacheItemsWithAlerts() {
+		return new HashSet<CacheItemOperations<?,?>>();
 	}
 
 	public long getInterval() {

Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/RenewableCacheMonitorServiceMBean.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/RenewableCacheMonitorServiceMBean.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/service/monitor/RenewableCacheMonitorServiceMBean.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -3,7 +3,7 @@
 import java.util.List;
 import java.util.Set;
 
-import org.jboss.shotoku.cache.RenewableCacheItemOperations;
+import org.jboss.shotoku.cache.CacheItemOperations;
 import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
 
 /**
@@ -58,18 +58,18 @@
     
     /**
      * 
-     * @param rcid {@link RenewableCacheItem} for which to get alerts.
-     * @return A list of alerts for the given {@link RenewableCacheItem}, sorted from the
+     * @param rcid {@link CacheItem} for which to get alerts.
+     * @return A list of alerts for the given {@link CacheItem}, sorted from the
      * newest alert, or null is there are no alerts for the given cache item.
      */
-    public List<CacheAlert> getAlertsForCacheItem(RenewableCacheItemOperations<?,?> rcid);
+    public List<CacheAlert> getAlertsForCacheItem(CacheItemOperations<?,?> rcid);
     /**
      * Clears all alerts.
      */
     public void clearAlerts();
     /**
      * 
-     * @return A set of {@link RenewableCacheItemOperations}, for which there are any alerts.
+     * @return A set of {@link CacheItemOperations}, for which there are any alerts.
      */
-    public Set<RenewableCacheItemOperations<?,?>> getCacheItemsWithAlerts();
+    public Set<CacheItemOperations<?,?>> getCacheItemsWithAlerts();
 }

Modified: labs/shotoku/trunk/shotoku-cache/cache-service/src/java/org/jboss/shotoku/cache/service/RenewableCacheService.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-service/src/java/org/jboss/shotoku/cache/service/RenewableCacheService.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-service/src/java/org/jboss/shotoku/cache/service/RenewableCacheService.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -25,7 +25,7 @@
 import org.jboss.cache.CacheException;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.TreeCacheMBean;
-import org.jboss.shotoku.cache.RenewableCacheItemOperations;
+import org.jboss.shotoku.cache.CacheItemOperations;
 import org.jboss.shotoku.cache.SignalExitUpdateThreadData;
 import org.jboss.shotoku.cache.UpdateThread;
 import org.jboss.shotoku.cache.UpdateThreadData;
@@ -149,8 +149,8 @@
      * Cache handling
      */
 
-    private final ConcurrentSet<RenewableCacheItemOperations<?,?>> cacheItems =
-            new ConcurrentHashSet<RenewableCacheItemOperations<?,?>>();
+    private final ConcurrentSet<CacheItemOperations<?,?>> cacheItems =
+            new ConcurrentHashSet<CacheItemOperations<?,?>>();
 
 	public Object get(Fqn fqn, Object key) throws CacheException {
 		return treeCache.get(fqn, key);
@@ -164,11 +164,11 @@
 		treeCache.remove(fqn, key);
 	}
 
-    public void register(RenewableCacheItemOperations<?,?> cacheItem) {
+    public void register(CacheItemOperations<?,?> cacheItem) {
         cacheItems.add(cacheItem);
     }
     
-    public void unregister(RenewableCacheItemOperations<?,?> cacheItem) throws CacheException {
+    public void unregister(CacheItemOperations<?,?> cacheItem) throws CacheException {
     	cacheItems.remove(cacheItem);
     	
     	for (Object key : cacheItem.getKeysUpdates().keySet()) {
@@ -176,7 +176,7 @@
     	}
     }
    
-    public Set<? extends RenewableCacheItemOperations<?,?>> getCacheItemsOperations() {
+    public Set<? extends CacheItemOperations<?,?>> getCacheItemsOperations() {
 		return cacheItems;
 	}
 
@@ -270,7 +270,7 @@
 	 */
 
     public void update() {
-        for (RenewableCacheItemOperations<?,?> sci : cacheItems) {
+        for (CacheItemOperations<?,?> sci : cacheItems) {
             try {
                 sci.update();
             } catch (Throwable t) {

Modified: labs/shotoku/trunk/shotoku-cache/cache-service/src/java/org/jboss/shotoku/cache/service/monitor/RenewableCacheMonitorService.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-service/src/java/org/jboss/shotoku/cache/service/monitor/RenewableCacheMonitorService.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-service/src/java/org/jboss/shotoku/cache/service/monitor/RenewableCacheMonitorService.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -10,7 +10,7 @@
 import java.util.Set;
 
 import org.apache.log4j.Logger;
-import org.jboss.shotoku.cache.RenewableCacheItemOperations;
+import org.jboss.shotoku.cache.CacheItemOperations;
 import org.jboss.shotoku.cache.service.RenewableCacheServiceMBean;
 
 /**
@@ -101,9 +101,9 @@
 
 	//
 	
-	private Set<RenewableCacheItemOperations<?,?>> cacheItemsWithAlerts = new HashSet<RenewableCacheItemOperations<?,?>>();
-	private Map<RenewableCacheItemOperations<?,?>, Set<CacheAlert>> alertsForCacheItems =
-		new HashMap<RenewableCacheItemOperations<?,?>, Set<CacheAlert>>();
+	private Set<CacheItemOperations<?,?>> cacheItemsWithAlerts = new HashSet<CacheItemOperations<?,?>>();
+	private Map<CacheItemOperations<?,?>, Set<CacheAlert>> alertsForCacheItems =
+		new HashMap<CacheItemOperations<?,?>, Set<CacheAlert>>();
 	
 	private int currentNumberOfAlerts;
 	
@@ -119,7 +119,7 @@
 			return;
 		}
 		
-		for (RenewableCacheItemOperations<?,?> rcid : getRenewableCacheService().getCacheItemsOperations()) {
+		for (CacheItemOperations<?,?> rcid : getRenewableCacheService().getCacheItemsOperations()) {
 			// Checking for keys that are in update for too long/ haven't been updated for a long
 			// time.
 			Set<?> keysDuringUpdate = rcid.getKeysDuringUpdate();
@@ -149,7 +149,7 @@
 		}
 	}
 	
-	private synchronized void addAlertForCacheItem(RenewableCacheItemOperations<?,?> rcid, CacheAlert alert) {
+	private synchronized void addAlertForCacheItem(CacheItemOperations<?,?> rcid, CacheAlert alert) {
 		Set<CacheAlert> alertsForCacheItem = alertsForCacheItems.get(rcid);
 	
 		if (alertsForCacheItem == null) {
@@ -178,7 +178,7 @@
 		}
 	};
 	
-	public synchronized List<CacheAlert> getAlertsForCacheItem(RenewableCacheItemOperations<?,?> rcid) {
+	public synchronized List<CacheAlert> getAlertsForCacheItem(CacheItemOperations<?,?> rcid) {
 		Set<CacheAlert> alertsForCacheItem = alertsForCacheItems.get(rcid);
 		if (alertsForCacheItem == null) {
 			return null;
@@ -190,7 +190,7 @@
 		return alertsList;
 	}
 
-	public synchronized Set<RenewableCacheItemOperations<?,?>> getCacheItemsWithAlerts() {
+	public synchronized Set<CacheItemOperations<?,?>> getCacheItemsWithAlerts() {
 		return cacheItemsWithAlerts;
 	}
 
@@ -201,7 +201,7 @@
 		alertsForCacheItems.clear();
 		
 		// Clearing all exceptions in cache items.
-		for (RenewableCacheItemOperations<?,?> rcid : getRenewableCacheService().getCacheItemsOperations()) {
+		for (CacheItemOperations<?,?> rcid : getRenewableCacheService().getCacheItemsOperations()) {
 			rcid.getKeysExceptions().clear();
 		}
 	}

Modified: labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestCacheItem.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestCacheItem.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestCacheItem.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -1,9 +1,9 @@
 package org.jboss.shotoku.cache.test;
 
-import org.jboss.shotoku.cache.RenewableCacheItemDataSource;
+import org.jboss.shotoku.cache.CacheItemDataSource;
 import org.jboss.shotoku.cache.ValueChange;
 
-public class TestCacheItem implements RenewableCacheItemDataSource<String, Integer> {
+public class TestCacheItem implements CacheItemDataSource<String, Integer> {
 	public Integer init(String key) {
 		return 0;
 	}

Modified: labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestCacheItem2.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestCacheItem2.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestCacheItem2.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -1,9 +1,9 @@
 package org.jboss.shotoku.cache.test;
 
-import org.jboss.shotoku.cache.RenewableCacheItemDataSource;
+import org.jboss.shotoku.cache.CacheItemDataSource;
 import org.jboss.shotoku.cache.ValueChange;
 
-public class TestCacheItem2 implements RenewableCacheItemDataSource<String, Integer> {
+public class TestCacheItem2 implements CacheItemDataSource<String, Integer> {
 	public Integer init(String key) {
 		return 0;
 	}

Modified: labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestCacheItem3.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestCacheItem3.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestCacheItem3.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -1,9 +1,9 @@
 package org.jboss.shotoku.cache.test;
 
-import org.jboss.shotoku.cache.RenewableCacheItemDataSource;
+import org.jboss.shotoku.cache.CacheItemDataSource;
 import org.jboss.shotoku.cache.ValueChange;
 
-public class TestCacheItem3 implements RenewableCacheItemDataSource<String, Integer> {
+public class TestCacheItem3 implements CacheItemDataSource<String, Integer> {
 	public Integer init(String key) {
 		return 0;
 	}

Modified: labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestServlet.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestServlet.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-cache/cache-test/src/java/org/jboss/shotoku/cache/test/TestServlet.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -8,15 +8,15 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.jboss.shotoku.cache.RenewableCacheItem;
-import org.jboss.shotoku.cache.RenewableCacheItemUser;
+import org.jboss.shotoku.cache.CacheItem;
+import org.jboss.shotoku.cache.CacheItemUser;
 
 public class TestServlet extends HttpServlet {
-	private RenewableCacheItemUser<String,Integer> tci;
-	private RenewableCacheItemUser<String,Integer> tci2;
-	private RenewableCacheItemUser<String,Integer> tci3;
-	private RenewableCacheItemUser<String,Integer> tci4;
-	private RenewableCacheItemUser<String,Integer> tci5;
+	private CacheItemUser<String,Integer> tci;
+	private CacheItemUser<String,Integer> tci2;
+	private CacheItemUser<String,Integer> tci3;
+	private CacheItemUser<String,Integer> tci4;
+	private CacheItemUser<String,Integer> tci5;
 	
 	@Override
 	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
@@ -33,11 +33,11 @@
 
 	@Override
 	public void init(ServletConfig config) throws ServletException {
-		tci = RenewableCacheItem.create(new TestCacheItem());
-		tci2 = RenewableCacheItem.create(new TestCacheItem2());
-		tci3 = RenewableCacheItem.create(new TestCacheItem());
-		tci4 = RenewableCacheItem.create(new TestCacheItem2());
-		tci5 = RenewableCacheItem.create(new TestCacheItem3());
+		tci = CacheItem.create(new TestCacheItem());
+		tci2 = CacheItem.create(new TestCacheItem2());
+		tci3 = CacheItem.create(new TestCacheItem());
+		tci4 = CacheItem.create(new TestCacheItem2());
+		tci5 = CacheItem.create(new TestCacheItem3());
 		
 		super.init(config);
 	}

Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptorImpl.java
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptorImpl.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptorImpl.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -31,7 +31,7 @@
 import org.apache.xerces.parsers.DOMParser;
 import org.apache.log4j.Logger;
 import org.jboss.shotoku.ContentManager;
-import org.jboss.shotoku.cache.RenewableCacheItemUser;
+import org.jboss.shotoku.cache.CacheItemUser;
 import org.jboss.shotoku.feeds.data.NormalFeed;
 import org.jboss.shotoku.feeds.data.special.SpecialFeed;
 import org.jboss.shotoku.feeds.data.Feed;
@@ -96,12 +96,12 @@
      */
     private String id;
 
-    private RenewableCacheItemUser<Pair<String, String>, Properties> fcw;
+    private CacheItemUser<Pair<String, String>, Properties> fcw;
     
     private int readTimeout;
     private int connTimeout;
 
-    public FeedsDescriptorImpl(String id, RenewableCacheItemUser<Pair<String, String>, Properties> fcw, int connTimeout, int readTimeout) {
+    public FeedsDescriptorImpl(String id, CacheItemUser<Pair<String, String>, Properties> fcw, int connTimeout, int readTimeout) {
     	this.readTimeout = readTimeout;
     	this.connTimeout = connTimeout;
     	

Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/service/FeedsServiceImpl.java
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/service/FeedsServiceImpl.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/service/FeedsServiceImpl.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -3,8 +3,8 @@
 import org.jboss.annotation.ejb.Service;
 import org.jboss.annotation.ejb.Management;
 import org.jboss.annotation.ejb.Depends;
-import org.jboss.shotoku.cache.RenewableCacheItem;
-import org.jboss.shotoku.cache.RenewableCacheItemUser;
+import org.jboss.shotoku.cache.CacheItem;
+import org.jboss.shotoku.cache.CacheItemUser;
 import org.jboss.shotoku.feeds.DummyFeedsDescriptor;
 import org.jboss.shotoku.feeds.FeedsService;
 import org.jboss.shotoku.feeds.FeedsDescriptorImpl;
@@ -40,7 +40,7 @@
      * FeedsService implementation.
      */
 
-    private static RenewableCacheItemUser<Pair<String, String>, Properties> conf;
+    private static CacheItemUser<Pair<String, String>, Properties> conf;
 
     private Map<String, FeedsDescriptor> fds;
     
@@ -91,7 +91,7 @@
     public void create() throws Exception {
         super.create();
 
-        conf = RenewableCacheItem.create(new FeedsConfigurationWatcher());
+        conf = CacheItem.create(new FeedsConfigurationWatcher());
 
         setTimerInterval(ContentManager.getProperty(FeedsConstants.PROPERTY_INTERVAL, 600000));
         setRemoteReadTimeout(ContentManager.getProperty(FeedsConstants.PROPERTY_READ_TIMEOUT, 3000));

Modified: labs/shotoku/trunk/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java
===================================================================
--- labs/shotoku/trunk/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java	2007-08-26 14:58:15 UTC (rev 14597)
+++ labs/shotoku/trunk/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java	2007-08-26 15:05:13 UTC (rev 14598)
@@ -1,7 +1,7 @@
 package org.jboss.shotoku.fileaccess;
 
-import org.jboss.shotoku.cache.RenewableCacheItem;
-import org.jboss.shotoku.cache.RenewableCacheItemUser;
+import org.jboss.shotoku.cache.CacheItem;
+import org.jboss.shotoku.cache.CacheItemUser;
 import org.jboss.shotoku.tools.Pair;
 import org.jboss.shotoku.tools.Tools;
 import org.jboss.shotoku.ContentManager;
@@ -34,10 +34,10 @@
     private ContentManager contentManager;
     private Pair<String, String> confKey;
 
-    private RenewableCacheItemUser<Pair<String, String>, FileAccessConfiguration> conf;
+    private CacheItemUser<Pair<String, String>, FileAccessConfiguration> conf;
 
     public void init(ServletConfig conf) {
-        this.conf = RenewableCacheItem.create(new FileAccessConfigurationWatcher());
+        this.conf = CacheItem.create(new FileAccessConfigurationWatcher());
 
         contentManager = ContentManager.getContentManager(
                 conf.getInitParameter("contentManagerId"),




More information about the jboss-svn-commits mailing list