public ComponentReferenceNotFound(String referenceName, ComponentDefinition definition, XMLStreamReader reader) { super("The component " + definition.getName() + " does not have a reference " + referenceName, reader); this.referenceName = referenceName; this.definition = definition; }
public ComponentPropertyNotFound(String propertyName, ComponentDefinition definition, XMLStreamReader reader) { super("The component " + definition.getName() + " does not have a property " + propertyName, reader); this.propertyName = propertyName; this.definition = definition; }
public DuplicateConfiguredProperty(String propertyName, ComponentDefinition definition, XMLStreamReader reader) { super("The property " + propertyName + " on component " + definition.getName() + "is configured more than once", reader); this.propertyName = propertyName; this.definition = definition; }
public ComponentServiceNotFound(String serviceName, ComponentDefinition definition, XMLStreamReader reader) { super("The component " + definition.getName() + " does not have a service " + serviceName, reader); this.serviceName = serviceName; this.definition = definition; }
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); } } }
public JUnitSourceDefinition generateSource(LogicalBinding<JUnitBindingDefinition> bindingDefinition, ServiceContract contract, List<LogicalOperation> operations, EffectivePolicy policy) throws GenerationException { ComponentDefinition<?> definition = bindingDefinition.getParent().getParent().getDefinition(); String testName = definition.getName(); ContextConfiguration configuration = bindingDefinition.getDefinition().getConfiguration(); return new JUnitSourceDefinition(testName, configuration); }
private void handleInclude(Composite type, XMLStreamReader reader, IntrospectionContext childContext) throws XMLStreamException, UnrecognizedElementException { Include include = registry.load(reader, Include.class, childContext); if (include == null) { // errror encountered loading the include return; } QName includeName = include.getName(); if (type.getIncludes().containsKey(includeName)) { String identifier = includeName.toString(); DuplicateInclude failure = new DuplicateInclude(identifier, reader); childContext.addError(failure); return; } for (ComponentDefinition definition : include.getIncluded().getComponents().values()) { String key = definition.getName(); if (type.getComponents().containsKey(key)) { DuplicateComponentName failure = new DuplicateComponentName(key, reader); childContext.addError(failure); } } type.add(include); }
private void handleComponent(Composite type, XMLStreamReader reader, IntrospectionContext childContext) throws XMLStreamException, UnrecognizedElementException { ComponentDefinition<?> componentDefinition = registry.load(reader, ComponentDefinition.class, childContext); if (componentDefinition == null) { // errror encountered loading the componentDefinition return; } String key = componentDefinition.getName(); if (type.getComponents().containsKey(key)) { DuplicateComponentName failure = new DuplicateComponentName(key, reader); childContext.addError(failure); return; } if (type.getAutowire() != Autowire.INHERITED && componentDefinition.getAutowire() == Autowire.INHERITED) { componentDefinition.setAutowire(type.getAutowire()); } type.add(componentDefinition); }
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 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); } }
@SuppressWarnings({"unchecked"}) public LogicalComponent instantiate(ComponentDefinition<?> definition, LogicalCompositeComponent parent, InstantiationContext context) { URI uri = URI.create(parent.getUri() + "/" + definition.getName()); LogicalComponent<?> component = new LogicalComponent(uri, definition, parent); if (parent.getComponent(uri) != null) { DuplicateComponent error = new DuplicateComponent(uri, parent); context.addError(error); } parent.addComponent(component); Implementation<?> impl = definition.getImplementation(); if (impl == null) { return component; } ComponentType componentType = impl.getComponentType(); if (componentTypeOverride) { // SCA policy conformance: override policy sets configured on the component type component.getPolicySets().removeAll(definition.getPolicySets()); } initializeProperties(component, definition, context); createServices(definition, component, componentType); createReferences(definition, component, componentType); createProducers(definition, component, componentType); createConsumers(definition, component, componentType); createResourceReferences(component, componentType); return component; }
public LogicalComponent<CompositeImplementation> instantiate(ComponentDefinition<CompositeImplementation> definition, LogicalCompositeComponent parent, InstantiationContext context) { URI uri = URI.create(parent.getUri() + "/" + definition.getName()); Composite composite = definition.getImplementation().getComponentType(); LogicalCompositeComponent component = new LogicalCompositeComponent(uri, definition, parent); if (componentTypeOverride) { // SCA policy conformance: override policy sets configured on the component type component.getPolicySets().removeAll(definition.getPolicySets()); } initializeProperties(component, definition, context); instantiateChildComponents(component, composite, context); instantiateCompositeServices(component, composite); wireInstantiator.instantiateCompositeWires(composite, component, context); instantiateCompositeReferences(component, composite); instantiateResources(component, composite); wireInstantiator.instantiateCompositeWires(composite, component, context); if (channelInstantiator != null) { channelInstantiator.instantiateChannels(composite, component, context); } if (parent.getComponent(uri) != null) { DuplicateComponent error = new DuplicateComponent(uri, parent); context.addError(error); } parent.addComponent(component); return component; }