Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Apache CXF API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT

## org.apache.cxf.annotations
Annotation Type UseAsyncMethod

    @Documented
    @Retention(value=RUNTIME)
    @Target(value=METHOD)
    public @interface UseAsyncMethod

Instructs the runtime to dispatch using the async method on service if continuations are available. This only applies to the JAX-WS frontend at this time. Instead of calling the "X methodName(Y, Z...) method, it will call the "Future methodName(Y, Z, ... AsyncHandler)" method passing in an AsyncHandler that you will need to call when the response is ready. An example would be:

     public Future greetMeAsync(final String requestType,
                                   final AsyncHandler asyncHandler) {
         final ServerAsyncResponse r = new ServerAsyncResponse();
         new Thread() {
             public void run() {
                //do some work on a backgound thread to generate the response...
                GreetMeResponse resp = new GreetMeResponse();
                resp.setResponseType("Hello " + requestType);
                r.set(resp);
                asyncHandler.handleResponse(r);
             }
        } .start();
        return r;
     }

The use of the org.apache.cxf.jaxws.ServerAsyncResponse class for the response as shown above can simplify things and is recommended.

Optional Element Summary
`boolean` | `always` By default, if continuations are not available, it will use the non-async method.

### always

    public abstract boolean always

  By default, if continuations are not available, it will use the non-async method. If you ALWAYS want the async method called, set this to true. However, that can cause threads to block.

  Default:
    false

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Apache CXF API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT

Apache CXF