summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-01-06 07:02:39 (EST)
committerEike Stepper2008-01-06 07:02:39 (EST)
commitebfc8a9bfaa583af31f657e3987140211f36d40e (patch)
treefcde6d91968a3e6bd13071ddeb7c2fab06d18c6d
parentd2ca41fa12690426c7aa11aa5e7df5deee0ea9e7 (diff)
downloadcdo-ebfc8a9bfaa583af31f657e3987140211f36d40e.zip
cdo-ebfc8a9bfaa583af31f657e3987140211f36d40e.tar.gz
cdo-ebfc8a9bfaa583af31f657e3987140211f36d40e.tar.bz2
[214435] Remove Type Manager
https://bugs.eclipse.org/bugs/show_bug.cgi?id=214435
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java46
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java25
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TypeManager.java414
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryObjectTypesIndication.java26
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITypeManager.java26
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java6
17 files changed, 37 insertions, 583 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
index c6e6e7e..b239890 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
@@ -26,12 +26,6 @@ public interface IMappingStrategy
{
public String getType();
- /**
- * @return <code>true</code> if this mapping strategy supports the efficient lookup of object types,
- * <code>false</code> otherwise.
- */
- public boolean hasEfficientTypeLookup();
-
public IDBStore getStore();
public void setStore(IDBStore store);
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 11cf856..9955b88 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,11 +109,6 @@ public class DBStore extends Store implements IDBStore
return false;
}
- public boolean hasEfficientTypeLookup()
- {
- return mappingStrategy.hasEfficientTypeLookup();
- }
-
public DBStoreAccessor getReader(ISession session) throws DBException
{
return new DBStoreAccessor(this, session);
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 2b8b58d..8c6efa7 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
@@ -526,7 +526,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
{
IRepository repository = getStore().getRepository();
IPackageManager packageManager = repository.getPackageManager();
- CDOClassRef type = repository.getTypeManager().getObjectType(this, id);
+ 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/HorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
index 1f111b6..6c84241 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
@@ -32,11 +32,6 @@ public class HorizontalMappingStrategy extends MappingStrategy
return "horizontal";
}
- public boolean hasEfficientTypeLookup()
- {
- return false;
- }
-
@Override
protected IClassMapping createClassMapping(CDOClass cdoClass)
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java
index 1106778..4cf04d2 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java
@@ -33,11 +33,6 @@ public class VerticalMappingStrategy extends MappingStrategy
return "vertical";
}
- public boolean hasEfficientTypeLookup()
- {
- return true;
- }
-
public RootClassMapping getRootClassMapping()
{
if (rootClassMapping == null)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
index 8e81a38..b9f68cf 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java
@@ -94,11 +94,6 @@ public class MEMStore extends Store
return false;
}
- public boolean hasEfficientTypeLookup()
- {
- return true;
- }
-
public void repairAfterCrash()
{
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java
index 361b449..9e5ac1a 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java
@@ -35,11 +35,6 @@ public class NOOPStore extends Store
return false;
}
- public boolean hasEfficientTypeLookup()
- {
- return true;
- }
-
public void repairAfterCrash()
{
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
index 4463d40..9644a67 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
@@ -39,8 +39,6 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
public static final String PROP_VERIFYING_REVISIONS = "verifyingRevisions";
- public static final String PROP_REMEMBERING_KNOWN_TYPES = "rememberingKnownTypes";
-
public static final String PROP_CURRENT_LRU_CAPACITY = "currentLRUCapacity";
public static final String PROP_REVISED_LRU_CAPACITY = "revisedLRUCapacity";
@@ -61,10 +59,6 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
private Boolean verifyingRevisions;
- private Boolean rememberingKnownTypes;
-
- private TypeManager typeManager = createTypeManager();
-
private PackageManager packageManager = createPackageManager();
private SessionManager sessionManager = createSessionManager();
@@ -160,22 +154,6 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
return verifyingRevisions;
}
- public boolean isRememberingKnownTypes()
- {
- if (rememberingKnownTypes == null)
- {
- String value = getProperties().get(PROP_REMEMBERING_KNOWN_TYPES);
- rememberingKnownTypes = value == null ? false : Boolean.valueOf(value);
- }
-
- return rememberingKnownTypes;
- }
-
- public TypeManager getTypeManager()
- {
- return typeManager;
- }
-
public PackageManager getPackageManager()
{
return packageManager;
@@ -231,24 +209,6 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
return MessageFormat.format("Repository[{0}, {1}]", name, uuid);
}
- protected TypeManager createTypeManager()
- {
- return new TypeManager(this)
- {
- @Override
- protected String getThreadName()
- {
- return "TypeManager-" + name;
- }
-
- @Override
- public String toString()
- {
- return getThreadName();
- }
- };
- }
-
protected PackageManager createPackageManager()
{
return new PackageManager(this);
@@ -288,8 +248,7 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
throw new IllegalStateException("Store without auditing support");
}
- elements = new IRepositoryElement[] { packageManager, sessionManager, resourceManager, revisionManager,
- typeManager, store };
+ elements = new IRepositoryElement[] { packageManager, sessionManager, resourceManager, revisionManager, store };
}
@Override
@@ -309,8 +268,6 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
protected void activateRepository() throws Exception
{
LifecycleUtil.activate(store);
- typeManager.setPersistent(!store.hasEfficientTypeLookup());
- typeManager.activate();
packageManager.activate();
if (store.wasCrashed())
{
@@ -328,7 +285,6 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
resourceManager.deactivate();
sessionManager.deactivate();
packageManager.deactivate();
- typeManager.deactivate();
LifecycleUtil.deactivate(store);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java
index 97cbe59..02891d7 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/RevisionManager.java
@@ -13,7 +13,6 @@
package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
-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.resource.CDOPathFeatureImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
@@ -209,27 +208,21 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
protected CDORevisionImpl loadRevision(CDOID id, int referenceChunk)
{
IStoreReader storeReader = StoreUtil.getReader();
- CDORevisionImpl revision = (CDORevisionImpl)storeReader.readRevision(id, referenceChunk);
- registerObjectType(revision);
- return revision;
+ return (CDORevisionImpl)storeReader.readRevision(id, referenceChunk);
}
@Override
protected CDORevisionImpl loadRevisionByTime(CDOID id, int referenceChunk, long timeStamp)
{
IStoreReader storeReader = StoreUtil.getReader();
- CDORevisionImpl revision = (CDORevisionImpl)storeReader.readRevisionByTime(id, referenceChunk, timeStamp);
- registerObjectType(revision);
- return revision;
+ return (CDORevisionImpl)storeReader.readRevisionByTime(id, referenceChunk, timeStamp);
}
@Override
protected CDORevisionImpl loadRevisionByVersion(CDOID id, int referenceChunk, int version)
{
IStoreReader storeReader = StoreUtil.getReader();
- CDORevisionImpl revision = (CDORevisionImpl)storeReader.readRevisionByVersion(id, referenceChunk, version);
- registerObjectType(revision);
- return revision;
+ return (CDORevisionImpl)storeReader.readRevisionByVersion(id, referenceChunk, version);
}
@Override
@@ -240,7 +233,7 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
for (CDOID id : ids)
{
CDORevisionImpl revision = (CDORevisionImpl)storeReader.readRevision(id, referenceChunk);
- registerObjectType(revision);
+ revisions.add(revision);
}
return revisions;
@@ -254,7 +247,7 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
for (CDOID id : ids)
{
CDORevisionImpl revision = (CDORevisionImpl)storeReader.readRevisionByTime(id, referenceChunk, timeStamp);
- registerObjectType(revision);
+ revisions.add(revision);
}
return revisions;
@@ -274,13 +267,6 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
return capacity == null ? 0 : Integer.valueOf(capacity);
}
- protected void registerObjectType(CDORevisionImpl revision)
- {
- CDOID id = revision.getID();
- CDOClassRefImpl type = revision.getCDOClass().createClassRef();
- repository.getTypeManager().registerObjectType(id, type);
- }
-
/**
* @author Eike Stepper
*/
@@ -300,7 +286,6 @@ public class RevisionManager extends CDORevisionResolverImpl implements IRevisio
public void phase2(IStoreWriter storeWriter)
{
- repository.getTypeManager().registerObjectType(revision.getID(), revision.getCDOClass().createClassRef());
addRevision(revision);
if (revision.isResource())
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
index a75d1b5..94ca116 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Session.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.internal.server.protocol.CDOServerProtocol;
import org.eclipse.emf.cdo.internal.server.protocol.InvalidationNotification;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
+import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IView;
@@ -34,7 +35,6 @@ import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.lifecycle.ILifecycle;
import java.text.MessageFormat;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -55,8 +55,6 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
private ConcurrentMap<Integer, View> views = new ConcurrentHashMap<Integer, View>();
- private Set<CDOID> knownTypes = new HashSet<CDOID>();
-
private IListener protocolListener = new LifecycleEventAdapter()
{
@Override
@@ -180,21 +178,17 @@ public class Session extends Container<IView> implements ISession, CDOIDProvider
return id;
}
- Repository repository = sessionManager.getRepository();
- if (repository.isRememberingKnownTypes())
- {
- if (knownTypes.contains(id))
- {
- return id;
- }
-
- knownTypes.add(id);
- }
-
- CDOClassRef type = repository.getTypeManager().getObjectType(StoreUtil.getReader(), id);
+ CDOClassRef type = getObjectTypeRef(id);
return CDOIDImpl.create(id.getValue(), type);
}
+ public CDOClassRef getObjectTypeRef(CDOID id)
+ {
+ RevisionManager revisionManager = sessionManager.getRepository().getRevisionManager();
+ CDOClass cdoClass = revisionManager.getObjectType(id);
+ return cdoClass != null ? cdoClass.createClassRef() : StoreUtil.getReader().readObjectType(id);
+ }
+
/**
* TODO I can't see how recursion is controlled/limited
*/
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TypeManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TypeManager.java
deleted file mode 100644
index 9f773bc..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TypeManager.java
+++ /dev/null
@@ -1,414 +0,0 @@
-/***************************************************************************
- * 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.internal.server;
-
-import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
-import org.eclipse.emf.cdo.internal.server.bundle.OM;
-import org.eclipse.emf.cdo.protocol.CDOID;
-import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
-import org.eclipse.emf.cdo.server.IStoreReader;
-import org.eclipse.emf.cdo.server.ITypeManager;
-
-import org.eclipse.net4j.internal.util.lifecycle.QueueWorker;
-import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
-import org.eclipse.net4j.util.ImplementationError;
-import org.eclipse.net4j.util.io.CachedFileMap;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-import org.eclipse.net4j.util.io.ExtendedIOUtil;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.io.SortedFileMap;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * @author Eike Stepper
- */
-public class TypeManager extends QueueWorker<ObjectEntry> implements ITypeManager
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_TYPES, TypeManager.class);
-
- private Repository repository;
-
- private boolean persistent;
-
- private ConcurrentMap<CDOID, CDOClassRef> objectTypes = new ConcurrentHashMap<CDOID, CDOClassRef>();
-
- private PackageURIMap packageURIMap;
-
- private PackageIDMap packageIDMap;
-
- private ObjectTypeMap objectTypeMap;
-
- /**
- * TODO Needed?
- */
- private ObjectTypeMap metaObjectTypeMap;
-
- private int nextPackageID;
-
- public TypeManager(Repository repository)
- {
- this.repository = repository;
- }
-
- public Repository getRepository()
- {
- return repository;
- }
-
- public boolean isPersistent()
- {
- return persistent;
- }
-
- public void setPersistent(boolean persistent)
- {
- this.persistent = persistent;
- }
-
- public CDOClassRef getObjectType(IStoreReader storeReader, CDOID id)
- {
- CDOClassRef type = objectTypes.get(id);
- if (type == null && persistent)
- {
- type = persistentLoadType(id);
- }
-
- if (type == null && storeReader != null)
- {
- type = storeReader.readObjectType(id);
- }
-
- if (type == null)
- {
- throw new ImplementationError("Type not found for id " + id);
- }
-
- objectTypes.put(id, type);
- return type;
- }
-
- public void registerObjectType(CDOID id, CDOClassRef type)
- {
- objectTypes.putIfAbsent(id, type);
- if (persistent)
- {
- addWork(new ObjectEntry(id, type));
- }
- }
-
- protected CDOClassRef persistentLoadType(CDOID id)
- {
- TypeEntry entry = null;
- if (id.isMeta())
- {
- if (objectTypeMap != null)
- {
- entry = objectTypeMap.get(id);
- }
- }
- else
- {
- if (metaObjectTypeMap != null)
- {
- entry = metaObjectTypeMap.get(id);
- }
- }
-
- if (entry == null)
- {
- return null;
- }
-
- String packageURI = packageURIMap.get(entry.getPackageID());
- return new CDOClassRefImpl(packageURI, entry.getClassifierID());
- }
-
- @Override
- protected void work(WorkContext context, ObjectEntry element)
- {
- CDOID id = element.getID();
- CDOClassRef type = element.getType();
- String packageURI = type.getPackageURI();
- int classifierID = type.getClassifierID();
-
- Integer packageID = packageIDMap.get(packageURI);
- if (packageID == null)
- {
- packageID = nextPackageID++;
- packageIDMap.put(packageURI, packageID);
- packageURIMap.put(packageID, packageURI);
- }
-
- TypeEntry entry = new TypeEntry(classifierID, packageID);
- if (id.isMeta())
- {
- metaObjectTypeMap.put(id, entry);
- }
- else
- {
- objectTypeMap.put(id, entry);
- }
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- if (persistent)
- {
- File stateFolder = new File(OM.BUNDLE.getStateLocation());
- File repositoryFolder = new File(stateFolder, repository.getUUID());
- IOUtil.mkdirs(repositoryFolder);
- if (TRACER.isEnabled())
- {
- TRACER.format("Repository state location: {0}", repositoryFolder.getAbsolutePath());
- }
-
- packageURIMap = new PackageURIMap(new File(repositoryFolder, "package.uris"));
- packageIDMap = new PackageIDMap(new File(repositoryFolder, "package.ids"));
- objectTypeMap = new ObjectTypeMap(new File(repositoryFolder, "object.types"));
- metaObjectTypeMap = new ObjectTypeMap(new File(repositoryFolder, "metaobject.types"));
-
- Integer max = packageURIMap.getMaxKey();
- nextPackageID = max == null ? 1 : max + 1;
- }
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- IOUtil.close(metaObjectTypeMap);
- IOUtil.close(objectTypeMap);
- IOUtil.close(packageIDMap);
- IOUtil.close(packageURIMap);
- super.doDeactivate();
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class TypeEntry
- {
- public static final int SIZE = 8;
-
- private int classifierID;
-
- private int packageID;
-
- public TypeEntry(int classifierID, int packageID)
- {
- this.classifierID = classifierID;
- this.packageID = packageID;
- }
-
- public TypeEntry(ExtendedDataInput in) throws IOException
- {
- classifierID = in.readInt();
- packageID = in.readInt();
- }
-
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeInt(classifierID);
- out.writeInt(packageID);
- }
-
- public int getClassifierID()
- {
- return classifierID;
- }
-
- public int getPackageID()
- {
- return packageID;
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class PackageURIMap extends CachedFileMap<Integer, String>
- {
- public PackageURIMap(File file)
- {
- super(file, "rw");
- }
-
- @Override
- public int getKeySize()
- {
- return 4;
- }
-
- @Override
- protected Integer readKey(ExtendedDataInput in) throws IOException
- {
- return in.readInt();
- }
-
- @Override
- protected void writeKey(ExtendedDataOutput out, Integer key) throws IOException
- {
- out.writeInt(key);
- }
-
- @Override
- public int getValueSize()
- {
- return 260;
- }
-
- @Override
- protected String readValue(ExtendedDataInput in) throws IOException
- {
- return in.readString();
- }
-
- @Override
- protected void writeValue(ExtendedDataOutput out, String value) throws IOException
- {
- byte[] bytes = value.getBytes();
- if (bytes.length + 4 > getValueSize())
- {
- throw new IllegalArgumentException("Value size of " + getValueSize() + " exceeded: " + value);
- }
-
- ExtendedIOUtil.writeByteArray(out, bytes);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class PackageIDMap extends CachedFileMap<String, Integer>
- {
- public PackageIDMap(File file)
- {
- super(file, "rw");
- }
-
- @Override
- public int getKeySize()
- {
- return 260;
- }
-
- @Override
- protected String readKey(ExtendedDataInput in) throws IOException
- {
- return in.readString();
- }
-
- @Override
- protected void writeKey(ExtendedDataOutput out, String key) throws IOException
- {
- // TODO Check length
- out.writeString(key);
- }
-
- @Override
- public int getValueSize()
- {
- return 4;
- }
-
- @Override
- protected Integer readValue(ExtendedDataInput in) throws IOException
- {
- return in.readInt();
- }
-
- @Override
- protected void writeValue(ExtendedDataOutput out, Integer value) throws IOException
- {
- out.writeInt(value);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class ObjectTypeMap extends SortedFileMap<CDOID, TypeEntry>
- {
- public ObjectTypeMap(File file)
- {
- super(file, "rw");
- }
-
- @Override
- public int getKeySize()
- {
- return 8;
- }
-
- @Override
- protected CDOID readKey(ExtendedDataInput in) throws IOException
- {
- return CDOIDImpl.read(in);
- }
-
- @Override
- protected void writeKey(ExtendedDataOutput out, CDOID key) throws IOException
- {
- CDOIDImpl.write(out, key);
- }
-
- @Override
- public int getValueSize()
- {
- return TypeEntry.SIZE;
- }
-
- @Override
- protected TypeEntry readValue(ExtendedDataInput in) throws IOException
- {
- return new TypeEntry(in);
- }
-
- @Override
- protected void writeValue(ExtendedDataOutput out, TypeEntry value) throws IOException
- {
- value.write(out);
- }
- }
-}
-
-/**
- * @author Eike Stepper
- */
-final class ObjectEntry
-{
- private CDOID id;
-
- private CDOClassRef type;
-
- public ObjectEntry(CDOID id, CDOClassRef type)
- {
- this.id = id;
- this.type = type;
- }
-
- public CDOID getID()
- {
- return id;
- }
-
- public CDOClassRef getType()
- {
- return type;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java
index 5ee45b1..c125246 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadChunkIndication.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl.MoveableList;
+import org.eclipse.emf.cdo.internal.server.Session;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
@@ -83,10 +84,11 @@ public class LoadChunkIndication extends CDOReadIndication
CDORevisionImpl revision = getRevisionManager().getRevisionByVersion(id, 0, version);
getRevisionManager().ensureChunk(revision, feature, fromIndex, toIndex + 1);
+ Session session = getSession();
MoveableList list = revision.getList(feature);
for (int i = fromIndex; i <= toIndex; i++)
{
- CDOIDImpl.write(out, getSession().provideCDOID(list.get(i)));
+ CDOIDImpl.write(out, session.provideCDOID(list.get(i)));
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryObjectTypesIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryObjectTypesIndication.java
index 8a7317d..ddc47ad 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryObjectTypesIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryObjectTypesIndication.java
@@ -12,12 +12,10 @@ package org.eclipse.emf.cdo.internal.server.protocol;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
-import org.eclipse.emf.cdo.internal.server.StoreUtil;
-import org.eclipse.emf.cdo.internal.server.TypeManager;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.server.IStoreReader;
+import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
@@ -48,26 +46,34 @@ public class QueryObjectTypesIndication extends CDOReadIndication
protected void indicating(ExtendedDataInputStream in) throws IOException
{
int size = in.readInt();
- if (PROTOCOL.isEnabled()) PROTOCOL.format("Reading {0} IDs", size);
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Reading {0} IDs", size);
+ }
ids = new CDOID[size];
for (int i = 0; i < ids.length; i++)
{
ids[i] = CDOIDImpl.read(in);
- if (PROTOCOL.isEnabled()) PROTOCOL.format("Read ID: {0}", ids[i]);
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Read ID: {0}", ids[i]);
+ }
}
}
@Override
protected void responding(ExtendedDataOutputStream out) throws IOException
{
- IStoreReader storeReader = StoreUtil.getReader();
- TypeManager typeManager = getRepository().getTypeManager();
for (CDOID id : ids)
{
- CDOClassRefImpl classRef = (CDOClassRefImpl)typeManager.getObjectType(storeReader, id);
- if (PROTOCOL.isEnabled()) PROTOCOL.format("Wrinting type: {0}", classRef);
- classRef.write(out, null);
+ CDOClassRef classRef = getSession().getObjectTypeRef(id);
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Wrinting type: {0}", classRef);
+ }
+
+ ((CDOClassRefImpl)classRef).write(out, null);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
index a36628d..a015ed6 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IRepository.java
@@ -10,8 +10,6 @@
**************************************************************************/
package org.eclipse.emf.cdo.server;
-import org.eclipse.emf.cdo.internal.server.TypeManager;
-
import org.eclipse.net4j.util.container.IContainer;
import java.util.Map;
@@ -39,8 +37,6 @@ public interface IRepository extends IContainer<IRepositoryElement>
public boolean isVerifyingRevisions();
- public TypeManager getTypeManager();
-
public IPackageManager getPackageManager();
public ISessionManager getSessionManager();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
index b302d28..f9c3611 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStore.java
@@ -54,18 +54,6 @@ public interface IStore extends IRepositoryElement
*/
public boolean hasBranchingSupport();
- /**
- * Returns if this store supports the efficient lookup of object types.
- * <p>
- * The contract includes that store implementations with efficient type lookup support must also implement
- * {@link IStoreReader#readObjectType(org.eclipse.emf.cdo.protocol.CDOID) IStoreReader.readObjectType(CDOID)} in a way
- * that it performs similar to a <code>HashMap</code> or <code>TreeMap</code>.
- *
- * @return <code>true</code> if this store supports the efficient lookup of object types, <code>false</code>
- * otherwise.
- */
- public boolean hasEfficientTypeLookup();
-
public boolean wasCrashed();
public void repairAfterCrash();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITypeManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITypeManager.java
deleted file mode 100644
index 9e6c9d3..0000000
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/ITypeManager.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/***************************************************************************
- * 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;
-
-import org.eclipse.emf.cdo.protocol.CDOID;
-import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
-
-/**
- * @author Eike Stepper
- */
-public interface ITypeManager extends IRepositoryElement
-{
- public boolean isPersistent();
-
- public CDOClassRef getObjectType(IStoreReader storeReader, CDOID id);
-
- public void registerObjectType(CDOID id, CDOClassRef type);
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java
index e74217d..7130c14 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryObjectTypesRequest.java
@@ -33,9 +33,6 @@ public class QueryObjectTypesRequest extends CDOClientRequest<CDOClassRef[]>
{
private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, QueryObjectTypesRequest.class);
- /**
- * TODO Consider single id
- */
private List<CDOID> ids;
public QueryObjectTypesRequest(IChannel channel, List<CDOID> ids)
@@ -57,14 +54,15 @@ public class QueryObjectTypesRequest extends CDOClientRequest<CDOClassRef[]>
{
PROTOCOL.format("Writing {0} IDs", ids.size());
}
- out.writeInt(ids.size());
+ out.writeInt(ids.size());
for (CDOID id : ids)
{
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Writing ID: {0}", id);
}
+
CDOIDImpl.write(out, id);
}
}