*/
public StoredClassCatalog(Database database)
throws DatabaseException, IllegalArgumentException {
db = database;
DatabaseConfig dbConfig = db.getConfig();
EnvironmentConfig envConfig = db.getEnvironment().getConfig();
writeLockMode = (DbCompat.getInitializeLocking(envConfig) ||
envConfig.getTransactional()) ? LockMode.RMW
: LockMode.DEFAULT;
cdbMode = DbCompat.getInitializeCDB(envConfig);
txnMode = dbConfig.getTransactional();
if (!DbCompat.isTypeBtree(dbConfig)) {
throw new IllegalArgumentException
("The class catalog must be a BTREE database.");
}
if (DbCompat.getSortedDuplicates(dbConfig) ||
DbCompat.getUnsortedDuplicates(dbConfig)) {
throw new IllegalArgumentException
("The class catalog database must not allow duplicates.");
}
/*
* Create the class format and class info maps. Note that these are not
* synchronized, and therefore the methods that use them are
* synchronized.
*/
classMap = new HashMap<String, ClassInfo>();
formatMap = new HashMap<BigInteger, ObjectStreamClass>();
DatabaseEntry key = new DatabaseEntry(LAST_CLASS_ID_KEY);
DatabaseEntry data = new DatabaseEntry();
if (dbConfig.getReadOnly()) {
/* Check that the class ID record exists. */
OperationStatus status = db.get(null, key, data, null);
if (status != OperationStatus.SUCCESS) {
throw DbCompat.unexpectedState
("A read-only catalog database may not be empty");