net.obsearch.ambient
Class AbstractAmbient<O extends OB,I extends Index<O>>

java.lang.Object
  extended by net.obsearch.ambient.AbstractAmbient<O,I>
Type Parameters:
I - The index that we want to create with this ambient.
All Implemented Interfaces:
Ambient<O,I>
Direct Known Subclasses:
AmbientBDBJe, AmbientTC

public abstract class AbstractAmbient<O extends OB,I extends Index<O>>
extends Object
implements Ambient<O,I>

An Ambient is the class that surrounds the index, its metadata and the storage devices. It helps to serialize the index and put the serialized data in an appropiate location. This is how you use an ambient: 1) Create the Index you want to use. 2) Create the Ambient that holds the storage device you want to use and pass the Index to it. 3) Forget about the Ambient, when you want to freeze the index, use the Ambient to freeze the index so that metadata is stored properly. 4) When you have closed the index and you want to use it back again, call the ambient and it will de-serialize the index and leave it ready for you to use it. Sub-classes of this class, create ambients for different storage devices.

Author:
Arnoldo Jose Muller Molina

Field Summary
protected  OBStoreFactory fact
          Factory that creates storage devices for the index.
 
Fields inherited from interface net.obsearch.ambient.Ambient
METADATA_FILENAME
 
Constructor Summary
protected AbstractAmbient(File directory)
          Constructor to be used after a freeze took place.
protected AbstractAmbient(I index, File directory)
           
 
Method Summary
 void close()
          Close all the internally used resources.
protected abstract  OBStoreFactory createFactory(File factoryDirectory)
          Creates the factory in the given folder.
 void freeze()
          Freezes the index and stores the metadata of the index (the index itself) in the DB.
 OBStoreFactory getFactory()
          Returns the factory (if the user wants to create some storages for personal use).
 I getIndex()
          Returns the index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fact

protected OBStoreFactory fact
Factory that creates storage devices for the index.

Constructor Detail

AbstractAmbient

protected AbstractAmbient(I index,
                          File directory)
                   throws AlreadyFrozenException,
                          FileNotFoundException,
                          OBStorageException,
                          NotFrozenException,
                          IllegalAccessException,
                          InstantiationException,
                          OBException,
                          IOException
Parameters:
index - An index whose isFrozen() == false.
directory - The directory in which everything will be stored.
Throws:
AlreadyFrozenException - if the given index is already frozen.
FileNotFoundException
OBStorageException
NotFrozenException
IllegalAccessException
InstantiationException
OBException
IOException

AbstractAmbient

protected AbstractAmbient(File directory)
                   throws FileNotFoundException,
                          OBStorageException,
                          NotFrozenException,
                          IllegalAccessException,
                          InstantiationException,
                          OBException,
                          IOException
Constructor to be used after a freeze took place.

Parameters:
directory - We will load the database from here.
Throws:
FileNotFoundException - if no metadata is found
OBStorageException
NotFrozenException
IllegalAccessException
InstantiationException
OBException
IOException
Method Detail

close

public void close()
           throws OBException
Description copied from interface: Ambient
Close all the internally used resources.

Specified by:
close in interface Ambient<O extends OB,I extends Index<O>>
Throws:
OBException

getIndex

public I getIndex()
Description copied from interface: Ambient
Returns the index.

Specified by:
getIndex in interface Ambient<O extends OB,I extends Index<O>>
Returns:
the index.

freeze

public void freeze()
            throws IOException,
                   AlreadyFrozenException,
                   IllegalIdException,
                   IllegalAccessException,
                   InstantiationException,
                   OBStorageException,
                   OutOfRangeException,
                   OBException,
                   PivotsUnavailableException
Description copied from interface: Ambient
Freezes the index and stores the metadata of the index (the index itself) in the DB.

Specified by:
freeze in interface Ambient<O extends OB,I extends Index<O>>
Throws:
PivotsUnavailableException
IOException
AlreadyFrozenException
IllegalIdException
IllegalAccessException
InstantiationException
OBStorageException
OutOfRangeException
OBException
See Also:
Index.freeze()

createFactory

protected abstract OBStoreFactory createFactory(File factoryDirectory)
                                         throws OBStorageException
Creates the factory in the given folder.

Parameters:
factoryDirectory - The location where the factory will work.
Returns:
The factory ready to work!
Throws:
OBStorageException - if something goes wrong with the DB.

getFactory

public OBStoreFactory getFactory()
Description copied from interface: Ambient
Returns the factory (if the user wants to create some storages for personal use).

Specified by:
getFactory in interface Ambient<O extends OB,I extends Index<O>>
Returns:
The factory used to create storage devices.


Copyright © 2007-2011 Arnoldo Jose Muller Molina. All Rights Reserved.