private Map<String, String> handleDefaultReferenceMappings(ComponentDefinition<SpringImplementation> componentDefinition, ComponentType type) { Map<String, String> mappings = new HashMap<String, String>(); for (ReferenceDefinition reference : type.getReferences().values()) { SpringReferenceDefinition springReference = (SpringReferenceDefinition) reference; String defaultStr = springReference.getDefaultValue(); if (defaultStr == null) { continue; } String refName = springReference.getName(); if (componentDefinition.getReferences().containsKey(refName)) { continue; } mappings.put(defaultStr, refName); } return mappings; }
public WebImplementation load(XMLStreamReader reader, IntrospectionContext context) throws XMLStreamException { Location startLocation = reader.getLocation(); URI uri = parseUri(reader, startLocation, context); WebImplementation impl = new WebImplementation(uri); validateAttributes(reader, context, impl); for (WebImplementationIntrospector introspector : introspectors) { introspector.introspect(impl, context); } try { ComponentType type = impl.getComponentType(); // FIXME we should allow implementation to specify the component type; ComponentType componentType = loadComponentType(context); for (Map.Entry<String, ReferenceDefinition> entry : componentType.getReferences().entrySet()) { type.add(entry.getValue()); } for (Map.Entry<String, Property> entry : componentType.getProperties().entrySet()) { type.add(entry.getValue()); } } catch (LoaderException e) { if (e.getCause() instanceof FileNotFoundException) { // ignore since we allow component types not to be specified in the web app } else { ElementLoadFailure failure = new ElementLoadFailure("Error loading web.componentType", e, startLocation); context.addError(failure); return null; } } LoaderUtil.skipToEndElement(reader); return impl; }
private void createReferences(ComponentDefinition<?> definition, LogicalComponent<?> component, ComponentType componentType) { for (AbstractReference reference : componentType.getReferences().values()) { String name = reference.getName(); URI referenceUri = component.getUri().resolve('#' + name); LogicalReference logicalReference = new LogicalReference(referenceUri, reference, component); // reference is configured in the component definition ComponentReference componentReference = definition.getReferences().get(name); if (componentReference != null) { logicalReference.addIntents(componentReference.getIntents()); for (BindingDefinition binding : componentReference.getBindings()) { LogicalBinding<BindingDefinition> logicalBinding = new LogicalBinding<BindingDefinition>(binding, logicalReference); logicalReference.addBinding(logicalBinding); } for (BindingDefinition binding : componentReference.getCallbackBindings()) { LogicalBinding<BindingDefinition> logicalBinding = new LogicalBinding<BindingDefinition>(binding, logicalReference); logicalReference.addCallbackBinding(logicalBinding); } } component.addReference(logicalReference); } }