[JBoss-dev] CVS update: jboss/src/main/org/jboss/util LRUCachePolicy.java

2002-02-16 Thread Jason Dillon

  User: user57  
  Date: 02/02/16 03:41:17

  Modified:src/main/org/jboss/util LRUCachePolicy.java
  Log:
   o reformat
  
  Revision  ChangesPath
  1.14  +423 -422  jboss/src/main/org/jboss/util/LRUCachePolicy.java
  
  Index: LRUCachePolicy.java
  ===
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/LRUCachePolicy.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- LRUCachePolicy.java   31 Jan 2002 00:05:02 -  1.13
  +++ LRUCachePolicy.java   16 Feb 2002 11:41:17 -  1.14
  @@ -4,6 +4,7 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
  +
   package org.jboss.util;
   
   import java.util.HashMap;
  @@ -12,430 +13,430 @@
* Implementation of a Least Recently Used cache policy.
*
* @author a href=mailto:[EMAIL PROTECTED];Simone Bordet/a
  - * @version $Revision: 1.13 $
  + * @version $Revision: 1.14 $
*/
   public class LRUCachePolicy
  - implements CachePolicy
  +   implements CachePolicy
   {
  - // Constants -
  +   // Constants -
   
  - // Attributes 
  - /**
  -  * The map holding the cached objects
  -  */
  - protected HashMap m_map;
  - /**
  -  * The linked list used to implement the LRU algorithm
  -  */
  - protected LRUList m_list;
  - /**
  -  * The maximum capacity of this cache
  -  */
  - protected int m_maxCapacity;
  - /**
  -  * The minimum capacity of this cache
  -  */
  - protected int m_minCapacity;
  -
  - // Static 
  -
  - // Constructors --
  - /**
  -  * Creates a LRU cache policy object with zero cache capacity.
  -  * @see #init
  -  */
  - public LRUCachePolicy()
  - {
  - }
  - /**
  -  * Creates a LRU cache policy object with the specified minimum
  -  * and maximum capacity.
  -  * @see #init
  -  */
  - public LRUCachePolicy(int min, int max)
  - {
  - if (min  2 || min  max) {throw new IllegalArgumentException(Illegal 
cache capacities);}
  - m_minCapacity = min;
  - m_maxCapacity = max;
  - }
  -
  - // Public 
  -
  - // Service implementation --
  - /**
  -  * Initializes the cache, creating all required objects and initializing their
  -  * values.
  -  * @see #start
  -  * @see #destroy
  -  */
  - public void create()
  - {
  - m_map = new HashMap();
  - m_list = createList();
  - m_list.m_maxCapacity = m_maxCapacity;
  - m_list.m_minCapacity = m_minCapacity;
  - m_list.m_capacity = m_maxCapacity;
  - }
  - /**
  -  * Starts this cache that is now ready to be used.
  -  * @see #init
  -  * @see #stop
  -  */
  - public void start()
  - {
  - }
  - /**
  -  * Stops this cache thus {@link #flush}ing all cached objects. br
  -  * After this method is called, a call to {@link #start} will restart the 
cache.
  -  * @see #start
  -  * @see #destroy
  -  */
  - public void stop()
  - {
  - if (m_list != null)
  - {
  - flush();
  - }
  - }
  - /**
  -  * Destroys the cache that is now unusable. br
  -  * To have it working again it must be re-{@link #init}ialized and
  -  * re-{@link #start}ed.
  -  * @see #init
  -  */
  - public void destroy()
  - {
  - }
  -
  - public Object get(Object key)
  - {
  - if (key == null)
  - {
  - throw new IllegalArgumentException(Requesting an object using 
a null key);
  - }
  -
  - LRUCacheEntry value = (LRUCacheEntry)m_map.get(key);
  - if (value != null)
  - {
  - m_list.promote(value);
  - return value.m_object;
  - }
  - else
  - {
  - cacheMiss();
  - return null;
  - }
  - }
  - public Object peek(Object key)
  - {
  - if (key == null)
  - {
  - throw new IllegalArgumentException(Requesting an object using 
a null key);
  - }
  -
  - LRUCacheEntry value = (LRUCacheEntry)m_map.get(key);
  - if (value == null)
  - {
  - return null;
  - }
  - else
  - {
  -

[JBoss-dev] CVS update: jboss/src/main/org/jboss/util LRUCachePolicy.java TimedCachePolicy.java CachePolicy.java

2002-01-30 Thread Bill Burke

  User: patriot1burke
  Date: 02/01/30 16:05:02

  Modified:src/main/org/jboss/util LRUCachePolicy.java
TimedCachePolicy.java CachePolicy.java
  Log:
  added getCacheSize and flushCache to MBean interface for EntityContainer
  
  Revision  ChangesPath
  1.13  +5 -1  jboss/src/main/org/jboss/util/LRUCachePolicy.java
  
  Index: LRUCachePolicy.java
  ===
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/LRUCachePolicy.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- LRUCachePolicy.java   2002/01/15 22:53:42 1.12
  +++ LRUCachePolicy.java   2002/01/31 00:05:02 1.13
  @@ -12,7 +12,7 @@
* Implementation of a Least Recently Used cache policy.
*
* @author a href=mailto:[EMAIL PROTECTED];Simone Bordet/a
  - * @version $Revision: 1.12 $
  + * @version $Revision: 1.13 $
*/
   public class LRUCachePolicy
implements CachePolicy
  @@ -180,6 +180,10 @@
ageOut(entry);
}
}
  +
  +public int size() {
  + return m_list.m_count;
  +}
   
// Y overrides ---
   
  
  
  
  1.5   +5 -1  jboss/src/main/org/jboss/util/TimedCachePolicy.java
  
  Index: TimedCachePolicy.java
  ===
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/TimedCachePolicy.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TimedCachePolicy.java 2001/12/19 06:45:20 1.4
  +++ TimedCachePolicy.java 2002/01/31 00:05:02 1.5
  @@ -23,7 +23,7 @@
   until they are accessed.
   
   @author a href=mailto:[EMAIL PROTECTED];Scott Stark/a.
  -@version $Revision: 1.4 $
  +@version $Revision: 1.5 $
   */
   public class TimedCachePolicy extends TimerTask implements CachePolicy
   {
  @@ -205,6 +205,10 @@
{
   entryMap.clear();
}
  +
  +public int size() {
  + return entryMap.size();
  +}
   // --- End CachePolicy interface methods
   
   /** The TimerTask run method. It updates the cache time to the
  
  
  
  1.6   +3 -1  jboss/src/main/org/jboss/util/CachePolicy.java
  
  Index: CachePolicy.java
  ===
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/CachePolicy.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CachePolicy.java  2001/08/30 03:50:12 1.5
  +++ CachePolicy.java  2002/01/31 00:05:02 1.6
  @@ -13,7 +13,7 @@
* a MRU one, or any other suitable policy.
* 
* @author a href=mailto:[EMAIL PROTECTED];Simone Bordet/a
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
*/
   public interface CachePolicy extends Service
   {
  @@ -67,4 +67,6 @@
 * Flushes the cached objects from the cache.
 */
public void flush();
  +
  +public int size();
   }
  
  
  

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



[JBoss-dev] CVS update: jboss/src/main/org/jboss/util LRUCachePolicy.java

2002-01-15 Thread Dain Sundstrom

  User: dsundstrom
  Date: 02/01/15 14:53:42

  Modified:src/main/org/jboss/util LRUCachePolicy.java
  Log:
  Removed unused throws Exception declaraion from create and start methods.
  
  Revision  ChangesPath
  1.12  +3 -3  jboss/src/main/org/jboss/util/LRUCachePolicy.java
  
  Index: LRUCachePolicy.java
  ===
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/LRUCachePolicy.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- LRUCachePolicy.java   2001/12/19 06:45:20 1.11
  +++ LRUCachePolicy.java   2002/01/15 22:53:42 1.12
  @@ -12,7 +12,7 @@
* Implementation of a Least Recently Used cache policy.
*
* @author a href=mailto:[EMAIL PROTECTED];Simone Bordet/a
  - * @version $Revision: 1.11 $
  + * @version $Revision: 1.12 $
*/
   public class LRUCachePolicy
implements CachePolicy
  @@ -68,7 +68,7 @@
 * @see #start
 * @see #destroy
 */
  - public void create() throws Exception
  + public void create()
{
m_map = new HashMap();
m_list = createList();
  @@ -81,7 +81,7 @@
 * @see #init
 * @see #stop
 */
  - public void start() throws Exception
  + public void start()
{
}
/**
  
  
  

___
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development



[JBoss-dev] CVS update: jboss/src/main/org/jboss/util LRUCachePolicy.java

2001-03-26 Thread biorn_steedom

  User: biorn_steedom
  Date: 01/03/26 04:40:33

  Modified:src/main/org/jboss/util LRUCachePolicy.java
  Log:
  Small fixes in case an application is not deployed, to avoid a NPE.
  Thanks to Dan Christopherson ([EMAIL PROTECTED]).
  
  Revision  ChangesPath
  1.8   +56 -53jboss/src/main/org/jboss/util/LRUCachePolicy.java
  
  Index: LRUCachePolicy.java
  ===
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/LRUCachePolicy.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LRUCachePolicy.java   2000/12/18 10:27:57 1.7
  +++ LRUCachePolicy.java   2001/03/26 12:40:33 1.8
  @@ -12,9 +12,9 @@
* Implementation of a Least Recently Used cache policy.
*
* @author Simone Bordet ([EMAIL PROTECTED])
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
*/
  -public class LRUCachePolicy 
  +public class LRUCachePolicy
implements CachePolicy
   {
// Constants -
  @@ -44,15 +44,15 @@
 * Creates a LRU cache policy object with zero cache capacity.
 * @see #init
 */
  - public LRUCachePolicy() 
  - {   
  + public LRUCachePolicy()
  + {
}
/**
  -  * Creates a LRU cache policy object with the specified minimum 
  +  * Creates a LRU cache policy object with the specified minimum
 * and maximum capacity.
 * @see #init
 */
  - public LRUCachePolicy(int min, int max) 
  + public LRUCachePolicy(int min, int max)
{
if (min  2 || min  max) {throw new IllegalArgumentException("Illegal 
cache capacities");}
m_minCapacity = min;
  @@ -68,7 +68,7 @@
 * @see #start
 * @see #destroy
 */
  - public void init() throws Exception 
  + public void init() throws Exception
{
m_map = new HashMap();
m_list = createList();
  @@ -81,7 +81,7 @@
 * @see #init
 * @see #stop
 */
  - public void start() throws Exception 
  + public void start() throws Exception
{
}
/**
  @@ -90,29 +90,32 @@
 * @see #start
 * @see #destroy
 */
  - public void stop() 
  + public void stop()
{
  - flush();
  + if (m_list != null)
  + {
  + flush();
  + }
}
/**
 * Destroys the cache that is now unusable. br
  -  * To have it working again it must be re-{@link #init}ialized and 
  +  * To have it working again it must be re-{@link #init}ialized and
 * re-{@link #start}ed.
 * @see #init
 */
  - public void destroy() 
  + public void destroy()
{
}
   
  - public Object get(Object key) 
  + public Object get(Object key)
{
  - if (key == null) 
  + if (key == null)
{
throw new IllegalArgumentException("Requesting an object using 
a null key");
}
   
LRUCacheEntry value = (LRUCacheEntry)m_map.get(key);
  - if (value != null) 
  + if (value != null)
{
m_list.promote(value);
return value.m_object;
  @@ -123,53 +126,53 @@
return null;
}
}
  - public Object peek(Object key) 
  + public Object peek(Object key)
{
  - if (key == null) 
  + if (key == null)
{
throw new IllegalArgumentException("Requesting an object using 
a null key");
}
  - 
  +
LRUCacheEntry value = (LRUCacheEntry)m_map.get(key);
  - if (value == null) 
  + if (value == null)
{
return null;
}
  - else 
  + else
{
return value.m_object;
}
}
  - public void insert(Object key, Object o) 
  + public void insert(Object key, Object o)
{
if (o == null) {throw new IllegalArgumentException("Cannot insert a 
null object in the cache");}
if (key == null) {throw new IllegalArgumentException("Cannot insert an 
object in the cache with null key");}
Object obj = m_map.get(key);
  - if (obj == null) 
  + if (obj == null)
{
m_list.demote();
LRUCacheEntry entry = createCacheEntry(key, o);
m_list.promote(entry);
m_map.put(key, entry);
}
  - else 
  + else
{