@Override public String getDeployedURI() { return deployedURI == null ? (binding == null ? null : binding.getURI()) : deployedURI; }
@Override public String getDeployedURI() { return deployedURI == null ? (binding == null ? null : binding.getURI()) : deployedURI; }
/** * Evaluates whether the bindings attached to a reference identify one or more target services. * @param reference - the reference * @return true if the bindings identify a target, false otherwise */ private boolean bindingsIdentifyTargets(ComponentReference reference) { for (Binding binding : reference.getBindings()) { // <binding.sca without a URI does not identify a target if ((binding instanceof SCABinding) && (binding.getURI() == null)) continue; // any other binding implies a target // TODO Processing for other binding types return true; } // end for return false; } // end bindingsIdentifyTargets
/** * Evaluates whether the bindings attached to a reference identify one or more target services. * @param reference - the reference * @return true if the bindings identify a target, false otherwise */ private boolean bindingsIdentifyTargets(ComponentReference reference) { for (Binding binding : reference.getBindings()) { // <binding.sca without a URI does not identify a target if ((binding instanceof SCABinding) && (binding.getURI() == null)) continue; // any other binding implies a target // TODO Processing for other binding types return true; } // end for return false; } // end bindingsIdentifyTargets
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); } } }
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 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 + "\")"; }
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 + "\")"; }
@Override public String getDeployedURI() { String targetURI = deployedURI; if (targetURI != null) { return targetURI; } if (getTargetEndpoint() != null) { targetURI = getTargetEndpoint().getDeployedURI(); } if (targetURI != null) { return targetURI; } if (binding != null) { targetURI = binding.getURI(); } return targetURI; }
@Override public String getDeployedURI() { String targetURI = deployedURI; if (targetURI != null) { return targetURI; } if (getTargetEndpoint() != null) { targetURI = getTargetEndpoint().getDeployedURI(); } if (targetURI != null) { return targetURI; } if (binding != null) { targetURI = binding.getURI(); } return targetURI; }
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
/** * ASM_5021: where a <reference/> of a <component/> has @autowire=true * and where the <reference/> has a <binding/> child element which * declares a single target service, the reference is wired only to * the single service identified by the <wire/> element */ private void setSingleAutoWireTarget(ComponentReference reference) { if (reference.getEndpointReferences().size() > 1 && reference.getBindings() != null && reference.getBindings().size() == 1) { String uri = reference.getBindings().get(0).getURI(); if (uri != null) { if (uri.indexOf('/') > -1) { // TODO: must be a way to avoid this fiddling int i = uri.indexOf('/'); String c = uri.substring(0, i); String s = uri.substring(i + 1); uri = c + "#service(" + s + ")"; } for (EndpointReference er : reference.getEndpointReferences()) { if (er.getTargetEndpoint() != null && uri.equals(er.getTargetEndpoint().getURI())) { reference.getEndpointReferences().clear(); reference.getEndpointReferences().add(er); return; } } } } }
/** * ASM_5021: where a <reference/> of a <component/> has @autowire=true * and where the <reference/> has a <binding/> child element which * declares a single target service, the reference is wired only to * the single service identified by the <wire/> element */ private void setSingleAutoWireTarget(ComponentReference reference) { if (reference.getEndpointReferences().size() > 1 && reference.getBindings() != null && reference.getBindings().size() == 1) { String uri = reference.getBindings().get(0).getURI(); if (uri != null) { if (uri.indexOf('/') > -1) { // TODO: must be a way to avoid this fiddling int i = uri.indexOf('/'); String c = uri.substring(0, i); String s = uri.substring(i + 1); uri = c + "#service(" + s + ")"; } for (EndpointReference er : reference.getEndpointReferences()) { if (er.getTargetEndpoint() != null && uri.equals(er.getTargetEndpoint().getURI())) { reference.getEndpointReferences().clear(); reference.getEndpointReferences().add(er); return; } } } } }
boolean services() throws IOException { if (getNode() == null) { return true; } DomainRegistry reg = ((NodeImpl)getNode()).getEndpointRegistry(); for (Endpoint endpoint : reg.getEndpoints()) { out.println(endpoint.getComponent().getURI() + "/" + endpoint.getService().getName()); for (Binding b : endpoint.getService().getBindings()) { if (!SCABinding.TYPE.equals(b.getType())) { out.println(" " + b.getType().getLocalPart() + " " + b.getURI()); } } } return true; }
boolean services() throws IOException { if (getNode() == null) { return true; } DomainRegistry reg = ((NodeImpl)getNode()).getEndpointRegistry(); for (Endpoint endpoint : reg.getEndpoints()) { out.println(endpoint.getComponent().getURI() + "/" + endpoint.getService().getName()); for (Binding b : endpoint.getService().getBindings()) { if (!SCABinding.TYPE.equals(b.getType())) { out.println(" " + b.getType().getLocalPart() + " " + b.getURI()); } } } return true; }
public void start() { ComponentService service = endpoint.getService(); Interface serviceInterface = service.getInterfaceContract().getInterface(); for (Operation op : serviceInterface.getOperations()) { JSONPServlet servlet = new JSONPServlet(endpoint, op); String path = endpoint.getBinding().getURI() + "/" + op.getName(); String mappedURI = servletHost.addServletMapping(path, servlet); String endpointURI = mappedURI.substring(0, mappedURI.lastIndexOf("/" + op.getName())); endpoint.setDeployedURI(endpointURI); endpoint.getBinding().setURI(endpointURI); } }
public void stop() { ComponentService service = endpoint.getService(); Interface serviceInterface = service.getInterfaceContract().getInterface(); for (Operation op : serviceInterface.getOperations()) { String path = endpoint.getBinding().getURI() + "/" + op.getName(); servletHost.removeServletMapping(path); } }
public void start() { if (started) { return; } else { provider.start(); // Set the resolved binding URI back to the binding.sca ((SCABinding)endpoint.getBinding()).setDelegateBindingType(delegateEndpoint.getBinding().getType().toString()); ((SCABinding)endpoint.getBinding()).setDelegateBindingURI(delegateEndpoint.getBinding().getURI()); endpoint.setDeployedURI(delegateEndpoint.getDeployedURI()); started = true; } }
public void start() { if (started) { return; } else { provider.start(); // Set the resolved binding URI back to the binding.sca ((SCABinding)endpoint.getBinding()).setDelegateBindingType(delegateEndpoint.getBinding().getType().toString()); ((SCABinding)endpoint.getBinding()).setDelegateBindingURI(delegateEndpoint.getBinding().getURI()); endpoint.setDeployedURI(delegateEndpoint.getDeployedURI()); started = true; } }
private void processUnknownEndpoint(EndpointReference endpointReference, Audit matchAudit){ Binding b = null; if (unknownEndpointHandler != null) { b = unknownEndpointHandler.handleUnknownEndpoint(endpointReference); } if (b != null) { Endpoint matchedEndpoint = new RuntimeEndpointImpl(extensionPoints); matchedEndpoint.setBinding(b); matchedEndpoint.setRemote(true); endpointReference.setTargetEndpoint(matchedEndpoint); endpointReference.setBinding(b); endpointReference.setUnresolved(false); endpointReference.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED); matchAudit.append("Match because the UnknownEndpointHandler provided a binding: " + b.getType() + " uri: " + b.getURI()); matchAudit.appendSeperator(); } }