blob: 73b45eb5b047d1f12b6a22ab219f4f1948d7d8d5 [file] [log] [blame]
/*-
* Copyright (C) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
*
* This file was distributed by Oracle as part of a version of Oracle Berkeley
* DB Java Edition made available at:
*
* http://www.oracle.com/technetwork/database/database-technologies/berkeleydb/downloads/index.html
*
* Please see the LICENSE file included in the top-level directory of the
* appropriate version of Oracle Berkeley DB Java Edition for a copy of the
* license and additional information.
*/
package com.sleepycat.persist.impl;
import java.util.Set;
import com.sleepycat.persist.model.ClassMetadata;
import com.sleepycat.persist.model.EntityMetadata;
import com.sleepycat.persist.model.EntityModel;
/**
* The EntityModel used when a RawStore is opened. The metadata and raw type
* information comes from the catalog directly, without using the current
* class definitions.
*
* @author Mark Hayes
*/
class StoredModel extends EntityModel {
private volatile PersistCatalog catalog;
private volatile Set<String> knownClasses;
StoredModel(final PersistCatalog catalog) {
this.catalog = catalog;
}
/**
* This method is used to initialize the model when catalog creation is
* complete, and reinitialize it when a Replica refresh occurs.
*/
@Override
protected void setCatalog(final PersistCatalog newCatalog) {
super.setCatalog(newCatalog);
this.catalog = newCatalog;
knownClasses = newCatalog.getModelClasses();
}
@Override
public ClassMetadata getClassMetadata(String className) {
ClassMetadata metadata = null;
Format format = catalog.getFormat(className);
if (format != null && format.isCurrentVersion()) {
metadata = format.getClassMetadata();
}
return metadata;
}
@Override
public EntityMetadata getEntityMetadata(String className) {
EntityMetadata metadata = null;
Format format = catalog.getFormat(className);
if (format != null && format.isCurrentVersion()) {
metadata = format.getEntityMetadata();
}
return metadata;
}
@Override
public Set<String> getKnownClasses() {
return knownClasses;
}
}