Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McDuff2008-08-07 20:59:19 -0400
committerSimon McDuff2008-08-07 20:59:19 -0400
commit5d9ea2ef3f568c69a9a47c0ddf5a758520128855 (patch)
tree8096fb626893f5019f2e670f06087e664f852259
parent2b840620662924b4ba7141411498c3f92cb73640 (diff)
downloadcdo-5d9ea2ef3f568c69a9a47c0ddf5a758520128855.tar.gz
cdo-5d9ea2ef3f568c69a9a47c0ddf5a758520128855.tar.xz
cdo-5d9ea2ef3f568c69a9a47c0ddf5a758520128855.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/CDOProtocolConstants.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryInfo.java36
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryQueue.java (renamed from plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryParameter.java)10
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ExceptionHolder.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQueryResult.java)13
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreQueryIterator.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NOOPStoreAccessor.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NotificationManager.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryManager.java39
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryResult.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQuery.java36
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOAutoAttacher.java51
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java35
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOEList.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/ECDOList.java)16
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java92
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryResultIteratorImpl.java91
22 files changed, 273 insertions, 306 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocolConstants.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocolConstants.java
index 868e63de2f..ce52ca6ab1 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocolConstants.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOProtocolConstants.java
@@ -84,4 +84,20 @@ public interface CDOProtocolConstants
public static final byte VIEW_READONLY = 3;
public static final byte VIEW_CLOSED = 4;
+
+ /**
+ * @since 2.0
+ */
+ public static final byte QUERY_MORE_OBJECT = 0;
+
+ /**
+ * @since 2.0
+ */
+ public static final byte QUERY_DONE = 1;
+
+ /**
+ * @since 2.0
+ */
+ public static final byte QUERY_EXCEPTION = 2;
+
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryInfo.java
new file mode 100644
index 0000000000..5449eecddd
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryInfo.java
@@ -0,0 +1,36 @@
+/***************************************************************************
+ * 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:
+ * Simon McDuff - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.cdo.common.query;
+
+import java.util.Map;
+
+/**
+ * @author Simon McDuff
+ * @since 2.0
+ */
+public interface CDOQueryInfo
+{
+ String getQueryLanguage();
+
+ String getQueryString();
+
+ Map<String, Object> getParameters();
+
+ /**
+ * Get the maximum number of results to retrieve.
+ *
+ * @param maxResult
+ * @return the same query instance
+ * @throws IllegalArgumentException
+ * if argument is negative
+ */
+ int getMaxResults();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryParameter.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryQueue.java
index 46926a75cf..38e6757039 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryParameter.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryQueue.java
@@ -10,19 +10,13 @@
**************************************************************************/
package org.eclipse.emf.cdo.common.query;
-import java.util.Map;
+import org.eclipse.emf.cdo.common.util.CloseableQueue;
/**
* @author Simon McDuff
* @since 2.0
*/
-public interface CDOQueryParameter
+public interface CDOQueryQueue<E> extends CloseableQueue<E>, ExceptionHolder
{
- String getQueryLanguage();
- String getQueryString();
-
- Map<String, Object> getParameters();
-
- int getMaxResult();
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQueryResult.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ExceptionHolder.java
index 613c6fbcb3..115da6ad77 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQueryResult.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/ExceptionHolder.java
@@ -8,20 +8,13 @@
* Contributors:
* Simon McDuff - initial API and implementation
**************************************************************************/
-package org.eclipse.emf.cdo.query;
-
-import org.eclipse.emf.cdo.common.query.ResultReaderQueue;
+package org.eclipse.emf.cdo.common.query;
/**
* @author Simon McDuff
* @since 2.0
*/
-public interface CDOQueryResult<T> extends ResultReaderQueue<T>
+public interface ExceptionHolder
{
- /**
- * It will throw an exception if not running.
- * <p>
- * Use close to terminate the query without throwing an exception
- */
- void cancel();
+ void setException(Throwable exception);
}
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 d3ee7bacc2..1c470f73d5 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
@@ -18,7 +18,7 @@ import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.model.CDOPackage;
import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
import org.eclipse.emf.cdo.common.model.resource.CDOPathFeature;
-import org.eclipse.emf.cdo.common.query.CDOQueryParameter;
+import org.eclipse.emf.cdo.common.query.CDOQueryInfo;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
@@ -194,14 +194,13 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt
/**
* @since 2.0
*/
- public CloseableIterator<Object> createQueryIterator(CDOQueryParameter queryParameter)
+ public CloseableIterator<Object> createQueryIterator(CDOQueryInfo queryInfo)
{
- if (queryParameter.getQueryLanguage().equals("TEST"))
+ if (queryInfo.getQueryLanguage().equals("TEST"))
{
- // queryParameter.getQueryString().equals("SLOW");
MEMStoreQueryIterator queryExecution = new MEMStoreQueryIterator(this.getStore());
- Object context = queryParameter.getParameters().get("context");
+ Object context = queryInfo.getParameters().get("context");
if (context != null)
{
@@ -227,7 +226,7 @@ public class MEMStoreAccessor extends StoreAccessor implements IStoreReader, ISt
return queryExecution;
}
- throw new RuntimeException("Unsupported language " + queryParameter.getQueryLanguage());
+ throw new RuntimeException("Unsupported language " + queryInfo.getQueryLanguage());
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreQueryIterator.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreQueryIterator.java
index 657e2ed2c2..506c60dc48 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreQueryIterator.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreQueryIterator.java
@@ -93,4 +93,9 @@ public class MEMStoreQueryIterator implements CloseableIterator<Object>
{
}
+ public boolean isClosed()
+ {
+ return false;
+ }
+
}
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 bbd048552d..3cf21c3e45 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
@@ -15,7 +15,7 @@ import org.eclipse.emf.cdo.common.model.CDOClassRef;
import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.model.CDOPackage;
import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
-import org.eclipse.emf.cdo.common.query.CDOQueryParameter;
+import org.eclipse.emf.cdo.common.query.CDOQueryInfo;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.server.ISession;
import org.eclipse.emf.cdo.server.IStoreChunkReader;
@@ -102,7 +102,7 @@ public class NOOPStoreAccessor extends StoreAccessor implements IStoreReader, IS
/**
* @since 2.0
*/
- public CloseableIterator<Object> createQueryIterator(CDOQueryParameter queryParameter)
+ public CloseableIterator<Object> createQueryIterator(CDOQueryInfo queryInfo)
{
throw new UnsupportedOperationException();
}
@@ -113,5 +113,5 @@ public class NOOPStoreAccessor extends StoreAccessor implements IStoreReader, IS
public void refreshRevisions()
{
}
-
+
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NotificationManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NotificationManager.java
index f157362b4c..d8358ca1e2 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NotificationManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/NotificationManager.java
@@ -16,6 +16,8 @@ import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.server.INotificationManager;
import org.eclipse.emf.cdo.server.IStoreWriter.CommitContext;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+
import java.util.ArrayList;
import java.util.List;
@@ -23,7 +25,7 @@ import java.util.List;
* @author Simon McDuff
* @since 2.0
*/
-public class NotificationManager implements INotificationManager
+public class NotificationManager extends Lifecycle implements INotificationManager
{
private Repository repository = null;
@@ -37,7 +39,7 @@ public class NotificationManager implements INotificationManager
CDORevisionDelta[] dirtyID = commitContext.getDirtyObjectDeltas();
int modifications = dirtyID == null ? 0 : dirtyID.length;
-
+
if (modifications > 0)
{
List<CDOIDAndVersion> dirtyIDs = new ArrayList<CDOIDAndVersion>(modifications);
@@ -52,9 +54,9 @@ public class NotificationManager implements INotificationManager
}
SessionManager sessionManager = (SessionManager)repository.getSessionManager();
-
+
sessionManager.handleCommitNotification(commitContext.getTimeStamp(), dirtyIDs, deltas, session);
}
-
+
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryManager.java
index 076c9dfd5b..c02b137706 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/QueryManager.java
@@ -10,8 +10,8 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server;
-import org.eclipse.emf.cdo.common.query.CDOQueryParameter;
-import org.eclipse.emf.cdo.common.query.ResultWriterQueue;
+import org.eclipse.emf.cdo.common.query.CDOQueryInfo;
+import org.eclipse.emf.cdo.common.query.CDOQueryQueue;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.server.IStoreReader;
import org.eclipse.emf.cdo.server.IView;
@@ -22,6 +22,7 @@ import org.eclipse.net4j.util.container.SingleDeltaContainerEvent;
import org.eclipse.net4j.util.container.IContainerDelta.Kind;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.util.Map;
@@ -34,7 +35,7 @@ import java.util.concurrent.Future;
* @author Simon McDuff
* @since 2.0
*/
-public class QueryManager
+public class QueryManager extends Lifecycle
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SESSION, QueryManager.class);
@@ -59,7 +60,7 @@ public class QueryManager
{
Future<?> future = executors.submit(queryContext);
- registerQueryNative(queryContext, future);
+ register(queryContext, future);
return future;
}
@@ -114,38 +115,38 @@ public class QueryManager
public void run()
{
- ResultWriterQueue<Object> resultQueue = queryResult.getResultWriterQueue();
+ CDOQueryQueue<Object> resultQueue = queryResult.getQueue();
CloseableIterator<Object> itrResult = null;
try
{
- itrResult = reader.createQueryIterator(queryResult.getQueryParameter());
+ itrResult = reader.createQueryIterator(queryResult.getQueryInfo());
- int maxResult = queryResult.getQueryParameter().getMaxResult();
+ int maxResult = queryResult.getQueryInfo().getMaxResults();
- if (maxResult < 0) maxResult = Integer.MAX_VALUE;
+ if (maxResult < 0)
+ {
+ maxResult = Integer.MAX_VALUE;
+ }
for (int i = 0; i < maxResult && itrResult.hasNext(); i++)
{
resultQueue.add(itrResult.next());
}
}
- catch (RuntimeException exception)
- {
- resultQueue.setException(exception);
- }
+
catch (Throwable exception)
{
- resultQueue.setException(new RuntimeException(exception));
+ resultQueue.setException(exception);
}
finally
{
- resultQueue.release();
+ resultQueue.close();
if (itrResult != null) itrResult.close();
- unregisterQueryNative(this);
+ unregister(this);
}
}
@@ -156,10 +157,10 @@ public class QueryManager
}
}
- public QueryResult execute(IView view, CDOQueryParameter queryParameter)
+ public QueryResult execute(IView view, CDOQueryInfo queryInfo)
{
- QueryResult queryResult = new QueryResult(view, queryParameter, nextQuery());
+ QueryResult queryResult = new QueryResult(view, queryInfo, nextQuery());
QueryContext queryContext = new QueryContext(StoreUtil.getReader(), queryResult);
@@ -187,14 +188,14 @@ public class QueryManager
queryContext.cancel(true);
}
- synchronized public void registerQueryNative(final QueryContext queryContext, Future<?> future)
+ synchronized public void register(final QueryContext queryContext, Future<?> future)
{
queryContexts.put(queryContext.getQueryResult().getQueryID(), queryContext);
associateThreads.put(queryContext.getQueryResult().getQueryID(), future);
queryContext.addListener();
}
- synchronized public void unregisterQueryNative(final QueryContext queryContext)
+ synchronized public void unregister(final QueryContext queryContext)
{
queryContexts.remove(queryContext.getQueryResult().getQueryID());
associateThreads.remove(queryContext.getQueryResult().getQueryID());
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 dbb56a4d35..33c35f424c 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
@@ -10,71 +10,23 @@
**************************************************************************/
package org.eclipse.emf.cdo.internal.server;
-import org.eclipse.emf.cdo.common.CDOProtocolView;
-import org.eclipse.emf.cdo.common.query.CDOQueryParameter;
-import org.eclipse.emf.cdo.common.query.ResultWriterQueue;
-import org.eclipse.emf.cdo.common.util.PollIterator;
-import org.eclipse.emf.cdo.common.util.StateConcurrentQueue;
+import org.eclipse.emf.cdo.common.query.CDOQueryInfo;
+import org.eclipse.emf.cdo.internal.common.query.AbstractQueryResult;
import org.eclipse.emf.cdo.server.IView;
-import java.util.Iterator;
-
/**
* @author Simon McDuff
* @since 2.0
*/
-public class QueryResult
+public class QueryResult extends AbstractQueryResult<Object>
{
- private long queryID;
-
- private CDOProtocolView view;
-
- private CDOQueryParameter queryParameter;
-
- private StateConcurrentQueue<Object> linkQueue = new StateConcurrentQueue<Object>();
-
- protected Iterator<Object> nextObject = new PollIterator<Object>(linkQueue);
-
- public QueryResult(IView view, CDOQueryParameter parameter, long queryID)
+ public QueryResult(IView view, CDOQueryInfo parameter, long queryID)
{
- this.queryID = queryID;
- this.view = view;
- this.queryParameter = parameter;
+ super(view, parameter, queryID);
}
- public CDOQueryParameter getQueryParameter()
+ public IView getView()
{
- return queryParameter;
+ return (IView)super.getView();
}
-
- public ResultWriterQueue<Object> getResultWriterQueue()
- {
- return linkQueue;
- }
-
- public CDOProtocolView getView()
- {
- return view;
- }
-
- public long getQueryID()
- {
- return queryID;
- }
-
- public boolean hasNext()
- {
- return nextObject.hasNext();
- }
-
- public Object next()
- {
- return nextObject.next();
- }
-
- public boolean hasNextNow()
- {
- return !linkQueue.isEmpty();
- }
-
}
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 b9e40690ac..71c6f0142d 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
@@ -310,6 +310,8 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
LifecycleUtil.activate(sessionManager);
LifecycleUtil.activate(resourceManager);
LifecycleUtil.activate(revisionManager);
+ LifecycleUtil.activate(queryManager);
+ LifecycleUtil.activate(notificationManager);
}
protected void deactivateRepository()
@@ -318,6 +320,8 @@ public class Repository extends Container<IRepositoryElement> implements IReposi
LifecycleUtil.deactivate(resourceManager);
LifecycleUtil.deactivate(sessionManager);
LifecycleUtil.deactivate(packageManager);
+ LifecycleUtil.deactivate(queryManager);
+ LifecycleUtil.deactivate(notificationManager);
LifecycleUtil.deactivate(store);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java
index b5ede84371..f0db082c29 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/QueryIndication.java
@@ -11,9 +11,9 @@
package org.eclipse.emf.cdo.internal.server.protocol;
import org.eclipse.emf.cdo.common.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.query.CDOQueryParameter;
+import org.eclipse.emf.cdo.common.query.CDOQueryInfo;
import org.eclipse.emf.cdo.common.util.CDOInstanceUtil;
-import org.eclipse.emf.cdo.internal.common.query.CDOQueryParameterImpl;
+import org.eclipse.emf.cdo.internal.common.query.CDOQueryInfoImpl;
import org.eclipse.emf.cdo.internal.server.QueryManager;
import org.eclipse.emf.cdo.internal.server.QueryResult;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
@@ -50,7 +50,7 @@ public class QueryIndication extends CDOReadIndication
{
int viewID = in.readInt();
- CDOQueryParameter cdoQuery = new CDOQueryParameterImpl(in, getStore().getCDOIDObjectFactory(), getPackageManager());
+ CDOQueryInfo cdoQuery = new CDOQueryInfoImpl(in, getStore().getCDOIDObjectFactory(), getPackageManager());
IView view = getSession().getView(viewID);
@@ -78,14 +78,12 @@ public class QueryIndication extends CDOReadIndication
// Object to return
numberOfResult++;
- out.writeByte(0);
- CDOInstanceUtil.writeInstance(out, object);
+ out.writeByte(CDOProtocolConstants.QUERY_MORE_OBJECT);
+ CDOInstanceUtil.writeObject(out, object);
- if (!queryResult.hasNextNow())
+ if (queryResult.peek() == null)
{
- // Flush only if empty
out.flush();
-
}
}
if (TRACER.isEnabled())
@@ -93,8 +91,8 @@ public class QueryIndication extends CDOReadIndication
TRACER.trace("Query had " + numberOfResult + " objects return");
}
- // DONE
- out.writeByte(1);
+ // Query is done successfully
+ out.writeByte(CDOProtocolConstants.QUERY_DONE);
}
catch (Exception exception)
{
@@ -103,8 +101,8 @@ public class QueryIndication extends CDOReadIndication
TRACER.trace(exception);
}
- // Exception occured
- out.writeByte(2);
+ // Exception occured during the query
+ out.writeByte(CDOProtocolConstants.QUERY_EXCEPTION);
out.writeString(exception.getMessage());
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
index ba0e811c26..5d35d5ac14 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
@@ -16,7 +16,7 @@ import org.eclipse.emf.cdo.common.model.CDOClassRef;
import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.model.CDOPackage;
import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
-import org.eclipse.emf.cdo.common.query.CDOQueryParameter;
+import org.eclipse.emf.cdo.common.query.CDOQueryInfo;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.net4j.util.collection.CloseableIterator;
@@ -32,11 +32,11 @@ public interface IStoreReader extends IStoreAccessor
public ISession getSession();
public IStoreChunkReader createChunkReader(CDORevision revision, CDOFeature feature);
-
+
/**
* @since 2.0
*/
- public CloseableIterator<Object> createQueryIterator(CDOQueryParameter queryParameter);
+ public CloseableIterator<Object> createQueryIterator(CDOQueryInfo queryInfo);
public Collection<CDOPackageInfo> readPackageInfos();
@@ -76,7 +76,7 @@ public interface IStoreReader extends IStoreAccessor
public String readResourcePath(CDOID id);
public CDORevision verifyRevision(CDORevision revision);
-
+
/**
* @since 2.0
*/
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQuery.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQuery.java
index e5259e0a97..85d07d4fbe 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQuery.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/query/CDOQuery.java
@@ -10,39 +10,45 @@
**************************************************************************/
package org.eclipse.emf.cdo.query;
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.common.query.CDOQueryInfo;
+
+import org.eclipse.net4j.util.collection.CloseableIterator;
+
import java.util.List;
/**
* @author Simon McDuff
* @since 2.0
*/
-public interface CDOQuery
+public interface CDOQuery extends CDOQueryInfo
{
-
- public <T> CDOQueryResult<T> getResultIterator(Class<T> classObject) throws Exception;
+ public <T> CloseableIterator<T> getResultAsync(Class<T> classObject);
+
+ public <T> List<T> getResult(Class<T> classObject);
-
- public <T> List<T> getResultList(Class<T> classObject) throws Exception;
-
/**
* Set the maximum number of results to retrieve.
+ *
* @param maxResult
* @return the same query instance
- * @throws IllegalArgumentException if argument is negative
+ * @throws IllegalArgumentException
+ * if argument is negative
*/
public CDOQuery setMaxResults(int maxResult);
- public int getMaxResults();
-
+
/**
* Bind an argument to a named parameter.
- * @param name the parameter name
+ *
+ * @param name
+ * the parameter name
* @param value
* @return the same query instance
- * @throws IllegalArgumentException if parameter name does not
- * correspond to parameter in query string
- * or argument is of incorrect type
+ * @throws IllegalArgumentException
+ * if parameter name does not correspond to parameter in query string or argument is of incorrect type
*/
public CDOQuery setParameter(String name, Object value);
-
-
+
+ public CDOView getView();
+
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOAutoAttacher.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOAutoAttacher.java
index 9409fb7ba0..fc604bb9d6 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOAutoAttacher.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOAutoAttacher.java
@@ -26,10 +26,10 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
+import org.eclipse.emf.internal.cdo.util.FSMUtil;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.resource.Resource;
import java.util.List;
@@ -44,16 +44,16 @@ public class CDOAutoAttacher implements CDOTransactionHandler
class CDOFeatureDeltaVisitorAutoAttach implements CDOFeatureDeltaVisitor
{
- Resource resource;
+ EObject referrer;
- CDOFeatureDeltaVisitorAutoAttach(Resource resource)
+ CDOFeatureDeltaVisitorAutoAttach(EObject referrer)
{
- this.resource = resource;
+ this.referrer = referrer;
}
public void visit(CDOAddFeatureDelta featureChange)
{
- persist(resource, featureChange.getValue());
+ persist(referrer, featureChange.getValue());
}
public void visit(CDOClearFeatureDelta featureChange)
@@ -77,7 +77,7 @@ public class CDOAutoAttacher implements CDOTransactionHandler
public void visit(CDOSetFeatureDelta featureChange)
{
- persist(resource, featureChange.getValue());
+ persist(referrer, featureChange.getValue());
}
public void visit(CDOUnsetFeatureDelta featureChange)
@@ -96,41 +96,35 @@ public class CDOAutoAttacher implements CDOTransactionHandler
transaction.addHandler(this);
}
- protected void persist(Resource res, Object object)
+ protected void persist(EObject res, Object object)
{
- if (object instanceof CDOResource)
- {
- return;
- }
-
- if (!(object instanceof InternalCDOObject))
+ if (!(object instanceof CDOResource) && object instanceof InternalCDOObject)
{
- return;
+ InternalCDOObject cdoObject = (InternalCDOObject)object;
+ if (FSMUtil.isTransient(cdoObject))
+ {
+ res.eResource().getContents().add(cdoObject);
+ }
}
-
- res.getContents().add((InternalCDOObject)object);
}
- private void check(Resource resource, EReference reference, EObject element)
+ private void check(EObject referrer, EReference reference, EObject element)
{
if (element != null && element.eResource() == null)
{
- if (reference.isContainment())
+ if (reference != null && reference.isContainment())
{
- handle(resource, element);
+ handle(referrer, element);
}
else
{
- persist(resource, element);
+ persist(referrer, element);
}
}
}
- /**
- * @param eObject
- */
@SuppressWarnings("unchecked")
- private void handle(Resource resource, EObject eObject)
+ private void handle(EObject referrer, EObject eObject)
{
for (EReference reference : eObject.eClass().getEAllReferences())
{
@@ -139,12 +133,12 @@ public class CDOAutoAttacher implements CDOTransactionHandler
List<EObject> list = (List<EObject>)eObject.eGet(reference);
for (EObject element : list)
{
- check(resource, reference, element);
+ check(referrer, reference, element);
}
}
else
{
- check(resource, reference, (EObject)eObject.eGet(reference));
+ check(referrer, reference, (EObject)eObject.eGet(reference));
}
}
@@ -158,7 +152,7 @@ public class CDOAutoAttacher implements CDOTransactionHandler
}
// Persist the graph as well.
- handle(object.eResource(), object);
+ handle(object, object);
}
public void committingTransaction(CDOTransaction transaction)
@@ -175,10 +169,9 @@ public class CDOAutoAttacher implements CDOTransactionHandler
if (featureChange != null)
{
- CDOFeatureDeltaVisitorAutoAttach featureChangeVisitor = new CDOFeatureDeltaVisitorAutoAttach(object.cdoResource());
+ CDOFeatureDeltaVisitorAutoAttach featureChangeVisitor = new CDOFeatureDeltaVisitorAutoAttach(object);
featureChange.accept(featureChangeVisitor);
}
-
}
public void rolledBackTransaction(CDOTransaction transaction)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index b235fe895c..332fdf674d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -53,6 +53,7 @@ import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.signal.failover.IFailOverEvent;
import org.eclipse.net4j.signal.failover.IFailOverStrategy;
+import org.eclipse.net4j.signal.failover.NOOPFailOverStrategy;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.container.Container;
@@ -214,7 +215,8 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
public IFailOverStrategy getFailOverStrategy()
{
- return failOverStrategy == null ? IFailOverStrategy.NOOP : failOverStrategy;
+ // DO NOT MERGE THAT
+ return failOverStrategy == null ? new NOOPFailOverStrategy() : failOverStrategy;
}
public void setFailOverStrategy(IFailOverStrategy failOverStrategy)
@@ -875,7 +877,6 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD
for (CDOViewImpl view : getViews())
{
- // TODO Array or something else that is synchronize.
for (InternalCDOObject internalCDOObject : view.getObjectsMap().values())
{
if (internalCDOObject.cdoRevision() != null && !internalCDOObject.cdoID().isTemporary()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index abf092c7b8..289f164587 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -37,7 +37,6 @@ import org.eclipse.emf.cdo.common.util.TransportException;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.EresourceFactory;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
-import org.eclipse.emf.cdo.internal.common.query.CDOQueryParameterImpl;
import org.eclipse.emf.cdo.query.CDOQuery;
import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
import org.eclipse.emf.cdo.util.CDOUtil;
@@ -276,9 +275,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
*/
public CDOQuery createQuery(String language, String queryString)
{
- CDOQueryParameterImpl parameter = new CDOQueryParameterImpl(language, queryString);
-
- return new CDOQueryImpl(this, parameter);
+ return new CDOQueryImpl(this, language, queryString);
}
public CDOID getResourceID(String path)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java
index 2e7bcb590c..8c1f939e18 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java
@@ -57,14 +57,16 @@ public final class Activator extends EMFPlugin
public void start(BundleContext context) throws Exception
{
super.start(context);
- OSGiActivator.startBundle(context, OM.BUNDLE);
+ // DO NOT MERGE THAT
+ // OSGiActivator.start(context);
}
@Override
public void stop(BundleContext context) throws Exception
{
plugin = null;
- OSGiActivator.stopBundle(context, OM.BUNDLE);
+ // DO NOT MERGE THAT
+ // OSGiActivator.stopBundle(context, OM.BUNDLE);
super.stop(context);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java
index 655e5330ea..f4096255b2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/QueryRequest.java
@@ -11,9 +11,9 @@
package org.eclipse.emf.internal.cdo.protocol;
import org.eclipse.emf.cdo.common.CDOProtocolConstants;
-import org.eclipse.emf.cdo.common.query.ResultWriterQueue;
+import org.eclipse.emf.cdo.common.query.CDOQueryQueue;
import org.eclipse.emf.cdo.common.util.CDOInstanceUtil;
-import org.eclipse.emf.cdo.internal.common.query.CDOQueryParameterImpl;
+import org.eclipse.emf.cdo.internal.common.query.CDOQueryInfoImpl;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.query.CDOQueryResultIteratorImpl;
@@ -21,7 +21,6 @@ import org.eclipse.emf.internal.cdo.query.CDOQueryResultIteratorImpl;
import org.eclipse.net4j.channel.IChannel;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.io.IOException;
@@ -37,17 +36,16 @@ public class QueryRequest extends CDOClientRequest<Object>
private int viewID;
- private CDOQueryParameterImpl cdoQuery;
+ private CDOQueryInfoImpl queryInfo;
private CDOQueryResultIteratorImpl<?> queryResult;
- public QueryRequest(int viewID, IChannel channel, CDOQueryResultIteratorImpl<?> queryResult,
- CDOQueryParameterImpl cdoQuery)
+ public QueryRequest(int viewID, IChannel channel, CDOQueryResultIteratorImpl<?> queryResult, CDOQueryInfoImpl cdoQuery)
{
super(channel);
this.viewID = viewID;
- this.cdoQuery = cdoQuery;
+ this.queryInfo = cdoQuery;
this.queryResult = queryResult;
}
@@ -63,7 +61,7 @@ public class QueryRequest extends CDOClientRequest<Object>
// Write ViewID
out.writeInt(viewID);
- cdoQuery.write(out);
+ queryInfo.write(out);
}
@@ -75,40 +73,31 @@ public class QueryRequest extends CDOClientRequest<Object>
queryResult.setQueryID(in.readLong());
- LifecycleUtil.activate(queryResult);
-
- ResultWriterQueue<Object> resulQueue = queryResult.getResultQueue();
+ CDOQueryQueue<Object> resulQueue = queryResult.getQueue();
try
{
int numberOfObjectReceived = 0;
- /**
- * state == 0 : Result
- * <p>
- * state == 1 : No more result
- * <p>
- * state == 2 : Exception
- */
while (true)
{
byte state = in.readByte();
- if (state == 0)
+ if (state == CDOProtocolConstants.QUERY_MORE_OBJECT)
{
// result
- Object element = CDOInstanceUtil.readInstance(in, getSession());
+ Object element = CDOInstanceUtil.readObject(in, getSession());
resulQueue.add(element);
numberOfObjectReceived++;
}
- else if (state == 1)
+ else if (state == CDOProtocolConstants.QUERY_DONE)
{
// End of result
break;
}
- else if (state == 2)
+ else if (state == CDOProtocolConstants.QUERY_EXCEPTION)
{
// Exception on the server
String exceptionString = in.readString();
@@ -134,7 +123,7 @@ public class QueryRequest extends CDOClientRequest<Object>
}
finally
{
- resulQueue.release();
+ resulQueue.close();
}
return returnList;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/ECDOList.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOEList.java
index 7a9e9d76b9..bb3585fd30 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/ECDOList.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOEList.java
@@ -24,15 +24,15 @@ import java.util.ListIterator;
/**
* @author Simon McDuff
*/
-public class ECDOList<T> implements EList<T>
+public class CDOEList<T> implements EList<T>
{
- private List<Object> listOfIDs;
+ private List<Object> listOfObjects;
private CDOView cdoView;
- public ECDOList(CDOView view, List<Object> list)
+ public CDOEList(CDOView view, List<Object> list)
{
- this.listOfIDs = list;
+ this.listOfObjects = list;
this.cdoView = view;
}
@@ -57,7 +57,7 @@ public class ECDOList<T> implements EList<T>
@SuppressWarnings("unchecked")
public T get(int index)
{
- Object object = this.listOfIDs.get(index);
+ Object object = this.listOfObjects.get(index);
if (object instanceof CDOID)
{
object = adapt((CDOID)object);
@@ -67,12 +67,12 @@ public class ECDOList<T> implements EList<T>
public boolean isEmpty()
{
- return listOfIDs.isEmpty();
+ return listOfObjects.isEmpty();
}
public Iterator<T> iterator()
{
- return new ECDOIDIterator(this.listOfIDs.iterator());
+ return new ECDOIDIterator(this.listOfObjects.iterator());
}
public void move(int newPosition, T object)
@@ -157,7 +157,7 @@ public class ECDOList<T> implements EList<T>
public int size()
{
- return listOfIDs.size();
+ return listOfObjects.size();
}
public List<T> subList(int arg0, int arg1)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java
index 3d5126173c..18b356fa4c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java
@@ -10,10 +10,11 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo.query;
+import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.common.model.CDOClass;
-import org.eclipse.emf.cdo.internal.common.query.CDOQueryParameterImpl;
+import org.eclipse.emf.cdo.common.util.CloseableBlockingIterator;
+import org.eclipse.emf.cdo.internal.common.query.CDOQueryInfoImpl;
import org.eclipse.emf.cdo.query.CDOQuery;
-import org.eclipse.emf.cdo.query.CDOQueryResult;
import org.eclipse.emf.internal.cdo.CDOViewImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
@@ -21,96 +22,92 @@ import org.eclipse.emf.internal.cdo.protocol.QueryRequest;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.WrappedException;
import org.eclipse.emf.ecore.EClass;
-import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
/**
* @author Simon McDuff
*/
-public class CDOQueryImpl implements CDOQuery
+public class CDOQueryImpl extends CDOQueryInfoImpl implements CDOQuery
{
- private CDOQueryParameterImpl queryParameter;
-
- private HashMap<String, Object> parameters = new HashMap<String, Object>();
-
private CDOViewImpl view = null;
- private int maxResult = -1;
-
- public CDOQueryImpl(CDOViewImpl cdoView, CDOQueryParameterImpl queryParameter)
+ public CDOQueryImpl(CDOViewImpl cdoView, String language, String queryString)
{
+ super(language, queryString);
view = cdoView;
- this.queryParameter = queryParameter;
}
- protected CDOQueryParameterImpl createQueryParameter()
+ protected CDOQueryInfoImpl createQueryInfo()
{
- CDOQueryParameterImpl queryParameter = new CDOQueryParameterImpl(this.queryParameter.getQueryLanguage(),
- this.queryParameter.getQueryString());
+ CDOQueryInfoImpl queryInfo = new CDOQueryInfoImpl(getQueryLanguage(), getQueryString());
- queryParameter.setMaxResult(maxResult);
+ queryInfo.setMaxResult(getMaxResults());
- for (Entry<String, Object> entry : parameters.entrySet())
+ for (Entry<String, Object> entry : getParameters().entrySet())
{
Object value = entry.getValue();
value = adapt(value);
- queryParameter.getParameters().put(entry.getKey(), value);
+ queryInfo.addParameter(entry.getKey(), value);
}
- return queryParameter;
+ return queryInfo;
}
- public <T> List<T> getResultList(Class<T> classObject) throws Exception
+ public <T> List<T> getResult(Class<T> classObject)
{
- CDOQueryParameterImpl queryParameter = createQueryParameter();
+ CDOQueryInfoImpl queryInfo = createQueryInfo();
- CDOQueryResultIteratorImpl<T> queryResult = new CDOQueryResultIteratorImpl<T>(view, queryParameter);
-
- new QueryRequest(view.getViewID(), view.getSession().getChannel(), queryResult, queryParameter).send();
+ CDOQueryResultIteratorImpl<T> queryResult = new CDOQueryResultIteratorImpl<T>(view, queryInfo);
+ try
+ {
+ QueryRequest request = new QueryRequest(view.getViewID(), view.getSession().getChannel(), queryResult, queryInfo);
+ view.getSession().getFailOverStrategy().send(request);
+ }
+ catch (Exception exception)
+ {
+ throw WrappedException.wrap(exception);
+ }
return queryResult.getAsList();
}
- public <T> CDOQueryResult<T> getResultIterator(Class<T> classObject)
+ public <T> CloseableBlockingIterator<T> getResultAsync(Class<T> classObject)
{
- final CDOQueryParameterImpl queryParameter = createQueryParameter();
- final CDOQueryResultIteratorImpl<T> queryResult = new CDOQueryResultIteratorImpl<T>(view, queryParameter);
-
+ final CDOQueryInfoImpl queryInfo = createQueryInfo();
+ final CDOQueryResultIteratorImpl<T> queryResult = new CDOQueryResultIteratorImpl<T>(view, queryInfo);
+ final Exception exception[] = new Exception[1];
Runnable runnable = new Runnable()
{
public void run()
{
try
{
-
- new QueryRequest(view.getViewID(), view.getSession().getChannel(), queryResult, queryParameter).send();
- }
- catch (RuntimeException ex)
- {
- queryResult.getResultQueue().setException(ex);
-
- // Be sure we activate queryResultObject
- if (!queryResult.isActive()) LifecycleUtil.activate(queryResult);
+ QueryRequest request = new QueryRequest(view.getViewID(), view.getSession().getChannel(), queryResult,
+ queryInfo);
+ view.getSession().getFailOverStrategy().send(request);
}
catch (Exception ex)
{
- queryResult.getResultQueue().setException(new RuntimeException(ex));
-
- // Be sure we activate queryResult
- if (!queryResult.isActive()) LifecycleUtil.activate(queryResult);
+ queryResult.close();
+ exception[0] = ex;
}
}
};
new Thread(runnable).start();
- queryResult.waitForActivate();
+ queryResult.waitInitialize();
+
+ if (exception[0] != null)
+ {
+ throw WrappedException.wrap(exception[0]);
+ }
return queryResult;
}
@@ -143,15 +140,14 @@ public class CDOQueryImpl implements CDOQuery
return this;
}
- public int getMaxResults()
- {
- return maxResult;
- }
-
public CDOQuery setParameter(String name, Object value)
{
parameters.put(name, value);
return this;
}
+ public CDOView getView()
+ {
+ return view;
+ }
}
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 d798fcff83..6b41b4914c 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
@@ -12,59 +12,53 @@ package org.eclipse.emf.internal.cdo.query;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.query.CDOQueryParameter;
-import org.eclipse.emf.cdo.common.util.PropertyChanged;
-import org.eclipse.emf.cdo.internal.common.query.CDOAbstractQueryResultImpl;
-import org.eclipse.emf.cdo.query.CDOQueryResult;
+import org.eclipse.emf.cdo.common.query.CDOQueryInfo;
+import org.eclipse.emf.cdo.common.util.ConcurrentValue;
+import org.eclipse.emf.cdo.internal.common.query.AbstractQueryResult;
import org.eclipse.emf.internal.cdo.protocol.QueryCancelRequest;
-import org.eclipse.net4j.util.lifecycle.ILifecycleState;
-
/**
* @author Simon McDuff
*/
-public class CDOQueryResultIteratorImpl<T> extends CDOAbstractQueryResultImpl<T> implements CDOQueryResult<T>
+public class CDOQueryResultIteratorImpl<T> extends AbstractQueryResult<T>
{
- protected CDOView cdoView;
-
- protected boolean cancelled = false;
-
- protected PropertyChanged<ILifecycleState> state = new PropertyChanged<ILifecycleState>(getLifecycleState());
+ protected boolean closed = false;
- public CDOQueryResultIteratorImpl(CDOView cdoView, CDOQueryParameter cdoQueryParameter)
- {
- super(cdoQueryParameter);
- this.cdoView = cdoView;
- }
+ ConcurrentValue<Boolean> queryIDSet = new ConcurrentValue<Boolean>(false);
- public void waitForActivate()
+ public CDOQueryResultIteratorImpl(CDOView cdoView, CDOQueryInfo queryInfo)
{
- state.acquire(ILifecycleState.ACTIVE, null);
+ super(cdoView, queryInfo, -1);
}
@Override
- protected void doActivate() throws Exception
+ public void setQueryID(long queryID)
{
- state.set(ILifecycleState.ACTIVE);
- super.doActivate();
+ super.setQueryID(queryID);
+ queryIDSet.set(true);
}
- @Override
- protected void doDeactivate() throws Exception
+ public void waitInitialize()
{
- state.set(ILifecycleState.INACTIVE);
- super.doDeactivate();
+ queryIDSet.acquire(new Object()
+ {
+ @Override
+ public boolean equals(Object obj)
+ {
+ return Boolean.TRUE.equals(obj) || isClosed();
+ }
+ });
}
- public boolean hasNext()
+ public CDOView getView()
{
- return nextObject.hasNext();
+ return (CDOView)super.getView();
}
public T next()
{
- return adapt(nextObject.next());
+ return adapt(super.next());
}
public void remove()
@@ -78,40 +72,29 @@ public class CDOQueryResultIteratorImpl<T> extends CDOAbstractQueryResultImpl<T>
if (object instanceof CDOID)
{
if (((CDOID)object).isNull()) return null;
- return (T)cdoView.getObject((CDOID)object, true);
+ return (T)getView().getObject((CDOID)object, true);
}
return (T)object;
}
public void close()
{
- try
+ if (!isClosed())
{
- cancel();
- }
- catch (RuntimeException ex)
- {
- // Hide exception
- }
- }
+ super.close();
- public void cancel()
- {
- cancelled = true;
- try
- {
- new QueryCancelRequest(queryID, cdoView.getSession().getChannel()).send();
- }
- catch (Exception ex)
- {
- throw new RuntimeException(ex);
- }
+ queryIDSet.reevaluate();
- }
+ try
+ {
+ QueryCancelRequest request = new QueryCancelRequest(this.getQueryID(), getView().getSession().getChannel());
- public boolean isCancelled()
- {
- return cancelled;
+ getView().getSession().getFailOverStrategy().send(request);
+ }
+ catch (Exception exception)
+ {
+ // Catch all exception
+ }
+ }
}
-
}

Back to the top