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

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

本文整理了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

/**
 * @return
 */
public static RuntimeComponent getCurrentComponent() {
  Message message = ThreadMessageContext.getMessageContext();
  if (message != null) {
    Endpoint to = message.getTo();
    if (to == null) {
      return null;
    }
    RuntimeComponent component = (RuntimeComponent)message.getTo().getComponent();
    return component;
  }
  return null;
}

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

/**
 * @return
 */
public static RuntimeComponent getCurrentComponent() {
  Message message = ThreadMessageContext.getMessageContext();
  if (message != null) {
    Endpoint to = message.getTo();
    if (to == null) {
      return null;
    }
    RuntimeComponent component = (RuntimeComponent)message.getTo().getComponent();
    return component;
  }
  return null;
}

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

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

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

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

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

private String getToAddress(Message msg) throws ServiceRuntimeException {
  String address = null;
  // if target endpoint was not specified when this invoker was created,
  // use dynamically specified target endpoint passed in with the message
  String to = getPortLocation();
  if (to == null) {
    Endpoint ep = msg.getTo();
    if (ep != null && ep.getBinding() != null) {
      address = ep.getDeployedURI();
    } else {
      throw new ServiceRuntimeException(
                       "[BWS20025] Unable to determine destination endpoint for endpoint reference " + endpointReference);
    }
  } else {
    address = to;
  }
  return address;
} // end method getToAddress

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

@SuppressWarnings("unchecked")
  public <CB> ServiceReference<CB> getCallbackReference() {
    Message msgContext = ThreadMessageContext.getMessageContext();
    if (msgContext == null || 
      msgContext.getTo() == null){
      // message in thread context could be null (or the default message where to == null)
      // if the user has spun up a new thread inside their component implementation 
      return null;
    }
    
    Endpoint to = msgContext.getTo();
    RuntimeComponentService service = (RuntimeComponentService) to.getService();
    RuntimeComponentReference callbackReference = (RuntimeComponentReference)service.getCallbackReference();
    if (callbackReference == null) {
      return null;
    }
    JavaInterface javaInterface = (JavaInterface) callbackReference.getInterfaceContract().getInterface();
    Class<CB> javaClass = (Class<CB>)javaInterface.getJavaClass();
    List<EndpointReference> wires = callbackReference.getEndpointReferences();
    ServiceReferenceImpl ref = new CallbackServiceReferenceImpl(javaClass, wires);

    return ref;
  }
}

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

private RuntimeEndpointReference selectCallbackEPR(Message msgContext) {
  
  // look for callback binding with same name as service binding
  Endpoint to = msgContext.getTo();
  if (to == null) {
    //FIXME: need better exception
    throw new ServiceRuntimeException("Destination for forward call is not available");
  }
  for (EndpointReference epr : callbackEPRs) {
    if (epr.getBinding().getName().equals(to.getBinding().getName())) {
      return (RuntimeEndpointReference) epr;
    }
  }
  // if no match, look for callback binding with same type as service binding
  for (EndpointReference epr : callbackEPRs) {
    if (epr.getBinding().getType().equals(to.getBinding().getType())) {
      return (RuntimeEndpointReference) epr;
    }
  }
  // no suitable callback wire was found
  return null;
}

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

/**
 * Sends message back to the browser client and reports connection status to
 * the runtime.
 * 
 * @param msg
 *            message to send to the browser
 * @return the connection status
 */
@Override
public Message invoke(final Message msg) {
  String sessionId = (String) msg.getHeaders().get(Constants.RELATES_TO);
  Broadcaster broadcaster = CometSessionManager.get(sessionId);
  Message response = new MessageImpl();
  if (broadcaster == null) {
    response.setBody(Status.CLIENT_DISCONNECTED);
  } else {
    String callbackMethod = msg.getTo().getURI();
    Object[] body = msg.getBody();
    broadcaster.broadcast(callbackMethod + "($.secureEvalJSON('" + JSONUtil.encodeResponse(body[0]) + "'))");
    response.setBody(Status.OK);
  }
  return response;
}

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

private String getToAddress( Message msg ) throws ServiceRuntimeException {
  String address = null;
  
  // if target endpoint was not specified when this invoker was created, 
  // use dynamically specified target endpoint passed in with the message
  if (options.getTo() == null) {
    Endpoint ep = msg.getTo();
    if (ep != null && 
      ep.getBinding() != null &&
      ep.getBinding().getURI() != null &&
      ep.getBinding().getURI().length() > 0) {
      address = ep.getBinding().getURI();
    } else {
      throw new ServiceRuntimeException("[BWS20025] Unable to determine destination endpoint for endpoint reference " + endpointReference);
    }
  } else {
    address = options.getTo().getAddress(); 
  }
  
  return address;
} // end method getToAddress

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

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

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

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

相关文章