use of org.eclipse.scout.jaxws.apt.internal.codemodel.JConditionalEx in project scout.rt by eclipse.
the class JaxWsAnnotationProcessor method addEntryPointMethodImplementation.
/**
* Creates the implementation of a entry point method.
*/
protected void addEntryPointMethodImplementation(final JCodeModel model, final JFieldVar webServiceContext, final JMethod method, final List<JClass> throwTypes, final boolean voidMethod, final String endpointInterfaceName) {
final JBlock methodBody = method.body();
final JInvocation runContext = JExpr.invoke(LOOKUP_RUN_CONTEXT_METHOD_NAME);
final JTryBlock tryBlock = methodBody._try();
// Invoke port type on behalf of RunContext.
final JInvocation runContextInvocation = createRunContextInvocation(model, runContext, voidMethod, method, endpointInterfaceName);
if (voidMethod) {
tryBlock.body().add(runContextInvocation);
} else {
tryBlock.body()._return(runContextInvocation);
}
// Create exception handling.
final JCatchBlock catchBlock = tryBlock._catch(model.ref(Exception.class));
final JVar caughtException = catchBlock.param("e");
final JBlock catchBody = catchBlock.body();
if (throwTypes.isEmpty()) {
// webservice method has no faults declared.
catchBody._throw(JExpr.invoke(HANDLE_UNDECLARED_FAULT_METHOD_NAME).arg(caughtException));
} else {
// handle declared webservice faults.
final JConditionalEx condition = new JConditionalEx(catchBody);
for (final JClass throwType : throwTypes) {
condition._elseif(caughtException._instanceof(throwType))._throw(JExprEx.cast(throwType, caughtException));
}
condition._else()._throw(JExpr.invoke(HANDLE_UNDECLARED_FAULT_METHOD_NAME).arg(caughtException));
}
}
Aggregations