本文整理了Java中org.apache.tuscany.sca.invocation.Message.isFault()
方法的一些代码示例,展示了Message.isFault()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.isFault()
方法的具体详情如下:
包路径:org.apache.tuscany.sca.invocation.Message
类名称:Message
方法名:isFault
[英]Determines if the message represents a fault/exception
[中]确定消息是否表示故障/异常
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-http-runtime
private Message invokeResponse(Message msg) throws IOException {
HTTPContext context = msg.getBindingContext();
HttpServletRequest servletRequest = context.getHttpRequest();
HttpServletResponse servletResponse = context.getHttpResponse();
if (msg.isFault()) {
servletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, String.valueOf(msg.getBody()));
} else {
String response = getResponseAsString(servletRequest, servletResponse, msg.getBody());
servletResponse.getOutputStream().println(response);
}
return msg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
Message msg = messageFactory.createMessage();
msg.setBody(args);
Message resp = invoke(operation, msg);
Object body = resp.getBody();
if (resp.isFault()) {
throw new InvocationTargetException((Throwable)body);
}
return body;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-http-runtime
private Message invokeResponse(Message msg) throws IOException {
HTTPContext context = msg.getBindingContext();
HttpServletResponse servletResponse = context.getHttpResponse();
servletResponse.setContentType("text/xml");
Object o = msg.getBody();
if (msg.isFault()) {
String xml = domHelper.saveAsString((Node)((FaultException)o).getFaultInfo());
servletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, xml);
} else {
String xml = "";
if (o instanceof Element) {
xml = domHelper.saveAsString((Node)o);
} else if ((o instanceof Object[]) && ((Object[])o)[0] instanceof Node) {
xml = domHelper.saveAsString((Node)((Object[])o)[0]);
} else if (o != null) {
throw new IllegalStateException("expecting Node payload: " + o);
}
servletResponse.getOutputStream().println(xml);
}
return msg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-atom-runtime
@Override
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Authenticate the user
String user = processAuthorizationHeader(request);
if (user == null) {
unauthorized(response);
return;
}
// Get the request path
String path = URLDecoder.decode(HTTPUtils.getRequestPath(request), "UTF-8");
String id;
if (path != null && path.startsWith("/")) {
id = path.substring(1);
} else {
id = "";
}
// Delete a specific entry from the collection
Message requestMessage = messageFactory.createMessage();
requestMessage.setBody(new Object[] {id});
Message responseMessage = deleteInvoker.invoke(requestMessage);
if (responseMessage.isFault()) {
Object body = responseMessage.getBody();
if (body.getClass().getName().endsWith(".NotFoundException")) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} else {
throw new ServletException((Throwable)responseMessage.getBody());
}
}
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-http-runtime
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HTTPContext bindingContext = new HTTPContext();
bindingContext.setHttpRequest(request);
bindingContext.setHttpResponse(response);
Message msg = messageFactory.createMessage();
msg.setBindingContext(bindingContext);
Message responseMessage = wire.invoke(msg);
// return response to client
if (responseMessage.isFault()) {
// Turn a fault into an exception
Throwable e = (Throwable)responseMessage.getBody();
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
}
}
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
if (resultMsg.isFault()) {
Object transformedFault = null;
if ((result instanceof Exception) && !(result instanceof RuntimeException)) {
代码示例来源:origin: org.apache.tuscany.sca/tuscany-core-databinding
if (resultMsg.isFault()) {
Object transformedFault = null;
if ((result instanceof Exception) && !(result instanceof RuntimeException)) {
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-rest-runtime
requestMessage.setBody(new Object[]{request, response});
Message responseMessage = serviceInvoker.invoke(requestMessage);
if (responseMessage.isFault()) {
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
public void run() {
Message context = ThreadMessageContext.setMessageContext(msg);
try {
Message response = null;
Throwable ex = null;
try {
response = next.invoke(msg);
} catch (Throwable t) {
ex = t;
}
// Tuscany-2225 - Did the @OneWay method complete successfully?
// (i.e. no exceptions)
if (response != null && response.isFault()) {
// The @OneWay method threw an Exception. Lets log it and
// then pass it on to the WorkScheduler so it can notify any
// listeners
ex = (Throwable)response.getBody();
}
if (ex != null) {
LOGGER.log(Level.SEVERE, "Exception from @OneWay invocation", ex);
throw new ServiceRuntimeException("Exception from @OneWay invocation", ex);
}
} finally {
ThreadMessageContext.setMessageContext(context);
}
}
});
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-sca-runtime
/**
* Regular (sync) processing of response message
*/
public Message processResponse(Message msg){
if (passByValue) {
// Note source and target operation swapped so result is in source class loader
if (msg.isFault()) {
Object transformedFault = bindingSCATransformer.transformFault(msg.getBody());
msg.setFaultBody(transformedFault);
} else {
Object transformedOutput = bindingSCATransformer.transformOutput(msg.getBody());
msg.setBody(transformedOutput);
} // end if
} // end if
return msg;
} // end method processResponse
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
/**
* Regular (sync) processing of response message
*/
public Message processResponse(Message msg){
if (passByValue) {
// Note source and target operation swapped so result is in source class loader
if (msg.isFault()) {
Object transformedFault = bindingSCATransformer.transformFault(msg.getBody());
msg.setFaultBody(transformedFault);
} else {
Object transformedOutput = bindingSCATransformer.transformOutput(msg.getBody());
msg.setBody(transformedOutput);
} // end if
} // end if
return msg;
} // end method processResponse
代码示例来源:origin: org.apache.tuscany.sca/tuscany-core-databinding
public Message invoke(Message msg) {
if (chain.allowsPassByReference()) {
return nextInvoker.invoke(msg);
}
msg.setBody(mediator.copyInput(msg.getBody(), operation));
Message resultMsg = nextInvoker.invoke(msg);
if (!resultMsg.isFault() && operation.getOutputType() != null) {
resultMsg.setBody(mediator.copyOutput(resultMsg.getBody(), operation));
}
if (resultMsg.isFault()) {
resultMsg.setFaultBody(mediator.copyFault(resultMsg.getBody(), operation));
}
return resultMsg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
public Message invoke(Message msg) {
if (chain.allowsPassByReference()) {
return nextInvoker.invoke(msg);
}
msg.setBody(mediator.copyInput(msg.getBody(), operation));
Message resultMsg = nextInvoker.invoke(msg);
if (!resultMsg.isFault() && operation.getOutputType() != null) {
resultMsg.setBody(mediator.copyOutput(resultMsg.getBody(), operation));
}
if (resultMsg.isFault()) {
resultMsg.setFaultBody(mediator.copyFault(resultMsg.getBody(), operation));
}
return resultMsg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-ws-runtime-axis2
MessageContext responseMC = bindingContext.getAxisOutMessageContext();
if(!response.isFault()) {
OMElement responseOM = response.getBody();
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime
public Message invokeResponse(Message msg) {
// get the jms context
JMSBindingContext context = msg.getBindingContext();
// The Binding Context may be null on an asynchronous response - in which case, create a new one
if(context == null) {
context = createBindingContext();
msg.setBindingContext(context);
}
Session session = context.getJmsResponseSession();
javax.jms.Message responseJMSMsg;
if (msg.isFault()) {
responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
} else {
Object response = msg.getBody();
responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, response);
}
msg.setBody(responseJMSMsg);
return msg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime
public Message invokeResponse(Message msg) {
// get the jms context
JMSBindingContext context = msg.getBindingContext();
// The Binding Context may be null on an asynchronous response - in which case, create a new one
if(context == null) {
context = createBindingContext();
msg.setBindingContext(context);
}
Session session = context.getJmsResponseSession();
javax.jms.Message responseJMSMsg;
if (msg.isFault()) {
responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
} else {
responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
}
msg.setBody(responseJMSMsg);
return msg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime
public Message invokeResponse(Message msg) {
// get the jms context
JMSBindingContext context = msg.getBindingContext();
// The Binding Context may be null on an asynchronous response - in which case, create a new one
if(context == null) {
context = createBindingContext();
msg.setBindingContext(context);
}
Session session = context.getJmsResponseSession();
javax.jms.Message responseJMSMsg = null;
if (msg.isFault()) {
responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
} else {
responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
}
msg.setBody(responseJMSMsg);
return msg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime
public Message invokeResponse(Message msg) {
// get the jms context
JMSBindingContext context = msg.getBindingContext();
// The Binding Context may be null on an asynchronous response - in which case, create a new one
if(context == null) {
context = createBindingContext();
msg.setBindingContext(context);
}
Session session = context.getJmsResponseSession();
javax.jms.Message responseJMSMsg;
if (msg.isFault()) {
responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
} else {
Object response = msg.getBody();
responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, response);
}
msg.setBody(responseJMSMsg);
return msg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime
public Message invokeResponse(Message msg) {
// get the jms context
JMSBindingContext context = msg.getBindingContext();
// The Binding Context may be null on an asynchronous response - in which case, create a new one
if(context == null) {
context = createBindingContext();
msg.setBindingContext(context);
}
Session session = context.getJmsResponseSession();
javax.jms.Message responseJMSMsg;
if (msg.isFault()) {
responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
} else {
Object response = msg.getBody();
responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, response);
}
msg.setBody(responseJMSMsg);
return msg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime
if (msg.isFault()) {
if (respondBytesMessage == true) {
responseJMSMsg = requestMessageProcessor.createFaultJMSBytesMessage(session, (Throwable) msg.getBody());
内容来源于网络,如有侵权,请联系作者删除!