summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-15 05:45:56 (EDT)
committerEike Stepper2007-09-15 05:45:56 (EDT)
commit098ddab1aafe9e4121b3bbeb42b2cd15e2ba1535 (patch)
tree83479d29a8ed88f41db535058c46b44600d2ad7d
parentf3c35bcad0b4e54f95b7176a85811a6b9ae3a646 (diff)
downloadcdo-098ddab1aafe9e4121b3bbeb42b2cd15e2ba1535.zip
cdo-098ddab1aafe9e4121b3bbeb42b2cd15e2ba1535.tar.gz
cdo-098ddab1aafe9e4121b3bbeb42b2cd15e2ba1535.tar.bz2
[203512] Implement a NOOPStore
https://bugs.eclipse.org/bugs/show_bug.cgi?id=203512
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java52
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java154
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreChunkReader.java45
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreFactory.java36
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreUtil.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java30
8 files changed, 316 insertions, 11 deletions
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 e88e714..49c2e71 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
@@ -37,7 +37,7 @@ import java.util.Set;
*/
public class DBStore extends Store implements IDBStore
{
- private static final String TYPE = "db";
+ public static final String TYPE = "db";
private IMappingStrategy mappingStrategy;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
index 46e0b61..8c3c4ec 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreFactory.java
@@ -41,7 +41,7 @@ public class DBStoreFactory implements IStoreFactory
public String getStoreType()
{
- return "db";
+ return DBStore.TYPE;
}
public IStore createStore(Element storeConfig)
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
new file mode 100644
index 0000000..424d565
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 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.server.ISession;
+import org.eclipse.emf.cdo.server.IView;
+
+/**
+ * @author Eike Stepper
+ */
+public class NOOPStore extends Store
+{
+ public static final String TYPE = "noop";
+
+ public NOOPStore()
+ {
+ super(TYPE);
+ }
+
+ public boolean hasAuditingSupport()
+ {
+ return true;
+ }
+
+ public boolean hasBranchingSupport()
+ {
+ return false;
+ }
+
+ public boolean hasEfficientTypeLookup()
+ {
+ return true;
+ }
+
+ public NOOPStoreAccessor getReader(ISession session)
+ {
+ return new NOOPStoreAccessor(this, session);
+ }
+
+ public NOOPStoreAccessor getWriter(IView view)
+ {
+ return new NOOPStoreAccessor(this, view);
+ }
+}
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
new file mode 100644
index 0000000..d02b9fa
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java
@@ -0,0 +1,154 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 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.model.CDOPackageImpl;
+import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.protocol.CDOID;
+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.revision.CDORevision;
+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.net4j.util.io.CloseableIterator;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @author Eike Stepper
+ */
+public class NOOPStoreAccessor implements IStoreWriter
+{
+ private NOOPStore store;
+
+ private Object context;
+
+ private boolean reader;
+
+ private NOOPStoreAccessor(NOOPStore store, Object context, boolean reader)
+ {
+ this.store = store;
+ this.context = context;
+ this.reader = reader;
+ }
+
+ public NOOPStoreAccessor(NOOPStore store, ISession session)
+ {
+ this(store, session, true);
+ }
+
+ public NOOPStoreAccessor(NOOPStore store, IView view)
+ {
+ this(store, view, false);
+ }
+
+ public void release()
+ {
+ }
+
+ public NOOPStore getStore()
+ {
+ return store;
+ }
+
+ public boolean isReader()
+ {
+ return reader;
+ }
+
+ public ISession getSession()
+ {
+ if (context instanceof IView)
+ {
+ return ((IView)context).getSession();
+ }
+
+ return (ISession)context;
+ }
+
+ public IView getView()
+ {
+ if (context instanceof IView)
+ {
+ return (IView)context;
+ }
+
+ return null;
+ }
+
+ public IStoreChunkReader createChunkReader(CDORevision revision, CDOFeature feature)
+ {
+ return new NOOPStoreChunkReader(this, revision, feature);
+ }
+
+ public Collection<CDOPackageInfo> readPackageInfos()
+ {
+ return Collections.emptySet();
+ }
+
+ public void readPackage(CDOPackageImpl cdoPackage)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CloseableIterator<CDOID> readObjectIDs(boolean withTypes)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOClassRef readObjectType(CDOID id)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDORevision readRevision(CDOID id, int referenceChunk)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDORevision readRevisionByTime(CDOID id, int referenceChunk, long timeStamp)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDORevision readRevisionByVersion(CDOID id, int referenceChunk, int version)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDOID readResourceID(String path)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String readResourcePath(CDOID id)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public CDORevisionImpl verifyRevision(CDORevisionImpl revision)
+ {
+ return revision;
+ }
+
+ public void writePackages(CDOPackageImpl... cdoPackages)
+ {
+ }
+
+ public void writeRevision(CDORevisionImpl revision)
+ {
+ }
+}
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
new file mode 100644
index 0000000..166fe25
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreChunkReader.java
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 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.protocol.model.CDOFeature;
+import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+import org.eclipse.emf.cdo.server.IStoreAccessor;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class NOOPStoreChunkReader extends StoreChunkReader
+{
+ public NOOPStoreChunkReader(IStoreAccessor storeAccessor, CDORevision revision, CDOFeature feature)
+ {
+ super(storeAccessor, revision, feature);
+ }
+
+ @Override
+ public void addSimpleChunk(int index)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void addRangedChunk(int fromIndex, int toIndex)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public List<Chunk> executeRead()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreFactory.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreFactory.java
new file mode 100644
index 0000000..8f2ca17
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreFactory.java
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 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.server.IStore;
+import org.eclipse.emf.cdo.server.IStoreFactory;
+
+import org.w3c.dom.Element;
+
+/**
+ * @author Eike Stepper
+ */
+public class NOOPStoreFactory implements IStoreFactory
+{
+ public NOOPStoreFactory()
+ {
+ }
+
+ public String getStoreType()
+ {
+ return NOOPStore.TYPE;
+ }
+
+ public IStore createStore(Element storeConfig)
+ {
+ return new NOOPStore();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreUtil.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreUtil.java
index d9a2187..7e53a09 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreUtil.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server;
+import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.server.IStoreReader;
/**
@@ -23,6 +24,11 @@ public final class StoreUtil
{
}
+ public static IStore createNOOPStore()
+ {
+ return new NOOPStore();
+ }
+
public static void setReader(IStoreReader reader)
{
THREAD_LOCAL.set(reader);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
index e27e80e..a5f6d6c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java
@@ -16,13 +16,17 @@ import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.internal.server.ContainerRepositoryProvider;
import org.eclipse.emf.cdo.internal.server.Repository;
+import org.eclipse.emf.cdo.internal.server.StoreUtil;
import org.eclipse.emf.cdo.server.CDOServerUtil;
+import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.emf.cdo.server.internal.db.DBStore;
import org.eclipse.emf.cdo.server.internal.db.HorizontalMappingStrategy;
import org.eclipse.emf.cdo.tests.model1.Model1Package;
import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.internal.cdo.util.FSMUtil;
+
import org.eclipse.net4j.db.ConnectionProvider;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
@@ -30,8 +34,6 @@ import org.eclipse.net4j.db.internal.derby.DerbyAdapter;
import org.eclipse.net4j.tests.AbstractTransportTest;
import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.emf.internal.cdo.util.FSMUtil;
-
import javax.sql.DataSource;
import java.util.Properties;
@@ -58,6 +60,22 @@ public abstract class AbstractCDOTest extends AbstractTransportTest
protected Repository createRepository()
{
+ IStore store = createStore();
+ Repository repository = new Repository();
+ repository.setName(REPOSITORY_NAME);
+ repository.setStore(store);
+
+ store.setRepository(repository);
+ return repository;
+ }
+
+ protected IStore createStore()
+ {
+ return StoreUtil.createNOOPStore();
+ }
+
+ protected DBStore createDBStore()
+ {
IMappingStrategy mappingStrategy = new HorizontalMappingStrategy();
IDBAdapter dbAdapter = new DerbyAdapter();
@@ -70,13 +88,7 @@ public abstract class AbstractCDOTest extends AbstractTransportTest
DBStore store = new DBStore(mappingStrategy, dbAdapter, connectionProvider);
mappingStrategy.setStore(store);
-
- Repository repository = new Repository();
- repository.setName(REPOSITORY_NAME);
- repository.setStore(store);
-
- store.setRepository(repository);
- return repository;
+ return store;
}
@Override