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; }
private void addProperty(InjectingComponentType componentType, TypeMapping typeMapping, String name, Type type, InjectionSite site) { Property property = new Property(name); MultiplicityType multiplicityType = helper.introspectMultiplicity(type, typeMapping); property.setMany(MultiplicityType.COLLECTION == multiplicityType || MultiplicityType.DICTIONARY == multiplicityType); componentType.add(property, site); }
String name = property.getName(); boolean required = property.isRequired(); PropertyValue propertyValue = propertyValues.get(name); if (propertyValue != null && propertyValue.getInstanceValue() != null) { String propertyKey = null; if (propertyValue == null) { String source = property.getSource(); if (source != null) { if (source.startsWith("${") && source.endsWith("}")) { for (Map.Entry<String, String> entry : property.getNamespaces().entrySet()) { nsContext.add(entry.getKey(), entry.getValue()); value = property.getDefaultValue(); value = loadValueFromFile(property.getName(), propertyValue.getFile(), logicalComponent, context); } else if (propertyValue.getSource() != null) { boolean many = property.isMany(); LogicalProperty.Builder builder = LogicalProperty.Builder.newBuilder(name, logicalComponent); LogicalProperty logicalProperty = builder.key(propertyKey).many(many).required(required).build(); logicalComponent.setProperties(logicalProperty); } else if (property.isRequired() && value == null && (propertyValue == null || (propertyValue != null && propertyValue.getInstanceValue() == null))) { } else if (!property.isRequired() && value == null) { boolean many = property.isMany();
private void includeProperty(Property property, LogicalCompositeComponent domain, InstantiationContext context) { String name = property.getName(); if (domain.getAllProperties().containsKey(name)) { DuplicateProperty error = new DuplicateProperty(name, domain); context.addError(error); } else { Document value = property.getDefaultValue(); boolean many = property.isMany(); QName type = property.getType(); LogicalProperty logicalProperty = LogicalProperty.Builder.newBuilder(name, domain).xmlValue(value).many(many).type(type).build(); domain.setProperties(logicalProperty); } }
Property property = new Property(name); property.setRequired(true); property.setType(XSD_INT); } else if (Boolean.class.getName().equals(propertyType)) { property.setType(XSD_BOOLEAN); } else { property.setType(XSD_STRING);
/** * Adds a property to the composite parsed from the XML source. * * @param name the property name * @param source the XML source * @return the builder * @throws ModelBuilderException if an error reading the source occurs */ public CompositeBuilder property(String name, URL source) { checkState(); try { Document document = DOCUMENT_FACTORY.newDocumentBuilder().parse(source.openStream()); // all properties have a root <values> element, append the existing root to it. The existing root will be taken as a property <value>. Element oldRoot = document.getDocumentElement(); Element newRoot = document.createElement("values"); document.removeChild(oldRoot); document.appendChild(newRoot); newRoot.appendChild(oldRoot); Property property = new Property(name); property.setDefaultValue(document); composite.add(property); } catch (IOException | ParserConfigurationException | SAXException e) { throw new ModelBuilderException(e); } return this; }
private void generatePropertyInjectionMapping(Property property, Map<String, Map<String, InjectionSite>> mappings) { Map<String, InjectionSite> mapping = mappings.get(property.getName()); if (mapping == null) { mapping = new HashMap<>(); mappings.put(property.getName(), mapping); } // inject the property into the session context // we don't need to do the type mappings from schema to Java so set Object as the type WebContextInjectionSite site = new WebContextInjectionSite(Object.class, SERVLET_CONTEXT); mapping.put(SESSION_CONTEXT_SITE, site); }
private void processPropertyValues(LogicalComponent<?> component, PhysicalSpringComponent springComponent) { for (LogicalProperty property : component.getAllProperties().values()) { String name = property.getName(); boolean many = property.isMany(); if (property.getXmlValue() != null) { Document document = property.getXmlValue(); ComponentType componentType = component.getDefinition().getImplementation().getComponentType(); QName type = componentType.getProperties().get(property.getName()).getType(); PhysicalProperty physicalProperty = PhysicalProperty.Builder.newBuilder(name).xmlValue(document).many(many).type(type).build(); springComponent.setProperty(physicalProperty); } else if (property.getInstanceValue() != null) { Object value = property.getInstanceValue(); PhysicalProperty physicalProperty = PhysicalProperty.Builder.newBuilder(name).instanceValue(value).many(many).build(); springComponent.setProperty(physicalProperty); } } }
String name = property.getName(); boolean required = property.isRequired(); PropertyValue propertyValue = propertyValues.get(name); if (propertyValue != null && propertyValue.getInstanceValue() != null) { String propertyKey = null; if (propertyValue == null) { String source = property.getSource(); if (source != null) { if (source.startsWith("${") && source.endsWith("}")) { for (Map.Entry<String, String> entry : property.getNamespaces().entrySet()) { nsContext.add(entry.getKey(), entry.getValue()); value = property.getDefaultValue(); value = loadValueFromFile(property.getName(), propertyValue.getFile(), logicalComponent, context); } else if (propertyValue.getSource() != null) { boolean many = property.isMany(); LogicalProperty.Builder builder = LogicalProperty.Builder.newBuilder(name, logicalComponent); LogicalProperty logicalProperty = builder.key(propertyKey).many(many).required(required).build(); logicalComponent.setProperties(logicalProperty); } else if (property.isRequired() && value == null && (propertyValue == null || (propertyValue != null && propertyValue.getInstanceValue() == null))) { } else if (!property.isRequired() && value == null) { boolean many = property.isMany();
private void includeProperty(Property property, LogicalCompositeComponent domain, InstantiationContext context) { String name = property.getName(); if (domain.getAllProperties().containsKey(name)) { DuplicateProperty error = new DuplicateProperty(name, domain); context.addError(error); } else { Document value = property.getDefaultValue(); boolean many = property.isMany(); QName type = property.getType(); LogicalProperty logicalProperty = LogicalProperty.Builder.newBuilder(name, domain).xmlValue(value).many(many).type(type).build(); domain.setProperties(logicalProperty); } }
Property property = new Property(name); property.setRequired(true); property.setType(XSD_INT); } else if (Boolean.class.getName().equals(propertyType)) { property.setType(XSD_BOOLEAN); } else { property.setType(XSD_STRING);
private void addProperty(InjectingComponentType componentType, String name, Type type, Class<?> declaringClass, InjectionSite site, IntrospectionContext context) { TypeMapping typeMapping = context.getTypeMapping(declaringClass); Property property = new Property(name); MultiplicityType multiplicityType = helper.introspectMultiplicity(type, typeMapping); property.setMany(MultiplicityType.COLLECTION == multiplicityType || MultiplicityType.DICTIONARY == multiplicityType); componentType.add(property, site); }
/** * Add a property and its associated with an injection site. * * @param property the property to add * @param injectionSite the injection site for the property */ public void add(Property property, InjectionSite injectionSite) { super.add(property); Injectable injectable = new Injectable(InjectableType.PROPERTY, property.getName()); addInjectionSite(injectionSite, injectable); injectionSiteMapping.put(property, injectionSite); }
private void processPropertyValues(LogicalComponent<?> component, PhysicalSpringComponent springComponent) { for (LogicalProperty property : component.getAllProperties().values()) { String name = property.getName(); boolean many = property.isMany(); if (property.getXmlValue() != null) { Document document = property.getXmlValue(); ComponentType componentType = component.getDefinition().getImplementation().getComponentType(); QName type = componentType.getProperties().get(property.getName()).getType(); PhysicalProperty physicalProperty = PhysicalProperty.Builder.newBuilder(name).xmlValue(document).many(many).type(type).build(); springComponent.setProperty(physicalProperty); } else if (property.getInstanceValue() != null) { Object value = property.getInstanceValue(); PhysicalProperty physicalProperty = PhysicalProperty.Builder.newBuilder(name).instanceValue(value).many(many).build(); springComponent.setProperty(physicalProperty); } } }