}
catch (IOException e)
{
throw new ApplicationException(e);
}
BuiltResponse serverResponse = (BuiltResponse)requestContext.getResponseAbortedWith();
if (serverResponse != null)
{
return serverResponse;
}
}
if (validator != null)
{
if (isValidatable)
{
validator.validate(request, target);
}
if (methodIsValidatable)
{
request.setAttribute(GeneralValidator.class.getName(), validator);
}
else if (isValidatable)
{
validator.checkViolations(request);
}
}
Object rtn = null;
try
{
rtn = methodInjector.invoke(request, response, target);
}
catch (RuntimeException ex)
{
if (request.getAsyncContext().isSuspended())
{
try
{
request.getAsyncContext().getAsyncResponse().resume(ex);
}
catch (Exception e)
{
logger.error("Error resuming failed async operation", e);
}
return null;
}
else
{
throw ex;
}
}
if (request.getAsyncContext().isSuspended() || request.wasForwarded())
{
return null;
}
if (rtn == null || method.getReturnType().equals(void.class))
{
BuiltResponse build = (BuiltResponse) Response.noContent().build();
build.addMethodAnnotations(getMethodAnnotations());
return build;
}
if (Response.class.isAssignableFrom(method.getReturnType()) || rtn instanceof Response)
{
if (!(rtn instanceof BuiltResponse))
{
Response r = (Response)rtn;
Headers<Object> metadata = new Headers<Object>();
metadata.putAll(r.getMetadata());
rtn = new BuiltResponse(r.getStatus(), metadata, r.getEntity(), null);
}
BuiltResponse rtn1 = (BuiltResponse) rtn;
rtn1.addMethodAnnotations(getMethodAnnotations());
if (rtn1.getGenericType() == null)
{
if (getMethod().getReturnType().equals(Response.class))
{
rtn1.setGenericType(rtn1.getEntityClass());
}
else
{
rtn1.setGenericType(method.getGenericReturnType());
}
}
return rtn1;
}
Response.ResponseBuilder builder = Response.ok(rtn);
BuiltResponse jaxrsResponse = (BuiltResponse)builder.build();
if (jaxrsResponse.getGenericType() == null)
{
if (getMethod().getReturnType().equals(Response.class))
{
jaxrsResponse.setGenericType(jaxrsResponse.getEntityClass());
}
else
{
jaxrsResponse.setGenericType(method.getGenericReturnType());
}
}
jaxrsResponse.addMethodAnnotations(getMethodAnnotations());
return jaxrsResponse;
}