Excalibur Store manages a simple file or memory store (or cache). Here's how you can use it in your own application:

First off, Excalibur Store only provides an abstract implementation of the persistant store (for example, { { { AbstractFileStore } } }), so you're going to want to extend this class. In fact, you can get away (for our simple example) with just creating an empty class like:

package org.project.store;

import org.apache.excalibur.store.impl.{ { { AbstractFilesystemStore } } };

public class { { { PersistantStoreImpl } } }
{{{    extends { { { AbstractFilesystemStore } } } { 

  public { { { PersistantStoreImpl() } } } { 
  } 

}   }}}

Now we want to set up our *.roles file like this:

  <role name="org.apache.excalibur.store.Store"> 
    <component shorthand="persistant-store" 
               class="org.project.{ { { PersistantStoreImpl } } }" 
               handler="org.apache.avalon.fortress.impl.handler.{ { { ThreadSafeComponentHandler } } }"/> 
    <component shorthand="memory-store" 
               class="org.apache.excalibur.store.impl.{ { { ["MRUMemoryStore"] } } }" 
               handler="org.apache.avalon.fortress.impl.handler.{ { { ThreadSafeComponentHandler } } }"/> 
  </role> 

  <role name="org.apache.excalibur.store.{ { { StoreJanitor } } }"> 
    <component shorthand="store-gc" 
               class="org.apache.excalibur.store.impl.{ { { StoreJanitorImpl } } }" 
               handler="org.apache.avalon.fortress.impl.handler.{ { { ThreadSafeComponentHandler } } }"/> 
  </role> 

}}}

And our *.xconf file would have something like this in it:

   <persistant-store id="store"> 
    <parameter name="default" value="value"/> 
   </persistant-store> 

   <memory-store id="{ { { TransientStore } } }"> 
    <parameter name="maxobjects" value="100" /> 
    <parameter name="use-persistent-cache" value="false" /> 
   </memory-store> 

   <store-gc id="{ { { StoreJanitor } } }"> 
    <parameter name="freememory" value="1000000"/> 
    <parameter name="heapsize" value="60000000"/> 
    <parameter name="cleanupthreadinterval" value="10"/> 
    <parameter name="threadpriority" value="10"/> 
    <parameter name="percent_to_free" value="10"/> 
   </store-gc> 

}}}

The default persistant store will serialize objects to file in the current working directory (so make sure your objects are Seriablizable). At this point you can customize your { { { PersistantStoreImpl } } } and add some configuration or parameterization to it.

Excalibur/Store (last edited 2009-09-20 23:32:14 by localhost)