You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by tv...@apache.org on 2007/04/16 21:05:49 UTC
svn commit: r529358 - in
/jakarta/turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache:
DefaultGlobalCacheService.java ObjectExpiredException.java
Author: tv
Date: Mon Apr 16 12:05:48 2007
New Revision: 529358
URL: http://svn.apache.org/viewvc?view=rev&rev=529358
Log:
Stop housekeeping thread correctly at dispose(), add serial version numbers
Modified:
jakarta/turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/DefaultGlobalCacheService.java
jakarta/turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/ObjectExpiredException.java
Modified: jakarta/turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/DefaultGlobalCacheService.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/DefaultGlobalCacheService.java?view=diff&rev=529358&r1=529357&r2=529358
==============================================================================
--- jakarta/turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/DefaultGlobalCacheService.java (original)
+++ jakarta/turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/DefaultGlobalCacheService.java Mon Apr 16 12:05:48 2007
@@ -87,9 +87,10 @@
private int cacheInitialSize;
/** thread for removing stale items from the cache */
private Thread housekeeping;
+
/** flag to stop the housekeeping thread when the component is disposed. */
private boolean continueThread;
- private boolean disposed;
+
/**
* @return
*/
@@ -188,7 +189,7 @@
{
String key = (String) itr.next();
try {
- CachedObject obj = getObject(key);
+ /* CachedObject obj = */ getObject(key);
} catch (ObjectExpiredException oee) {
// this is OK we just do not want this key
continue;
@@ -232,7 +233,7 @@
*/
public void run()
{
- while (true)
+ while (continueThread)
{
// Sleep for amount of time set in cacheCheckFrequency -
// default = 5 seconds.
@@ -242,7 +243,9 @@
}
catch (InterruptedException exc)
{
+ if (!continueThread) return;
}
+
clearCache();
}
}
@@ -325,6 +328,7 @@
}
}
}
+
// ---------------- Avalon Lifecycle Methods ---------------------
/**
* Avalon component lifecycle method
@@ -334,6 +338,10 @@
cacheCheckFrequency = conf.getAttributeAsLong(CACHE_CHECK_FREQUENCY, DEFAULT_CACHE_CHECK_FREQUENCY);
cacheInitialSize = conf.getAttributeAsInteger(INITIAL_CACHE_SIZE, DEFAULT_INITIAL_CACHE_SIZE);
}
+
+ /**
+ * Avalon component lifecycle method
+ */
public void initialize() throws Exception
{
try
@@ -354,6 +362,7 @@
throw new Exception("DefaultGlobalCacheService failed to initialize", e);
}
}
+
/**
* Avalon component lifecycle method
*/
@@ -361,8 +370,8 @@
{
continueThread = false;
housekeeping.interrupt();
- disposed = true;
}
+
/**
* The name used to specify this component in TurbineResources.properties
* @deprecated part of the pre-avalon compatibility layer
Modified: jakarta/turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/ObjectExpiredException.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/ObjectExpiredException.java?view=diff&rev=529358&r1=529357&r2=529358
==============================================================================
--- jakarta/turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/ObjectExpiredException.java (original)
+++ jakarta/turbine/fulcrum/trunk/cache/src/java/org/apache/fulcrum/cache/ObjectExpiredException.java Mon Apr 16 12:05:48 2007
@@ -28,4 +28,9 @@
public class ObjectExpiredException
extends Exception
{
+
+ /**
+ * Serial version id
+ */
+ private static final long serialVersionUID = -4331535517388875678L;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org