org.apache.tuscany.sca.invocation.Message.getTo()方法的使用及代码示例

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

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

Message.getTo介绍

[英]Get the end point reference of target service
[中]获取目标服务的端点引用

代码示例

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

  1. /**
  2. * @return
  3. */
  4. public static RuntimeComponent getCurrentComponent() {
  5. Message message = ThreadMessageContext.getMessageContext();
  6. if (message != null) {
  7. Endpoint to = message.getTo();
  8. if (to == null) {
  9. return null;
  10. }
  11. RuntimeComponent component = (RuntimeComponent)message.getTo().getComponent();
  12. return component;
  13. }
  14. return null;
  15. }

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

  1. /**
  2. * @return
  3. */
  4. public static RuntimeComponent getCurrentComponent() {
  5. Message message = ThreadMessageContext.getMessageContext();
  6. if (message != null) {
  7. Endpoint to = message.getTo();
  8. if (to == null) {
  9. return null;
  10. }
  11. RuntimeComponent component = (RuntimeComponent)message.getTo().getComponent();
  12. return component;
  13. }
  14. return null;
  15. }

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

  1. public String getServiceName() {
  2. Message msgContext = ThreadMessageContext.getMessageContext();
  3. if (msgContext != null &&
  4. msgContext.getTo() != null){
  5. return msgContext.getTo().getService().getName();
  6. } else {
  7. // message in thread context could be null (or the default message where to == null)
  8. // if the user has spun up a new thread inside their component implementation
  9. return null;
  10. }
  11. }

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

  1. public <B> ServiceReference<B> getServiceReference() {
  2. Message msgContext = ThreadMessageContext.getMessageContext();
  3. if (msgContext == null ||
  4. msgContext.getTo() == null){
  5. // message in thread context could be null (or the default message where to == null)
  6. // if the user has spun up a new thread inside their component implementation
  7. return null;
  8. }
  9. // FIXME: [rfeng] Is this the service reference matching the caller side?
  10. RuntimeEndpoint to = (RuntimeEndpoint) msgContext.getTo();
  11. RuntimeComponent component = (RuntimeComponent) to.getComponent();
  12. ServiceReference<B> callableReference = component.getComponentContext().getServiceReference(null, to);
  13. return callableReference;
  14. }

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

  1. private String getToAddress(Message msg) throws ServiceRuntimeException {
  2. String address = null;
  3. // if target endpoint was not specified when this invoker was created,
  4. // use dynamically specified target endpoint passed in with the message
  5. String to = getPortLocation();
  6. if (to == null) {
  7. Endpoint ep = msg.getTo();
  8. if (ep != null && ep.getBinding() != null) {
  9. address = ep.getDeployedURI();
  10. } else {
  11. throw new ServiceRuntimeException(
  12. "[BWS20025] Unable to determine destination endpoint for endpoint reference " + endpointReference);
  13. }
  14. } else {
  15. address = to;
  16. }
  17. return address;
  18. } // end method getToAddress

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

  1. @SuppressWarnings("unchecked")
  2. public <CB> ServiceReference<CB> getCallbackReference() {
  3. Message msgContext = ThreadMessageContext.getMessageContext();
  4. if (msgContext == null ||
  5. msgContext.getTo() == null){
  6. // message in thread context could be null (or the default message where to == null)
  7. // if the user has spun up a new thread inside their component implementation
  8. return null;
  9. }
  10. Endpoint to = msgContext.getTo();
  11. RuntimeComponentService service = (RuntimeComponentService) to.getService();
  12. RuntimeComponentReference callbackReference = (RuntimeComponentReference)service.getCallbackReference();
  13. if (callbackReference == null) {
  14. return null;
  15. }
  16. JavaInterface javaInterface = (JavaInterface) callbackReference.getInterfaceContract().getInterface();
  17. Class<CB> javaClass = (Class<CB>)javaInterface.getJavaClass();
  18. List<EndpointReference> wires = callbackReference.getEndpointReferences();
  19. ServiceReferenceImpl ref = new CallbackServiceReferenceImpl(javaClass, wires);
  20. return ref;
  21. }
  22. }

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

  1. private RuntimeEndpointReference selectCallbackEPR(Message msgContext) {
  2. // look for callback binding with same name as service binding
  3. Endpoint to = msgContext.getTo();
  4. if (to == null) {
  5. //FIXME: need better exception
  6. throw new ServiceRuntimeException("Destination for forward call is not available");
  7. }
  8. for (EndpointReference epr : callbackEPRs) {
  9. if (epr.getBinding().getName().equals(to.getBinding().getName())) {
  10. return (RuntimeEndpointReference) epr;
  11. }
  12. }
  13. // if no match, look for callback binding with same type as service binding
  14. for (EndpointReference epr : callbackEPRs) {
  15. if (epr.getBinding().getType().equals(to.getBinding().getType())) {
  16. return (RuntimeEndpointReference) epr;
  17. }
  18. }
  19. // no suitable callback wire was found
  20. return null;
  21. }

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

  1. /**
  2. * Sends message back to the browser client and reports connection status to
  3. * the runtime.
  4. *
  5. * @param msg
  6. * message to send to the browser
  7. * @return the connection status
  8. */
  9. @Override
  10. public Message invoke(final Message msg) {
  11. String sessionId = (String) msg.getHeaders().get(Constants.RELATES_TO);
  12. Broadcaster broadcaster = CometSessionManager.get(sessionId);
  13. Message response = new MessageImpl();
  14. if (broadcaster == null) {
  15. response.setBody(Status.CLIENT_DISCONNECTED);
  16. } else {
  17. String callbackMethod = msg.getTo().getURI();
  18. Object[] body = msg.getBody();
  19. broadcaster.broadcast(callbackMethod + "($.secureEvalJSON('" + JSONUtil.encodeResponse(body[0]) + "'))");
  20. response.setBody(Status.OK);
  21. }
  22. return response;
  23. }

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

  1. private String getToAddress( Message msg ) throws ServiceRuntimeException {
  2. String address = null;
  3. // if target endpoint was not specified when this invoker was created,
  4. // use dynamically specified target endpoint passed in with the message
  5. if (options.getTo() == null) {
  6. Endpoint ep = msg.getTo();
  7. if (ep != null &&
  8. ep.getBinding() != null &&
  9. ep.getBinding().getURI() != null &&
  10. ep.getBinding().getURI().length() > 0) {
  11. address = ep.getBinding().getURI();
  12. } else {
  13. throw new ServiceRuntimeException("[BWS20025] Unable to determine destination endpoint for endpoint reference " + endpointReference);
  14. }
  15. } else {
  16. address = options.getTo().getAddress();
  17. }
  18. return address;
  19. } // end method getToAddress

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

  1. throw new ServiceRuntimeException("No callback binding found for " + msgContext.getTo().toString());

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

  1. Endpoint ep = msg.getTo();
  2. if (ep != null && ep.getBinding() != null) {
  3. String address = ep.getDeployedURI();

相关文章