public Optional<PhysicalInterceptor> generate(LogicalOperation source, LogicalOperation target) { return source.getDefinition().isOneWay() ? Optional.of(new PhysicalNonBlockingInterceptor()) : Optional.empty(); } }
private void setPolicyConfigs(Axis2PolicyAware policyAware, Policy policy, List<LogicalOperation> operations) throws Axis2GenerationException { for (LogicalOperation operation : operations) { List<PolicySet> policySets = policy.getProvidedPolicySets(operation); if (policySets == null) { continue; } for (PolicySet policySet : policy.getProvidedPolicySets(operation)) { Element policyDefinition = policySet.getExtension(); QName qname = new QName(policyDefinition.getNamespaceURI(), policyDefinition.getNodeName()); if (POLICY_ELEMENT.equals(qname)) { throw new Axis2GenerationException("Unknow policy element " + qname); } String module = policyDefinition.getAttribute("module"); String message = policyDefinition.getAttribute("message"); Element opaquePolicy = null; NodeList nodeList = policyDefinition.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { if (nodeList.item(i) instanceof Element) { opaquePolicy = (Element) nodeList.item(i); break; } } AxisPolicy axisPolicy = new AxisPolicy(message, module, opaquePolicy); policyAware.addPolicy(operation.getDefinition().getName(), axisPolicy); } } }
private Class<?> getType(LogicalProducer producer) { Operation operation = producer.getStreamOperation().getDefinition(); List<DataType> params = operation.getInputTypes(); if (params.size() != 1) { String interfaceName = producer.getServiceContract().getQualifiedInterfaceName(); throw new Fabric3Exception("A channel interface must have one parameter: operation " + operation.getName() + " on " + interfaceName); } return params.get(0).getType(); }
private Class<?> getType(LogicalProducer producer) { Operation operation = producer.getStreamOperation().getDefinition(); List<DataType> params = operation.getInputTypes(); if (params.size() != 1) { String interfaceName = producer.getServiceContract().getQualifiedInterfaceName(); throw new Fabric3Exception("A channel interface must have one parameter: operation " + operation.getName() + " on " + interfaceName); } return params.get(0).getType(); }
Operation definition = entry.getKey().getDefinition(); for (PolicySet policySet : entry.getValue()) { Element expression = policySet.getExpression();
private PhysicalEventStreamDefinition generate(LogicalOperation operation) { Operation o = operation.getDefinition(); PhysicalEventStreamDefinition definition = new PhysicalEventStreamDefinition(o.getName()); definition.setName(o.getName()); List<DataType<?>> params = o.getInputTypes(); for (DataType<?> param : params) { Class<?> paramType = param.getPhysical(); String paramName = paramType.getName(); definition.addEventType(paramName); } return definition; }
if (operation.getDefinition().getName().equals(operationName)) { operations.add(operation); if (contract.getInterfaceName().equals(interfaceName)) { for (LogicalOperation operation : reference.getOperations()) { if (operation.getDefinition().getName().equals(operationName)) { operations.add(operation);
public LogicalOperation resolve(LogicalOperation source, List<LogicalOperation> targets) { Operation sourceDefinition = source.getDefinition(); for (LogicalOperation target : targets) { Operation targetDefinition = target.getDefinition(); if (sourceDefinition.getName().equals(targetDefinition.getName())) { List<DataType> sourceInputTypes = sourceDefinition.getInputTypes(); DataType sourceOutputType = sourceDefinition.getOutputType(); DataType targetOutputType = targetDefinition.getOutputType(); if (sourceOutputType.equals(targetOutputType) && sourceInputTypes.equals(targetDefinition.getInputTypes())) { return target; } } } LogicalInvocable parent = source.getParent(); if (parent != null) { String sourceComponent = parent.getParent().getUri().toString(); throw new Fabric3Exception("Target operation not found for " + sourceDefinition.getName() + " on source component " + sourceComponent); } else { throw new Fabric3Exception("Target operation not found for " + sourceDefinition.getName()); } }
/** * 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 LogicalOperation resolve(LogicalOperation source, List<LogicalOperation> targets) { Operation sourceDefinition = source.getDefinition(); for (LogicalOperation target : targets) { Operation targetDefinition = target.getDefinition(); if (sourceDefinition.getName().equals(targetDefinition.getName())) { List<DataType> sourceInputTypes = sourceDefinition.getInputTypes(); DataType sourceOutputType = sourceDefinition.getOutputType(); DataType targetOutputType = targetDefinition.getOutputType(); if (sourceOutputType.equals(targetOutputType) && sourceInputTypes.equals(targetDefinition.getInputTypes())) { return target; } } } LogicalInvocable parent = source.getParent(); if (parent != null) { String sourceComponent = parent.getParent().getUri().toString(); throw new Fabric3Exception("Target operation not found for " + sourceDefinition.getName() + " on source component " + sourceComponent); } else { throw new Fabric3Exception("Target operation not found for " + sourceDefinition.getName()); } }
public LogicalOperation resolve(LogicalOperation source, List<LogicalOperation> targets) throws OperationNotFoundException { Operation sourceDefinition = source.getDefinition(); for (LogicalOperation target : targets) { Operation targetDefinition = target.getDefinition();
public PhysicalConnectionTarget generateConnectionTarget(LogicalProducer producer, LogicalBinding<JmsBinding> binding, DeliveryType deliveryType) { URI uri = binding.getDefinition().getTargetUri(); JmsBindingMetadata metadata = binding.getDefinition().getJmsMetadata().snapshot(); JmsGeneratorHelper.generateDefaultFactoryConfiguration(metadata.getConnectionFactory(), SessionType.AUTO_ACKNOWLEDGE); DataType type = isJAXB(producer.getStreamOperation().getDefinition().getInputTypes().get(0)) ? PhysicalDataTypes.JAXB : PhysicalDataTypes.JAVA_TYPE; JmsConnectionTarget target = new JmsConnectionTarget(uri, metadata, type); if (provisioner != null) { provisioner.generateConnectionTarget(target); } return target; }
Operation o = source.getDefinition(); PhysicalOperationDefinition operation = new PhysicalOperationDefinition(); operation.setName(o.getName()); operation.addSourceParameterType(paramType.getName()); Operation targetDefinition = target.getDefinition();
Operation o = source.getDefinition(); PhysicalOperationDefinition operation = new PhysicalOperationDefinition(); operation.setName(o.getName());
Operation o = source.getDefinition(); PhysicalOperation operation = new PhysicalOperation(); operation.setName(o.getName()); operation.addSourceParameterType(paramType); Operation targetDefinition = target.getDefinition();
Operation o = source.getDefinition(); PhysicalOperation operation = new PhysicalOperation(); operation.setName(o.getName()); operation.addSourceParameterType(paramType); Operation targetDefinition = target.getDefinition();
/** * Generates a PhysicalOperationDefinition when the source reference and target service contracts are the same. * * @param source the logical operation to generate from * @return the PhysicalOperationDefinition */ private PhysicalOperation generate(LogicalOperation source) { Operation o = source.getDefinition(); PhysicalOperation operation = new PhysicalOperation(); operation.setName(o.getName()); operation.setOneWay(o.isOneWay()); operation.setRemotable(o.isRemotable()); // the source and target in-, out- and fault types are the same since the source and target contracts are the same Class<?> returnType = o.getOutputType().getType(); operation.setSourceReturnType(returnType); operation.setTargetReturnType(returnType); for (DataType fault : o.getFaultTypes()) { Class<?> faultType = fault.getType(); operation.addSourceFaultType(faultType); operation.addTargetFaultType(faultType); } List<DataType> params = o.getInputTypes(); for (DataType param : params) { Class<?> paramType = param.getType(); operation.addSourceParameterType(paramType); operation.addTargetParameterType(paramType); } return operation; }
/** * Generates a PhysicalOperationDefinition when the source reference and target service contracts are the same. * * @param source the logical operation to generate from * @return the PhysicalOperationDefinition */ private PhysicalOperation generate(LogicalOperation source) { Operation o = source.getDefinition(); PhysicalOperation operation = new PhysicalOperation(); operation.setName(o.getName()); operation.setOneWay(o.isOneWay()); operation.setRemotable(o.isRemotable()); // the source and target in-, out- and fault types are the same since the source and target contracts are the same Class<?> returnType = o.getOutputType().getType(); operation.setSourceReturnType(returnType); operation.setTargetReturnType(returnType); for (DataType fault : o.getFaultTypes()) { Class<?> faultType = fault.getType(); operation.addSourceFaultType(faultType); operation.addTargetFaultType(faultType); } List<DataType> params = o.getInputTypes(); for (DataType param : params) { Class<?> paramType = param.getType(); operation.addSourceParameterType(paramType); operation.addTargetParameterType(paramType); } return operation; }
public PolicyResult resolvePolicies(LogicalConsumer consumer) throws PolicyResolutionException { LogicalComponent<?> component = consumer.getParent(); if (noPolicy(component)) { return EMPTY_RESULT; } // synthesize an operation and binding PolicyResultImpl policyResult = new PolicyResultImpl(); LogicalOperation operation = new LogicalOperation(DEFINITION, consumer); IntentPair targetOperationIntentPair = interactionResolver.resolveIntents(operation, LocalBindingDefinition.INSTANCE.getType()); policyResult.addTargetProvidedIntents(operation, targetOperationIntentPair.getProvidedIntents()); IntentPair sourceImplementationIntentPair = implementationResolver.resolveIntents(component, operation); policyResult.addSourceProvidedIntents(operation, sourceImplementationIntentPair.getProvidedIntents()); Set<PolicySet> policies = interactionResolver.resolvePolicySets(operation, consumer, LocalBindingDefinition.INSTANCE.getType()); policyResult.addTargetPolicySets(operation, CollectionUtils.filter(policies, PROVIDED)); policyResult.addInterceptedPolicySets(operation, CollectionUtils.filter(policies, INTERCEPTION)); // resolve policies using the target (as opposed to source) operation so target implementation policies are included policies = implementationResolver.resolvePolicySets(component, operation); // add policy metadata to the result PolicyMetadata metadata = policyResult.getMetadata(operation); metadata.addAll(operation.getDefinition().getMetadata()); // add metadata from implementation metadata.addAll(operation.getParent().getParent().getDefinition().getImplementation().getMetadata()); // important: use reference side operation as the key policyResult.addTargetPolicySets(operation, CollectionUtils.filter(policies, PROVIDED)); policyResult.addInterceptedPolicySets(operation, CollectionUtils.filter(policies, INTERCEPTION)); overrideDirectIfExternalAttachedPolicies(policyResult); return policyResult; }
metadata.addAll(targetOperation.getDefinition().getMetadata());