X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.databoard%2Fsrc%2Forg%2Fsimantics%2Fdataboard%2Fchannel%2FAsyncRequest.java;h=1ab7bad1307ea884cf4786988c4f56de01317075;hb=refs%2Fchanges%2F38%2F238%2F2;hp=65bcd68cf43742a8ad8d458409a7ebcc5bdf4641;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.databoard/src/org/simantics/databoard/channel/AsyncRequest.java b/bundles/org.simantics.databoard/src/org/simantics/databoard/channel/AsyncRequest.java index 65bcd68cf..1ab7bad13 100644 --- a/bundles/org.simantics.databoard/src/org/simantics/databoard/channel/AsyncRequest.java +++ b/bundles/org.simantics.databoard/src/org/simantics/databoard/channel/AsyncRequest.java @@ -1,108 +1,108 @@ -package org.simantics.databoard.channel; - -import java.io.IOException; -import java.util.concurrent.Executor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.simantics.databoard.binding.Binding; - -/** - * Delayed response object. The result or error may be or become available to - * this object at any given time. - * - * This interface is intended to be used by clients that make service requests - * over command channel. - * - * @author Toni Kalajainen - */ -public interface AsyncRequest { - - /** - * Get the current request status.

- * - * If Succeeded or Failed, then result or error is available and can be read - * without wait.

- * - * Succeeded and Failed statuses are final.

- */ - enum Status {Waiting, Succeed, Failed} Status getStatus(); - - /** - * Get result if available. - * - * @param binding - * @return result or null - * @throws RequestException - */ - Object getResult(Binding binding) throws RequestException; - - /** - * Get error if available. - * - * Cause is (typically) one of these: - * o Communication problems {@link IOException} - * o Timeout {@link TimeoutException} - * o Service(handler) problem {@link ServiceException} - * - * @return error or null - */ - Exception getError(); - - /** - * Synchronous wait for result until default timeout. - * Default timeout is configured to the channel. - * If timeout occurs TimeoutException is thrown wrapped in RequestException. - * - * @param binding the format for the result - * @return the result object - * @throws RequestException - */ - Object waitForResult(Binding binding) throws RequestException; - - /** - * Wait for result or break after until timeout. - * If timeout occurs TimeoutException is thrown wrapped in RequestException. - * - * @param binding - * @param timeout - * @param unit - * @return result - * @throws RequestException - */ - Object waitForResult(Binding binding, long timeout, TimeUnit unit) throws RequestException; - - /** - * Set a listener. If the result is already available, the event - * schedueled immediately. - * - * @param listener (listener may not block) or null to remove listener - */ - void setListener(RequestListener listener); - - interface RequestListener { - - /** - * Get thread where the listening is to be processed - * - * @return thread to run listener events - */ - Executor getThread(); - - /** - * Request completed, the result is available - * - * @param result the result - */ - void onCompleted(Object result); - - /** - * There was an error in processing the request - * - * @param error the error - */ - void onError(ServiceException error); - - } - -} +package org.simantics.databoard.channel; + +import java.io.IOException; +import java.util.concurrent.Executor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.simantics.databoard.binding.Binding; + +/** + * Delayed response object. The result or error may be or become available to + * this object at any given time. + * + * This interface is intended to be used by clients that make service requests + * over command channel. + * + * @author Toni Kalajainen + */ +public interface AsyncRequest { + + /** + * Get the current request status.

+ * + * If Succeeded or Failed, then result or error is available and can be read + * without wait.

+ * + * Succeeded and Failed statuses are final.

+ */ + enum Status {Waiting, Succeed, Failed} Status getStatus(); + + /** + * Get result if available. + * + * @param binding + * @return result or null + * @throws RequestException + */ + Object getResult(Binding binding) throws RequestException; + + /** + * Get error if available. + * + * Cause is (typically) one of these: + * o Communication problems {@link IOException} + * o Timeout {@link TimeoutException} + * o Service(handler) problem {@link ServiceException} + * + * @return error or null + */ + Exception getError(); + + /** + * Synchronous wait for result until default timeout. + * Default timeout is configured to the channel. + * If timeout occurs TimeoutException is thrown wrapped in RequestException. + * + * @param binding the format for the result + * @return the result object + * @throws RequestException + */ + Object waitForResult(Binding binding) throws RequestException; + + /** + * Wait for result or break after until timeout. + * If timeout occurs TimeoutException is thrown wrapped in RequestException. + * + * @param binding + * @param timeout + * @param unit + * @return result + * @throws RequestException + */ + Object waitForResult(Binding binding, long timeout, TimeUnit unit) throws RequestException; + + /** + * Set a listener. If the result is already available, the event + * schedueled immediately. + * + * @param listener (listener may not block) or null to remove listener + */ + void setListener(RequestListener listener); + + interface RequestListener { + + /** + * Get thread where the listening is to be processed + * + * @return thread to run listener events + */ + Executor getThread(); + + /** + * Request completed, the result is available + * + * @param result the result + */ + void onCompleted(Object result); + + /** + * There was an error in processing the request + * + * @param error the error + */ + void onError(ServiceException error); + + } + +}