Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


com.tangosol.io.bdb
Class DatabaseFactory

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.io.bdb.DatabaseFactory


public class DatabaseFactory
extends Base

Factory for Berkeley DB Environments and Databases.

Temporary Environments will be automatically deleted upon JVM shutdown or GC.

Author:
mf 2005.10.04

Nested Class Summary
protected static class DatabaseFactory.EnvironmentHolder
          Holder for Berkeley DB Environment and its Databases.

 

Field Summary
protected  long m_cDbId
          Counter used to generate unique Database names for this Environment.
protected  com.sleepycat.je.DatabaseConfig m_dbConfig
          Configuration to use when creating new Databases.
protected  DatabaseFactory.EnvironmentHolder m_envHolder
          Holder for Environment used to create Databases.

 

Constructor Summary
DatabaseFactory(BerkeleyDBBinaryStoreManager bdbManager)
          Construct a DatabaseFactory for a given Berkeley DB Environment.

 

Method Summary
 com.sleepycat.je.Database createNamedDatabase(java.lang.String sName)
          Create a named Database instance.
protected  void finalize()
          Finalize for the DatabaseFactory.
 void forgetDatabase(com.sleepycat.je.Database db)
          Remove a database handle from the cleanup list.
 com.sleepycat.je.DatabaseConfig getDbConfig()
          Get the DatabaseConfiguration used to create Databases.
 long getDbIdCounter()
          Get the DB ID Counter value.
 DatabaseFactory.EnvironmentHolder getEnvHolder()
          Get the EnvironmentHolder.
 java.lang.String getUniqueDbName()
          Get a unique (within the Factory) database name.
protected  DatabaseFactory.EnvironmentHolder instantiateEnvironment(BerkeleyDBBinaryStoreManager bdbManager)
          Create a EnvironmentHolder within the specified parent directory.
 java.lang.String toString()
          Output the DatabaseFactory state as a String.

 

Field Detail

m_envHolder

protected DatabaseFactory.EnvironmentHolder m_envHolder
Holder for Environment used to create Databases.

m_dbConfig

protected com.sleepycat.je.DatabaseConfig m_dbConfig
Configuration to use when creating new Databases.

m_cDbId

protected long m_cDbId
Counter used to generate unique Database names for this Environment.

Constructor Detail

DatabaseFactory

public DatabaseFactory(BerkeleyDBBinaryStoreManager bdbManager)
                throws com.sleepycat.je.DatabaseException
Construct a DatabaseFactory for a given Berkeley DB Environment.

Berkeley DB Environments are bound to a single directory. Java File locking is used to ensure that only one JVM uses the Environment.

Parameters:
bdbManager - the BinaryStoreManager to create Databases for
Throws:
com.sleepycat.je.DatabaseException - if the Berkeley DB Environment could not be created
See Also:
Berkeley DB Configuration

Method Detail

toString

public java.lang.String toString()
Output the DatabaseFactory state as a String.

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalize for the DatabaseFactory.

When the factory is finalized it will force the EnvironmentHolder to be destroyed if it is temporary, and deregister the associated shutdown hook.

Throws:
java.lang.Throwable

createNamedDatabase

public com.sleepycat.je.Database createNamedDatabase(java.lang.String sName)
                                              throws com.sleepycat.je.DatabaseException
Create a named Database instance.
Parameters:
sName - the name of the database to create
Returns:
new a Database instance
Throws:
com.sleepycat.je.DatabaseException - if the Database creation failed

getUniqueDbName

public java.lang.String getUniqueDbName()
Get a unique (within the Factory) database name.
Returns:
a unique database name

instantiateEnvironment

protected DatabaseFactory.EnvironmentHolder instantiateEnvironment(BerkeleyDBBinaryStoreManager bdbManager)
                                                            throws com.sleepycat.je.DatabaseException
Create a EnvironmentHolder within the specified parent directory.
Parameters:
bdbManager - the BinaryStore to create the environment for
Returns:
a new EnvironmentHolder
Throws:
com.sleepycat.je.DatabaseException - if the Environment could not be created

forgetDatabase

public void forgetDatabase(com.sleepycat.je.Database db)
Remove a database handle from the cleanup list.
Parameters:
db - the Database to remove from list

getEnvHolder

public DatabaseFactory.EnvironmentHolder getEnvHolder()
Get the EnvironmentHolder.
Returns:
the EnvironmentHolder

getDbConfig

public com.sleepycat.je.DatabaseConfig getDbConfig()
Get the DatabaseConfiguration used to create Databases.
Returns:
the DatabaseConfiguration

getDbIdCounter

public long getDbIdCounter()
Get the DB ID Counter value.
Returns:
the DB ID Counter value

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.