private Set<Intent> getRequestedIntents(LogicalComponent<?> logicalComponent, LogicalOperation operation) throws PolicyResolutionException { // Aggregate all the intents from the ancestors Set<QName> intentNames = new LinkedHashSet<>(); intentNames.addAll(operation.getIntents()); ComponentDefinition<? extends Implementation<?>> definition = logicalComponent.getDefinition(); Implementation<?> implementation = definition.getImplementation(); ComponentType componentType = implementation.getComponentType(); intentNames.addAll(implementation.getIntents()); intentNames.addAll(componentType.getIntents()); intentNames.addAll(aggregateIntents(logicalComponent)); // Expand all the profile intents Set<Intent> requiredIntents = resolveIntents(intentNames); // Remove intents not applicable to the artifact filterInvalidIntents(Intent.IMPLEMENTATION, requiredIntents); filterMutuallyExclusiveIntents(requiredIntents); return requiredIntents; }
/** * Aggregate intents from ancestors of a component. Components are handled differently than other SCA artifacts as implementation intents are inherited. * * @param component the logical artifact to aggregate intents for * @return the aggregated intents */ protected Set<QName> aggregateIntents(LogicalComponent<?> component) { LogicalComponent<?> current = component; Set<QName> aggregatedIntents = new LinkedHashSet<>(); while (current != null) { Set<QName> currentIntents = current.getIntents(); processIntents(currentIntents, aggregatedIntents); ComponentDefinition<? extends Implementation<?>> definition = current.getDefinition(); if (definition != null) { processIntents(definition.getIntents(), aggregatedIntents); Implementation<?> implementation = definition.getImplementation(); if (implementation != null) { processIntents(implementation.getIntents(), aggregatedIntents); ComponentType componentType = implementation.getComponentType(); if (componentType != null) { processIntents(componentType.getIntents(), aggregatedIntents); } } } current = current.getParent(); } return aggregatedIntents; }
ComponentType componentType = implementation.getComponentType(); if (componentType != null) { processIntents(componentType.getIntents(), aggregatedIntents); processIntents(type.getIntents(), aggregatedIntents);
ComponentType componentType = implementation.getComponentType(); if (componentType != null) { processIntents(componentType.getIntents(), aggregatedIntents); processIntents(type.getIntents(), aggregatedIntents);