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(); } }
/** * 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); } }
LogicalBinding<?> binding = (LogicalBinding) artifact; Bindable parent = binding.getParent(); List<LogicalOperation> operations = parent.getOperations(); for (LogicalOperation operation : operations) { if (!operation.getIntents().contains(ONEWAY)) { LogicalBinding<?> binding = (LogicalBinding) artifact; Bindable parent = binding.getParent(); List<LogicalOperation> operations = parent.getOperations(); for (LogicalOperation operation : operations) { if (!operation.getIntents().contains(ONEWAY)) {