ozone API

org.ozoneDB
Class CurrentDatabase

java.lang.Object
  extended byorg.ozoneDB.CurrentDatabase

public class CurrentDatabase
extends java.lang.Object

A method for maintaining an implicit reference to the current database

Author:
Xuân Baldauf,Medium.net

Method Summary
static OzoneInterface get()
          Returns a reference to the current database.
static void register(OzoneInterface newCurrentDatabase)
          Registers a new current database.
static void unregister()
          Unregisters the current database.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

register

public static void register(OzoneInterface newCurrentDatabase)
Registers a new current database. Every call to this method must be matched by a call to unregister(). Thus, the usage should be as following:
          CurrentDatabase.register(database);

            try {
                ... do something useful ...
            } finally {
                CurrentDatabase.unregister();
            }
        
Registering current databases may be nested. If already a current database is registered, registering a new one hides the old one until unregister() is called.
Registered current databases only apply to the current thread. Each thread has to register its current database separately.


unregister

public static void unregister()
Unregisters the current database. The database which was current before the matching call to register(org.ozoneDB.OzoneInterface) will be the new current database.


get

public static OzoneInterface get()
                          throws java.lang.IllegalStateException
Returns a reference to the current database.

Returns:
a reference to the current database
Throws:
java.lang.IllegalStateException - If no current database is set.

ozone API

Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.