org.apache.tuscany.sca.invocation.Message类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(254)

本文整理了Java中org.apache.tuscany.sca.invocation.Message类的一些代码示例,展示了Message类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message类的具体详情如下:
包路径:org.apache.tuscany.sca.invocation.Message
类名称:Message

Message介绍

[英]Represents a request, response, or exception flowing through a wire
[中]表示通过连接的请求、响应或异常

代码示例

代码示例来源:origin: com.jns.apps/scallop-binding-rmi-runtime

  1. public Message invoke(Message msg) {
  2. try {
  3. Object[] args = msg.getBody();
  4. Object resp = invokeTarget(args);
  5. msg.setBody(resp);
  6. } catch (InvocationTargetException e) {
  7. msg.setFaultBody(e.getCause());
  8. } catch (Exception e) {
  9. msg.setFaultBody(e);
  10. }
  11. return msg;
  12. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-implementation-script-runtime

  1. public Message invoke(Message msg) {
  2. try {
  3. Object resp = doInvoke((Object[])msg.getBody(), msg.getOperation());
  4. msg.setBody(resp);
  5. } catch (ScriptException e) {
  6. msg.setFaultBody(e.getCause());
  7. }
  8. return msg;
  9. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime

  1. public Message invokeResponse(Message msg) {
  2. // get the jms context
  3. JMSBindingContext context = msg.getBindingContext();
  4. // The Binding Context may be null on an asynchronous response - in which case, create a new one
  5. if(context == null) {
  6. context = createBindingContext();
  7. msg.setBindingContext(context);
  8. }
  9. Session session = context.getJmsResponseSession();
  10. javax.jms.Message responseJMSMsg;
  11. if (msg.isFault()) {
  12. responseJMSMsg = responseMessageProcessor.createFaultMessage(session, (Throwable)msg.getBody());
  13. } else {
  14. responseJMSMsg = responseMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
  15. }
  16. msg.setBody(responseJMSMsg);
  17. return msg;
  18. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-implementation-bpel-runtime

  1. public Message invoke(Message msg) {
  2. try {
  3. if( isCallback ) {
  4. // Extract the callback endpoint metadata
  5. callbackEPR = msg.getFrom();
  6. } // end if
  7. Object[] args = msg.getBody();
  8. Object resp = doTheWork(args);
  9. msg.setBody(resp);
  10. } catch (InvocationTargetException e) {
  11. msg.setFaultBody(e.getCause());
  12. }
  13. return msg;
  14. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-sca-runtime

  1. /**
  2. * Regular (sync) processing of response message
  3. */
  4. public Message processResponse(Message msg){
  5. if (passByValue) {
  6. // Note source and target operation swapped so result is in source class loader
  7. if (msg.isFault()) {
  8. Object transformedFault = bindingSCATransformer.transformFault(msg.getBody());
  9. msg.setFaultBody(transformedFault);
  10. } else {
  11. Object transformedOutput = bindingSCATransformer.transformOutput(msg.getBody());
  12. msg.setBody(transformedOutput);
  13. } // end if
  14. } // end if
  15. return msg;
  16. } // end method processResponse

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

  1. Message msg = messageFactory.createMessage();
  2. if (source instanceof RuntimeEndpointReference) {
  3. msg.setFrom((RuntimeEndpointReference)source);
  4. msg.setTo(target);
  5. } else {
  6. if (source instanceof RuntimeEndpointReference) {
  7. msg.setTo(((RuntimeEndpointReference)source).getTargetEndpoint());
  8. msg.getHeaders().put(Constants.CALLBACK, ((CallbackServiceReferenceImpl)callableReference).getCallbackHandler());
  9. operation = chain.getTargetOperation();
  10. msg.setOperation(operation);
  11. msg.setBody(args);
  12. msg.getHeaders().put(Constants.RELATES_TO, msgID);
  13. Object body = resp.getBody();
  14. if (resp.isFault()) {
  15. throw (Throwable)body;

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

  1. public Message processRequest(Message msg){
  2. if (passByValue) {
  3. Object transformedBody = bindingSCATransformer.transformInput(msg.getBody());
  4. msg.setBody(transformedBody);
  5. } // end if
  6. ep.getInvocationChains();
  7. if ( !ep.getCallbackEndpointReferences().isEmpty() ) {
  8. RuntimeEndpointReference asyncEPR = (RuntimeEndpointReference) ep.getCallbackEndpointReferences().get(0);
  9. // Place a link to the callback EPR into the message headers...
  10. msg.getHeaders().put("ASYNC_CALLBACK", asyncEPR );
  11. } // end if
  12. if( ep.isAsyncInvocation() ) {
  13. // Get the message ID
  14. String msgID = (String)msg.getHeaders().get("MESSAGE_ID");
  15. String operationName = msg.getOperation().getName();
  16. // Create a response invoker and add it to the message headers
  17. AsyncResponseInvoker<RuntimeEndpointReference> respInvoker =
  18. new AsyncResponseInvoker<RuntimeEndpointReference>(ep, null, epr, msgID, operationName, getMessageFactory());
  19. respInvoker.setBindingType("SCA_LOCAL");
  20. msg.getHeaders().put("ASYNC_RESPONSE_INVOKER", respInvoker);
  21. } // end if
  22. return msg;
  23. } // end method processRequest

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

  1. msg.setOperation(getOperation( args ));
  2. msg.setTo(requestEndpoint);
  3. msg.setFrom(responseEndpointReference);
  4. msg.getHeaders().putAll(headers);
  5. msg.setFaultBody(args);
  6. } else {
  7. msg.setBody(args);

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

  1. public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
  2. Message msg = messageFactory.createMessage();
  3. msg.setBody(args);
  4. Message resp = invoke(operation, msg);
  5. Object body = resp.getBody();
  6. if (resp.isFault()) {
  7. throw new InvocationTargetException((Throwable)body);
  8. }
  9. return body;
  10. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-core-databinding

  1. public Message processRequest(Message msg) {
  2. Map<String, Object> metadata = new HashMap<String, Object>();
  3. metadata.put(Invocable.class.getName(), invocable);
  4. Object input = mediator.mediateInput(msg.getBody(), sourceOperation, targetOperation, metadata);
  5. msg.setBody(input);
  6. return msg;
  7. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime

  1. public Message invokeRequest(Message msg) {
  2. try {
  3. // get the jms context
  4. JMSBindingContext context = msg.getBindingContext();
  5. Session session = context.getJmsSession();
  6. javax.jms.Message requestMsg;
  7. if (((WireFormatJMSDefault) jmsBinding.getRequestWireFormat()).isUseBytesMessage()) {
  8. requestMsg = requestMessageProcessor.insertPayloadIntoJMSBytesMessage(session, msg.getBody(), this.inputWrapperMap.get(msg.getOperation().getName()));
  9. } else {
  10. requestMsg = requestMessageProcessor.insertPayloadIntoJMSTextMessage(session, msg.getBody(), this.inputWrapperMap.get(msg.getOperation().getName()));
  11. }
  12. msg.setBody(requestMsg);
  13. requestMsg.setJMSReplyTo(context.getReplyToDestination());
  14. return msg;
  15. } catch (JMSException e) {
  16. throw new JMSBindingException(e);
  17. }
  18. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime

  1. public Message invokeRequest(Message msg) {
  2. try {
  3. // get the jms context
  4. JMSBindingContext context = msg.getBindingContext();
  5. Session session = context.getJmsSession();
  6. javax.jms.Message requestMsg = requestMessageProcessor.insertPayloadIntoJMSMessage(session, msg.getBody());
  7. msg.setBody(requestMsg);
  8. requestMsg.setJMSReplyTo(context.getReplyToDestination());
  9. return msg;
  10. } catch (JMSException e) {
  11. throw new JMSBindingException(e);
  12. }
  13. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

  1. requestMsg.setBody(body);
  2. requestMsg.setOperation(operation);
  3. from.setTargetEndpoint(fromEndpoint);
  4. from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
  5. requestMsg.setFrom(from);
  6. RuntimeEndpoint callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
  7. if (responseMsg.isFault()) {
  8. FaultException fe = responseMsg.getBody();
  9. SOAPFault fault = response.getSOAPBody().addFault(new QName(response.getSOAPBody().getNamespaceURI(), "Server"), fe.getMessage());
  10. Detail d = fault.addDetail();
  11. Element element = responseMsg.getBody();
  12. response.getSOAPBody().addChildElement(soapFactory.createElement(element));

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-http-runtime

  1. private Message invokeRequest(Message msg) throws IOException {
  2. HTTPContext context = msg.getBindingContext();
  3. HttpServletRequest servletRequest = context.getHttpRequest();
  4. if ("GET".equals(servletRequest.getMethod())) {
  5. msg.setBody(getRequestFromQueryString(msg.getOperation(), servletRequest));
  6. } else {
  7. msg.setBody(getRequestFromPost(msg.getOperation(), servletRequest));
  8. }
  9. return msg;
  10. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-jms-runtime

  1. public Message invokeRequest(Message msg) {
  2. // get the jms context
  3. JMSBindingContext context = msg.getBindingContext();
  4. javax.jms.Message jmsMsg = context.getJmsMsg();
  5. Object requestPayload = requestMessageProcessor.extractPayloadFromJMSMessage(jmsMsg);
  6. msg.setBody(new Object[]{requestPayload});
  7. return msg;
  8. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-ws-runtime-axis2

  1. WSAxis2BindingContext bindingContext = msg.getBindingContext();
  2. MessageContext responseMC = bindingContext.getAxisOutMessageContext();
  3. if(!response.isFault()) {
  4. OMElement responseOM = response.getBody();
  5. while(iter.hasNext()){
  6. BindingOperation bOp = (BindingOperation)iter.next();
  7. if (bOp.getName().equals(msg.getOperation().getName())){
  8. for (Object ext : bOp.getBindingOutput().getExtensibilityElements()){
  9. if (ext instanceof javax.wsdl.extensions.soap.SOAPBody){
  10. msg.getOperation().getName() + "Response");
  11. OMElement operationResponseElement = factory.createOMElement(operationResponseQName);
  12. operationResponseElement.addChild(responseOM);

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-http-runtime

  1. private Message invokeResponse(Message msg) throws IOException {
  2. HTTPContext context = msg.getBindingContext();
  3. HttpServletRequest servletRequest = context.getHttpRequest();
  4. HttpServletResponse servletResponse = context.getHttpResponse();
  5. if (msg.isFault()) {
  6. servletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, String.valueOf(msg.getBody()));
  7. } else {
  8. String response = getResponseAsString(servletRequest, servletResponse, msg.getBody());
  9. servletResponse.getOutputStream().println(response);
  10. }
  11. return msg;
  12. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-implementation-osgi-runtime

  1. public Message invoke(Message msg) {
  2. try {
  3. Object resp = invokeTarget(msg);
  4. msg.setBody(resp);
  5. } catch (InvocationTargetException e) {
  6. msg.setFaultBody(e.getCause());
  7. }
  8. return msg;
  9. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-http-runtime

  1. @Override
  2. protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  3. HTTPContext bindingContext = new HTTPContext();
  4. bindingContext.setHttpRequest(request);
  5. bindingContext.setHttpResponse(response);
  6. Message msg = messageFactory.createMessage();
  7. msg.setBindingContext(bindingContext);
  8. Message responseMessage = wire.invoke(msg);
  9. // return response to client
  10. if (responseMessage.isFault()) {
  11. // Turn a fault into an exception
  12. Throwable e = (Throwable)responseMessage.getBody();
  13. response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.toString());
  14. }
  15. }
  16. }

代码示例来源:origin: org.apache.tuscany.sca/tuscany-binding-comet-runtime

  1. /**
  2. * Creates a message with a mocked EndpointReference in the 'from' field to
  3. * simulate a comet reference (because requests are coming from browsers).
  4. * This is needed by the callback mechanism to have a source for the
  5. * request.
  6. *
  7. * @param args
  8. * arguments for the method invocation
  9. * @param sessionId
  10. * the session id of the client
  11. * @param callbackMethod
  12. * method to call once a response is available
  13. * @return an invocation message
  14. */
  15. private Message createMessageWithMockedCometReference(Object[] args, String sessionId, String callbackMethod) {
  16. Message msg = new MessageImpl();
  17. msg.getHeaders().put(Constants.MESSAGE_ID, sessionId);
  18. msg.setBody(args);
  19. EndpointReference re = new RuntimeEndpointReferenceImpl();
  20. RuntimeEndpointImpl callbackEndpoint = new RuntimeEndpointImpl();
  21. callbackEndpoint.setURI(callbackMethod);
  22. re.setCallbackEndpoint(callbackEndpoint);
  23. msg.setFrom(re);
  24. return msg;
  25. }

相关文章