com.j_spaces.sadapter.GenericPA
Interface IBasicPersistence


public interface IBasicPersistence

This interface is a mandatory interface that must be implemented by any persistent adapter. It contains the basic methods required for correct space operation


Method Summary
 void closeContext(PersistentContext context)
          This method called whenever a context is about to be closed.
 void createClassTable(PersistentContext context, String className, String[] fieldNames, String[] fieldTypes, String uidFieldName, String uidFieldNameType, boolean[] indexIndicators, boolean isFifoSupported)
          This method called when the space engine creates new metadata class/table in the persistent storage.
 void createIndex(PersistentContext context, String className, String fieldType, int fieldPosition)
          This method called when the space engine create index in persistent storage for specified table column/class attribute.
 int delete(PersistentContext context, String className, Object UID)
          This method called when the engine removes an the entry from persistent storage.
 void dropClassTable(PersistentContext context, String className)
          This method called when the space engine removes table/metadata class from the persistent storage.
 void dropIndex(PersistentContext context, String className, String indexName)
          This method called when the space engine remove index from persistent storage.
 void flush(PersistentContext context)
          This method called when the space engine instruct the persistent store to flush its cache into the disk.
 int getCount(PersistentContext context, String className)
          This method called when the space engine retrieve class instance count.
 Iterator getEntries(PersistentContext context, String className, Object[] uids)
          This method called when the space engine searches for multiple entries using array of UID's and className in the persistent storage.
 PersistentEntry getEntry(PersistentContext context, String className, Object uid)
          This method called when the space engine search for entry using UID and class name in the persistent storage.
 void init(String url, String user, String password, boolean isColdMode, Properties properties)
          This method called when the persistent adapter initializes, information kept per-connection.
 void initContext(PersistentContext context)
          This method is called whenever a new context is created.
 void insert(PersistentContext context, PersistentEntry entry)
          This method called whenever the space engine store an the entry in the persistent storage.
 void shutDown()
          This method called when the space engine shut down the persistent storage.
 void update(PersistentContext context, PersistentEntry entry)
          This method called the the space engine updates the entry in persistent storage.
 

Method Detail

init

void init(String url,
          String user,
          String password,
          boolean isColdMode,
          Properties properties)
          throws SAException
This method called when the persistent adapter initializes, information kept per-connection.

Parameters:
url - The URL string of the datastore connection
user - The datastore user login
password - The datastore user password
isColdMode - If true the datastore should remove all internal tables/classes.
properties - persistent adapter properties as defined in the <persistent> element in the space configuration
Throws:
SAException - in case a persistent adapter error occurred

initContext

void initContext(PersistentContext context)
                 throws SAException
This method is called whenever a new context is created. This method should be used mainly by the SA implementation in order to retrieve new connection from some internal connection pool

Parameters:
context - new context
Throws:
SAException - in case a persistent adapter error occurred

closeContext

void closeContext(PersistentContext context)
                  throws SAException
This method called whenever a context is about to be closed.

Parameters:
context - closed context
Throws:
SAException - in case a persistent adapter error occurred

insert

void insert(PersistentContext context,
            PersistentEntry entry)
            throws SAException
This method called whenever the space engine store an the entry in the persistent storage.

Parameters:
context - Persistent implementation context
entry - The entry to be stored
Throws:
SAException - in case a persistent adapter error occurred

delete

int delete(PersistentContext context,
           String className,
           Object UID)
           throws SAException
This method called when the engine removes an the entry from persistent storage.

Parameters:
context - Persistent implementation context
className - The class name of the entry that is about to be removed from persistent store
UID - The entry unique id that is about to removed from persistent store
Returns:
the number of entries removed
Throws:
SAException - in case a persistent adapter error occurred

update

void update(PersistentContext context,
            PersistentEntry entry)
            throws SAException
This method called the the space engine updates the entry in persistent storage.

Parameters:
context - Persistent implementation context
entry - The entry that is about to be updated in persistent store The PersistentEntry object should include all object values.
Throws:
SAException - in case a persistent adapter error occurred

createClassTable

void createClassTable(PersistentContext context,
                      String className,
                      String[] fieldNames,
                      String[] fieldTypes,
                      String uidFieldName,
                      String uidFieldNameType,
                      boolean[] indexIndicators,
                      boolean isFifoSupported)
                      throws SAException
This method called when the space engine creates new metadata class/table in the persistent storage.

Parameters:
context - Persistent implementation context
className - The name of the table/metadata class that should be created
fieldNames - The names of the tables fields/metadata class attributes NOTE: the last field is the fields names array is the unique ID (UID) field of the entry.
fieldTypes - The types of the fields. These are represented using Java types � i.e. "java.lang.Integer , java.lang.String �etc.
uidFieldName - name of the UID (unique id) field. This is relevant for implementations that supports indexing � in this case the UID should be the primary key
uidFieldNameType - name of the UID type (unique id) field.
indexIndicators - If indicator element is true the corresponding field should be indexed (relevant only when the implementation supports indexing)
isFifoSupported - If the IQueryablePersistent interface is implemented, the table/class should support selectEntries with FIFO parameter=true
Throws:
SAException - in case a persistent adapter error occurred

dropClassTable

void dropClassTable(PersistentContext context,
                    String className)
                    throws SAException
This method called when the space engine removes table/metadata class from the persistent storage.

Parameters:
context - Persistent implementation context
className - The name of the table/metadata class that should be dropped
Throws:
SAException - in case a persistent adapter error occurred

getEntries

Iterator getEntries(PersistentContext context,
                    String className,
                    Object[] uids)
                    throws SAException
This method called when the space engine searches for multiple entries using array of UID's and className in the persistent storage.

Parameters:
context - Persistent implementation context
className - The entries class name to lookup
uids - The array of entries UID's to lookup ,if this parameter is null - all entries with this class name will be returned
Returns:
an iterator over the provided UIDs' entries
Throws:
SAException - in case a persistent adapter error occurred

getEntry

PersistentEntry getEntry(PersistentContext context,
                         String className,
                         Object uid)
                         throws SAException
This method called when the space engine search for entry using UID and class name in the persistent storage.

Parameters:
context - Persistent implementation context
className - The class name of the entry that should be selected
uid - The unique id (UID) of the entry to be selected
Returns:
the entry that matched the provided UID, otherwise null
Throws:
SAException - in case a persistent adapter error occurred

shutDown

void shutDown()
              throws SAException
This method called when the space engine shut down the persistent storage.

Throws:
SAException - in case a persistent adapter error occurred

createIndex

void createIndex(PersistentContext context,
                 String className,
                 String fieldType,
                 int fieldPosition)
                 throws SAException
This method called when the space engine create index in persistent storage for specified table column/class attribute.

Parameters:
context - Persistent implementation context
className - The name of the table/metadata class name
fieldType - The name of the index to create
fieldPosition - The field order at the table/metadata class
Throws:
SAException - in case a persistent adapter error occurred

dropIndex

void dropIndex(PersistentContext context,
               String className,
               String indexName)
               throws SAException
This method called when the space engine remove index from persistent storage.

Parameters:
context - Persistent implementation context
className - The name of the table/metadata class
indexName - The name of the index to be dropped
Throws:
SAException - in case a persistent adapter error occurred

flush

void flush(PersistentContext context)
           throws SAException
This method called when the space engine instruct the persistent store to flush its cache into the disk.

Parameters:
context - Persistent implementation context
Throws:
SAException - in case a persistent adapter error occurred

getCount

int getCount(PersistentContext context,
             String className)
             throws SAException
This method called when the space engine retrieve class instance count.

Parameters:
context - Persistent implementation context
className - The name of the class (and subclasses) for which instance count should be returned
Returns:
class instance count
Throws:
SAException - in case a persistent adapter error occurred