private void validateRequiredProperties(ComponentDefinition<? extends Implementation<?>> definition, XMLStreamReader reader, IntrospectionContext context) { AbstractComponentType<?, ?, ?, ?> type = definition.getImplementation().getComponentType(); Map<String, ? extends Property> properties = type.getProperties(); Map<String, PropertyValue> values = definition.getPropertyValues(); for (Property property : properties.values()) { if (property.isRequired() && !values.containsKey(property.getName())) { RequiredPropertyNotProvided failure = new RequiredPropertyNotProvided(property, definition.getName(), reader); context.addError(failure); } } }
private void validateReferencePromotions(Composite type, XMLStreamReader reader, IntrospectionContext childContext) { for (CompositeReference reference : type.getReferences().values()) { for (URI promotedUri : reference.getPromotedUris()) { String componentName = UriHelper.getDefragmentedNameAsString(promotedUri); ComponentDefinition promoted = type.getComponents().get(componentName); if (promoted == null) { PromotionNotFound error = new PromotionNotFound("Component " + componentName + " referenced by " + reference.getName() + " not found", reader); childContext.addError(error); } else { String referenceName = promotedUri.getFragment(); if (referenceName == null && promoted.getComponentType().getReferences().size() != 1) { PromotionNotFound error = new PromotionNotFound("A promoted reference must be specified for " + reference.getName(), reader); childContext.addError(error); } if (referenceName != null && !promoted.getComponentType().getReferences().containsKey(referenceName)) { PromotionNotFound error = new PromotionNotFound("Reference " + referenceName + " promoted by " + reference.getName() + " not found", reader); childContext.addError(error); } } } } }
private void validateServicePromotions(Composite type, XMLStreamReader reader, IntrospectionContext childContext) { for (CompositeService service : type.getServices().values()) { URI promotedUri = service.getPromote(); String componentName = UriHelper.getDefragmentedNameAsString(promotedUri); ComponentDefinition promoted = type.getComponents().get(componentName); if (promoted == null) { PromotionNotFound error = new PromotionNotFound("Component " + componentName + " referenced by " + service.getName() + " not found", reader); childContext.addError(error); } else { String serviceName = promotedUri.getFragment(); if (serviceName == null && promoted.getComponentType().getServices().size() != 1) { PromotionNotFound error = new PromotionNotFound("A promoted service must be specified for " + service.getName(), reader); childContext.addError(error); } if (serviceName != null && !promoted.getComponentType().getServices().containsKey(serviceName)) { PromotionNotFound error = new PromotionNotFound("Service " + serviceName + " promoted by " + service.getName() + " not found", reader); childContext.addError(error); } } } }
private void parseReference(ComponentDefinition<Implementation<?>> componentDefinition, AbstractComponentType<?, ?, ?, ?> componentType, XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException, UnrecognizedElementException { ComponentReference reference; reference = registry.load(reader, ComponentReference.class, context); if (reference == null) { // there was an error with the reference configuration, just skip it return; } if (!componentType.hasReference(reference.getName())) { // ensure the reference exists ComponentReferenceNotFound failure = new ComponentReferenceNotFound(reference.getName(), componentDefinition, reader); context.addError(failure); return; } String refKey = reference.getName(); if (componentDefinition.getReferences().containsKey(refKey)) { DuplicateComponentReference failure = new DuplicateComponentReference(refKey, componentDefinition.getName(), reader); context.addError(failure); } else { componentDefinition.add(reference); } }
private void parseProperty(ComponentDefinition<Implementation<?>> componentDefinition, AbstractComponentType<?, ?, ?, ?> componentType, XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException, UnrecognizedElementException { PropertyValue value; value = registry.load(reader, PropertyValue.class, context); if (value == null) { // there was an error with the property configuration, just skip it return; } if (!componentType.hasProperty(value.getName())) { // ensure the property exists ComponentPropertyNotFound failure = new ComponentPropertyNotFound(value.getName(), componentDefinition, reader); context.addError(failure); return; } if (componentDefinition.getPropertyValues().containsKey(value.getName())) { String id = value.getName(); DuplicateConfiguredProperty failure = new DuplicateConfiguredProperty(id, componentDefinition, reader); context.addError(failure); } else { componentDefinition.add(value); } }
private void parseService(ComponentDefinition<Implementation<?>> componentDefinition, AbstractComponentType<?, ?, ?, ?> componentType, XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException, UnrecognizedElementException { ComponentService service; service = registry.load(reader, ComponentService.class, context); if (service == null) { // there was an error with the service configuration, just skip it return; } if (!componentType.hasService(service.getName())) { // ensure the service exists ComponentServiceNotFound failure = new ComponentServiceNotFound(service.getName(), componentDefinition, reader); context.addError(failure); return; } if (componentDefinition.getServices().containsKey(service.getName())) { String id = service.getName(); DuplicateComponentService failure = new DuplicateComponentService(id, componentDefinition.getName(), reader); context.addError(failure); } else { componentDefinition.add(service); } }