} else if (methodName.equals("equals")) {
return this.equals(proxy);
} else if (methodName.equals("hashCode")) {
return this.hashCode();
}
RESTEasyBindingData requestData = new RESTEasyBindingData();
HttpHeaders headers = ResteasyProviderFactory.getContextData(HttpHeaders.class);
if (headers != null) {
requestData.setHeaders(headers.getRequestHeaders());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Incoming Headers to SwitchYard through InboundHandler [");
traceLog(LOGGER, headers.getRequestHeaders());
LOGGER.trace("]");
}
}
SecurityContext securityContext = ResteasyProviderFactory.getContextData(SecurityContext.class);
if (securityContext != null) {
if (securityContext instanceof ServletSecurityContext && SERVLET_REQUEST_ACCESS != null) {
HttpServletRequest servletRequest = SERVLET_REQUEST_ACCESS.read((ServletSecurityContext)securityContext);
requestData.setServletRequest(servletRequest);
}
requestData.setSecured(securityContext.isSecure());
requestData.setPrincipal(securityContext.getUserPrincipal());
}
requestData.setOperationName(methodName);
if ((args != null) && (args.length > 0)) {
requestData.setParameters(args);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace(args);
}
}
RESTEasyBindingData responseData = _serviceConsumer.invoke(requestData, method.getReturnType().equals(Void.TYPE));
Response.ResponseBuilder builder = Response.ok();
if (responseData != null) {
if (method.getReturnType().equals(Response.class)) {
if (responseData.getParameters().length > 0) {
Object param = responseData.getParameters()[0];
if (param instanceof Response) {
// In future use builder = Response.ResponseBuilder.fromResponse((Response)param);
Response response = (Response)param;
builder.entity(response.getEntity());
builder.status(response.getStatus());
} else {
builder.entity(param);
}
}
// Data overrides status
if (responseData.getStatusCode() != null) {
builder.status(responseData.getStatusCode());
}
for (Map.Entry<String, List<String>> entry : responseData.getHeaders().entrySet()) {
String name = entry.getKey();
List<String> values = entry.getValue();
for (String value : values) {
builder.header(name, value);
}
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Outgoing Headers from SwitchYard through InboundHandler [");
traceLog(LOGGER, responseData.getHeaders());
LOGGER.trace("]");
}
} else if (responseData.getParameters().length > 0) {
return responseData.getParameters()[0];
}
}
return builder.build();
}