Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-09-12 01:22:20 -0400
committerslewis2007-09-12 01:22:20 -0400
commitd7aa2946a61250f1c92a6f1243c1ef9a8951d73d (patch)
treec2acbfc03e1924fd801aca9c42cd2f79dc719ce9
parent517fde96e1668525b1f408d7c8f0d9df800130a1 (diff)
downloadorg.eclipse.ecf-d7aa2946a61250f1c92a6f1243c1ef9a8951d73d.tar.gz
org.eclipse.ecf-d7aa2946a61250f1c92a6f1243c1ef9a8951d73d.tar.xz
org.eclipse.ecf-d7aa2946a61250f1c92a6f1243c1ef9a8951d73d.zip
Changed name of AsynchResult to AsyncResult. Abstracted public API for AsyncResult to IAsyncResult. Added method to IRemoteService.callAsynch that returns IAsyncResult. Implemented new method in org.eclipse.ecf.provider.remoteservice. Added test case for testing new API.
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/AsyncResult.java (renamed from framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/AsynchResult.java)53
-rw-r--r--framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/IAsyncResult.java76
2 files changed, 90 insertions, 39 deletions
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/AsynchResult.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/AsyncResult.java
index ffd9b0478..fbc1f2549 100644
--- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/AsynchResult.java
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/AsyncResult.java
@@ -14,14 +14,14 @@ import java.lang.reflect.InvocationTargetException;
* Class to represent asynchronous result (aka Future)
*
*/
-public class AsynchResult {
+public class AsyncResult implements IAsyncResult {
protected Object resultValue = null;
protected boolean resultReady = false;
protected InvocationTargetException resultException = null;
- public AsynchResult() {
+ public AsyncResult() {
}
/**
@@ -50,14 +50,8 @@ public class AsynchResult {
return resultValue;
}
- /**
- * Get the underlying result. Block until result is available.
- *
- * @return Object that is result
- * @throws InterruptedException
- * thrown if waiting is interrupted
- * @throws InvocationTargetException
- * thrown if exception was thrown by execution
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.util.IAsyncResult#get()
*/
public synchronized Object get() throws InterruptedException, InvocationTargetException {
while (!resultReady)
@@ -65,20 +59,8 @@ public class AsynchResult {
return doGet();
}
- /**
- * Get the underlying result with limited wait time. Behaves similarly to
- * {@link #wait()}, but only waits msecs (ms) before throwing
- * TimeoutException
- *
- * @param msecs
- * to wait before timing out
- * @return Object that is result
- * @throws TimeoutException
- * thrown if msecs elapse before a result is available
- * @throws InterruptedException
- * thrown if waiting is interrupted
- * @throws InvocationTargetException
- * thrown if exception was thrown by execution
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.util.IAsyncResult#get(long)
*/
public synchronized Object get(long msecs) throws TimeoutException, InterruptedException, InvocationTargetException {
long startTime = (msecs <= 0) ? 0 : System.currentTimeMillis();
@@ -125,36 +107,29 @@ public class AsynchResult {
notifyAll();
}
- /**
- * Get the InvocationTargetException that occured during invocation. If
- * null, no exception was thrown
- *
- * @return InvocationTargetException if an exception occurred (available via
- * {@link InvocationTargetException#getCause()}. Null if no
- * exception has occurred
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.util.IAsyncResult#getException()
*/
public synchronized InvocationTargetException getException() {
return resultException;
}
- /**
- * @return true if result has been set or exception has occurred, false if
- * not.
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.util.IAsyncResult#isReady()
*/
public synchronized boolean isReady() {
return resultReady;
}
- /**
- * @return Object result that has been set or null if has not been set
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.util.IAsyncResult#peek()
*/
public synchronized Object peek() {
return resultValue;
}
- /**
- * Clear this AsynchResult. Clears both the result Object and the
- * InvocationTargetException (if set)
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.util.IAsyncResult#clear()
*/
public synchronized void clear() {
resultValue = null;
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/IAsyncResult.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/IAsyncResult.java
new file mode 100644
index 000000000..aeca09b75
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/IAsyncResult.java
@@ -0,0 +1,76 @@
+/****************************************************************************
+ * Copyright (c) 2007 Composent, Inc. and others.
+ * 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:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.core.util;
+
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ *
+ */
+public interface IAsyncResult {
+
+ /**
+ * Get the underlying result. Block until result is available.
+ *
+ * @return Object that is result
+ * @throws InterruptedException
+ * thrown if waiting is interrupted
+ * @throws InvocationTargetException
+ * thrown if exception was thrown by execution
+ */
+ public abstract Object get() throws InterruptedException, InvocationTargetException;
+
+ /**
+ * Get the underlying result with limited wait time. Behaves similarly to
+ * {@link #wait()}, but only waits msecs (ms) before throwing
+ * TimeoutException
+ *
+ * @param msecs
+ * to wait before timing out
+ * @return Object that is result
+ * @throws TimeoutException
+ * thrown if msecs elapse before a result is available
+ * @throws InterruptedException
+ * thrown if waiting is interrupted
+ * @throws InvocationTargetException
+ * thrown if exception was thrown by execution
+ */
+ public abstract Object get(long msecs) throws TimeoutException, InterruptedException, InvocationTargetException;
+
+ /**
+ * Get the InvocationTargetException that occured during invocation. If
+ * null, no exception was thrown
+ *
+ * @return InvocationTargetException if an exception occurred (available via
+ * {@link InvocationTargetException#getCause()}. Null if no
+ * exception has occurred
+ */
+ public abstract InvocationTargetException getException();
+
+ /**
+ * @return true if result has been set or exception has occurred, false if
+ * not.
+ */
+ public abstract boolean isReady();
+
+ /**
+ * @return Object result that has been set or null if has not been set
+ */
+ public abstract Object peek();
+
+ /**
+ * Clear this AsyncResult. Clears both the result Object and the
+ * InvocationTargetException (if set)
+ */
+ public abstract void clear();
+
+} \ No newline at end of file

Back to the top