Datastore Developers Guide
Utilities
previous :: contents :: next

Back to > Overview > Developers Guide

Utilities

Authors:
Szabo Csaba <crow@nolimits.ro>
Antal Attila <atech@nolimits.ro>
Table of Contents
1. Using JNDI naming system
2. Scheduling the lexical jobs
    2.1. Why Datastore need the scheduler?
    2.2. Using the Avalon Cornerstone
    2.3. The StoreScheduler
    2.4. StoreScheduler targets


1. Using JNDI naming system

For passing parameters between block (services) the Datastore is use the JNDI naming system. The JNDI MemoryContextFactory was make static to obtain only one reference for every block. In the initial context factory we have this static object named StaticMemoryContextFactory. This context is uploaded first time together with the naming block. This block file is the naming.jar. All blocks which using the naming system is dependent from this block.

The following example shows, how you can initialize the naming system:


Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
           "org.media.datastore.naming.StaticMemoryContextFactory");
Context ctx = new InitialContext(env);

    

In each block where was used the naming you will find this context initialization, and after this, everywhere was used the ctx.bind(), and the ctx.lookup() methods for put and get objects.

top

2. Scheduling the lexical jobs

2.1. Why Datastore need the scheduler?

When Datastore stores data in database you need to cut the data to obtain and store the words. These words will be used for the indexed search. This procedure can take a longer period of time and depends on the volume of stored data. This method was separated from the engine and it was attached to a self-scheduler system. In other case it can be called directly.

top

2.2. Using the Avalon Cornerstone

The cornerstone is an Avalon utility package for the framework and has some utilities. One of them is the scheduler and the Datastore it was used.

top

2.3. The StoreScheduler

The StoreScheduler is a Datastore scheduler service using the cornerstone scheduler, on the other hand the StoreScheduler is a block named scheduler.jar having a dependency from cornerstone.bar. The offered service and the dependency was registered in the self-.xinfo file and in the assembly.xml, they are the following:

StoreScheduler.xinfo

<?xml version="1.0"?>

<blockinfo>

  <block>
    <version>1.0</version>
  </block>

  <dependencies>
    <dependency>
       <role>org.apache.avalon.cornerstone.services.scheduler.TimeScheduler</role>
       <service name="org.apache.avalon.cornerstone.services.scheduler.TimeScheduler"
                version="1.0"/>
    </dependency>
  </dependencies>

</blockinfo>
        

assembly.xml


  <block class="org.media.datastore.scheduler.StoreScheduler" name="schedulestore">
         <provide name="scheduler"
                  role="org.apache.avalon.cornerstone.services.scheduler.TimeScheduler"/>
  </block>
        

The important thing in configuration is the conversion of the crontables. The cornerstone scheduler uses a special self-format. Datastore uses the Unix like crontab. The Unix systems crontab format was need to be converted to a format named cornerstone crontable.

top

2.4. StoreScheduler targets

Each class can be a target of StoreScheduler, for this you need:

In the Datastore we have only a single target named LexiconManager. You can see there the whole implementation of the target.

top


© 2001