org.netbeans.mdr.persistence
Interface Storage

All Known Implementing Classes:
BtreeStorage

public interface Storage

Set of indexes (Singlevalued and Multivalued) that are all updated in a single transaction. Every index holds keys and every key in the index is connected with a value or an ordered/unordered values. The type of objects that can be stored in the index is resticted by the Storage.Entrytype.

Version:
1.0
Author:
Pavel Buzek

Nested Class Summary
static class Storage.EntryType
          Type of values and keys stored in index.
 
Method Summary
 void close()
           
 void commitChanges()
          Save all objects changed since this method was last call.
 void create(boolean replace, ObjectResolver resolver)
           
 MultivaluedIndex createMultivaluedIndex(java.lang.String name, Storage.EntryType keyType, Storage.EntryType valueType, boolean unique)
          Create index that hold a set of values for each key.
 MultivaluedOrderedIndex createMultivaluedOrderedIndex(java.lang.String name, Storage.EntryType keyType, Storage.EntryType valueType, boolean unique)
          Create index that holds sorted set of values for each key.
 SinglevaluedIndex createSinglevaluedIndex(java.lang.String name, Storage.EntryType keyType, Storage.EntryType valueType)
          Create index that holds exactly one value for each key.
 boolean delete()
          Delete any persistent resources associated with the Storage.
 void dropIndex(java.lang.String name)
          Delete index.
 boolean exists()
           
 Index getIndex(java.lang.String name)
          Retrieve index by name.
 MultivaluedIndex getMultivaluedIndex(java.lang.String name)
          Retrieve index by name.
 MultivaluedOrderedIndex getMultivaluedOrderedIndex(java.lang.String name)
          Retrieve index by name.
 java.lang.String getName()
           
 SinglevaluedIndex getPrimaryIndex()
          Returns the primary index in this Storage.
 long getSerialNumber()
           
 SinglevaluedIndex getSinglevaluedIndex(java.lang.String name)
          Retrieve index by name.
 java.lang.String getStorageId()
           
 void objectStateChanged(java.lang.Object key)
          Notify the Storage that state of the object associated with this key was changed.
 void objectStateWillChange(java.lang.Object key)
          Notify the Storage that state of the object associated with this key will be changed.
 void open(boolean createOnNoExist, ObjectResolver resolver)
           
 MOFID readMOFID(java.io.InputStream inputStream)
          Reads a MOFID from Storage, must be called in the streamable read context.
 void rollBackChanges()
          Discard all changes since commitChanges() method was last call.
 void shutDown()
          Performs operations needed on exit.
 void writeMOFID(java.io.OutputStream outputStream, MOFID mofid)
          Writes a MOFID into Storage, must be called in the streamable write context.
 

Method Detail

getName

java.lang.String getName()

getStorageId

java.lang.String getStorageId()

getSerialNumber

long getSerialNumber()

readMOFID

MOFID readMOFID(java.io.InputStream inputStream)
                throws StorageException
Reads a MOFID from Storage, must be called in the streamable read context.

Returns:
MOFID red object
Throws:
StorageException

writeMOFID

void writeMOFID(java.io.OutputStream outputStream,
                MOFID mofid)
                throws StorageException
Writes a MOFID into Storage, must be called in the streamable write context.

Parameters:
MOFID - mofid, object to be written
Throws:
StorageException

getPrimaryIndex

SinglevaluedIndex getPrimaryIndex()
                                  throws StorageException
Returns the primary index in this Storage. There is exactly one primary index in every storage, primary index has valueType STREAMABLE.

Throws:
StorageException

exists

boolean exists()
               throws StorageException
Throws:
StorageException

delete

boolean delete()
               throws StorageException
Delete any persistent resources associated with the Storage.

Returns:
true if and only if the Storage is succesfully deleted, false otherwise
Throws:
StorageException

create

void create(boolean replace,
            ObjectResolver resolver)
            throws StorageException
Throws:
StorageException

open

void open(boolean createOnNoExist,
          ObjectResolver resolver)
          throws StorageException
Throws:
StorageException

close

void close()
           throws StorageException
Throws:
StorageException

createSinglevaluedIndex

SinglevaluedIndex createSinglevaluedIndex(java.lang.String name,
                                          Storage.EntryType keyType,
                                          Storage.EntryType valueType)
                                          throws StorageException
Create index that holds exactly one value for each key.

Parameters:
name - name of the index
keyType - type of keys in the index
valueType - type of values in the index (any type except STREAMABLE)
Returns:
created index
Throws:
StorageException

createMultivaluedOrderedIndex

MultivaluedOrderedIndex createMultivaluedOrderedIndex(java.lang.String name,
                                                      Storage.EntryType keyType,
                                                      Storage.EntryType valueType,
                                                      boolean unique)
                                                      throws StorageException
Create index that holds sorted set of values for each key.

Parameters:
name - name of the index
keyType - type of keys in the index
valueType - type of values in the index (any type except STREAMABLE)
unique - true if values associated with one key do not contain duplicates
Returns:
created index
Throws:
StorageException

createMultivaluedIndex

MultivaluedIndex createMultivaluedIndex(java.lang.String name,
                                        Storage.EntryType keyType,
                                        Storage.EntryType valueType,
                                        boolean unique)
                                        throws StorageException
Create index that hold a set of values for each key. Elements in one Multivalued are not sorted. Set does not contain duplicate values.

Parameters:
name - name of the index
keyType - type of keys in the index
valueType - type of values in the index (any type except STREAMABLE)
unique - true if values associated with one key do not contain duplicates
Returns:
created index
Throws:
StorageException

getIndex

Index getIndex(java.lang.String name)
               throws StorageException
Retrieve index by name.

Parameters:
name - name of the index
Returns:
index of the specified name
Throws:
StorageException

getSinglevaluedIndex

SinglevaluedIndex getSinglevaluedIndex(java.lang.String name)
                                       throws StorageException
Retrieve index by name.

Parameters:
name - name of the index
Returns:
index of the specified name and type
Throws:
StorageException

getMultivaluedIndex

MultivaluedIndex getMultivaluedIndex(java.lang.String name)
                                     throws StorageException
Retrieve index by name.

Parameters:
name - name of the index
Returns:
index of the specified name and type
Throws:
StorageException

getMultivaluedOrderedIndex

MultivaluedOrderedIndex getMultivaluedOrderedIndex(java.lang.String name)
                                                   throws StorageException
Retrieve index by name.

Parameters:
name - name of the index
Returns:
index of the specified name and type
Throws:
StorageException

dropIndex

void dropIndex(java.lang.String name)
               throws StorageException
Delete index.

Parameters:
name - name of the index
Throws:
StorageException

objectStateWillChange

void objectStateWillChange(java.lang.Object key)
                           throws StorageException
Notify the Storage that state of the object associated with this key will be changed. This must be called before the change. Storage can use this notification to handle information needed to perform rollback. Note that the notification does not imply object change will perform necessary (the planned change can be canceled), however every performed change (notified by objectStateChanged(java.lang.Object)) is supposed to be precedesed by this notification.

Parameters:
key - key of the object that will be changed
Throws:
StorageException

objectStateChanged

void objectStateChanged(java.lang.Object key)
                        throws StorageException
Notify the Storage that state of the object associated with this key was changed. This must be called after the change is made to ensure that the changed state is comitted correctly.

Parameters:
key - key of the object that was changed and must be saved
Throws:
StorageException

commitChanges

void commitChanges()
                   throws StorageException
Save all objects changed since this method was last call. This operation implements transactions on the storage. It must either whole complete or whole fail.

Throws:
StorageException

rollBackChanges

void rollBackChanges()
                     throws StorageException
Discard all changes since commitChanges() method was last call. This operation implements transactions on the storage. It must either whole complete or whole fail. Note that, after this method completes, the persistent MDR and any modified objects in memory are inconsistent, so it should be followed shortly by program exit.

Throws:
StorageException

shutDown

void shutDown()
              throws StorageException
Performs operations needed on exit.

Throws:
StorageException


Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.