private RuntimeEndpoint getEndpoint(Binding targetBinding) { for(Endpoint ep: service.getEndpoints()) { if(ep.getBinding() == targetBinding) { return (RuntimeEndpoint) ep; } } return endpoint; }
public synchronized void addEndpoint(Endpoint endpoint) { endpoints.add(endpoint); for (EndpointListener listener : listeners) { listener.endpointAdded(endpoint); } if (logger.isLoggable(quietLogging ? Level.FINE : Level.INFO)) { String uri = null; Binding b = endpoint.getBinding(); if (b != null) { uri = b.getURI(); if (uri != null && uri.startsWith("/")) { uri = uri.substring(1); } } String msg = "Add endpoint - " + (uri == null ? endpoint.getURI() : b.getType().getLocalPart()+" - " + uri); if (quietLogging) { logger.fine(msg); } else { logger.info(msg); } } }
public synchronized void removeEndpoint(Endpoint endpoint) { endpoints.remove(endpoint); endpointRemoved(endpoint); if (logger.isLoggable(quietLogging ? Level.FINE : Level.INFO)) { String uri = null; Binding b = endpoint.getBinding(); if (b != null) { uri = b.getURI(); if (uri != null && uri.startsWith("/")) { uri = uri.substring(1); } } String msg = "Remove endpoint - " + (uri == null ? endpoint.getURI() : b.getType().getLocalPart()+" - "+uri); if (quietLogging) { logger.fine(msg); } else { logger.info(msg); } } }
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
private void build(Endpoint endpoint) { BindingBuilder builder = builders.getBindingBuilder(endpoint.getBinding().getType()); if (builder != null) { builder.build(endpoint.getComponent(), endpoint.getService(), endpoint.getBinding(), new BuilderContext(extensionPoints), true); } }
public String createJavascriptReference(ComponentReference componentReference) throws IOException { EndpointReference epr = componentReference.getEndpointReferences().get(0); Endpoint targetEndpoint = epr.getTargetEndpoint(); if (targetEndpoint.isUnresolved()) { //force resolution and targetEndpoint binding calculations //by calling the getInvocationChain ((RuntimeEndpointReference) epr).getInvocationChains(); targetEndpoint = epr.getTargetEndpoint(); } Binding binding = targetEndpoint.getBinding(); URI targetURI = URI.create(binding.getURI()); String targetPath = targetURI.getPath(); return "tuscany.AtomService(\"" + targetPath + "\")"; }
public String createJavascriptReference(ComponentReference componentReference) throws IOException { EndpointReference epr = componentReference.getEndpointReferences().get(0); Endpoint targetEndpoint = epr.getTargetEndpoint(); if (targetEndpoint.isUnresolved()) { //force resolution and targetEndpoint binding calculations //by calling the getInvocationChain ((RuntimeEndpointReference) epr).getInvocationChains(); targetEndpoint = epr.getTargetEndpoint(); } Binding binding = targetEndpoint.getBinding(); URI targetURI = URI.create(binding.getURI()); String targetPath = targetURI.getPath(); return "tuscany.RestService(\"" + targetPath + "\")"; }
private RuntimeEndpointReference selectCallbackWire( org.apache.tuscany.sca.assembly.Endpoint endpoint, RuntimeComponentReference componentReference) { // Look for callback binding with same name as service binding if (endpoint == null) { throw new RuntimeException("Destination for forward call is not available"); } for (EndpointReference epr : componentReference.getEndpointReferences()) { if (epr.getBinding().getName().equals(endpoint.getBinding().getName())) { return (RuntimeEndpointReference) epr; } } // if no match, look for callback binding with same type as service binding for (EndpointReference epr : componentReference.getEndpointReferences()) { if (epr.getBinding().getType().equals(endpoint.getBinding().getType())) { return (RuntimeEndpointReference) epr; } } // no suitable callback wire was found return null; } // end method selectCallbackWire
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; }
Binding binding = targetEndpoint.getBinding(); if (binding != null) { JavascriptProxyFactory jsProxyFactory = javascriptProxyFactories.getProxyFactory(binding.getClass());
public synchronized Endpoint getEndpoint(String uri) { for (Endpoint ep : endpoints) { String epURI = ep.getComponent().getURI() + "#" + ep.getService().getName() + "/" + ep.getBinding().getName(); if (epURI.equals(uri)) { return ep; } if (ep.getBinding().getName() == null || ep.getBinding().getName().equals(ep.getService().getName())) { epURI = ep.getComponent().getURI() + "#" + ep.getService().getName(); if (epURI.equals(uri)) { return ep; } } } return null; }
/** * Select an endpoint reference from the component reference * @param ref * @return */ private Endpoint getEndpoint(ComponentService service, String bindingName) { if (bindingName == null) { // The default binding name is the name of the promoted service bindingName = getPromotedService(service).getName(); } Endpoint returnEp = null; List<Endpoint> eps = service.getEndpoints(); for (Endpoint ep : eps) { Binding binding = ep.getBinding(); if (bindingName.equals(binding.getName()) || binding.getName() == null) { returnEp = ep; break; } } //TUSCANY-3543 if (returnEp == null) { returnEp = eps.get(0); } return returnEp; }
if (bindingName == null || bindingName.equals(ep.getBinding().getName())) { return ep.getDeployedURI();
if (bindingName == null || bindingName.equals(ep.getBinding().getName())) { return ep.getDeployedURI();
Binding binding = targetEndpoint.getBinding(); if (binding != null) { String referenceName = reference.getName();
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
protected Destination getRequestDestination(org.apache.tuscany.sca.invocation.Message tuscanyMsg, Session session) throws JMSBindingException, NamingException, JMSException { Destination requestDestination = null; if (endpointReference.getReference().isForCallback()) { // Check if the CallbackDestinationInterceptor set a callback destination from the request msg if (tuscanyMsg.getFrom().getTargetEndpoint() != null) { if (tuscanyMsg.getFrom().getTargetEndpoint().getBinding() != null) { this.jmsBinding = (JMSBinding)tuscanyMsg.getFrom().getTargetEndpoint().getBinding(); /* TUSCANY-4011 - we could delay until this point until setting the callback destination CallbackHandler callbackHandler = (CallbackHandler)tuscanyMsg.getHeaders().get(Constants.CALLBACK); if (callbackHandler != null && callbackHandler.getCallbackTargetURI() != null){ this.jmsBinding.setDestinationName(callbackHandler.getCallbackTargetURI()); } */ requestDestination = lookupDestination(); } } } if (requestDestination == null) { requestDestination = bindingRequestDest; } return requestDestination; }
Endpoint ep = endpointFinder.findEndpoint(domainRegistry, serviceURI); if (((RuntimeComponent)ep.getComponent()).getComponentContext() != null) { String serviceName = ep.getService().getName() + '/' + ep.getBinding().getName(); return ((RuntimeComponent)ep.getComponent()).getServiceReference(serviceInterface, serviceName).getService();
componentReference.getPolicySets().addAll(service.getPolicySets()); componentReference.getRequiredIntents().addAll(service.getRequiredIntents()); componentReference.getBindings().add(endpoint.getBinding()); endpointReference.setComponent(component); endpointReference.setReference(componentReference); endpointReference.setBinding(endpoint.getBinding()); endpointReference.setUnresolved(false); endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
componentReference.getPolicySets().addAll(service.getPolicySets()); componentReference.getRequiredIntents().addAll(service.getRequiredIntents()); componentReference.getBindings().add(endpoint.getBinding()); endpointReference.setComponent(component); endpointReference.setReference(componentReference); endpointReference.setBinding(endpoint.getBinding()); endpointReference.setUnresolved(false); endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);