uCosminexus Application Server, EJB Container Functionality Guide
You can select either of the following values as a return value in an asynchronous method.
Note that if you select void, you cannot declare an application exception. If you select Future<V>, you can declare an application exception. If invoked from a remote interface, the Future<V> object used to access the processing result is retained in an EJB container.
In an asynchronous method, you can pass the processing result object of the method to the invocation source by using javax.ejb.AsyncResult<V>, which is an implementation class of Future<V>.
The examples when Future<V> and void are specified as return values in coding that uses the @Asynchronous annotation are as follows:
// Enterprise Bean Business method //Example when Future<V> is specified as return value @Asynchronous public Future<Integer> performCalculation(...) { // ... do calculation Integer result = null; if (ejb_context.wasCancelCalled()) { return new AsyncResult<Integer>(-1); } ... return new AsyncResult<Integer>(result); } // Example when void is specified as return value @Asynchronous public void performAddition (...) { Integer result = null; // ... do addition } |
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.