...
Code Block |
---|
|
@Policies({
@Policy(uri = "annotationpolicies/TestInterfacePolicy.xml"),
@Policy(uri = "annotationpolicies/TestImplPolicy.xml",
placement = Policy.Placement.SERVICE_PORT),
@Policy(uri = "annotationpolicies/TestPortTypePolicy.xml",
placement = Policy.Placement.PORT_TYPE)
}
)
@WebService
public static interface TestInterface {
@Policies({
@Policy(uri = "annotationpolicies/TestOperationPolicy.xml"),
@Policy(uri = "annotationpolicies/TestOperationInputPolicy.xml",
placement = Policy.Placement.BINDING_OPERATION_INPUT),
@Policy(uri = "annotationpolicies/TestOperationOutputPolicy.xml",
placement = Policy.Placement.BINDING_OPERATION_OUTPUT),
@Policy(uri = "annotationpolicies/TestOperationPTPolicy.xml",
placement = Policy.Placement.PORT_TYPE_OPERATION),
@Policy(uri = "annotationpolicies/TestOperationPTInputPolicy.xml",
placement = Policy.Placement.PORT_TYPE_OPERATION_INPUT),
@Policy(uri = "annotationpolicies/TestOperationPTOutputPolicy.xml",
placement = Policy.Placement.PORT_TYPE_OPERATION_OUTPUT)
}
)
int echoInt(int i);
}
|
org.apache.cxf.annotations.UseAsyncMethod (since 2.6.0)
Used on the JAX-WS service implementation object to mark a method as preferring the 'async' version of the method instead of the synchronous version. With JAX-WS, services default to the synchronous methods that require the returning value to be returned from the method. By marking a method with the @UseAsyncMethod annotation, if the transport supports it, CXF will call the async version that takes an AsynHandler object and the service can call that handler when the response is ready. If the transport does not support the CXF continuations, the synchronous method will be called as normal.
Code Block |
---|
|
@UseAsyncMethod
public String greetMeSometime(String me) {
LOG.info("Executing operation greetMeSometime synchronously");
System.out.println("Executing operation greetMeSometime synchronously\n");
return "How are you " + me;
}
public Future<?> greetMeSometimeAsync(final String me,
final AsyncHandler<GreetMeSometimeResponse> asyncHandler) {
LOG.info("Executing operation greetMeSometimeAsync asynchronously");
System.out.println("Executing operation greetMeSometimeAsync asynchronously\n");
final ServerAsyncResponse<GreetMeSometimeResponse> r
= new ServerAsyncResponse<GreetMeSometimeResponse>();
new Thread() {
public void run() {
GreetMeSometimeResponse resp = new GreetMeSometimeResponse();
resp.setResponseType("How are you " + me);
r.set(resp);
System.out.println("Responding on background thread\n");
asyncHandler.handleResponse(r);
}
} .start();
return r;
}
|