com.businessobjects.sdk.biar
Class AsyncImport

java.lang.Object
  extended by com.businessobjects.sdk.biar.AsyncImport
All Implemented Interfaces:
ICancelable

public class AsyncImport
extends java.lang.Object
implements ICancelable

A class for running an import asynchronously, in another thread. The single-argument constructor takes an IImport instance as its parameter, and this import is run in another thread. The progress of the import can then be monitored and managed through the methods of this class.

An AsyncImport must be always disposed by calling AsyncImport.dispose() when it will no longer be used, in order to release any resources it holds.

A note on terminology: the import is said to be terminated when it is no longer running, no matter the manner in which it terminated; the import is said to be completed only when it has terminated as a result of successfully completing the import.


Constructor Summary
AsyncImport(IImport theImport)
          Constructs an AsyncImport object which runs the supplied import.
 
Method Summary
 void cancel()
          Cancels the import.
 void dispose()
          Disposes of the import and release any resources it holds.
 java.util.concurrent.Future getResult()
          Gets a java.lang.concurrent.Future representing the calculated result of the import.
 boolean isCompleted()
          Checks if the import is completed.
 boolean isTerminated()
          Checks if the import has terminated.
 void waitToTermination()
          Waits until the import has terminated.
 void waitToTermination(long time)
          Waits until the import has terminated, or until the given time-out has expired, whichever comes first.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncImport

public AsyncImport(IImport theImport)
            throws BIARException
Constructs an AsyncImport object which runs the supplied import.

Parameters:
theImport - the import to run asynchronously.
Throws:
BIARException - if the operation is unsuccessful.
Method Detail

isCompleted

public boolean isCompleted()
Checks if the import is completed. There's no strict synchronization, so data races may occur.

Returns:
true if the import is completed.

isTerminated

public boolean isTerminated()
Checks if the import has terminated. There's no strict synchronization, so data races may occur.

Returns:
true if the import is terminated.

waitToTermination

public void waitToTermination(long time)
                       throws java.lang.InterruptedException
Waits until the import has terminated, or until the given time-out has expired, whichever comes first.

Parameters:
time - the time-out.
Throws:
java.lang.InterruptedException - if the wait is interrupted.

waitToTermination

public void waitToTermination()
                       throws java.lang.InterruptedException
Waits until the import has terminated.

Throws:
java.lang.InterruptedException - if the wait is interrupted.

getResult

public java.util.concurrent.Future getResult()
Gets a java.lang.concurrent.Future representing the calculated result of the import. The result value is an IObjectManager containing the imported objects.

Returns:
the future result of the import.

cancel

public void cancel()
Cancels the import. The import, if cancelled, will be terminated but not completed. Because no strict synchronization is used, an import may complete before notification of the cancellation occurs.

Specified by:
cancel in interface ICancelable

dispose

public void dispose()
             throws BIARException
Disposes of the import and release any resources it holds. If the import is still in-progress, it is cancelled.

Throws:
BIARException - if this operation is unsuccessful.