org.apache.cocoon.components.store
Class MRUMemoryStore

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.components.store.MRUMemoryStore
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.logger.Loggable, Store, org.apache.avalon.framework.thread.ThreadSafe

public final class MRUMemoryStore
extends org.apache.avalon.framework.logger.AbstractLoggable
implements Store, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.thread.ThreadSafe, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.context.Contextualizable

This class provides a cache algorithm for the requested documents. It combines a HashMap and a LinkedList to create a so called MRU (Most Recently Used) cache. The idea was taken from the "Writing Advanced Application Tutorial" from javasoft. Many thanx to the writers!

Author:
Gerhard Froehlich, Davanum Srinivas

Fields inherited from interface org.apache.cocoon.components.store.Store
ROLE
 
Constructor Summary
MRUMemoryStore()
           
 
Method Summary
 void compose(org.apache.avalon.framework.component.ComponentManager manager)
          Get components of the ComponentManager
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
          Initialize the MRUMemoryStore.
 boolean containsKey(java.lang.Object key)
          Indicates if the given key is associated to a contained object.
 void contextualize(org.apache.avalon.framework.context.Context context)
          Get the context
 void dispose()
          Dispose the component
 void free()
          Frees some of the fast memory used by this store.
 java.lang.Object get(java.lang.Object key)
          Get the object associated to the given unique key.
 void hold(java.lang.Object key, java.lang.Object value)
          This method holds the requested object in a HashMap combined with a LinkedList to create the MRU.
 java.util.Enumeration keys()
          Returns the list of used keys as an Enumeration.
 void remove(java.lang.Object key)
          Remove the object associated to the given key.
 void store(java.lang.Object key, java.lang.Object value)
          Store the given object in a persistent state.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MRUMemoryStore

public MRUMemoryStore()
Method Detail

compose

public void compose(org.apache.avalon.framework.component.ComponentManager manager)
             throws org.apache.avalon.framework.component.ComponentException
Get components of the ComponentManager
Specified by:
compose in interface org.apache.avalon.framework.component.Composable
Parameters:
the - ComponentManager

contextualize

public void contextualize(org.apache.avalon.framework.context.Context context)
                   throws org.apache.avalon.framework.context.ContextException
Get the context
Specified by:
contextualize in interface org.apache.avalon.framework.context.Contextualizable
Parameters:
the - Context of the application

configure

public void configure(org.apache.avalon.framework.configuration.Configuration conf)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Initialize the MRUMemoryStore. A few options can be used :
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Parameters:
the - Configuration of the application
Throws:
org.apache.avalon.framework.configuration.ConfigurationException -  

dispose

public void dispose()
Dispose the component
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable

store

public void store(java.lang.Object key,
                  java.lang.Object value)
Store the given object in a persistent state. It is up to the caller to ensure that the key has a persistent state across different JVM executions.
Specified by:
store in interface Store
Parameters:
the - key for the object to store
the - object to store

hold

public void hold(java.lang.Object key,
                 java.lang.Object value)
This method holds the requested object in a HashMap combined with a LinkedList to create the MRU. It also stores objects onto the filesystem if configured.
Specified by:
hold in interface Store
Parameters:
the - key of the object to be stored
the - object to be stored

get

public java.lang.Object get(java.lang.Object key)
Get the object associated to the given unique key.
Specified by:
get in interface Store
Parameters:
the - key of the requested object
Returns:
the requested object

remove

public void remove(java.lang.Object key)
Remove the object associated to the given key.
Specified by:
remove in interface Store
Parameters:
the - key of to be removed object

containsKey

public boolean containsKey(java.lang.Object key)
Indicates if the given key is associated to a contained object.
Specified by:
containsKey in interface Store
Parameters:
the - key of the object
Returns:
true if the key exists

keys

public java.util.Enumeration keys()
Returns the list of used keys as an Enumeration.
Specified by:
keys in interface Store
Returns:
the enumeration of the cache

free

public void free()
Frees some of the fast memory used by this store. It removes the last element in the store.
Specified by:
free in interface Store


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.