org.opcfoundation.ua.transport
Interface AsyncResult<T>

All Known Implementing Classes:
AsyncResultImpl

public interface AsyncResult<T>

Asynchronous result is a multi-thread object that operates as a container for a result. The result is either an error or the result object. The result can be blocked (waitForResult()), polled (getResult() and getError()), or listened to setListener(ResultListener). AsyncResult can be used from any thread and from multiple-thread.

See Also:
AsyncResultImpl

Nested Class Summary
static class AsyncResult.AsyncResultStatus
           
 
Method Summary
 ServiceResultException getError()
          getError.
 T getResult()
          Get result if available
 AsyncResult.AsyncResultStatus getStatus()
          Get request status
 void setListener(ResultListener<T> listener)
          Set a listener.
 T waitForResult()
          Wait for result until result is available.
 T waitForResult(long timeout, TimeUnit unit)
          Wait for result or time out.
 

Method Detail

setListener

void setListener(ResultListener<T> listener)
Set a listener. If the result is already available, the listener is invoked from the current thread. Otherwise, the notification is placed from the thread that sets the result. The listener implementation may not create any locks during the handling of the result, also it is good policy not do any long term operations in the listener implementation.

Parameters:
listener - (listener may not block) or null to remove listener

getResult

T getResult()
            throws ServiceResultException
Get result if available

Returns:
result or null if not complete
Throws:
ServiceResultException - if error

getError

ServiceResultException getError()

getError.

Returns:
a ServiceResultException object.

getStatus

AsyncResult.AsyncResultStatus getStatus()
Get request status

Returns:
status

waitForResult

T waitForResult()
                throws ServiceResultException
Wait for result until result is available. Typically result becomes available in a default operation time out period. (120s)

Returns:
the result
Throws:
ServiceResultException - network error, e.g. IOException of MethodNotSupportedException

waitForResult

T waitForResult(long timeout,
                TimeUnit unit)
                throws ServiceResultException
Wait for result or time out. On timeout ServiceResultException(Bad_Timeout) is thrown.

Parameters:
timeout - time out value
unit - time unit
Returns:
the result
Throws:
ServiceResultException - error during invocation


Copyright © 2018. All rights reserved.