summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-01-25 10:02:49 (EST)
committerEike Stepper2008-01-25 10:02:49 (EST)
commiteebaf0b3e9ef0de0d4fce7216c609395ebd70803 (patch)
treee9e8b5ee8fd24d76aa4edd472f4a12583b60f0dc
parentd6935a8d3b2272c780150e3602bc9d8a054bd7e3 (diff)
downloadcdo-eebaf0b3e9ef0de0d4fce7216c609395ebd70803.zip
cdo-eebaf0b3e9ef0de0d4fce7216c609395ebd70803.tar.gz
cdo-eebaf0b3e9ef0de0d4fce7216c609395ebd70803.tar.bz2
[216586] Provide optional pooling of store accessors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=216586
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java18
-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/MappingStrategy.java42
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStore.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStore.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java43
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/StoreAccessor.java7
9 files changed, 94 insertions, 47 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 80d441d..36d8154 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
@@ -113,12 +113,26 @@ public class DBStore extends Store implements IDBStore
return false;
}
- public DBStoreReader getReader(ISession session) throws DBException
+ @Override
+ public DBStoreReader getReader(ISession session)
+ {
+ return (DBStoreReader)super.getReader(session);
+ }
+
+ @Override
+ public DBStoreReader createReader(ISession session) throws DBException
{
return new DBStoreReader(this, session);
}
- public DBStoreWriter getWriter(IView view) throws DBException
+ @Override
+ public DBStoreWriter getWriter(IView view)
+ {
+ return (DBStoreWriter)super.getWriter(view);
+ }
+
+ @Override
+ public DBStoreWriter createWriter(IView view) throws DBException
{
return new DBStoreWriter(this, view);
}
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 afeefc1..3e88ccc 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
@@ -66,7 +66,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
}
@Override
- public void release() throws DBException
+ protected void doRelease() throws DBException
{
DBUtil.close(statement);
DBUtil.close(connection);
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 02eb156..98d9def 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
@@ -58,12 +58,6 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat
private Map<String, String> properties;
- private Precedence precedence;
-
- private ToMany toMany;
-
- private ToOne toOne;
-
private Map<Object, IDBTable> referenceTables = new HashMap<Object, IDBTable>();
private Map<Integer, CDOClassRef> classRefs = new HashMap<Integer, CDOClassRef>();
@@ -92,7 +86,7 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat
this.store = store;
}
- public Map<String, String> getProperties()
+ public synchronized Map<String, String> getProperties()
{
if (properties == null)
{
@@ -102,42 +96,27 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat
return properties;
}
- public void setProperties(Map<String, String> properties)
+ public synchronized void setProperties(Map<String, String> properties)
{
this.properties = properties;
}
public Precedence getPrecedence()
{
- if (precedence == null)
- {
- String value = getProperties().get(PROP_MAPPING_PRECEDENCE);
- precedence = value == null ? Precedence.STRATEGY : Precedence.valueOf(value);
- }
-
- return precedence;
+ String value = getProperties().get(PROP_MAPPING_PRECEDENCE);
+ return value == null ? Precedence.STRATEGY : Precedence.valueOf(value);
}
public ToMany getToMany()
{
- if (toMany == null)
- {
- String value = getProperties().get(PROP_TO_MANY_REFERENCE_MAPPING);
- toMany = value == null ? ToMany.PER_REFERENCE : ToMany.valueOf(value);
- }
-
- return toMany;
+ String value = getProperties().get(PROP_TO_MANY_REFERENCE_MAPPING);
+ return value == null ? ToMany.PER_REFERENCE : ToMany.valueOf(value);
}
public ToOne getToOne()
{
- if (toOne == null)
- {
- String value = getProperties().get(PROP_TO_ONE_REFERENCE_MAPPING);
- toOne = value == null ? ToOne.LIKE_ATTRIBUTES : ToOne.valueOf(value);
- }
-
- return toOne;
+ String value = getProperties().get(PROP_TO_ONE_REFERENCE_MAPPING);
+ return value == null ? ToOne.LIKE_ATTRIBUTES : ToOne.valueOf(value);
}
public Map<Object, IDBTable> getReferenceTables()
@@ -326,7 +305,10 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat
getStore().getDBAdapter().appendValue(builder, whereField, whereValue);
String sql = builder.toString();
- if (TRACER.isEnabled()) TRACER.trace(sql);
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(sql);
+ }
ResultSet resultSet = null;
try
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 ab731f6..7cdd01f 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
@@ -150,12 +150,14 @@ public class MEMStore extends Store
{
}
- public MEMStoreAccessor getReader(ISession session)
+ @Override
+ public MEMStoreAccessor createReader(ISession session)
{
return new MEMStoreAccessor(this, session);
}
- public MEMStoreAccessor getWriter(IView view)
+ @Override
+ public MEMStoreAccessor createWriter(IView view)
{
return new MEMStoreAccessor(this, view);
}
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 15b9e13..bf0cc1e 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
@@ -146,12 +146,6 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt
newRevisions.add(newRevision);
}
- @Override
- public void release()
- {
- newRevisions.clear();
- }
-
public void commit()
{
MEMStore store = getStore();
@@ -164,4 +158,10 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt
public void rollback()
{
}
+
+ @Override
+ protected void doRelease()
+ {
+ newRevisions.clear();
+ }
}
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 dcb2c84..5033b39 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,12 +35,14 @@ public class NOOPStore extends Store
{
}
- public NOOPStoreAccessor getReader(ISession session)
+ @Override
+ public NOOPStoreAccessor createReader(ISession session)
{
return new NOOPStoreAccessor(this, session);
}
- public NOOPStoreAccessor getWriter(IView view)
+ @Override
+ public NOOPStoreAccessor createWriter(IView view)
{
return new NOOPStoreAccessor(this, view);
}
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 3295cc2..45fbfbe 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
@@ -16,7 +16,6 @@ import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.server.IRepository;
import org.eclipse.emf.cdo.server.IRepositoryElement;
import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.server.IRepository.Props;
import org.eclipse.net4j.internal.util.container.Container;
import org.eclipse.net4j.util.StringUtil;
@@ -95,7 +94,7 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
return uuid;
}
- public Map<String, String> getProperties()
+ public synchronized Map<String, String> getProperties()
{
if (properties == null)
{
@@ -105,7 +104,7 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
return properties;
}
- public void setProperties(Map<String, String> properties)
+ public synchronized void setProperties(Map<String, String> properties)
{
this.properties = properties;
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
index f6c3e1e..000e84b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Store.java
@@ -13,10 +13,18 @@ package org.eclipse.emf.cdo.internal.server;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOIDUtil;
import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.IStoreAccessor;
+import org.eclipse.emf.cdo.server.IStoreReader;
+import org.eclipse.emf.cdo.server.IStoreWriter;
+import org.eclipse.emf.cdo.server.IView;
import org.eclipse.net4j.internal.util.lifecycle.Lifecycle;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* @author Eike Stepper
*/
@@ -26,6 +34,8 @@ public abstract class Store extends Lifecycle implements IStore
private String type;
+ private Map<String, String> properties;
+
private IRepository repository;
private long nextOIDValue = INITIAL_OID_VALUE;
@@ -40,6 +50,21 @@ public abstract class Store extends Lifecycle implements IStore
return type;
}
+ public synchronized Map<String, String> getProperties()
+ {
+ if (properties == null)
+ {
+ properties = new HashMap<String, String>();
+ }
+
+ return properties;
+ }
+
+ public synchronized void setProperties(Map<String, String> properties)
+ {
+ this.properties = properties;
+ }
+
public IRepository getRepository()
{
return repository;
@@ -87,4 +112,22 @@ public abstract class Store extends Lifecycle implements IStore
{
return false;
}
+
+ public IStoreReader getReader(ISession session)
+ {
+ return createReader(session);
+ }
+
+ protected abstract IStoreReader createReader(ISession session);
+
+ public IStoreWriter getWriter(IView view)
+ {
+ return createWriter(view);
+ }
+
+ protected abstract IStoreWriter createWriter(IView view);
+
+ protected void releaseAccessor(IStoreAccessor accessor)
+ {
+ }
}
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 589a769..6254797 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
@@ -48,7 +48,12 @@ public class StoreAccessor implements IStoreAccessor
this(store, view, false);
}
- public void release()
+ public final void release()
+ {
+ store.releaseAccessor(this);
+ }
+
+ protected void doRelease()
{
}