public PromotedComponentNotFound(Bindable bindable, URI promotedComponentUri) { super(bindable.getParent().getUri(), bindable.getParent().getDefinition().getContributionUri(), Collections.singletonList(bindable)); this.bindableUri = bindable.getUri(); this.promotedComponentUri = promotedComponentUri; }
private ServiceEndpointDefinition synthesizeEndpointFromClass(LogicalBinding<WsBindingDefinition> binding, JavaServiceContract contract, Class<?> serviceClass) throws GenerationException { URI targetUri; Bindable service = binding.getParent(); for (LogicalBinding<?> otherBinding : service.getBindings()) { if (binding == otherBinding) { continue; } if (WsBindingDefinition.BINDING_QNAME.equals(otherBinding.getDefinition().getType())) { // check to see if other WS bindings also use a default WsBindingDefinition wsDefinition = (WsBindingDefinition) otherBinding.getDefinition(); if (wsDefinition.getTargetUri() == null && wsDefinition.getWsdlElement() == null) { throw new GenerationException("If there is more than one web service binding, one must provide a URI or WSDLElement:" + service.getUri()); } } } targetUri = URI.create(service.getUri().getFragment()); return synthesizer.synthesizeServiceEndpoint(contract, serviceClass, targetUri); }
public PolicyResult resolveCallbackPolicies(LogicalBinding<?> binding) throws PolicyResolutionException { LogicalBinding<RemoteBindingDefinition> remoteBinding = new LogicalBinding<>(RemoteBindingDefinition.INSTANCE, binding.getParent()); Bindable bindable = binding.getParent(); if (bindable instanceof LogicalReference) { return resolvePolicies(bindable.getCallbackOperations(), remoteBinding, binding, bindable.getParent(), null); } else if (bindable instanceof LogicalService) { return resolvePolicies(bindable.getCallbackOperations(), remoteBinding, binding, bindable.getParent(), null); } else { throw new IllegalArgumentException("Only services and references can have callback operations"); } }
public PolicyResult resolvePolicies(LogicalBinding<?> binding) throws PolicyResolutionException { Bindable parent = binding.getParent(); LogicalBinding<RemoteBindingDefinition> remoteBinding = new LogicalBinding<>(RemoteBindingDefinition.INSTANCE, parent); Bindable bindable = binding.getParent(); if (bindable instanceof LogicalReference) { return resolvePolicies(bindable.getOperations(), remoteBinding, binding, bindable.getParent(), null); } else if (bindable instanceof LogicalService) { return resolvePolicies(bindable.getOperations(), binding, remoteBinding, null, bindable.getParent()); } else { throw new UnsupportedOperationException(); } }
private ServiceEndpointDefinition synthesizeEndpointFromWsdlInterface(LogicalBinding<WsBindingDefinition> binding, WsdlServiceContract wsdlContract) throws EndpointResolutionException { URI targetUri; Definition wsdl = wsdlContract.getDefinition(); QName portType = wsdlContract.getPortType().getQName(); QName serviceName = new QName(portType.getNamespaceURI(), portType.getLocalPart() + "Service"); QName portName = new QName(portType.getNamespaceURI(), portType.getLocalPart() + "Port"); Bindable service = binding.getParent(); targetUri = URI.create(service.getUri().getFragment()); String serializedWsdl = endpointResolver.serializeWsdl(wsdl); return new ServiceEndpointDefinition(serviceName, portName, targetUri, serializedWsdl); }
private void validateIntents(Bindable bindable, InstantiationContext context) { if (registry == null) { // don't validate intents during bootstrap return; } Set<QName> intents = bindable.getIntents(); if (intents.isEmpty()) { return; } Set<Intent> resolved = registry.getDefinitions(intents, Intent.class); // check for mutually exclusive intents for (Intent intent : resolved) { for (QName exclude : intent.getExcludes()) { if (intents.contains(exclude)) { String prefix = bindable instanceof LogicalReference ? "Reference " : "Service "; MutuallyExclusiveIntents error = new MutuallyExclusiveIntents(prefix + bindable.getUri() + " is configured with mutually exclusive intents: " + intent.getName() + "," + exclude, bindable); context.addError(error); } } } }
/** * Returns a binding matching the name * * @param name the binding name * @param bindable the bindable containing the binding * @return the matching binding or null if no matching one was found */ private LogicalBinding<?> getBinding(String name, Bindable bindable) { LogicalBinding<?> selectedBinding = null; for (LogicalBinding<?> binding : bindable.getBindings()) { if (name.equals(binding.getDefinition().getName())) { selectedBinding = binding; break; } } return selectedBinding; }
LogicalBinding<?> binding = (LogicalBinding) artifact; Bindable parent = binding.getParent(); List<LogicalOperation> operations = parent.getOperations(); for (LogicalOperation operation : operations) { if (!operation.getIntents().contains(ONEWAY)) { throw new PolicyResolutionException("Cannot specify transacted one-way for a request-response operation: " + parent.getUri()); LogicalBinding<?> binding = (LogicalBinding) artifact; Bindable parent = binding.getParent(); List<LogicalOperation> operations = parent.getOperations(); for (LogicalOperation operation : operations) { if (!operation.getIntents().contains(ONEWAY)) { throw new PolicyResolutionException("Cannot specify immediate one-way for a request-response operation: " + parent.getUri());
ServiceContract otherContract = binding.getParent().getServiceContract(); SOAPBinding soapBinding = (SOAPBinding) element; if (!SOAP_HTTP_TRANSPORT.equals(soapBinding.getTransportURI())) { throw new EndpointValidationException("Invalid SOAP binding transport specified for: " + binding.getParent().getUri());
/** * Matches operation definitions on the source and target sides of a wire so that policy sets and intents can be determined. Note that if the source * operation belongs to a service, the wire is a callback wire. * * @param operation the source operation to match against. * @param bindable the target bindable. * @return the matching operation * @throws PolicyResolutionException if there is a matching error */ private LogicalOperation matchOperation(LogicalOperation operation, Bindable bindable) throws PolicyResolutionException { String name = operation.getDefinition().getName(); List<LogicalOperation> operations; if (bindable instanceof LogicalReference) { // target is a reference so this is a callback operations = bindable.getCallbackOperations(); } else { operations = bindable.getOperations(); } try { LogicalOperation matched = operationResolver.resolve(operation, operations); if (matched == null) { throw new AssertionError("No matching operation for " + name); } return matched; } catch (OperationNotFoundException e) { throw new PolicyResolutionException(e); } }
public ZeroMQTargetDefinition generateServiceBindingTarget(LogicalBinding<ZeroMQBindingDefinition> binding, ServiceContract contract, List<LogicalOperation> operations, EffectivePolicy policy) throws GenerationException { URI targetUri = binding.getParent().getUri(); ZeroMQMetadata metadata = binding.getDefinition().getZeroMQMetadata(); return generateTarget(contract, targetUri, metadata); }
/** * Selects a binding from the given bindable by matching it against another binding * * @param bindable the bindable to select the binding from * @param binding the binding to match against * @return the selected binding or null if no matching ones were found */ private LogicalBinding<?> selectBinding(Bindable bindable, LogicalBinding binding) { for (LogicalBinding<?> candidate : bindable.getBindings()) { if (candidate.getDefinition().getType().equals(binding.getDefinition().getType())) { return candidate; } } return null; }
private void validateIntents(LogicalBinding<?> binding) throws PolicyResolutionException { Set<Intent> intents = policyRegistry.getDefinitions(binding.getIntents(), Intent.class); for (Intent current : intents) { for (Intent intent : intents) { if (current.getExcludes().contains(intent.getName())) { throw new PolicyResolutionException("Mutually exclusive intents specified on binding: " + binding.getParent().getUri()); } } } }
if (localName.startsWith("binding.")) { List<LogicalBinding<?>> bindings = new ArrayList<>(); for (LogicalBinding<?> binding : bindable.getBindings()) {
public MetroJavaWireSourceDefinition generateSource(LogicalBinding<WsBindingDefinition> binding, JavaServiceContract contract, EffectivePolicy policy) throws GenerationException { URI contributionUri = binding.getParent().getParent().getDefinition().getContributionUri(); Class<?> serviceClass = loadServiceClass(contract, contributionUri); WsBindingDefinition definition = binding.getDefinition(); LogicalComponent<?> component = binding.getParent().getParent(); for (LogicalService service : component.getServices()) { if (service.getServiceContract().getQualifiedInterfaceName().equals(contract.getQualifiedInterfaceName())) { serviceUri = binding.getParent().getUri();