}
private Object invokeSEIMethod(Object proxy, Method method, Object parameters[])
throws Exception {
ObjectMessageContext objMsgContext = clientBinding.createObjectContext();
objMsgContext.putAll(getRequestContext());
objMsgContext.put(ObjectMessageContext.REQUEST_PROXY, proxy);
objMsgContext.setMessageObjects(parameters);
objMsgContext.put(METHOD, method);
objMsgContext.put(ObjectMessageContext.METHOD_OBJ, method);
boolean isOneway = (method.getAnnotation(Oneway.class) != null) ? true : false;
boolean isAsync = method.getName().endsWith("Async");
if (isOneway) {
clientBinding.invokeOneWay(objMsgContext,
new JAXBDataBindingCallback(method,
DataBindingCallback.Mode.PARTS,
context,
schema));
} else if (isAsync) {
Future<ObjectMessageContext> objMsgContextAsynch =
clientBinding.invokeAsync(objMsgContext,
new JAXBDataBindingCallback(method,
DataBindingCallback.Mode.PARTS,
context,
schema)
, service.getExecutor());
Response<?> r = new AsyncResponse<Object>(objMsgContextAsynch, Object.class);
if (parameters.length > 0 && parameters[parameters.length - 1] instanceof AsyncHandler) {
// callback style
AsyncCallbackFuture f = new AsyncCallbackFuture(r,
(AsyncHandler)parameters[parameters.length - 1]);
// service must always have an executor associated with it
service.getExecutor().execute(f);
return f;
} else {
return r;
}
} else {
objMsgContext = clientBinding.invoke(objMsgContext,
new JAXBDataBindingCallback(method,
DataBindingCallback.Mode.PARTS,
context,
schema));
}
populateResponseContext(objMsgContext);
if (objMsgContext.getException() != null) {
LOG.log(Level.INFO, "ENDPOINT_INVOCATION_FAILED", method.getName());
if (isValidException(objMsgContext)) {
throw (Exception)objMsgContext.getException();
} else {
throw new ProtocolException(objMsgContext.getException());
}
}
return objMsgContext.getReturn();
}