eu.cedarsoft.async
Class AsyncCallSupport<T>

java.lang.Object
  extended by eu.cedarsoft.async.AsyncCallSupport<T>
Type Parameters:
T - the type of calls

public class AsyncCallSupport<T>
extends java.lang.Object

An asynchronous call.


Field Summary
static java.lang.String NAME_PREFIX
           
 
Constructor Summary
AsyncCallSupport()
           
 
Method Summary
protected  void acknowledge(T action, java.lang.Object returnValue)
          Acknowledges the asynchronous dao that an action has been executed
static int countWorkerThreadsLeft()
           
 void initializeWorker(CallbackCaller<T> callbackCaller)
           
<R> R
invoke(T callback)
          Invokes a callback
<R> R
invokeNullable(T callback)
          Invoke a nullable callback
 void invokeVoid(T callback)
          Invokes a void callback
 boolean isInitialized()
           
 void shutdown()
           
static void shutdownWorkerThreads()
           
static void verifyNoWorkerThreadsLeft()
          Verifies that no worker threads have been left
protected  T waitForNextCallback()
          Returns the next action
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME_PREFIX

@NotNull
@NonNls
public static final java.lang.String NAME_PREFIX
See Also:
Constant Field Values
Constructor Detail

AsyncCallSupport

public AsyncCallSupport()
Method Detail

initializeWorker

public void initializeWorker(@NotNull
                             CallbackCaller<T> callbackCaller)

shutdown

public void shutdown()

invoke

@NotNull
public <R> R invoke(T callback)
         throws AsynchroniousInvocationException
Invokes a callback

Parameters:
callback - the callback
Returns:
the return value of the callback
Throws:
AsynchroniousInvocationException

invokeNullable

@Nullable
public <R> R invokeNullable(@NotNull
                                     T callback)
                 throws AsynchroniousInvocationException
Invoke a nullable callback

Parameters:
callback - the callback
Returns:
the return value (may be null)
Throws:
AsynchroniousInvocationException

invokeVoid

public void invokeVoid(@NotNull
                       T callback)
                throws AsynchroniousInvocationException
Invokes a void callback

Parameters:
callback - the callback
Throws:
AsynchroniousInvocationException

isInitialized

public boolean isInitialized()

waitForNextCallback

@NotNull
protected T waitForNextCallback()
                         throws java.lang.InterruptedException
Returns the next action

Returns:
the next action from the queue
Throws:
java.lang.InterruptedException

acknowledge

protected void acknowledge(@NotNull
                           T action,
                           @Nullable
                           java.lang.Object returnValue)
Acknowledges the asynchronous dao that an action has been executed

Parameters:
action - the action that has been executed
returnValue - the return value (or exception)

verifyNoWorkerThreadsLeft

public static void verifyNoWorkerThreadsLeft()
                                      throws java.lang.InterruptedException
Verifies that no worker threads have been left

Throws:
java.lang.InterruptedException

countWorkerThreadsLeft

public static int countWorkerThreadsLeft()
                                  throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

shutdownWorkerThreads

public static void shutdownWorkerThreads()
                                  throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException


Copyright © 2008 cedarsoft GmbH. All Rights Reserved.