summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-01-06 13:08:36 (EST)
committerEike Stepper2008-01-06 13:08:36 (EST)
commitc083fd0be1b273d6088d981db8ccd6cd33d36894 (patch)
tree41b6f3cda4d626007ce0cdc872d405d7ec5e17b8
parentcccfcaf5b8ce5a6b8b5d8853c93e46bc6fbe8d75 (diff)
downloadcdo-c083fd0be1b273d6088d981db8ccd6cd33d36894.zip
cdo-c083fd0be1b273d6088d981db8ccd6cd33d36894.tar.gz
cdo-c083fd0be1b273d6088d981db8ccd6cd33d36894.tar.bz2
[214437] Provide efficient type lookup service in storage framework
https://bugs.eclipse.org/bugs/show_bug.cgi?id=214437
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeCache.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeLookup.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java417
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java290
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java213
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreChunkReader.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreChunkReader.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreChunkReader.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreChunkReader.java2
20 files changed, 595 insertions, 493 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeCache.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeCache.java
index c28ede8..6166f5a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeCache.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeCache.java
@@ -18,5 +18,5 @@ import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
*/
public interface IObjectTypeCache extends IObjectTypeLookup
{
- public void putObjectType(CDOID id, CDOClassRef type);
+ public void putObjectType(IDBStoreWriter storeWriter, CDOID id, CDOClassRef type);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeLookup.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeLookup.java
index dc2ae7d..4e04c7a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeLookup.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IObjectTypeLookup.java
@@ -18,5 +18,5 @@ import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
*/
public interface IObjectTypeLookup
{
- public CDOClassRef getObjectType(CDOID id);
+ public CDOClassRef getObjectType(IDBStoreReader storeReader, CDOID id);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java
index ee71b0a..bc26fcd 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IReferenceMapping.java
@@ -26,7 +26,7 @@ public interface IReferenceMapping extends IFeatureMapping
public void writeReference(IDBStoreAccessor storeAccessor, CDORevisionImpl revision);
- public void readReference(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, int referenceChunk);
+ public void readReference(IDBStoreReader storeReader, CDORevisionImpl revision, int referenceChunk);
public void readChunks(IDBStoreChunkReader chunkReader, List<Chunk> chunks, String string);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
index 2d3d5ca..ed4fb41 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.server.db.IAttributeMapping;
import org.eclipse.emf.cdo.server.db.IClassMapping;
import org.eclipse.emf.cdo.server.db.IDBStore;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
+import org.eclipse.emf.cdo.server.db.IDBStoreReader;
import org.eclipse.emf.cdo.server.db.IReferenceMapping;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
@@ -499,13 +500,13 @@ public abstract class ClassMapping implements IClassMapping
}
}
- public void readRevision(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, int referenceChunk)
+ public void readRevision(IDBStoreReader storeReader, CDORevisionImpl revision, int referenceChunk)
{
String where = CDODBSchema.ATTRIBUTES_REVISED + "=0";
- readRevision(storeAccessor, revision, where, true, referenceChunk);
+ readRevision(storeReader, revision, where, true, referenceChunk);
}
- public void readRevisionByTime(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, long timeStamp,
+ public void readRevisionByTime(IDBStoreReader storeReader, CDORevisionImpl revision, long timeStamp,
int referenceChunk)
{
StringBuilder where = new StringBuilder();
@@ -519,32 +520,31 @@ public abstract class ClassMapping implements IClassMapping
where.append(timeStamp);
where.append(">=");
where.append(CDODBSchema.ATTRIBUTES_CREATED);
- readRevision(storeAccessor, revision, where.toString(), true, referenceChunk);
+ readRevision(storeReader, revision, where.toString(), true, referenceChunk);
}
- public void readRevisionByVersion(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, int version,
+ public void readRevisionByVersion(IDBStoreReader storeReader, CDORevisionImpl revision, int version,
int referenceChunk)
{
String where = CDODBSchema.ATTRIBUTES_VERSION + "=" + version;
- readRevision(storeAccessor, revision, where, false, referenceChunk);
+ readRevision(storeReader, revision, where, false, referenceChunk);
}
- protected void readRevision(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, String where,
- boolean readVersion, int referenceChunk)
+ protected void readRevision(IDBStoreReader storeReader, CDORevisionImpl revision, String where, boolean readVersion,
+ int referenceChunk)
{
if (attributeMappings != null)
{
- readAttributes(storeAccessor, revision, where, readVersion);
+ readAttributes(storeReader, revision, where, readVersion);
}
if (referenceMappings != null)
{
- readReferences(storeAccessor, revision, referenceChunk);
+ readReferences(storeReader, revision, referenceChunk);
}
}
- protected void readAttributes(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, String where,
- boolean readVersion)
+ protected void readAttributes(IDBStoreReader storeReader, CDORevisionImpl revision, String where, boolean readVersion)
{
long id = revision.getID().getValue();
StringBuilder builder = new StringBuilder(readVersion ? selectPrefixWithVersion : selectPrefix);
@@ -561,7 +561,7 @@ public abstract class ClassMapping implements IClassMapping
try
{
- resultSet = storeAccessor.getStatement().executeQuery(sql);
+ resultSet = storeReader.getStatement().executeQuery(sql);
if (!resultSet.next())
{
throw new IllegalStateException("Revision not found: " + id);
@@ -600,11 +600,11 @@ public abstract class ClassMapping implements IClassMapping
}
}
- protected void readReferences(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, int referenceChunk)
+ protected void readReferences(IDBStoreReader storeReader, CDORevisionImpl revision, int referenceChunk)
{
for (IReferenceMapping referenceMapping : referenceMappings)
{
- referenceMapping.readReference(storeAccessor, revision, referenceChunk);
+ referenceMapping.readReference(storeReader, revision, referenceChunk);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index 9955b88..a3dc368 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -109,14 +109,14 @@ public class DBStore extends Store implements IDBStore
return false;
}
- public DBStoreAccessor getReader(ISession session) throws DBException
+ public DBStoreReader getReader(ISession session) throws DBException
{
- return new DBStoreAccessor(this, session);
+ return new DBStoreReader(this, session);
}
- public DBStoreAccessor getWriter(IView view) throws DBException
+ public DBStoreWriter getWriter(IView view) throws DBException
{
- return new DBStoreAccessor(this, view);
+ return new DBStoreWriter(this, view);
}
public int getNextPackageID()
@@ -265,7 +265,7 @@ public class DBStore extends Store implements IDBStore
public void repairAfterCrash()
{
Repository repository = (Repository)getRepository();
- DBStoreAccessor storeReader = getReader(null);
+ DBStoreReader storeReader = getReader(null);
StoreUtil.setReader(storeReader);
try
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index 8c6efa7..57f838b 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -10,48 +10,22 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db;
-import org.eclipse.emf.cdo.internal.protocol.CDOIDRangeImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassProxy;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOTypeImpl;
-import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.internal.server.StoreAccessor;
-import org.eclipse.emf.cdo.protocol.CDOID;
-import org.eclipse.emf.cdo.protocol.CDOIDRange;
-import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
-import org.eclipse.emf.cdo.protocol.model.CDOFeature;
-import org.eclipse.emf.cdo.protocol.model.CDOPackageInfo;
-import org.eclipse.emf.cdo.protocol.model.CDOType;
-import org.eclipse.emf.cdo.protocol.revision.CDORevision;
-import org.eclipse.emf.cdo.server.IPackageManager;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.IRevisionManager;
import org.eclipse.emf.cdo.server.ISession;
-import org.eclipse.emf.cdo.server.IStoreChunkReader;
-import org.eclipse.emf.cdo.server.IStoreWriter;
import org.eclipse.emf.cdo.server.IView;
import org.eclipse.emf.cdo.server.db.IClassMapping;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
-import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBRowHandler;
import org.eclipse.net4j.db.IDBTable;
-import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
-import org.eclipse.net4j.util.io.CloseableIterator;
-import org.eclipse.net4j.util.transaction.ITransaction;
import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -60,19 +34,19 @@ import java.util.Set;
*/
public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DBStoreAccessor.class);
+ // private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DBStoreAccessor.class);
private Connection connection;
private Statement statement;
- public DBStoreAccessor(DBStore store, ISession session) throws DBException
+ protected DBStoreAccessor(DBStore store, ISession session) throws DBException
{
super(store, session);
initConnection();
}
- public DBStoreAccessor(DBStore store, IView view) throws DBException
+ protected DBStoreAccessor(DBStore store, IView view) throws DBException
{
super(store, view);
initConnection();
@@ -94,22 +68,8 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
@Override
public void release() throws DBException
{
- try
- {
- if (!isReader())
- {
- connection.commit();
- }
- }
- catch (SQLException ex)
- {
- throw new DBException(ex);
- }
- finally
- {
- DBUtil.close(statement);
- DBUtil.close(connection);
- }
+ DBUtil.close(statement);
+ DBUtil.close(connection);
}
@Override
@@ -140,365 +100,6 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
return statement;
}
- public IStoreChunkReader createChunkReader(CDORevision revision, CDOFeature feature)
- {
- return new DBStoreChunkReader(this, revision, feature);
- }
-
- public void writePackages(CDOPackageImpl... cdoPackages)
- {
- for (CDOPackageImpl cdoPackage : cdoPackages)
- {
- writePackage(cdoPackage);
- }
-
- Set<IDBTable> affectedTables = mapPackages(cdoPackages);
- getStore().getDBAdapter().createTables(affectedTables, connection);
- }
-
- protected void writePackage(CDOPackageImpl cdoPackage)
- {
- int id = getStore().getNextPackageID();
- PackageServerInfo.setDBID(cdoPackage, id);
- if (TRACER.isEnabled())
- {
- TRACER.format("Inserting package: {0} --> {1}", cdoPackage, id);
- }
-
- String packageURI = cdoPackage.getPackageURI();
- String name = cdoPackage.getName();
- String ecore = cdoPackage.getEcore();
- boolean dynamic = cdoPackage.isDynamic();
- CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
- long lb = metaIDRange == null ? 0L : metaIDRange.getLowerBound().getValue();
- long ub = metaIDRange == null ? 0L : metaIDRange.getUpperBound().getValue();
-
- String sql = "INSERT INTO " + CDODBSchema.PACKAGES + " VALUES (?, ?, ?, ?, ?, ?, ?)";
- DBUtil.trace(sql);
- PreparedStatement pstmt = null;
-
- try
- {
- pstmt = connection.prepareStatement(sql);
- pstmt.setInt(1, id);
- pstmt.setString(2, packageURI);
- pstmt.setString(3, name);
- pstmt.setString(4, ecore);
- pstmt.setBoolean(5, dynamic);
- pstmt.setLong(6, lb);
- pstmt.setLong(7, ub);
-
- if (pstmt.execute())
- {
- throw new DBException("No result set expected");
- }
-
- if (pstmt.getUpdateCount() == 0)
- {
- throw new DBException("No row inserted into table " + CDODBSchema.PACKAGES);
- }
- }
- catch (SQLException ex)
- {
- throw new DBException(ex);
- }
- finally
- {
- DBUtil.close(pstmt);
- }
-
- for (CDOClassImpl cdoClass : cdoPackage.getClasses())
- {
- writeClass(cdoClass);
- }
- }
-
- protected void writeClass(CDOClassImpl cdoClass)
- {
- int id = getStore().getNextClassID();
- ClassServerInfo.setDBID(cdoClass, id);
-
- CDOPackageImpl cdoPackage = cdoClass.getContainingPackage();
- int packageID = ServerInfo.getDBID(cdoPackage);
- int classifierID = cdoClass.getClassifierID();
- String name = cdoClass.getName();
- boolean isAbstract = cdoClass.isAbstract();
- DBUtil.insertRow(connection, getStore().getDBAdapter(), CDODBSchema.CLASSES, id, packageID, classifierID, name,
- isAbstract);
-
- for (CDOClassProxy superType : cdoClass.getSuperTypeProxies())
- {
- writeSuperType(id, superType);
- }
-
- for (CDOFeatureImpl feature : cdoClass.getFeatures())
- {
- writeFeature(feature);
- }
- }
-
- protected void writeSuperType(int type, CDOClassProxy superType)
- {
- String packageURI = superType.getPackageURI();
- int classifierID = superType.getClassifierID();
- DBUtil.insertRow(connection, getStore().getDBAdapter(), CDODBSchema.SUPERTYPES, type, packageURI, classifierID);
- }
-
- protected void writeFeature(CDOFeatureImpl feature)
- {
- int id = getStore().getNextFeatureID();
- FeatureServerInfo.setDBID(feature, id);
-
- int classID = ServerInfo.getDBID(feature.getContainingClass());
- String name = feature.getName();
- int featureID = feature.getFeatureID();
- int type = feature.getType().getTypeID();
- CDOClassProxy reference = feature.getReferenceTypeProxy();
- String packageURI = reference == null ? null : reference.getPackageURI();
- int classifierID = reference == null ? 0 : reference.getClassifierID();
- boolean many = feature.isMany();
- boolean containment = feature.isContainment();
- int idx = feature.getFeatureIndex();
- DBUtil.insertRow(connection, getStore().getDBAdapter(), CDODBSchema.FEATURES, id, classID, featureID, name, type,
- packageURI, classifierID, many, containment, idx);
- }
-
- public Collection<CDOPackageInfo> readPackageInfos()
- {
- final Collection<CDOPackageInfo> result = new ArrayList<CDOPackageInfo>(0);
- IDBRowHandler rowHandler = new IDBRowHandler()
- {
- public boolean handle(int row, final Object... values)
- {
- String packageURI = (String)values[0];
- boolean dynamic = getBoolean(values[1]);
- long rangeLB = (Long)values[2];
- long rangeUB = (Long)values[3];
- CDOIDRange metaIDRange = rangeLB == 0L && rangeUB == 0L ? null : CDOIDRangeImpl.create(rangeLB, rangeUB);
- result.add(new CDOPackageInfo(packageURI, dynamic, metaIDRange));
- return true;
- }
- };
-
- DBUtil.select(connection, rowHandler, CDODBSchema.PACKAGES_URI, CDODBSchema.PACKAGES_DYNAMIC,
- CDODBSchema.PACKAGES_RANGE_LB, CDODBSchema.PACKAGES_RANGE_UB);
- return result;
- }
-
- public void readPackage(final CDOPackageImpl cdoPackage)
- {
- String where = CDODBSchema.PACKAGES_URI.getName() + " = '" + cdoPackage.getPackageURI() + "'";
- Object[] values = DBUtil.select(connection, where, CDODBSchema.PACKAGES_ID, CDODBSchema.PACKAGES_NAME,
- CDODBSchema.PACKAGES_ECORE);
- PackageServerInfo.setDBID(cdoPackage, (Integer)values[0]);
- cdoPackage.setName((String)values[1]);
- cdoPackage.setEcore((String)values[2]);
- readClasses(cdoPackage);
-
- mapPackages(cdoPackage);
- }
-
- protected void readClasses(final CDOPackageImpl cdoPackage)
- {
- IDBRowHandler rowHandler = new IDBRowHandler()
- {
- public boolean handle(int row, Object... values)
- {
- int classID = (Integer)values[0];
- int classifierID = (Integer)values[1];
- String name = (String)values[2];
- boolean isAbstract = getBoolean(values[3]);
- CDOClassImpl cdoClass = new CDOClassImpl(cdoPackage, classifierID, name, isAbstract);
- ClassServerInfo.setDBID(cdoClass, classID);
- cdoPackage.addClass(cdoClass);
- readSuperTypes(cdoClass, classID);
- readFeatures(cdoClass, classID);
- return true;
- }
- };
-
- String where = CDODBSchema.CLASSES_PACKAGE.getName() + "=" + ServerInfo.getDBID(cdoPackage);
- DBUtil.select(connection, rowHandler, where, CDODBSchema.CLASSES_ID, CDODBSchema.CLASSES_CLASSIFIER,
- CDODBSchema.CLASSES_NAME, CDODBSchema.CLASSES_ABSTRACT);
- }
-
- protected void readSuperTypes(final CDOClassImpl cdoClass, int classID)
- {
- IDBRowHandler rowHandler = new IDBRowHandler()
- {
- public boolean handle(int row, Object... values)
- {
- String packageURI = (String)values[0];
- int classifierID = (Integer)values[1];
- cdoClass.addSuperType(new CDOClassRefImpl(packageURI, classifierID));
- return true;
- }
- };
-
- String where = CDODBSchema.SUPERTYPES_TYPE.getName() + "=" + classID;
- DBUtil.select(connection, rowHandler, where, CDODBSchema.SUPERTYPES_SUPERTYPE_PACKAGE,
- CDODBSchema.SUPERTYPES_SUPERTYPE_CLASSIFIER);
- }
-
- protected void readFeatures(final CDOClassImpl cdoClass, int classID)
- {
- IDBRowHandler rowHandler = new IDBRowHandler()
- {
- public boolean handle(int row, Object... values)
- {
- int featureID = (Integer)values[1];
- String name = (String)values[2];
- CDOTypeImpl type = CDOTypeImpl.getType((Integer)values[3]);
- boolean many = getBoolean(values[6]);
-
- CDOFeatureImpl feature;
- if (type == CDOType.OBJECT)
- {
- String packageURI = (String)values[4];
- int classifierID = (Integer)values[5];
- boolean containment = getBoolean(values[7]);
- CDOClassRefImpl classRef = new CDOClassRefImpl(packageURI, classifierID);
- CDOClassProxy referenceType = new CDOClassProxy(classRef, cdoClass.getPackageManager());
- feature = new CDOFeatureImpl(cdoClass, featureID, name, referenceType, many, containment);
- }
- else
- {
- feature = new CDOFeatureImpl(cdoClass, featureID, name, type, many);
- }
-
- FeatureServerInfo.setDBID(feature, (Integer)values[0]);
- cdoClass.addFeature(feature);
- return true;
- }
- };
-
- String where = CDODBSchema.FEATURES_CLASS.getName() + "=" + classID;
- DBUtil.select(connection, rowHandler, where, CDODBSchema.FEATURES_ID, CDODBSchema.FEATURES_FEATURE,
- CDODBSchema.FEATURES_NAME, CDODBSchema.FEATURES_TYPE, CDODBSchema.FEATURES_REFERENCE_PACKAGE,
- CDODBSchema.FEATURES_REFERENCE_CLASSIFIER, CDODBSchema.FEATURES_MANY, CDODBSchema.FEATURES_CONTAINMENT);
- }
-
- public String readPackageURI(int packageID)
- {
- String where = CDODBSchema.PACKAGES_ID.getName() + "=" + packageID;
- Object[] uri = DBUtil.select(connection, where, CDODBSchema.PACKAGES_URI);
- return (String)uri[0];
- }
-
- public CDOClassRef readClassRef(int classID)
- {
- String where = CDODBSchema.CLASSES_ID.getName() + "=" + classID;
- Object[] ids = DBUtil.select(connection, where, CDODBSchema.CLASSES_CLASSIFIER, CDODBSchema.CLASSES_PACKAGE);
- String packageURI = readPackageURI((Integer)ids[1]);
- return new CDOClassRefImpl(packageURI, (Integer)ids[0]);
- }
-
- public void writeRevision(CDORevisionImpl revision)
- {
- if (TRACER.isEnabled()) TRACER.format("Inserting revision: {0}", revision);
- CDOClassImpl cdoClass = revision.getCDOClass();
-
- IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
- IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass);
- mapping.writeRevision(this, revision);
- }
-
- public void rollback(IView view, ITransaction<IStoreWriter> storeTransaction)
- {
- try
- {
- if (TRACER.isEnabled()) TRACER.format("Rolling back transaction: {0}", view);
- connection.rollback();
- }
- catch (SQLException ex)
- {
- throw new DBException(ex);
- }
- }
-
- public CloseableIterator<CDOID> readObjectIDs(boolean withTypes)
- {
- if (TRACER.isEnabled())
- {
- TRACER.trace("Selecting object IDs");
- }
-
- return getStore().getMappingStrategy().readObjectIDs(this, withTypes);
- }
-
- public CDOClassRef readObjectType(CDOID id)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Selecting object type: {0}", id);
- }
-
- return getStore().getMappingStrategy().readObjectType(this, id);
- }
-
- public CDORevision readRevision(CDOID id, int referenceChunk)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Selecting revision: {0}", id);
- }
-
- IRevisionManager revisionManager = getStore().getRepository().getRevisionManager();
- CDOClassImpl cdoClass = getObjectType(id);
- CDORevisionImpl revision = new CDORevisionImpl(revisionManager, cdoClass, id);
-
- IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
- IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass);
- mapping.readRevision(this, revision, referenceChunk);
- return revision;
- }
-
- public CDORevision readRevisionByTime(CDOID id, int referenceChunk, long timeStamp)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Selecting revision: {0}, timestamp={1,date} {1,time}", id, timeStamp);
- }
-
- IRevisionManager revisionManager = getStore().getRepository().getRevisionManager();
- CDOClassImpl cdoClass = getObjectType(id);
- CDORevisionImpl revision = new CDORevisionImpl(revisionManager, cdoClass, id);
-
- IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
- IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass);
- mapping.readRevisionByTime(this, revision, timeStamp, referenceChunk);
- return revision;
- }
-
- public CDORevision readRevisionByVersion(CDOID id, int referenceChunk, int version)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Selecting revision: {0}, version={1}", id, version);
- }
-
- IRevisionManager revisionManager = getStore().getRepository().getRevisionManager();
- CDOClassImpl cdoClass = getObjectType(id);
- CDORevisionImpl revision = new CDORevisionImpl(revisionManager, cdoClass, id);
-
- IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
- IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass);
- mapping.readRevisionByVersion(this, revision, version, referenceChunk);
- return revision;
- }
-
- public CDOID readResourceID(String path)
- {
- IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
- return mappingStrategy.readResourceID(this, path);
- }
-
- public String readResourcePath(CDOID id)
- {
- IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
- return mappingStrategy.readResourcePath(this, id);
- }
-
/**
* TODO Move this somehow to DBAdapter
*/
@@ -522,14 +123,6 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
throw new IllegalArgumentException("Not a boolean value: " + value);
}
- protected CDOClassImpl getObjectType(CDOID id)
- {
- IRepository repository = getStore().getRepository();
- IPackageManager packageManager = repository.getPackageManager();
- CDOClassRef type = readObjectType(id);
- return (CDOClassImpl)type.resolve(packageManager);
- }
-
protected Set<IDBTable> mapPackages(CDOPackageImpl... cdoPackages)
{
Set<IDBTable> affectedTables = new HashSet<IDBTable>();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java
index f9d5792..d056a05 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreChunkReader.java
@@ -14,8 +14,8 @@ import org.eclipse.emf.cdo.internal.server.StoreChunkReader;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.server.db.IClassMapping;
-import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IDBStoreChunkReader;
+import org.eclipse.emf.cdo.server.db.IDBStoreReader;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.IReferenceMapping;
@@ -30,18 +30,18 @@ public class DBStoreChunkReader extends StoreChunkReader implements IDBStoreChun
private StringBuilder builder = new StringBuilder();
- public DBStoreChunkReader(IDBStoreAccessor storeAccessor, CDORevision revision, CDOFeature feature)
+ public DBStoreChunkReader(IDBStoreReader storeReader, CDORevision revision, CDOFeature feature)
{
- super(storeAccessor, revision, feature);
- IMappingStrategy mappingStrategy = storeAccessor.getStore().getMappingStrategy();
+ super(storeReader, revision, feature);
+ IMappingStrategy mappingStrategy = storeReader.getStore().getMappingStrategy();
IClassMapping mapping = mappingStrategy.getClassMapping(revision.getCDOClass());
referenceMapping = mapping.getReferenceMapping(feature);
}
@Override
- public IDBStoreAccessor getStoreAccessor()
+ public DBStoreReader getStoreReader()
{
- return (IDBStoreAccessor)super.getStoreAccessor();
+ return (DBStoreReader)super.getStoreReader();
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
new file mode 100644
index 0000000..021646e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
@@ -0,0 +1,290 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.server.internal.db;
+
+import org.eclipse.emf.cdo.internal.protocol.CDOIDRangeImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassProxy;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOTypeImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.CDOIDRange;
+import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
+import org.eclipse.emf.cdo.protocol.model.CDOFeature;
+import org.eclipse.emf.cdo.protocol.model.CDOPackageInfo;
+import org.eclipse.emf.cdo.protocol.model.CDOType;
+import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+import org.eclipse.emf.cdo.server.IPackageManager;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.IRevisionManager;
+import org.eclipse.emf.cdo.server.ISession;
+import org.eclipse.emf.cdo.server.IStoreChunkReader;
+import org.eclipse.emf.cdo.server.IView;
+import org.eclipse.emf.cdo.server.db.IClassMapping;
+import org.eclipse.emf.cdo.server.db.IDBStoreReader;
+import org.eclipse.emf.cdo.server.db.IMappingStrategy;
+import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
+
+import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBRowHandler;
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.io.CloseableIterator;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author Eike Stepper
+ */
+public class DBStoreReader extends DBStoreAccessor implements IDBStoreReader
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DBStoreReader.class);
+
+ public DBStoreReader(DBStore store, ISession session) throws DBException
+ {
+ super(store, session);
+ }
+
+ protected DBStoreReader(DBStore store, IView view) throws DBException
+ {
+ super(store, view);
+ }
+
+ public IStoreChunkReader createChunkReader(CDORevision revision, CDOFeature feature)
+ {
+ return new DBStoreChunkReader(this, revision, feature);
+ }
+
+ public Collection<CDOPackageInfo> readPackageInfos()
+ {
+ final Collection<CDOPackageInfo> result = new ArrayList<CDOPackageInfo>(0);
+ IDBRowHandler rowHandler = new IDBRowHandler()
+ {
+ public boolean handle(int row, final Object... values)
+ {
+ String packageURI = (String)values[0];
+ boolean dynamic = getBoolean(values[1]);
+ long rangeLB = (Long)values[2];
+ long rangeUB = (Long)values[3];
+ CDOIDRange metaIDRange = rangeLB == 0L && rangeUB == 0L ? null : CDOIDRangeImpl.create(rangeLB, rangeUB);
+ result.add(new CDOPackageInfo(packageURI, dynamic, metaIDRange));
+ return true;
+ }
+ };
+
+ DBUtil.select(getConnection(), rowHandler, CDODBSchema.PACKAGES_URI, CDODBSchema.PACKAGES_DYNAMIC,
+ CDODBSchema.PACKAGES_RANGE_LB, CDODBSchema.PACKAGES_RANGE_UB);
+ return result;
+ }
+
+ public void readPackage(final CDOPackageImpl cdoPackage)
+ {
+ String where = CDODBSchema.PACKAGES_URI.getName() + " = '" + cdoPackage.getPackageURI() + "'";
+ Object[] values = DBUtil.select(getConnection(), where, CDODBSchema.PACKAGES_ID, CDODBSchema.PACKAGES_NAME,
+ CDODBSchema.PACKAGES_ECORE);
+ PackageServerInfo.setDBID(cdoPackage, (Integer)values[0]);
+ cdoPackage.setName((String)values[1]);
+ cdoPackage.setEcore((String)values[2]);
+ readClasses(cdoPackage);
+
+ mapPackages(cdoPackage);
+ }
+
+ protected void readClasses(final CDOPackageImpl cdoPackage)
+ {
+ IDBRowHandler rowHandler = new IDBRowHandler()
+ {
+ public boolean handle(int row, Object... values)
+ {
+ int classID = (Integer)values[0];
+ int classifierID = (Integer)values[1];
+ String name = (String)values[2];
+ boolean isAbstract = getBoolean(values[3]);
+ CDOClassImpl cdoClass = new CDOClassImpl(cdoPackage, classifierID, name, isAbstract);
+ ClassServerInfo.setDBID(cdoClass, classID);
+ cdoPackage.addClass(cdoClass);
+ readSuperTypes(cdoClass, classID);
+ readFeatures(cdoClass, classID);
+ return true;
+ }
+ };
+
+ String where = CDODBSchema.CLASSES_PACKAGE.getName() + "=" + ServerInfo.getDBID(cdoPackage);
+ DBUtil.select(getConnection(), rowHandler, where, CDODBSchema.CLASSES_ID, CDODBSchema.CLASSES_CLASSIFIER,
+ CDODBSchema.CLASSES_NAME, CDODBSchema.CLASSES_ABSTRACT);
+ }
+
+ protected void readSuperTypes(final CDOClassImpl cdoClass, int classID)
+ {
+ IDBRowHandler rowHandler = new IDBRowHandler()
+ {
+ public boolean handle(int row, Object... values)
+ {
+ String packageURI = (String)values[0];
+ int classifierID = (Integer)values[1];
+ cdoClass.addSuperType(new CDOClassRefImpl(packageURI, classifierID));
+ return true;
+ }
+ };
+
+ String where = CDODBSchema.SUPERTYPES_TYPE.getName() + "=" + classID;
+ DBUtil.select(getConnection(), rowHandler, where, CDODBSchema.SUPERTYPES_SUPERTYPE_PACKAGE,
+ CDODBSchema.SUPERTYPES_SUPERTYPE_CLASSIFIER);
+ }
+
+ protected void readFeatures(final CDOClassImpl cdoClass, int classID)
+ {
+ IDBRowHandler rowHandler = new IDBRowHandler()
+ {
+ public boolean handle(int row, Object... values)
+ {
+ int featureID = (Integer)values[1];
+ String name = (String)values[2];
+ CDOTypeImpl type = CDOTypeImpl.getType((Integer)values[3]);
+ boolean many = getBoolean(values[6]);
+
+ CDOFeatureImpl feature;
+ if (type == CDOType.OBJECT)
+ {
+ String packageURI = (String)values[4];
+ int classifierID = (Integer)values[5];
+ boolean containment = getBoolean(values[7]);
+ CDOClassRefImpl classRef = new CDOClassRefImpl(packageURI, classifierID);
+ CDOClassProxy referenceType = new CDOClassProxy(classRef, cdoClass.getPackageManager());
+ feature = new CDOFeatureImpl(cdoClass, featureID, name, referenceType, many, containment);
+ }
+ else
+ {
+ feature = new CDOFeatureImpl(cdoClass, featureID, name, type, many);
+ }
+
+ FeatureServerInfo.setDBID(feature, (Integer)values[0]);
+ cdoClass.addFeature(feature);
+ return true;
+ }
+ };
+
+ String where = CDODBSchema.FEATURES_CLASS.getName() + "=" + classID;
+ DBUtil.select(getConnection(), rowHandler, where, CDODBSchema.FEATURES_ID, CDODBSchema.FEATURES_FEATURE,
+ CDODBSchema.FEATURES_NAME, CDODBSchema.FEATURES_TYPE, CDODBSchema.FEATURES_REFERENCE_PACKAGE,
+ CDODBSchema.FEATURES_REFERENCE_CLASSIFIER, CDODBSchema.FEATURES_MANY, CDODBSchema.FEATURES_CONTAINMENT);
+ }
+
+ public String readPackageURI(int packageID)
+ {
+ String where = CDODBSchema.PACKAGES_ID.getName() + "=" + packageID;
+ Object[] uri = DBUtil.select(getConnection(), where, CDODBSchema.PACKAGES_URI);
+ return (String)uri[0];
+ }
+
+ public CloseableIterator<CDOID> readObjectIDs(boolean withTypes)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace("Selecting object IDs");
+ }
+
+ return getStore().getMappingStrategy().readObjectIDs(this, withTypes);
+ }
+
+ public CDOClassRef readObjectType(CDOID id)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Selecting object type: {0}", id);
+ }
+
+ return getStore().getMappingStrategy().readObjectType(this, id);
+ }
+
+ public CDOClassRef readClassRef(int classID)
+ {
+ String where = CDODBSchema.CLASSES_ID.getName() + "=" + classID;
+ Object[] ids = DBUtil.select(getConnection(), where, CDODBSchema.CLASSES_CLASSIFIER, CDODBSchema.CLASSES_PACKAGE);
+ String packageURI = readPackageURI((Integer)ids[1]);
+ return new CDOClassRefImpl(packageURI, (Integer)ids[0]);
+ }
+
+ public CDORevision readRevision(CDOID id, int referenceChunk)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Selecting revision: {0}", id);
+ }
+
+ IRevisionManager revisionManager = getStore().getRepository().getRevisionManager();
+ CDOClassImpl cdoClass = getObjectType(id);
+ CDORevisionImpl revision = new CDORevisionImpl(revisionManager, cdoClass, id);
+
+ IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
+ IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass);
+ mapping.readRevision(this, revision, referenceChunk);
+ return revision;
+ }
+
+ public CDORevision readRevisionByTime(CDOID id, int referenceChunk, long timeStamp)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Selecting revision: {0}, timestamp={1,date} {1,time}", id, timeStamp);
+ }
+
+ IRevisionManager revisionManager = getStore().getRepository().getRevisionManager();
+ CDOClassImpl cdoClass = getObjectType(id);
+ CDORevisionImpl revision = new CDORevisionImpl(revisionManager, cdoClass, id);
+
+ IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
+ IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass);
+ mapping.readRevisionByTime(this, revision, timeStamp, referenceChunk);
+ return revision;
+ }
+
+ public CDORevision readRevisionByVersion(CDOID id, int referenceChunk, int version)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Selecting revision: {0}, version={1}", id, version);
+ }
+
+ IRevisionManager revisionManager = getStore().getRepository().getRevisionManager();
+ CDOClassImpl cdoClass = getObjectType(id);
+ CDORevisionImpl revision = new CDORevisionImpl(revisionManager, cdoClass, id);
+
+ IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
+ IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass);
+ mapping.readRevisionByVersion(this, revision, version, referenceChunk);
+ return revision;
+ }
+
+ public CDOID readResourceID(String path)
+ {
+ IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
+ return mappingStrategy.readResourceID(this, path);
+ }
+
+ public String readResourcePath(CDOID id)
+ {
+ IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
+ return mappingStrategy.readResourcePath(this, id);
+ }
+
+ protected CDOClassImpl getObjectType(CDOID id)
+ {
+ IRepository repository = getStore().getRepository();
+ IPackageManager packageManager = repository.getPackageManager();
+ CDOClassRef type = readObjectType(id);
+ return (CDOClassImpl)type.resolve(packageManager);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
new file mode 100644
index 0000000..252ae85
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
@@ -0,0 +1,213 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.server.internal.db;
+
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassProxy;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.protocol.CDOIDRange;
+import org.eclipse.emf.cdo.server.IStoreWriter;
+import org.eclipse.emf.cdo.server.IView;
+import org.eclipse.emf.cdo.server.db.IClassMapping;
+import org.eclipse.emf.cdo.server.db.IDBStoreWriter;
+import org.eclipse.emf.cdo.server.db.IMappingStrategy;
+import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
+
+import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBTable;
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import org.eclipse.net4j.util.transaction.ITransaction;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DBStoreWriter.class);
+
+ public DBStoreWriter(DBStore store, IView view) throws DBException
+ {
+ super(store, view);
+ }
+
+ @Override
+ public void release() throws DBException
+ {
+ try
+ {
+ getConnection().commit();
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ super.release();
+ }
+ }
+
+ public void writePackages(CDOPackageImpl... cdoPackages)
+ {
+ for (CDOPackageImpl cdoPackage : cdoPackages)
+ {
+ writePackage(cdoPackage);
+ }
+
+ Set<IDBTable> affectedTables = mapPackages(cdoPackages);
+ getStore().getDBAdapter().createTables(affectedTables, getConnection());
+ }
+
+ protected void writePackage(CDOPackageImpl cdoPackage)
+ {
+ int id = getStore().getNextPackageID();
+ PackageServerInfo.setDBID(cdoPackage, id);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Inserting package: {0} --> {1}", cdoPackage, id);
+ }
+
+ String packageURI = cdoPackage.getPackageURI();
+ String name = cdoPackage.getName();
+ String ecore = cdoPackage.getEcore();
+ boolean dynamic = cdoPackage.isDynamic();
+ CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
+ long lb = metaIDRange == null ? 0L : metaIDRange.getLowerBound().getValue();
+ long ub = metaIDRange == null ? 0L : metaIDRange.getUpperBound().getValue();
+
+ String sql = "INSERT INTO " + CDODBSchema.PACKAGES + " VALUES (?, ?, ?, ?, ?, ?, ?)";
+ DBUtil.trace(sql);
+ PreparedStatement pstmt = null;
+
+ try
+ {
+ pstmt = getConnection().prepareStatement(sql);
+ pstmt.setInt(1, id);
+ pstmt.setString(2, packageURI);
+ pstmt.setString(3, name);
+ pstmt.setString(4, ecore);
+ pstmt.setBoolean(5, dynamic);
+ pstmt.setLong(6, lb);
+ pstmt.setLong(7, ub);
+
+ if (pstmt.execute())
+ {
+ throw new DBException("No result set expected");
+ }
+
+ if (pstmt.getUpdateCount() == 0)
+ {
+ throw new DBException("No row inserted into table " + CDODBSchema.PACKAGES);
+ }
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ DBUtil.close(pstmt);
+ }
+
+ for (CDOClassImpl cdoClass : cdoPackage.getClasses())
+ {
+ writeClass(cdoClass);
+ }
+ }
+
+ protected void writeClass(CDOClassImpl cdoClass)
+ {
+ int id = getStore().getNextClassID();
+ ClassServerInfo.setDBID(cdoClass, id);
+
+ CDOPackageImpl cdoPackage = cdoClass.getContainingPackage();
+ int packageID = ServerInfo.getDBID(cdoPackage);
+ int classifierID = cdoClass.getClassifierID();
+ String name = cdoClass.getName();
+ boolean isAbstract = cdoClass.isAbstract();
+ DBUtil.insertRow(getConnection(), getStore().getDBAdapter(), CDODBSchema.CLASSES, id, packageID, classifierID,
+ name, isAbstract);
+
+ for (CDOClassProxy superType : cdoClass.getSuperTypeProxies())
+ {
+ writeSuperType(id, superType);
+ }
+
+ for (CDOFeatureImpl feature : cdoClass.getFeatures())
+ {
+ writeFeature(feature);
+ }
+ }
+
+ protected void writeSuperType(int type, CDOClassProxy superType)
+ {
+ String packageURI = superType.getPackageURI();
+ int classifierID = superType.getClassifierID();
+ DBUtil
+ .insertRow(getConnection(), getStore().getDBAdapter(), CDODBSchema.SUPERTYPES, type, packageURI, classifierID);
+ }
+
+ protected void writeFeature(CDOFeatureImpl feature)
+ {
+ int id = getStore().getNextFeatureID();
+ FeatureServerInfo.setDBID(feature, id);
+
+ int classID = ServerInfo.getDBID(feature.getContainingClass());
+ String name = feature.getName();
+ int featureID = feature.getFeatureID();
+ int type = feature.getType().getTypeID();
+ CDOClassProxy reference = feature.getReferenceTypeProxy();
+ String packageURI = reference == null ? null : reference.getPackageURI();
+ int classifierID = reference == null ? 0 : reference.getClassifierID();
+ boolean many = feature.isMany();
+ boolean containment = feature.isContainment();
+ int idx = feature.getFeatureIndex();
+ DBUtil.insertRow(getConnection(), getStore().getDBAdapter(), CDODBSchema.FEATURES, id, classID, featureID, name,
+ type, packageURI, classifierID, many, containment, idx);
+ }
+
+ public void writeRevision(CDORevisionImpl revision)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Inserting revision: {0}", revision);
+ }
+
+ CDOClassImpl cdoClass = revision.getCDOClass();
+ IMappingStrategy mappingStrategy = getStore().getMappingStrategy();
+ IClassMapping mapping = mappingStrategy.getClassMapping(cdoClass);
+ mapping.writeRevision(this, revision);
+ }
+
+ public void rollback(IView view, ITransaction<IStoreWriter> storeTransaction)
+ {
+ try
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Rolling back transaction: {0}", view);
+ }
+
+ getConnection().rollback();
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
index 6944fbc..70a8a2e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
@@ -20,7 +20,7 @@ import org.eclipse.emf.cdo.server.IPackageManager;
import org.eclipse.emf.cdo.server.db.IAttributeMapping;
import org.eclipse.emf.cdo.server.db.IClassMapping;
import org.eclipse.emf.cdo.server.db.IDBStore;
-import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
+import org.eclipse.emf.cdo.server.db.IDBStoreReader;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
@@ -225,11 +225,11 @@ public abstract class MappingStrategy implements IMappingStrategy
resourcePathField = resourcePathMapping.getField();
}
- public CloseableIterator<CDOID> readObjectIDs(final IDBStoreAccessor storeAccessor, final boolean withTypes)
+ public CloseableIterator<CDOID> readObjectIDs(final IDBStoreReader storeReader, final boolean withTypes)
{
List<CDOClass> classes = getClassesWithObjectInfo();
final Iterator<CDOClass> classIt = classes.iterator();
- return new ObjectIDIterator(this, storeAccessor, withTypes)
+ return new ObjectIDIterator(this, storeReader, withTypes)
{
@Override
protected ResultSet getNextResultSet()
@@ -258,7 +258,7 @@ public abstract class MappingStrategy implements IMappingStrategy
try
{
- return storeAccessor.getStatement().executeQuery(sql);
+ return storeReader.getStatement().executeQuery(sql);
}
catch (SQLException ex)
{
@@ -273,7 +273,7 @@ public abstract class MappingStrategy implements IMappingStrategy
};
}
- public CDOClassRef readObjectType(IDBStoreAccessor storeAccessor, CDOID id)
+ public CDOClassRef readObjectType(IDBStoreReader storeReader, CDOID id)
{
// TODO Change to support vertical mappings
String prefix = "SELECT DISTINCT " + CDODBSchema.ATTRIBUTES_CLASS + " FROM ";
@@ -292,11 +292,11 @@ public abstract class MappingStrategy implements IMappingStrategy
try
{
- resultSet = storeAccessor.getStatement().executeQuery(sql);
+ resultSet = storeReader.getStatement().executeQuery(sql);
if (resultSet.next())
{
int classID = resultSet.getInt(1);
- return getClassRef(storeAccessor, classID);
+ return getClassRef(storeReader, classID);
}
}
catch (SQLException ex)
@@ -314,7 +314,7 @@ public abstract class MappingStrategy implements IMappingStrategy
throw new DBException("No object with id " + id);
}
- public CDOClassRef getClassRef(IDBStoreAccessor storeAccessor, int classID)
+ public CDOClassRef getClassRef(IDBStoreReader storeReader, int classID)
{
CDOClassRef classRef = classRefs.get(classID);
if (classRef == null)
@@ -327,7 +327,7 @@ public abstract class MappingStrategy implements IMappingStrategy
}
else
{
- classRef = storeAccessor.readClassRef(classID);
+ classRef = storeReader.readClassRef(classID);
}
classRefs.put(classID, classRef);
@@ -336,23 +336,23 @@ public abstract class MappingStrategy implements IMappingStrategy
return classRef;
}
- public CDOID readResourceID(IDBStoreAccessor storeAccessor, String path)
+ public CDOID readResourceID(IDBStoreReader storeReader, String path)
{
IDBTable resourceTable = getResourceTable();
IDBField selectField = getResourceIDField();
IDBField whereField = getResourcePathField();
- return (CDOID)readResourceInfo(storeAccessor, resourceTable, selectField, whereField, path);
+ return (CDOID)readResourceInfo(storeReader, resourceTable, selectField, whereField, path);
}
- public String readResourcePath(IDBStoreAccessor storeAccessor, CDOID id)
+ public String readResourcePath(IDBStoreReader storeReader, CDOID id)
{
IDBTable resourceTable = getResourceTable();
IDBField selectField = getResourcePathField();
IDBField whereField = getResourceIDField();
- return (String)readResourceInfo(storeAccessor, resourceTable, selectField, whereField, id);
+ return (String)readResourceInfo(storeReader, resourceTable, selectField, whereField, id);
}
- protected Object readResourceInfo(IDBStoreAccessor storeAccessor, IDBTable resourceTable, IDBField selectField,
+ protected Object readResourceInfo(IDBStoreReader storeReader, IDBTable resourceTable, IDBField selectField,
IDBField whereField, Object whereValue)
{
StringBuilder builder = new StringBuilder();
@@ -371,7 +371,7 @@ public abstract class MappingStrategy implements IMappingStrategy
try
{
- Statement statement = storeAccessor.getStatement();
+ Statement statement = storeReader.getStatement();
statement.setMaxRows(1); // Reset by DBUtil.close(resultSet)
resultSet = statement.executeQuery(sql);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
index 782f91d..73b2655 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/NoClassMapping.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.server.db.IAttributeMapping;
import org.eclipse.emf.cdo.server.db.IClassMapping;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
+import org.eclipse.emf.cdo.server.db.IDBStoreReader;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.emf.cdo.server.db.IReferenceMapping;
@@ -80,16 +81,16 @@ public class NoClassMapping implements IClassMapping
{
}
- public void readRevision(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, int referenceChunk)
+ public void readRevision(IDBStoreReader storeReader, CDORevisionImpl revision, int referenceChunk)
{
}
- public void readRevisionByTime(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, long timeStamp,
+ public void readRevisionByTime(IDBStoreReader storeReader, CDORevisionImpl revision, long timeStamp,
int referenceChunk)
{
}
- public void readRevisionByVersion(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, int version,
+ public void readRevisionByVersion(IDBStoreReader storeReader, CDORevisionImpl revision, int version,
int referenceChunk)
{
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java
index 54f65c6..d4cb7d0 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ObjectIDIterator.java
@@ -13,7 +13,7 @@ package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
-import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
+import org.eclipse.emf.cdo.server.db.IDBStoreReader;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
@@ -30,7 +30,7 @@ public abstract class ObjectIDIterator implements CloseableIterator<CDOID>
{
private MappingStrategy mappingStrategy;
- private IDBStoreAccessor storeAccessor;
+ private IDBStoreReader storeReader;
private boolean withTypes;
@@ -42,10 +42,10 @@ public abstract class ObjectIDIterator implements CloseableIterator<CDOID>
* Creates an iterator over all objects in a store. It is important to {@link #dispose()} of this iterator after usage
* to properly close internal result sets.
*/
- public ObjectIDIterator(MappingStrategy mappingStrategy, IDBStoreAccessor storeAccessor, boolean withTypes)
+ public ObjectIDIterator(MappingStrategy mappingStrategy, IDBStoreReader storeReader, boolean withTypes)
{
this.mappingStrategy = mappingStrategy;
- this.storeAccessor = storeAccessor;
+ this.storeReader = storeReader;
this.withTypes = withTypes;
}
@@ -59,9 +59,9 @@ public abstract class ObjectIDIterator implements CloseableIterator<CDOID>
return mappingStrategy;
}
- public IDBStoreAccessor getStoreAccessor()
+ public IDBStoreReader getStoreReader()
{
- return storeAccessor;
+ return storeReader;
}
public boolean isWithTypes()
@@ -91,7 +91,7 @@ public abstract class ObjectIDIterator implements CloseableIterator<CDOID>
if (withTypes)
{
int classID = currentResultSet.getInt(2);
- CDOClassRef type = mappingStrategy.getClassRef(storeAccessor, classID);
+ CDOClassRef type = mappingStrategy.getClassRef(storeReader, classID);
nextID = CDOIDImpl.create(id, type);
}
else
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
index 7608d46..a4f8904 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ReferenceMapping.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk;
import org.eclipse.emf.cdo.server.db.IDBStoreAccessor;
import org.eclipse.emf.cdo.server.db.IDBStoreChunkReader;
+import org.eclipse.emf.cdo.server.db.IDBStoreReader;
import org.eclipse.emf.cdo.server.db.IReferenceMapping;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
@@ -94,7 +95,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
}
}
- public void readReference(IDBStoreAccessor storeAccessor, CDORevisionImpl revision, int referenceChunk)
+ public void readReference(IDBStoreReader storeReader, CDORevisionImpl revision, int referenceChunk)
{
MoveableList list = revision.getList(getFeature());
CDOID source = revision.getID();
@@ -106,7 +107,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
try
{
- resultSet = storeAccessor.getStatement().executeQuery(sql);
+ resultSet = storeReader.getStatement().executeQuery(sql);
while (resultSet.next() && (referenceChunk == CDORevision.UNCHUNKED || --referenceChunk >= 0))
{
long target = resultSet.getLong(1);
@@ -131,7 +132,7 @@ public class ReferenceMapping extends FeatureMapping implements IReferenceMappin
public void readChunks(IDBStoreChunkReader chunkReader, List<Chunk> chunks, String where)
{
- IDBStoreAccessor storeAccessor = chunkReader.getStoreAccessor();
+ IDBStoreAccessor storeAccessor = chunkReader.getStoreReader();
CDOID source = chunkReader.getRevision().getID();
int version = chunkReader.getRevision().getVersion();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
index 0f57770..c2f8818 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.protocol.revision.CDODuplicateRevisionException;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStoreChunkReader;
+import org.eclipse.emf.cdo.server.IStoreReader;
import org.eclipse.emf.cdo.server.IStoreWriter;
import org.eclipse.emf.cdo.server.IView;
@@ -36,7 +37,7 @@ import java.util.List;
/**
* @author Simon McDuff
*/
-public class MEMStoreAccessor extends StoreAccessor
+public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, IStoreWriter
{
List<CDORevisionImpl> listToCommit = new ArrayList<CDORevisionImpl>();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreChunkReader.java
index 672e397..1f54d47 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreChunkReader.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreChunkReader.java
@@ -15,7 +15,7 @@ import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
-import org.eclipse.emf.cdo.server.IStoreAccessor;
+import org.eclipse.emf.cdo.server.IStoreReader;
import java.util.List;
@@ -24,23 +24,23 @@ import java.util.List;
*/
public class MEMStoreChunkReader extends StoreChunkReader
{
- public MEMStoreChunkReader(IStoreAccessor storeAccessor, CDORevision revision, CDOFeature feature)
+ public MEMStoreChunkReader(IStoreReader storeReader, CDORevision revision, CDOFeature feature)
{
- super(storeAccessor, revision, feature);
+ super(storeReader, revision, feature);
}
public List<Chunk> executeRead()
{
- for (Chunk chunk : this.getChunks())
+ MEMStore store = getStoreReader().getStore();
+ for (Chunk chunk : getChunks())
{
int startIndex = chunk.getStartIndex();
int size = chunk.size();
- CDORevisionImpl revisionMEM = (CDORevisionImpl)this.getStoreAccessor().getStore().getRevision(
- this.getRevision().getID());
+ CDORevisionImpl revisionMEM = (CDORevisionImpl)store.getRevision(getRevision().getID());
for (int i = 0; i < size; i++)
{
- Object object = revisionMEM.get(this.getFeature(), startIndex + i);
+ Object object = revisionMEM.get(getFeature(), startIndex + i);
chunk.addID(i, (CDOID)object);
}
}
@@ -49,8 +49,8 @@ public class MEMStoreChunkReader extends StoreChunkReader
}
@Override
- public MEMStoreAccessor getStoreAccessor()
+ public MEMStoreAccessor getStoreReader()
{
- return (MEMStoreAccessor)super.getStoreAccessor();
+ return (MEMStoreAccessor)super.getStoreReader();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java
index 151da43..d7be96e 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.cdo.protocol.model.CDOPackageInfo;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStoreChunkReader;
+import org.eclipse.emf.cdo.server.IStoreReader;
import org.eclipse.emf.cdo.server.IStoreWriter;
import org.eclipse.emf.cdo.server.IView;
@@ -31,7 +32,7 @@ import java.util.Collections;
/**
* @author Eike Stepper
*/
-public class NOOPStoreAccessor extends StoreAccessor
+public class NOOPStoreAccessor extends StoreAccessor implements IStoreReader, IStoreWriter
{
public NOOPStoreAccessor(NOOPStore store, ISession session)
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreChunkReader.java
index 88bfc41..eeabf04 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreChunkReader.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreChunkReader.java
@@ -12,7 +12,7 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
-import org.eclipse.emf.cdo.server.IStoreAccessor;
+import org.eclipse.emf.cdo.server.IStoreReader;
import java.util.List;
@@ -21,9 +21,9 @@ import java.util.List;
*/
public class NOOPStoreChunkReader extends StoreChunkReader
{
- public NOOPStoreChunkReader(IStoreAccessor storeAccessor, CDORevision revision, CDOFeature feature)
+ public NOOPStoreChunkReader(IStoreReader storeReader, CDORevision revision, CDOFeature feature)
{
- super(storeAccessor, revision, feature);
+ super(storeReader, revision, feature);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java
index 38e423a..a04a30f 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java
@@ -16,13 +16,13 @@ import org.eclipse.emf.cdo.internal.protocol.revision.delta.CDORevisionDeltaImpl
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.server.ISession;
-import org.eclipse.emf.cdo.server.IStoreWriter;
+import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.IView;
/**
* @author Eike Stepper
*/
-public abstract class StoreAccessor implements IStoreWriter
+public class StoreAccessor implements IStoreAccessor
{
private Store store;
@@ -37,12 +37,12 @@ public abstract class StoreAccessor implements IStoreWriter
this.reader = reader;
}
- public StoreAccessor(Store store, ISession session)
+ protected StoreAccessor(Store store, ISession session)
{
this(store, session, true);
}
- public StoreAccessor(Store store, IView view)
+ protected StoreAccessor(Store store, IView view)
{
this(store, view, false);
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreChunkReader.java
index dd31340..869956c 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreChunkReader.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreChunkReader.java
@@ -12,8 +12,8 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
-import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.IStoreChunkReader;
+import org.eclipse.emf.cdo.server.IStoreReader;
import java.util.ArrayList;
import java.util.List;
@@ -23,7 +23,7 @@ import java.util.List;
*/
public abstract class StoreChunkReader implements IStoreChunkReader
{
- private IStoreAccessor storeAccessor;
+ private IStoreReader storeReader;
private CDORevision revision;
@@ -31,16 +31,16 @@ public abstract class StoreChunkReader implements IStoreChunkReader
private List<Chunk> chunks = new ArrayList<Chunk>(0);
- public StoreChunkReader(IStoreAccessor storeAccessor, CDORevision revision, CDOFeature feature)
+ public StoreChunkReader(IStoreReader storeReader, CDORevision revision, CDOFeature feature)
{
- this.storeAccessor = storeAccessor;
+ this.storeReader = storeReader;
this.revision = revision;
this.feature = feature;
}
- public IStoreAccessor getStoreAccessor()
+ public IStoreReader getStoreReader()
{
- return storeAccessor;
+ return storeReader;
}
public CDORevision getRevision()
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreChunkReader.java
index 30d3c39..147e3c1 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreChunkReader.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreChunkReader.java
@@ -22,6 +22,8 @@ import java.util.List;
*/
public interface IStoreChunkReader
{
+ public IStoreReader getStoreReader();
+
public CDORevision getRevision();
public CDOFeature getFeature();