[jboss-svn-commits] JBL Code SVN: r14597 - in labs/shotoku/trunk: shotoku-base/src/java/org/jboss/shotoku/cache and 11 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Aug 26 10:58:16 EDT 2007
Author: adamw
Date: 2007-08-26 10:58:15 -0400 (Sun, 26 Aug 2007)
New Revision: 14597
Added:
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/RenewableCacheItemUser.java
labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/ValueChange.java
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/CacheItem.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCacheItem.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuPropertiesWatcher.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuResourceWatcher.java
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuResourceWatcherSplitDescriptor.java
labs/shotoku/trunk/shotoku-cache/TODO
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/RenewableCacheItem.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/SignalExitUpdateThreadData.java
labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UpdateThread.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/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/ClosedContentInformation.java
labs/shotoku/trunk/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessConfigurationWatcher.java
labs/shotoku/trunk/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java
Log:
Admin, 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:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheInjectAspect.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -25,7 +25,8 @@
import org.jboss.aop.Bind;
import org.jboss.aop.joinpoint.*;
import org.jboss.aop.advice.Scope;
-import org.jboss.shotoku.cache.ShotokuCacheItem;
+import org.jboss.shotoku.cache.RenewableCacheItem;
+import org.jboss.shotoku.cache.RenewableCacheItemUser;
/**
* @author Adam Warski (adamw at aster.pl)
@@ -33,7 +34,7 @@
@Aspect(scope=Scope.PER_JOINPOINT)
public class CacheInjectAspect {
private final static Object synchronizer = new Object();
- private ShotokuCacheItem sci;
+ private RenewableCacheItemUser<?,?> sci;
private CacheItem getCurrentAnnotation(FieldInvocation invocation) {
CacheItem current = invocation.getField().getAnnotation(CacheItem.class);
@@ -44,7 +45,7 @@
return current;
}
- @Bind(pointcut="field($instanceof{org.jboss.shotoku.cache.ShotokuCacheItem} " +
+ @Bind(pointcut="field($instanceof{org.jboss.shotoku.cache.RenewableCacheItemUser} " +
"*->@org.jboss.shotoku.aop.CacheItem)")
public Object accessCacheItem(FieldReadInvocation invocation) throws Throwable {
if (sci == null) {
@@ -52,14 +53,7 @@
if (sci == null) {
CacheItem ci = getCurrentAnnotation(invocation);
- if (ci.interval() == 0) {
- sci = (ShotokuCacheItem)
- invocation.getField().getType().getConstructor().newInstance();
- } else {
- sci = (ShotokuCacheItem)
- invocation.getField().getType().getConstructor(Long.TYPE).newInstance(
- ci.interval());
- }
+ sci = RenewableCacheItem.create(ci.dataSource().newInstance(), null, null, ci.interval());
}
}
}
@@ -67,7 +61,7 @@
return sci;
}
- @Bind(pointcut="field(org.jboss.shotoku.cache.ShotokuCacheItem " +
+ @Bind(pointcut="field(org.jboss.shotoku.cache.RenewableCacheItemUser " +
"*->@org.jboss.shotoku.aop.CacheItem)")
public Object access(FieldWriteInvocation invocation) throws Throwable {
throw new RuntimeException("You cannot set a @CacheItem or a " +
Modified: 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:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-aop/src/java/org/jboss/shotoku/aop/CacheItem.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -26,6 +26,8 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import org.jboss.shotoku.cache.RenewableCacheItemDataSource;
+
/**
* @author Adam Warski (adamw at aster.pl)
*/
@@ -33,4 +35,5 @@
@Retention(RetentionPolicy.RUNTIME)
public @interface CacheItem {
long interval() default 0;
+ Class<? extends RenewableCacheItemDataSource<?,?>> 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:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuCacheItem.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -36,24 +36,10 @@
* @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> extends RenewableCacheItem<K, T> {
+public abstract class ShotokuCacheItem<K, T> implements RenewableCacheItemDataSource<K, T> {
private final Map<K, ContentManager> cmForKeys = new HashMap<K, ContentManager>();
/**
- *
- * @param interval Interval at which the update operation will be executed.
- * Effectively, the interval will be rounded to the nearest multiplicity of
- * the service timer interval. The interval should be given in milliseconds.
- */
- public ShotokuCacheItem(long interval) {
- super(null, null, interval, 0);
- }
-
- public ShotokuCacheItem() {
- this(0);
- }
-
- /**
* Use this to bind a content manager with a key. There will always be
* at most one content manager for each key. On first call for a given
* key, initContentManager(key) will be called.
@@ -82,4 +68,8 @@
protected ContentManager initContentManager(K key) {
return ContentManager.getContentManager();
}
+
+ public String getInfo() {
+ return null;
+ }
}
Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuPropertiesWatcher.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuPropertiesWatcher.java 2007-08-26 14:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuPropertiesWatcher.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -33,8 +33,8 @@
return getProperties(key);
}
- protected void update(K key, Properties currentObject,
+ protected ValueChange<Properties> update(K key, Properties currentObject,
Map<String, ChangeType> changes) {
- put(key, getProperties(key));
+ return ValueChange.changeTo(getProperties(key));
}
}
Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuResourceWatcher.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuResourceWatcher.java 2007-08-26 14:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuResourceWatcher.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -51,17 +51,11 @@
return ret;
}
- public ShotokuResourceWatcher(long interval) {
- super(interval);
-
+ public ShotokuResourceWatcher() {
allStatuses = new ConcurrentHashMap<K,
ConcurrentMap<String, ResourceStatus>>();
}
- public ShotokuResourceWatcher() {
- this(0);
- }
-
/**
* Adds a path to the watched resources.
* @param key
@@ -79,7 +73,7 @@
getStatuses(key).clear();
}
- public void update(K key, T currentObject) {
+ public ValueChange<T> update(K key, T currentObject) {
// Checking all paths.
Map<String, ResourceStatus> statuses = getStatuses(key);
Map<String, ChangeType> changes = new HashMap<String, ChangeType>();
@@ -87,7 +81,7 @@
ContentManager cm = getContentManager(key);
if (cm == null) {
log.warn("Null content manager for key " + key + ".");
- return;
+ return ValueChange.noChange();
}
for (String path : statuses.keySet()) {
@@ -102,21 +96,29 @@
if (changes.size() != 0) {
// Changes found, invoking the update function.
- update(key, currentObject, changes);
+ return update(key, currentObject, changes);
}
+
+ return ValueChange.noChange();
}
/**
* Same as ShotokuCacheItem.update(String, T), but is called only when
* some of the watched resources change, not on each call of update by
- * the service. If the object in the cache should be changed, the
- * implementing method must call put(key, newObject).
+ * the service.
* @param key Key of the object to update.
* @param currentObject Current value held in the cache.
* @param changes A map of descripiton of changes that occured since last
* update.
+ * @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>
*/
- protected abstract void update(K key, T currentObject,
+ protected abstract ValueChange<T> update(K key, T currentObject,
Map<String, ChangeType> changes);
private class ResourceStatus {
Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuResourceWatcherSplitDescriptor.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuResourceWatcherSplitDescriptor.java 2007-08-26 14:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/cache/ShotokuResourceWatcherSplitDescriptor.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -25,10 +25,10 @@
* @param added Set of paths that were added since the last update.
* @param deleted Set of paths that were deleted the last update.
*/
- abstract protected void update(K key, T currentObject, Set<String> modified,
+ abstract protected ValueChange<T> update(K key, T currentObject, Set<String> modified,
Set<String> added, Set<String> deleted);
- protected void update(K key, T currentObject, Map<String, ChangeType> changes) {
+ protected ValueChange<T> update(K key, T currentObject, Map<String, ChangeType> changes) {
Set<String> modified = new HashSet<String>();
Set<String> added = new HashSet<String>();
Set<String> deleted = new HashSet<String>();
@@ -49,6 +49,6 @@
}
}
- update(key, currentObject, modified, added, deleted);
+ return update(key, currentObject, modified, added, deleted);
}
}
Modified: labs/shotoku/trunk/shotoku-cache/TODO
===================================================================
--- labs/shotoku/trunk/shotoku-cache/TODO 2007-08-26 14:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-cache/TODO 2007-08-26 14:58:15 UTC (rev 14597)
@@ -6,3 +6,5 @@
* check form-sending for cache item configuration
* migrate AdministratedServices
* service unavailability when stopped; null get() when CI unregistered
+* split RenewableCacheService into independent parts
+* generalize UpdateThreadData
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:23:05 UTC (rev 14596)
+++ 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)
@@ -78,7 +78,7 @@
if (cacheItems == null) {
cacheItems = new ArrayList<CacheItemBean>();
- for (RenewableCacheItemOperations<?> cacheItemData : getService().getCacheItemsOperations()) {
+ for (RenewableCacheItemOperations<?,?> 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:23:05 UTC (rev 14596)
+++ 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)
@@ -11,7 +11,7 @@
import org.jboss.shotoku.cache.service.monitor.CacheAlert;
public class CacheItemBean {
- private RenewableCacheItemOperations<?> cacheItem;
+ private RenewableCacheItemOperations<?,?> 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(RenewableCacheItemOperations<?,?> 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:23:05 UTC (rev 14596)
+++ 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)
@@ -51,7 +51,7 @@
public List<String> getCurrentAlerts() {
if (currentAlerts == null) {
currentAlerts = new ArrayList<String>();
- for (RenewableCacheItemOperations<?> rcid : getMonitor().getCacheItemsWithAlerts()) {
+ for (RenewableCacheItemOperations<?,?> rcid : getMonitor().getCacheItemsWithAlerts()) {
currentAlerts.add(rcid.getName());
}
}
Modified: 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:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItem.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -56,9 +56,11 @@
*
* @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
*/
-public abstract class RenewableCacheItem<K, T> implements RenewableCacheItemOperations<K> {
+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;
@@ -82,24 +84,9 @@
private RenewableCacheServiceMBean service;
- /**
- * 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 RenewableCacheItem(Fqn fqn, String mbeanName, long interval) {
+ private RenewableCacheItem(RenewableCacheItemDataSource<K, T> dataSource, Fqn fqn, String mbeanName, long interval) {
+ this.dataSource = dataSource;
+
if (mbeanName == null) {
mbeanName = CacheTools.DEFAULT_RENEWABLE_CACHE_MBEAN;
}
@@ -123,22 +110,43 @@
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 RenewableCacheItem() {
- this(null, null, 0);
+ public static <K,T> RenewableCacheItemUser<K,T> create(RenewableCacheItemDataSource<K,T> dataSource) {
+ return create(dataSource, null, null, 0);
}
/**
- * Registers this cache item in the service. This method is automatically called
- * by the constructor, so you will only need to use it if you previously
- * manually unregistered the cache item using {@link #unregister()}.
+ * 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) {
@@ -147,7 +155,7 @@
try {
service = (RenewableCacheServiceMBean)
- CacheTools.getService(mbeanName, RenewableCacheServiceMBean.class);
+ CacheTools.getService(mbeanName, RenewableCacheServiceMBean.class);
} catch (Exception e) {
log.error("No RenewableCacheService bound to "
+ mbeanName + " in cache item "
@@ -160,9 +168,9 @@
}
}
- /**
- * Removes all keys handled by this cache item from the associated TreeCache node and
- * stops updates on this cache item.
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.shotoku.cache.RenewableCacheItemUser#unregister()
*/
public synchronized void unregister() {
try {
@@ -244,7 +252,7 @@
* @see org.jboss.shotoku.cache.RenewableCacheItemData#getInfo()
*/
public String getInfo() {
- return "";
+ return dataSource.getInfo();
}
/*
@@ -252,7 +260,7 @@
* @see org.jboss.shotoku.cache.RenewableCacheItemData#getName()
*/
public String getName() {
- return this.getClass().getName();
+ return dataSource.getClass().getName();
}
/**
@@ -263,7 +271,7 @@
* @param key Key of the object.
* @param object Object that should be bound.
*/
- public synchronized final void put(K key, T object) {
+ private synchronized final void put(K key, T object) {
if (!keysDuringUpdate.contains(key)) {
return;
}
@@ -275,19 +283,16 @@
}
}
- /**
- * 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.
- * @param key Key of the object to get.
- * @return Value of the object.
+ /*
+ * (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 = init(key);
+ T ret = dataSource.init(key);
try {
service.put(fqn, key, ret);
} catch (CacheException e) {
@@ -313,23 +318,26 @@
}
}
- /**
- * Called by the service update thread. You shouldn't call it from inside your
- * code.
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.shotoku.cache.RenewableCacheItemOperations#update()
*/
- public final void 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>(key, this) {
+ service.addUpdateThreadData(new UpdateThreadData<K, T>(key, this) {
public void execute() {
keysUpdates.put(key, System.currentTimeMillis());
keysDuringUpdate.add(key);
try {
- update(key, get(key));
+ ValueChange<T> change = dataSource.update(key, get(key));
+ if (change.hasValue()) {
+ put(key, change.getValue());
+ }
} finally {
keysInUpdate.remove(key);
keysDuringUpdate.remove(key);
@@ -369,24 +377,4 @@
"subsequent exceptions.", t);
}
}
-
- /**
- * Called by the service periodically to update the object held in the
- * cache.
- * If the object in the cache should be changed, the implementing
- * method must call {@link #put(Object, Object)}.
- * @param key Key of the object to update.
- * @param currentObject Current value held in the cache.
- */
- public abstract void 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. Here,
- * {@link #put(Object, Object)} should <b>not</b> be called, as the returned object
- * is automatically placed in the cache.
- * @param key Key of the object to initialize.
- * @return Initial value of an object with the given key.
- */
- public abstract T init(K key);
}
Added: 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 (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemDataSource.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -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 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();
+}
Modified: 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:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemOperations.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -22,99 +22,21 @@
******************************************************************************/
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;
-
/**
- * Configuration nad other operations on a cache item ({@link RenewableCacheItem}).
- * @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).
+ * 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> {
+public interface RenewableCacheItemOperations<K,T> extends RenewableCacheItemUser<K,T> {
/**
- *
- * @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();
+ * 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();
/**
- *
- * @return 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 RenewableCacheItem#update()} method will be executed on every service
- * thread update.
- */
- 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 RenewableCacheItem#update()} method will be executed on every service
- * thread update.
- */
- 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 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();
-
- /**
- *
- * @return A unique id of this instance of cache item.
- */
- public int getId();
-
- /**
- * 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 thread. Use with caution.
- * @param key Key, which update status should be reset.
- */
- public void resetKey(Object key);
-
- /**
- *
- * @return Additional information about the state of this object. Defaults to an empty string, but
- * {@link RenewableCacheItem} implementations can override this method.
- */
- public String getInfo();
-
- /**
- *
- * @return Name of this {@link RenewableCacheItem}. Usually the fully qualified class name.
- */
- public String getName();
-
- /**
* Reports that an update of a key ended wihtout any exceptions.
* @param key Key which has been updated.
*/
Added: 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 (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/RenewableCacheItemUser.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -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 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/SignalExitUpdateThreadData.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/SignalExitUpdateThreadData.java 2007-08-26 14:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/SignalExitUpdateThreadData.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -23,11 +23,11 @@
package org.jboss.shotoku.cache;
/**
+ * Data, that signals an update thread that it should exit (end).
*
- *
* @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
*/
-public class SignalExitUpdateThreadData<K> extends UpdateThreadData<K> {
+public class SignalExitUpdateThreadData<K,T> extends UpdateThreadData<K,T> {
public SignalExitUpdateThreadData() {
super(null, null);
}
Modified: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UpdateThread.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UpdateThread.java 2007-08-26 14:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UpdateThread.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -29,15 +29,17 @@
import java.util.concurrent.LinkedBlockingQueue;
/**
+ * An update thread, which reads data packets from a queue, executes an update
+ * on them, and reports on the statistics and possible errors.
* @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
*/
public class UpdateThread extends Thread {
private static final Logger log = Logger.getLogger(UpdateThread.class);
- private BlockingQueue<UpdateThreadData<?>> queue;
+ private BlockingQueue<UpdateThreadData<?,?>> queue;
private RenewableCacheServiceMBean service;
- public UpdateThread(RenewableCacheServiceMBean service, LinkedBlockingQueue<UpdateThreadData<?>> queue) {
+ public UpdateThread(RenewableCacheServiceMBean service, LinkedBlockingQueue<UpdateThreadData<?,?>> queue) {
this.queue = queue;
this.service = service;
@@ -48,7 +50,7 @@
service.reportThreadNew();
while (true) {
- UpdateThreadData<?> data;
+ UpdateThreadData<?,?> data;
try {
data = queue.take();
service.reportThreadBusy();
@@ -56,16 +58,17 @@
long start = System.currentTimeMillis();
service.getStatistics().addPacketWaitingTime(start - data.getCreateTime());
- if (data instanceof SignalExitUpdateThreadData<?>) {
+ if (data instanceof SignalExitUpdateThreadData<?,?>) {
+ service.reportThreadExit();
break;
}
try {
data.execute();
- data.updateOk();
+ data.executeOk();
service.getStatistics().addPacketProcessingTime(System.currentTimeMillis() - start, false);
} catch (Throwable t) {
- data.updateWithException(t);
+ data.executeWithException(t);
service.getStatistics().addPacketProcessingTime(System.currentTimeMillis() - start, true);
}
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:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/UpdateThreadData.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -27,13 +27,13 @@
* key in a cache item.
* @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
*/
-public abstract class UpdateThreadData<K> {
+public abstract class UpdateThreadData<K, T> {
private long createTime;
private K key;
- private RenewableCacheItemOperations<K> cacheItem;
+ private RenewableCacheItemOperations<K, T> cacheItem;
- public UpdateThreadData(K key, RenewableCacheItemOperations<K> cacheItem) {
+ public UpdateThreadData(K key, RenewableCacheItemOperations<K, T> cacheItem) {
createTime = System.currentTimeMillis();
this.key = key;
@@ -44,11 +44,11 @@
return createTime;
}
- public void updateOk() {
+ public void executeOk() {
cacheItem.reportUpdateOk(key);
}
- public void updateWithException(Throwable t) {
+ public void executeWithException(Throwable t) {
cacheItem.reportUpdateWithException(key, t);
}
Added: labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/ValueChange.java
===================================================================
--- labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/ValueChange.java (rev 0)
+++ labs/shotoku/trunk/shotoku-cache/cache-base/src/java/org/jboss/shotoku/cache/ValueChange.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * A class which represents either a change of value, and holds the new value,
+ * or no value change. Instances can be obtained using the
+ * {@link ValueChange#noChange()} and {@link ValueChange#changeTo(Object)} methods.
+ * @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
+ */
+public class ValueChange<T> {
+ private boolean hasValue;
+ private T newValue;
+
+ private ValueChange(boolean hasValue, T newValue) {
+ this.hasValue = hasValue;
+ this.newValue = newValue;
+ }
+
+ public static <T> ValueChange<T> noChange() {
+ return new ValueChange<T>(false, null);
+ }
+
+ public static <T> ValueChange<T> changeTo(T newValue) {
+ return new ValueChange<T>(true, newValue);
+ }
+
+ public T getValue() {
+ return newValue;
+ }
+
+ public boolean hasValue() {
+ return hasValue;
+ }
+}
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:23:05 UTC (rev 14596)
+++ 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)
@@ -6,7 +6,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeCacheMBean;
-import org.jboss.shotoku.cache.RenewableCacheItem;
import org.jboss.shotoku.cache.RenewableCacheItemOperations;
import org.jboss.shotoku.cache.UpdateThreadData;
@@ -16,7 +15,7 @@
* @author <a href="mailto:adam.warski at jboss.org">Adam Warski</a>
*/
public class DummyRenewableCacheService implements RenewableCacheServiceMBean {
- public void addUpdateThreadData(UpdateThreadData<?> data) {
+ public void addUpdateThreadData(UpdateThreadData<?,?> data) {
}
public Fqn generateNextFqn() {
@@ -58,7 +57,7 @@
public void put(Fqn fqn, Object key, Object o) throws CacheException {
}
- public void register(RenewableCacheItem<?,?> cacheItem) {
+ public void register(RenewableCacheItemOperations<?,?> cacheItem) {
}
public void remove(Fqn fqn, Object key) throws CacheException {
@@ -82,13 +81,13 @@
public void stop() {
}
- public void unregister(RenewableCacheItem<?,?> cacheItem) throws CacheException {
+ public void unregister(RenewableCacheItemOperations<?,?> cacheItem) throws CacheException {
}
public void update() {
}
- public Set<? extends RenewableCacheItemOperations<?>> getCacheItemsOperations() {
+ public Set<? extends RenewableCacheItemOperations<?,?>> getCacheItemsOperations() {
return null;
}
@@ -119,4 +118,8 @@
public void reportThreadNew() {
}
+
+ public void reportThreadExit() {
+
+ }
}
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:23:05 UTC (rev 14596)
+++ 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)
@@ -27,7 +27,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeCacheMBean;
-import org.jboss.shotoku.cache.RenewableCacheItem;
import org.jboss.shotoku.cache.RenewableCacheItemOperations;
import org.jboss.shotoku.cache.UpdateThreadData;
@@ -40,12 +39,12 @@
public void put(Fqn fqn, Object key, Object o) throws CacheException;
public void remove(Fqn fqn, Object key) throws CacheException;
- public void register(RenewableCacheItem<?,?> cacheItem);
- public void unregister(RenewableCacheItem<?,?> cacheItem) throws CacheException;
+ public void register(RenewableCacheItemOperations<?,?> cacheItem);
+ public void unregister(RenewableCacheItemOperations<?,?> cacheItem) throws CacheException;
public Fqn generateNextFqn();
- public void addUpdateThreadData(UpdateThreadData<?> data);
+ public void addUpdateThreadData(UpdateThreadData<?, ?> data);
public int getCurrentQueueSize();
public RenewableCacheStatistics getStatistics();
@@ -65,11 +64,12 @@
public void reportThreadIdle();
public void reportThreadBusy();
public void reportThreadNew();
+ public void reportThreadExit();
public int getIdleThreadCount();
public int getBusyThreadCount();
- public Set<? extends RenewableCacheItemOperations<?>> getCacheItemsOperations();
+ public Set<? extends RenewableCacheItemOperations<?, ?>> getCacheItemsOperations();
public void update();
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:23:05 UTC (rev 14596)
+++ 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)
@@ -12,12 +12,12 @@
}
- public List<CacheAlert> getAlertsForCacheItem(RenewableCacheItemOperations<?> rcid) {
+ public List<CacheAlert> getAlertsForCacheItem(RenewableCacheItemOperations<?,?> rcid) {
return null;
}
- public Set<RenewableCacheItemOperations<?>> getCacheItemsWithAlerts() {
- return new HashSet<RenewableCacheItemOperations<?>>();
+ public Set<RenewableCacheItemOperations<?,?>> getCacheItemsWithAlerts() {
+ return new HashSet<RenewableCacheItemOperations<?,?>>();
}
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:23:05 UTC (rev 14596)
+++ 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)
@@ -62,7 +62,7 @@
* @return A list of alerts for the given {@link RenewableCacheItem}, 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(RenewableCacheItemOperations<?,?> rcid);
/**
* Clears all alerts.
*/
@@ -71,5 +71,5 @@
*
* @return A set of {@link RenewableCacheItemOperations}, for which there are any alerts.
*/
- public Set<RenewableCacheItemOperations<?>> getCacheItemsWithAlerts();
+ public Set<RenewableCacheItemOperations<?,?>> 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:23:05 UTC (rev 14596)
+++ 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)
@@ -25,7 +25,6 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.TreeCacheMBean;
-import org.jboss.shotoku.cache.RenewableCacheItem;
import org.jboss.shotoku.cache.RenewableCacheItemOperations;
import org.jboss.shotoku.cache.SignalExitUpdateThreadData;
import org.jboss.shotoku.cache.UpdateThread;
@@ -150,8 +149,8 @@
* Cache handling
*/
- private final ConcurrentSet<RenewableCacheItem<?,?>> cacheItems =
- new ConcurrentHashSet<RenewableCacheItem<?,?>>();
+ private final ConcurrentSet<RenewableCacheItemOperations<?,?>> cacheItems =
+ new ConcurrentHashSet<RenewableCacheItemOperations<?,?>>();
public Object get(Fqn fqn, Object key) throws CacheException {
return treeCache.get(fqn, key);
@@ -165,11 +164,11 @@
treeCache.remove(fqn, key);
}
- public void register(RenewableCacheItem<?,?> cacheItem) {
+ public void register(RenewableCacheItemOperations<?,?> cacheItem) {
cacheItems.add(cacheItem);
}
- public void unregister(RenewableCacheItem<?,?> cacheItem) throws CacheException {
+ public void unregister(RenewableCacheItemOperations<?,?> cacheItem) throws CacheException {
cacheItems.remove(cacheItem);
for (Object key : cacheItem.getKeysUpdates().keySet()) {
@@ -177,7 +176,7 @@
}
}
- public Set<? extends RenewableCacheItemOperations<?>> getCacheItemsOperations() {
+ public Set<? extends RenewableCacheItemOperations<?,?>> getCacheItemsOperations() {
return cacheItems;
}
@@ -195,8 +194,8 @@
* Update threads management.
*/
- private final LinkedBlockingQueue<UpdateThreadData<?>> updateThreadDataQueue =
- new LinkedBlockingQueue<UpdateThreadData<?>>();
+ private final LinkedBlockingQueue<UpdateThreadData<?,?>> updateThreadDataQueue =
+ new LinkedBlockingQueue<UpdateThreadData<?,?>>();
private int updateThreadCount;
private int busyThreads;
@@ -204,7 +203,7 @@
private final Object threadCounterSynchronizer = new Object();
- public void addUpdateThreadData(UpdateThreadData<?> data) {
+ public void addUpdateThreadData(UpdateThreadData<?,?> data) {
updateThreadDataQueue.offer(data);
}
@@ -220,7 +219,7 @@
}
} else if (n < updateThreadCount) {
for (int i = updateThreadCount; i > n; i--) {
- updateThreadDataQueue.offer(new SignalExitUpdateThreadData<Object>());
+ updateThreadDataQueue.offer(new SignalExitUpdateThreadData<Object,Object>());
}
}
@@ -252,22 +251,26 @@
busyThreads--;
idleThreads++;
}
-
}
public void reportThreadNew() {
synchronized (threadCounterSynchronizer) {
idleThreads++;
}
-
}
+ public void reportThreadExit() {
+ synchronized (threadCounterSynchronizer) {
+ busyThreads--;
+ }
+ }
+
/*
* Update function.
*/
public void update() {
- for (RenewableCacheItem<?,?> sci : cacheItems) {
+ for (RenewableCacheItemOperations<?,?> 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:23:05 UTC (rev 14596)
+++ 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)
@@ -101,9 +101,9 @@
//
- private Set<RenewableCacheItemOperations<?>> cacheItemsWithAlerts = new HashSet<RenewableCacheItemOperations<?>>();
- private Map<RenewableCacheItemOperations<?>, Set<CacheAlert>> alertsForCacheItems =
- new HashMap<RenewableCacheItemOperations<?>, Set<CacheAlert>>();
+ private Set<RenewableCacheItemOperations<?,?>> cacheItemsWithAlerts = new HashSet<RenewableCacheItemOperations<?,?>>();
+ private Map<RenewableCacheItemOperations<?,?>, Set<CacheAlert>> alertsForCacheItems =
+ new HashMap<RenewableCacheItemOperations<?,?>, Set<CacheAlert>>();
private int currentNumberOfAlerts;
@@ -119,7 +119,7 @@
return;
}
- for (RenewableCacheItemOperations<?> rcid : getRenewableCacheService().getCacheItemsOperations()) {
+ for (RenewableCacheItemOperations<?,?> 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(RenewableCacheItemOperations<?,?> 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(RenewableCacheItemOperations<?,?> 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<RenewableCacheItemOperations<?,?>> getCacheItemsWithAlerts() {
return cacheItemsWithAlerts;
}
@@ -201,7 +201,7 @@
alertsForCacheItems.clear();
// Clearing all exceptions in cache items.
- for (RenewableCacheItemOperations<?> rcid : getRenewableCacheService().getCacheItemsOperations()) {
+ for (RenewableCacheItemOperations<?,?> 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:23:05 UTC (rev 14596)
+++ 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)
@@ -1,15 +1,18 @@
package org.jboss.shotoku.cache.test;
-import org.jboss.shotoku.cache.RenewableCacheItem;
+import org.jboss.shotoku.cache.RenewableCacheItemDataSource;
+import org.jboss.shotoku.cache.ValueChange;
-public class TestCacheItem extends RenewableCacheItem<String, Integer> {
- @Override
+public class TestCacheItem implements RenewableCacheItemDataSource<String, Integer> {
public Integer init(String key) {
return 0;
}
- @Override
- public void update(String key, Integer currentObject) {
- put(key, currentObject + 1);
+ public ValueChange<Integer> update(String key, Integer currentObject) {
+ return ValueChange.changeTo(currentObject + 1);
}
+
+ public String getInfo() {
+ return null;
+ }
}
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:23:05 UTC (rev 14596)
+++ 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)
@@ -1,21 +1,24 @@
package org.jboss.shotoku.cache.test;
-import org.jboss.shotoku.cache.RenewableCacheItem;
+import org.jboss.shotoku.cache.RenewableCacheItemDataSource;
+import org.jboss.shotoku.cache.ValueChange;
-public class TestCacheItem2 extends RenewableCacheItem<String, Integer> {
- @Override
+public class TestCacheItem2 implements RenewableCacheItemDataSource<String, Integer> {
public Integer init(String key) {
return 0;
}
- @Override
- public void update(String key, Integer currentObject) {
+ public ValueChange<Integer> update(String key, Integer currentObject) {
try {
Thread.sleep(30000);
} catch (InterruptedException e) {
e.printStackTrace();
}
- put(key, currentObject + 1);
+ return ValueChange.changeTo(currentObject + 1);
}
+
+ public String getInfo() {
+ return null;
+ }
}
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:23:05 UTC (rev 14596)
+++ 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)
@@ -1,18 +1,22 @@
package org.jboss.shotoku.cache.test;
-import org.jboss.shotoku.cache.RenewableCacheItem;
+import org.jboss.shotoku.cache.RenewableCacheItemDataSource;
+import org.jboss.shotoku.cache.ValueChange;
-public class TestCacheItem3 extends RenewableCacheItem<String, Integer> {
- @Override
+public class TestCacheItem3 implements RenewableCacheItemDataSource<String, Integer> {
public Integer init(String key) {
return 0;
}
- @Override
- public void update(String key, Integer currentObject) {
- put(key, currentObject + 1);
+ public ValueChange<Integer> update(String key, Integer currentObject) {
if (currentObject % 4 != 0) {
throw new RuntimeException("TRALALALA");
}
+
+ return ValueChange.changeTo(currentObject + 1);
}
+
+ public String getInfo() {
+ return null;
+ }
}
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:23:05 UTC (rev 14596)
+++ 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)
@@ -8,12 +8,15 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.jboss.shotoku.cache.RenewableCacheItem;
+import org.jboss.shotoku.cache.RenewableCacheItemUser;
+
public class TestServlet extends HttpServlet {
- private TestCacheItem tci;
- private TestCacheItem2 tci2;
- private TestCacheItem tci3;
- private TestCacheItem2 tci4;
- private TestCacheItem3 tci5;
+ 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;
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
@@ -30,11 +33,11 @@
@Override
public void init(ServletConfig config) throws ServletException {
- tci = new TestCacheItem();
- tci2 = new TestCacheItem2();
- tci3 = new TestCacheItem();
- tci4 = new TestCacheItem2();
- tci5 = new TestCacheItem3();
+ 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());
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:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptorImpl.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -31,6 +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.feeds.data.NormalFeed;
import org.jboss.shotoku.feeds.data.special.SpecialFeed;
import org.jboss.shotoku.feeds.data.Feed;
@@ -95,12 +96,12 @@
*/
private String id;
- private FeedsConfigurationWatcher fcw;
+ private RenewableCacheItemUser<Pair<String, String>, Properties> fcw;
private int readTimeout;
private int connTimeout;
- public FeedsDescriptorImpl(String id, FeedsConfigurationWatcher fcw, int connTimeout, int readTimeout) {
+ public FeedsDescriptorImpl(String id, RenewableCacheItemUser<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:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/service/FeedsServiceImpl.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -3,6 +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.feeds.DummyFeedsDescriptor;
import org.jboss.shotoku.feeds.FeedsService;
import org.jboss.shotoku.feeds.FeedsDescriptorImpl;
@@ -16,10 +18,12 @@
import org.jboss.shotoku.service.AdministratedService;
import org.jboss.shotoku.ContentManager;
import org.jboss.shotoku.tools.Constants;
+import org.jboss.shotoku.tools.Pair;
import javax.ejb.Local;
import java.util.HashMap;
import java.util.Map;
+import java.util.Properties;
/**
* @author Adam Warski (adamw at aster.pl)
@@ -36,7 +40,7 @@
* FeedsService implementation.
*/
- private static FeedsConfigurationWatcher conf;
+ private static RenewableCacheItemUser<Pair<String, String>, Properties> conf;
private Map<String, FeedsDescriptor> fds;
@@ -87,7 +91,7 @@
public void create() throws Exception {
super.create();
- conf = new FeedsConfigurationWatcher();
+ conf = RenewableCacheItem.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/ClosedContentInformation.java
===================================================================
--- labs/shotoku/trunk/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/ClosedContentInformation.java 2007-08-26 14:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/ClosedContentInformation.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -1,7 +1,5 @@
package org.jboss.shotoku.fileaccess;
-import java.io.InputStream;
-
/**
* @author Adam Warski (adamw at aster.pl)
*/
Modified: labs/shotoku/trunk/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessConfigurationWatcher.java
===================================================================
--- labs/shotoku/trunk/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessConfigurationWatcher.java 2007-08-26 14:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessConfigurationWatcher.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -2,9 +2,9 @@
import org.jboss.shotoku.ContentManager;
import org.jboss.shotoku.exceptions.ResourceDoesNotExist;
-import org.jboss.shotoku.cache.ShotokuPropertiesWatcher;
import org.jboss.shotoku.cache.ShotokuResourceWatcher;
import org.jboss.shotoku.cache.ChangeType;
+import org.jboss.shotoku.cache.ValueChange;
import org.jboss.shotoku.tools.Pair;
import org.apache.log4j.Logger;
@@ -46,8 +46,8 @@
return ContentManager.getContentManager(key.getFirst(), key.getSecond());
}
- protected void update(Pair<String, String> key, FileAccessConfiguration currentObject,
+ protected ValueChange<FileAccessConfiguration> update(Pair<String, String> key, FileAccessConfiguration currentObject,
Map<String, ChangeType> changes) {
- put(key, getConfiguration(key));
+ return ValueChange.changeTo(getConfiguration(key));
}
}
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:23:05 UTC (rev 14596)
+++ labs/shotoku/trunk/shotoku-file-access/src/java/org/jboss/shotoku/fileaccess/FileAccessServlet.java 2007-08-26 14:58:15 UTC (rev 14597)
@@ -1,5 +1,7 @@
package org.jboss.shotoku.fileaccess;
+import org.jboss.shotoku.cache.RenewableCacheItem;
+import org.jboss.shotoku.cache.RenewableCacheItemUser;
import org.jboss.shotoku.tools.Pair;
import org.jboss.shotoku.tools.Tools;
import org.jboss.shotoku.ContentManager;
@@ -32,11 +34,10 @@
private ContentManager contentManager;
private Pair<String, String> confKey;
- @SuppressWarnings({"UNUSED_SYMBOL"})
- private FileAccessConfigurationWatcher conf;
+ private RenewableCacheItemUser<Pair<String, String>, FileAccessConfiguration> conf;
public void init(ServletConfig conf) {
- this.conf = new FileAccessConfigurationWatcher();
+ this.conf = RenewableCacheItem.create(new FileAccessConfigurationWatcher());
contentManager = ContentManager.getContentManager(
conf.getInitParameter("contentManagerId"),
More information about the jboss-svn-commits
mailing list