Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McDuff2008-07-10 15:33:55 -0400
committerSimon McDuff2008-07-10 15:33:55 -0400
commit913cec61d57cfbc270f67ff0bb0fb9ddce733d22 (patch)
tree1fdc7ff7a5323941c939627614f1fff7cb6664c5
parenta6eca3ba9bbe689416e14f6dcc306f26ee140c33 (diff)
downloadcdo-913cec61d57cfbc270f67ff0bb0fb9ddce733d22.tar.gz
cdo-913cec61d57cfbc270f67ff0bb0fb9ddce733d22.tar.xz
cdo-913cec61d57cfbc270f67ff0bb0fb9ddce733d22.zip
[238414] Merge simon_pre_0_9 to HEAD
https://bugs.eclipse.org/bugs/show_bug.cgi?id=238414
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ResultReaderQueue.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ResultWriterQueue.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOInstanceUtil.java31
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PollIterator.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PropertyChanged.java46
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/StateConcurrentQueue.java17
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOAbstractQueryResultImpl.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOQueryParameterImpl.java120
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOQueryState.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryResult.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryResultIteratorImpl.java20
11 files changed, 126 insertions, 148 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ResultReaderQueue.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ResultReaderQueue.java
index 3e81a46344..b0668d9265 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ResultReaderQueue.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ResultReaderQueue.java
@@ -12,12 +12,24 @@ package org.eclipse.emf.cdo.common.query;
import org.eclipse.net4j.util.collection.CloseableIterator;
-import java.util.concurrent.Future;
-
/**
* @author Simon McDuff
* @since 2.0
*/
-public interface ResultReaderQueue<T> extends CloseableIterator<T>, Future<T>
+public interface ResultReaderQueue<T> extends CloseableIterator<T>
{
+ /**
+ * Returns <tt>true</tt> if this task was cancelled before it completed normally.
+ *
+ * @return <tt>true</tt> if this task was cancelled before it completed
+ */
+ boolean isCancelled();
+
+ /**
+ * Returns <tt>true</tt> if this task completed. Completion may be due to normal termination, an exception, or
+ * cancellation -- in all of these cases, this method will return <tt>true</tt>.
+ *
+ * @return <tt>true</tt> if this task completed
+ */
+ boolean isDone();
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ResultWriterQueue.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ResultWriterQueue.java
index 91b0b94622..b3ad1c244a 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ResultWriterQueue.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ResultWriterQueue.java
@@ -17,8 +17,8 @@ import java.util.Queue;
* @since 2.0
*/
public interface ResultWriterQueue<E> extends Queue<E>
-{
+{
void setException(RuntimeException exception);
-
+
void release();
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOInstanceUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOInstanceUtil.java
index b4adf3c9a7..457fca17ef 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOInstanceUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOInstanceUtil.java
@@ -33,7 +33,7 @@ import java.util.Map;
public class CDOInstanceUtil
{
public static Map<Class<?>, CDOType> idTypes = new HashMap<Class<?>, CDOType>();
-
+
static
{
idTypes.put(String.class, CDOType.STRING);
@@ -63,12 +63,13 @@ public class CDOInstanceUtil
CDOModelUtil.writeClassRef(out, ((CDOClass)id).createClassRef(), null);
return;
}
-
+
out.writeByte(1);
-
+
writeInstance(out, id);
}
+
/**
* @param out
* @param id
@@ -84,23 +85,24 @@ public class CDOInstanceUtil
{
id = ((CDORevision)id).getID();
}
-
+
CDOType type = null;
-
+
if (id instanceof CDOID)
{
type = CDOType.OBJECT;
}
else
{
- type = idTypes.get(id.getClass());
+ type = idTypes.get(id.getClass());
}
-
+
if (type == null) throw new IllegalStateException("No type for object " + id.getClass());
CDOModelUtil.writeType(out, type);
type.writeValue(out, id);
}
+
/**
* @param out
* @param id
@@ -108,14 +110,15 @@ public class CDOInstanceUtil
*/
static public Object readInstance(ExtendedDataInput in, CDOIDObjectFactory objectFactory) throws IOException
{
- CDOType type = CDOModelUtil.readType(in);
- return type.readValue(in, objectFactory);
+ CDOType type = CDOModelUtil.readType(in);
+ return type.readValue(in, objectFactory);
}
-
- static public Object readObject(ExtendedDataInput in, CDOIDObjectFactory objectFactory, CDOPackageManager packageManager) throws IOException
+
+ static public Object readObject(ExtendedDataInput in, CDOIDObjectFactory objectFactory,
+ CDOPackageManager packageManager) throws IOException
{
byte value = in.readByte();
-
+
if (value == 0)
{
return CDOModelUtil.readClassRef(in).resolve(packageManager);
@@ -123,7 +126,7 @@ public class CDOInstanceUtil
else if (value == 1)
{
readInstance(in, objectFactory);
- }
+ }
throw new IllegalStateException();
- }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PollIterator.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PollIterator.java
index 9a3f1d441d..15cb327033 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PollIterator.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PollIterator.java
@@ -39,7 +39,7 @@ public class PollIterator<E> implements Iterator<E>
}
catch (InterruptedException ex)
{
- Thread.currentThread().interrupt();
+ Thread.currentThread().interrupt();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PropertyChanged.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PropertyChanged.java
index efd4128992..03215bc149 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PropertyChanged.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PropertyChanged.java
@@ -10,7 +10,6 @@
**************************************************************************/
package org.eclipse.emf.cdo.common.util;
-
/**
* @author Simon McDuff
* @since 2.0
@@ -18,48 +17,48 @@ package org.eclipse.emf.cdo.common.util;
public class PropertyChanged<T>
{
Object notifier = new Object();
-
+
T value;
-
+
RuntimeException exception = null;
-
+
public PropertyChanged(T value)
{
this.value = value;
}
-
+
public T get()
{
return value;
}
-
+
public void set(T newValue)
{
- synchronized(notifier)
+ synchronized (notifier)
{
value = newValue;
notifier.notifyAll();
}
}
-
+
public void setException(RuntimeException exception)
{
- synchronized(notifier)
+ synchronized (notifier)
{
this.exception = exception;
notifier.notifyAll();
}
}
-
+
public void acquire(Object accept, Object refuse)
{
acquire(accept, refuse, 0);
}
-
+
public void acquire(Object accept, Object refuse, long timeout)
{
- synchronized(notifier)
- {
+ synchronized (notifier)
+ {
while (!equalToOneElement(accept, refuse))
{
try
@@ -73,19 +72,16 @@ public class PropertyChanged<T>
}
}
}
-
+
private boolean equalToOneElement(Object accept, Object refuse)
{
- if (this.exception != null)
- throw this.exception;
-
- if (accept != null && accept.equals(value))
- return true;
-
- if (refuse != null && refuse.equals(value))
- throw new IllegalStateException();
-
- return false;
+ if (this.exception != null) throw this.exception;
+
+ if (accept != null && accept.equals(value)) return true;
+
+ if (refuse != null && refuse.equals(value)) throw new IllegalStateException();
+
+ return false;
}
-
+
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/StateConcurrentQueue.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/StateConcurrentQueue.java
index 5ac5e40395..c6f9d82480 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/StateConcurrentQueue.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/StateConcurrentQueue.java
@@ -21,11 +21,11 @@ import java.util.concurrent.ConcurrentLinkedQueue;
public class StateConcurrentQueue<E> extends ConcurrentLinkedQueue<E> implements ResultWriterQueue<E>
{
private static final long serialVersionUID = 1L;
-
+
private boolean done = false;
private RuntimeException exception = null;
-
+
public StateConcurrentQueue()
{
}
@@ -34,7 +34,7 @@ public class StateConcurrentQueue<E> extends ConcurrentLinkedQueue<E> implements
{
this.exception = exception;
}
-
+
public E poll()
{
if (exception != null) throw exception;
@@ -49,20 +49,11 @@ public class StateConcurrentQueue<E> extends ConcurrentLinkedQueue<E> implements
public void release()
{
- done = true;
+ done = true;
}
public void setException(RuntimeException exception)
{
this.exception = exception;
}
-
- public void isReleased()
- {
- synchronized(this)
- {
-
- }
- }
-
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOAbstractQueryResultImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOAbstractQueryResultImpl.java
index 8c7e0cc871..523c4d3039 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOAbstractQueryResultImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOAbstractQueryResultImpl.java
@@ -22,11 +22,10 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-
/**
* @author Simon McDuff
*/
-public abstract class CDOAbstractQueryResultImpl<T> extends Lifecycle implements ResultReaderQueue<T>
+public abstract class CDOAbstractQueryResultImpl<T> extends Lifecycle implements ResultReaderQueue<T>
{
protected long queryID = -1;
@@ -35,17 +34,17 @@ public abstract class CDOAbstractQueryResultImpl<T> extends Lifecycle implement
protected StateConcurrentQueue<Object> queue = new StateConcurrentQueue<Object>();
protected Iterator<Object> nextObject = new PollIterator<Object>(queue);
-
+
public CDOAbstractQueryResultImpl(CDOQueryParameter cdoQueryParameter)
{
this.cdoQueryParameter = cdoQueryParameter;
}
-
+
public ResultWriterQueue<Object> getResultQueue()
{
return queue;
}
-
+
public void setQueryID(long queryID)
{
this.queryID = queryID;
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOQueryParameterImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOQueryParameterImpl.java
index 654fc409a4..e56e43a0dd 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOQueryParameterImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOQueryParameterImpl.java
@@ -22,71 +22,71 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+
/**
* @author Simon McDuff
*/
public class CDOQueryParameterImpl implements CDOQueryParameter
{
- private String queryLanguage;
-
- private String queryString;
-
- private Map<String, Object> parameters = new HashMap<String, Object>();
-
- private int maxResult = -1;
-
- public CDOQueryParameterImpl(String language, String queryString)
- {
- this.queryLanguage = language;
- this.queryString = queryString;
- }
-
- public CDOQueryParameterImpl(ExtendedDataInput in, CDOIDObjectFactory objectFactory, CDOPackageManager packageManager) throws IOException
- {
- queryLanguage = in.readString();
- queryString = in.readString();
- maxResult = in.readInt();
-
- int size = in.readInt();
- for (int i =0; i< size; i++)
- {
- String key = in.readString();
- Object object = CDOInstanceUtil.readObject(in, objectFactory, packageManager);
- parameters.put(key, object);
- }
- }
-
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeString(queryLanguage);
- out.writeString(queryString);
- out.writeInt(maxResult);
-
- out.writeInt(parameters.size());
- for (Entry<String, Object> entry : parameters.entrySet())
- {
- out.writeString(entry.getKey());
- Object value = entry.getValue();
- CDOInstanceUtil.writeObject(out, value);
- }
- }
-
-
-
- public String getQueryString()
- {
- return queryString;
- }
-
- public String getQueryLanguage()
- {
- return this.queryLanguage;
- }
-
- public Map<String, Object> getParameters()
- {
- return parameters;
- }
+ private String queryLanguage;
+
+ private String queryString;
+
+ private Map<String, Object> parameters = new HashMap<String, Object>();
+
+ private int maxResult = -1;
+
+ public CDOQueryParameterImpl(String language, String queryString)
+ {
+ this.queryLanguage = language;
+ this.queryString = queryString;
+ }
+
+ public CDOQueryParameterImpl(ExtendedDataInput in, CDOIDObjectFactory objectFactory, CDOPackageManager packageManager)
+ throws IOException
+ {
+ queryLanguage = in.readString();
+ queryString = in.readString();
+ maxResult = in.readInt();
+
+ int size = in.readInt();
+ for (int i = 0; i < size; i++)
+ {
+ String key = in.readString();
+ Object object = CDOInstanceUtil.readObject(in, objectFactory, packageManager);
+ parameters.put(key, object);
+ }
+ }
+
+ public void write(ExtendedDataOutput out) throws IOException
+ {
+ out.writeString(queryLanguage);
+ out.writeString(queryString);
+ out.writeInt(maxResult);
+
+ out.writeInt(parameters.size());
+ for (Entry<String, Object> entry : parameters.entrySet())
+ {
+ out.writeString(entry.getKey());
+ Object value = entry.getValue();
+ CDOInstanceUtil.writeObject(out, value);
+ }
+ }
+
+ public String getQueryString()
+ {
+ return queryString;
+ }
+
+ public String getQueryLanguage()
+ {
+ return this.queryLanguage;
+ }
+
+ public Map<String, Object> getParameters()
+ {
+ return parameters;
+ }
public int getMaxResult()
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOQueryState.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOQueryState.java
index 8bd3b608e1..501ccb1236 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOQueryState.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/query/CDOQueryState.java
@@ -15,8 +15,5 @@ package org.eclipse.emf.cdo.internal.common.query;
*/
public enum CDOQueryState
{
- INIT,
- ACTIVAT,
- DONE,
- CANCEL
+ INIT, ACTIVAT, DONE, CANCEL
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryResult.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryResult.java
index 79dc0c969b..dbb56a4d35 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryResult.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryResult.java
@@ -56,7 +56,7 @@ public class QueryResult
{
return view;
}
-
+
public long getQueryID()
{
return queryID;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryResultIteratorImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryResultIteratorImpl.java
index 11dd0c81be..4117ab8bb2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryResultIteratorImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryResultIteratorImpl.java
@@ -21,10 +21,6 @@ import org.eclipse.emf.internal.cdo.protocol.QueryCancelRequest;
import org.eclipse.net4j.util.lifecycle.ILifecycleState;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
/**
* @author Simon McDuff
*/
@@ -100,22 +96,6 @@ public class CDOQueryResultIteratorImpl<T> extends CDOAbstractQueryResultImpl<T>
}
}
- public boolean cancel(boolean arg0)
- {
- close();
- return true;
- }
-
- public T get() throws InterruptedException, ExecutionException
- {
- return null;
- }
-
- public T get(long arg0, TimeUnit arg1) throws InterruptedException, ExecutionException, TimeoutException
- {
- return null;
- }
-
public boolean isCancelled()
{
return cancelled;

Back to the top