本文整理了Java中org.apache.tuscany.sca.invocation.Message
类的一些代码示例,展示了Message
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message
类的具体详情如下:
包路径:org.apache.tuscany.sca.invocation.Message
类名称:Message
[英]Represents a request, response, or exception flowing through a wire
[中]表示通过连接的请求、响应或异常
代码示例来源:origin: com.jns.apps/scallop-binding-rmi-runtime
public Message invoke(Message msg) {
try {
Object[] args = msg.getBody();
Object resp = invokeTarget(args);
msg.setBody(resp);
} catch (InvocationTargetException e) {
msg.setFaultBody(e.getCause());
} catch (Exception e) {
msg.setFaultBody(e);
}
return msg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-implementation-script-runtime
public Message invoke(Message msg) {
try {
Object resp = doInvoke((Object[])msg.getBody(), msg.getOperation());
msg.setBody(resp);
} catch (ScriptException e) {
msg.setFaultBody(e.getCause());
}
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-implementation-bpel-runtime
public Message invoke(Message msg) {
try {
if( isCallback ) {
// Extract the callback endpoint metadata
callbackEPR = msg.getFrom();
} // end if
Object[] args = msg.getBody();
Object resp = doTheWork(args);
msg.setBody(resp);
} catch (InvocationTargetException e) {
msg.setFaultBody(e.getCause());
}
return msg;
}
代码示例来源: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
Message msg = messageFactory.createMessage();
if (source instanceof RuntimeEndpointReference) {
msg.setFrom((RuntimeEndpointReference)source);
msg.setTo(target);
} else {
if (source instanceof RuntimeEndpointReference) {
msg.setTo(((RuntimeEndpointReference)source).getTargetEndpoint());
msg.getHeaders().put(Constants.CALLBACK, ((CallbackServiceReferenceImpl)callableReference).getCallbackHandler());
operation = chain.getTargetOperation();
msg.setOperation(operation);
msg.setBody(args);
msg.getHeaders().put(Constants.RELATES_TO, msgID);
Object body = resp.getBody();
if (resp.isFault()) {
throw (Throwable)body;
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
public Message processRequest(Message msg){
if (passByValue) {
Object transformedBody = bindingSCATransformer.transformInput(msg.getBody());
msg.setBody(transformedBody);
} // end if
ep.getInvocationChains();
if ( !ep.getCallbackEndpointReferences().isEmpty() ) {
RuntimeEndpointReference asyncEPR = (RuntimeEndpointReference) ep.getCallbackEndpointReferences().get(0);
// Place a link to the callback EPR into the message headers...
msg.getHeaders().put("ASYNC_CALLBACK", asyncEPR );
} // end if
if( ep.isAsyncInvocation() ) {
// Get the message ID
String msgID = (String)msg.getHeaders().get("MESSAGE_ID");
String operationName = msg.getOperation().getName();
// Create a response invoker and add it to the message headers
AsyncResponseInvoker<RuntimeEndpointReference> respInvoker =
new AsyncResponseInvoker<RuntimeEndpointReference>(ep, null, epr, msgID, operationName, getMessageFactory());
respInvoker.setBindingType("SCA_LOCAL");
msg.getHeaders().put("ASYNC_RESPONSE_INVOKER", respInvoker);
} // end if
return msg;
} // end method processRequest
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
msg.setOperation(getOperation( args ));
msg.setTo(requestEndpoint);
msg.setFrom(responseEndpointReference);
msg.getHeaders().putAll(headers);
msg.setFaultBody(args);
} else {
msg.setBody(args);
代码示例来源: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-core-databinding
public Message processRequest(Message msg) {
Map<String, Object> metadata = new HashMap<String, Object>();
metadata.put(Invocable.class.getName(), invocable);
Object input = mediator.mediateInput(msg.getBody(), sourceOperation, targetOperation, metadata);
msg.setBody(input);
return msg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime
public Message invokeRequest(Message msg) {
try {
// get the jms context
JMSBindingContext context = msg.getBindingContext();
Session session = context.getJmsSession();
javax.jms.Message requestMsg;
if (((WireFormatJMSDefault) jmsBinding.getRequestWireFormat()).isUseBytesMessage()) {
requestMsg = requestMessageProcessor.insertPayloadIntoJMSBytesMessage(session, msg.getBody(), this.inputWrapperMap.get(msg.getOperation().getName()));
} else {
requestMsg = requestMessageProcessor.insertPayloadIntoJMSTextMessage(session, msg.getBody(), this.inputWrapperMap.get(msg.getOperation().getName()));
}
msg.setBody(requestMsg);
requestMsg.setJMSReplyTo(context.getReplyToDestination());
return msg;
} catch (JMSException e) {
throw new JMSBindingException(e);
}
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime
public Message invokeRequest(Message msg) {
try {
// get the jms context
JMSBindingContext context = msg.getBindingContext();
Session session = context.getJmsSession();
javax.jms.Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
msg.setBody(requestMsg);
requestMsg.setJMSReplyTo(context.getReplyToDestination());
return msg;
} catch (JMSException e) {
throw new JMSBindingException(e);
}
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime
requestMsg.setBody(body);
requestMsg.setOperation(operation);
from.setTargetEndpoint(fromEndpoint);
from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
requestMsg.setFrom(from);
RuntimeEndpoint callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
if (responseMsg.isFault()) {
FaultException fe = responseMsg.getBody();
SOAPFault fault = response.getSOAPBody().addFault(new QName(response.getSOAPBody().getNamespaceURI(), "Server"), fe.getMessage());
Detail d = fault.addDetail();
Element element = responseMsg.getBody();
response.getSOAPBody().addChildElement(soapFactory.createElement(element));
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-http-runtime
private Message invokeRequest(Message msg) throws IOException {
HTTPContext context = msg.getBindingContext();
HttpServletRequest servletRequest = context.getHttpRequest();
if ("GET".equals(servletRequest.getMethod())) {
msg.setBody(getRequestFromQueryString(msg.getOperation(), servletRequest));
} else {
msg.setBody(getRequestFromPost(msg.getOperation(), servletRequest));
}
return msg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime
public Message invokeRequest(Message msg) {
// get the jms context
JMSBindingContext context = msg.getBindingContext();
javax.jms.Message jmsMsg = context.getJmsMsg();
Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
msg.setBody(new Object[]{requestPayload});
return msg;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-ws-runtime-axis2
WSAxis2BindingContext bindingContext = msg.getBindingContext();
MessageContext responseMC = bindingContext.getAxisOutMessageContext();
if(!response.isFault()) {
OMElement responseOM = response.getBody();
while(iter.hasNext()){
BindingOperation bOp = (BindingOperation)iter.next();
if (bOp.getName().equals(msg.getOperation().getName())){
for (Object ext : bOp.getBindingOutput().getExtensibilityElements()){
if (ext instanceof javax.wsdl.extensions.soap.SOAPBody){
msg.getOperation().getName() + "Response");
OMElement operationResponseElement = factory.createOMElement(operationResponseQName);
operationResponseElement.addChild(responseOM);
代码示例来源: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-implementation-osgi-runtime
public Message invoke(Message msg) {
try {
Object resp = invokeTarget(msg);
msg.setBody(resp);
} catch (InvocationTargetException e) {
msg.setFaultBody(e.getCause());
}
return msg;
}
代码示例来源: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-binding-comet-runtime
/**
* Creates a message with a mocked EndpointReference in the 'from' field to
* simulate a comet reference (because requests are coming from browsers).
* This is needed by the callback mechanism to have a source for the
* request.
*
* @param args
* arguments for the method invocation
* @param sessionId
* the session id of the client
* @param callbackMethod
* method to call once a response is available
* @return an invocation message
*/
private Message createMessageWithMockedCometReference(Object[] args, String sessionId, String callbackMethod) {
Message msg = new MessageImpl();
msg.getHeaders().put(Constants.MESSAGE_ID, sessionId);
msg.setBody(args);
EndpointReference re = new RuntimeEndpointReferenceImpl();
RuntimeEndpointImpl callbackEndpoint = new RuntimeEndpointImpl();
callbackEndpoint.setURI(callbackMethod);
re.setCallbackEndpoint(callbackEndpoint);
msg.setFrom(re);
return msg;
}
内容来源于网络,如有侵权,请联系作者删除!