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; }
/** * Synthesizes a composite from a collection of composites using inclusion. * * @param composites the composites to synthesize * @return the synthesized composite */ private Composite synthesizeComposite(List<Composite> composites) { Composite synthesized = new Composite(SYNTHETIC_COMPOSITE); for (Composite composite : composites) { Include include = new Include(); include.setName(composite.getName()); include.setIncluded(composite); synthesized.add(include); } return synthesized; }
public RequiredPropertyNotProvided(Property property, String componentName, XMLStreamReader reader) { super("Component " + componentName + " has a required property " + property.getName() + " that is not set", reader); this.componentName = componentName; }
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 initializeDomainComposite() { Composite type = new Composite(null); CompositeImplementation impl = new CompositeImplementation(); impl.setComponentType(type); ComponentDefinition<CompositeImplementation> definition = new ComponentDefinition<CompositeImplementation>(domainUri.toString()); definition.setImplementation(impl); definition.setContributionUri(Names.BOOT_CONTRIBUTION); type.setAutowire(autowire); domain = new LogicalCompositeComponent(domainUri, definition, null); domain.setState(LogicalState.PROVISIONED); domain.setAutowire(autowire); }
private void processPropertyValues(LogicalComponent<?> component, SpringComponentDefinition physical) { for (LogicalProperty property : component.getAllProperties().values()) { Document document = property.getValue(); if (document != null) { String name = property.getName(); boolean many = property.isMany(); ComponentType componentType = component.getDefinition().getImplementation().getComponentType(); QName type = componentType.getProperties().get(property.getName()).getType(); PhysicalPropertyDefinition definition = new PhysicalPropertyDefinition(name, document, many, type); physical.setPropertyDefinition(definition); } } }
/** * Returns the key specified on the component definition, component type, or null * * @param component the component * @return the key or null */ private String getKey(LogicalComponent component) { String key = component.getDefinition().getKey(); if (key == null) { // check if the key was specified in the component type Implementation implementation = component.getDefinition().getImplementation(); if (implementation != null && implementation.getComponentType() != null) { key = implementation.getComponentType().getKey(); } } return key; }
/** * Returns the key specified on the component definition, component type, or {@link Integer#MIN_VALUE} * * @param component the component * @return the key or null */ private int getOrder(LogicalComponent component) { int order = component.getDefinition().getOrder(); if (order == Integer.MIN_VALUE) { ComponentDefinition<?> definition = component.getDefinition(); Implementation<?> implementation = definition.getImplementation(); if (implementation != null && implementation.getComponentType() != null) { order = implementation.getComponentType().getOrder(); } } return order; }
private boolean useByReference(LogicalOperation operation, boolean remote) { if (!passByValueEnabled || remote) { // Pass-by-value is disabled or the invocation chain is remote. Pass-by-reference semantics should be used for remote invocation chains // since the binding will enforce pass-by-value implicitly through serialization return true; } LogicalAttachPoint logicalAttachPoint = operation.getParent(); LogicalComponent<?> component = logicalAttachPoint.getParent(); return operation.getIntents().contains(ALLOWS_BY_REFERENCE) || logicalAttachPoint.getIntents().contains(ALLOWS_BY_REFERENCE) || component.getIntents().contains(ALLOWS_BY_REFERENCE) || component.getDefinition().getImplementation().getIntents().contains( ALLOWS_BY_REFERENCE) || component.getDefinition().getImplementation().getComponentType().getIntents().contains(ALLOWS_BY_REFERENCE); } }
private Property createDefinition(String name, boolean required, Type type, TypeMapping typeMapping) { Property property = new Property(name); property.setRequired(required); MultiplicityType multiplicityType = helper.introspectMultiplicity(type, typeMapping); property.setMany(MultiplicityType.COLLECTION == multiplicityType || MultiplicityType.DICTIONARY == multiplicityType); return property; }
/** * Returns true if the reference is not keyed, true if the reference is keyed and the target specifies a key, false if the reference is keyed and * the target does not specify a key. * * @param logicalReference the logical reference * @param target the target * @return true if the reference is not keyed, true if the reference is keyed and the target specifies a key, false if the reference is keyed and * the target does not specify a key */ private boolean validKey(LogicalReference logicalReference, LogicalComponent<?> target) { return !logicalReference.getDefinition().isKeyed() || target.getDefinition().getKey() != null || target.getDefinition().getComponentType().getKey() != null; } }
public ScopeContainer getScopeContainer(Scope scope) { return scopes.get(scope.getScope()); }
private void handleWire(Composite type, XMLStreamReader reader, IntrospectionContext childContext) throws XMLStreamException, UnrecognizedElementException { WireDefinition wire = registry.load(reader, WireDefinition.class, childContext); if (wire == null) { // errror encountered loading the wire return; } type.add(wire); }
private void createResourceReferences(LogicalComponent<?> component, ComponentType componentType) { for (ResourceReferenceDefinition resourceReference : componentType.getResourceReferences().values()) { URI resourceUri = component.getUri().resolve('#' + resourceReference.getName()); LogicalResourceReference<ResourceReferenceDefinition> logicalResourceReference = new LogicalResourceReference<ResourceReferenceDefinition>(resourceUri, resourceReference, component); component.addResource(logicalResourceReference); } }
private void resolveReferences(LogicalComponent<?> component, InstantiationContext context) { for (LogicalReference reference : component.getReferences()) { Multiplicity multiplicityValue = reference.getDefinition().getMultiplicity(); boolean refMultiplicity = multiplicityValue.equals(Multiplicity.ZERO_N) || multiplicityValue.equals(Multiplicity.ONE_N); if (refMultiplicity || !reference.isResolved()) { // Only resolve references that have not been resolved or ones that are multiplicities since the latter may be reinjected. // Explicitly set the reference to unresolved, since if it was a multiplicity it may have been previously resolved. reference.setResolved(false); resolve(reference, context); } } }
/** * Loads the key when the component is wired to a map based reference. * * @param componentDefinition the component definition * @param reader a reader positioned on the element containing the key definition @return a Document containing the key value. */ private void loadKey(ComponentDefinition<Implementation<?>> componentDefinition, XMLStreamReader reader) { componentDefinition.setKey(loaderHelper.loadKey(reader)); }
/** * Creates a wrapper used to include a composite at the domain level. The wrapper is thrown away during the inclusion. * * @param deployable the deployable being included * @return the composite wrapper * @throws DeploymentException if there is an error creating the composite wrapper */ private Composite createWrapper(QName deployable) throws DeploymentException { Composite composite = contributionHelper.findComposite(deployable); // In order to include a composite at the domain level, it must first be wrapped in a composite that includes it. // This wrapper is thrown away during the inclusion. Composite wrapper = new Composite(deployable); Include include = new Include(); include.setName(deployable); include.setIncluded(composite); wrapper.add(include); return wrapper; }
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; }
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; }