@Override protected boolean isEligibleAttribute(String attributeName) { return (super.isEligibleAttribute(attributeName) && !ENVIRONMENT_REF.equals(attributeName) && !LAZY_INIT_ATTRIBUTE .equals(attributeName)); }
@Override protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) { String id = super.resolveId(element, definition, parserContext); if (!StringUtils.hasText(id)) { id = element.getAttribute("static-field"); } return id; } }
/** * Parse the supplied {@link Element} and populate the supplied * {@link BeanDefinitionBuilder} as required. * <p>This implementation maps any attributes present on the * supplied element to {@link org.springframework.beans.PropertyValue} * instances, and * {@link BeanDefinitionBuilder#addPropertyValue(String, Object) adds them} * to the * {@link org.springframework.beans.factory.config.BeanDefinition builder}. * <p>The {@link #extractPropertyName(String)} method is used to * reconcile the name of an attribute with the name of a JavaBean * property. * @param element the XML element being parsed * @param builder used to define the {@code BeanDefinition} * @see #extractPropertyName(String) */ @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { NamedNodeMap attributes = element.getAttributes(); for (int x = 0; x < attributes.getLength(); x++) { Attr attribute = (Attr) attributes.item(x); if (isEligibleAttribute(attribute, parserContext)) { String propertyName = extractPropertyName(attribute.getLocalName()); Assert.state(StringUtils.hasText(propertyName), "Illegal property name returned from 'extractPropertyName(String)': cannot be null or empty."); builder.addPropertyValue(propertyName, attribute.getValue()); } } postProcess(builder, element); }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { super.doParse(element, parserContext, builder); Properties parsedProps = parserContext.getDelegate().parsePropsElement(element); builder.addPropertyValue("properties", parsedProps); String scope = element.getAttribute(SCOPE_ATTRIBUTE); if (StringUtils.hasLength(scope)) { builder.setScope(scope); } } }
/** {@inheritDoc} **/ protected void postProcess(final BeanDefinitionBuilder definitionBuilder, final Element ff4jTag) { super.postProcess(definitionBuilder, ff4jTag); logger.debug("Initialization from <ff4j:ff4j> TAG"); // If filename is present ff4j will be initialized with both features and properties inmemory. if (StringUtils.hasLength(ff4jTag.getAttribute(ATT_FF4J_FILENAME))) { String fileName = ff4jTag.getAttribute(ATT_FF4J_FILENAME); InMemoryFeatureStore imfs = new InMemoryFeatureStore(fileName); InMemoryPropertyStore imps = new InMemoryPropertyStore(fileName); definitionBuilder.getBeanDefinition().getPropertyValues().addPropertyValue("featureStore", imfs); definitionBuilder.getBeanDefinition().getPropertyValues().addPropertyValue("propertiesStore", imps); logger.debug("... Setting in-memory stores : " + imfs.readAll().size() + " feature(s), " + imps.readAllProperties().size() + " propertie(s)"); } if (StringUtils.hasLength(ff4jTag.getAttribute(ATT_FF4J_AUTOCREATE))) { String autocreate = ff4jTag.getAttribute(ATT_FF4J_AUTOCREATE); logger.debug("... Setting autocreate property to '" + autocreate + "'"); } if (StringUtils.hasLength(ff4jTag.getAttribute(ATT_FF4J_AUTH_MANAGER))) { String authManagerBeanId = ff4jTag.getAttribute(ATT_FF4J_AUTH_MANAGER); RuntimeBeanReference refSolution = new RuntimeBeanReference(authManagerBeanId); definitionBuilder.getBeanDefinition().getPropertyValues().addPropertyValue("authorizationsManager", refSolution); logger.debug("... Setting authorizationManager with " + authManagerBeanId); } logger.debug("... Initialization done"); } }
@Override protected void doParse(Element element, ParserContext context, BeanDefinitionBuilder builder) { super.doParse(element, context, builder); // look for a message converter attribute, which must a bean name String messageConverter = element.getAttribute("messageConverter"); if (StringUtils.hasText(messageConverter)) { builder.addPropertyReference("messageConverterRef", messageConverter); builder.addPropertyReference("messageConverter", messageConverter); } }
@Override protected boolean isEligibleAttribute(String attributeName) { return (super.isEligibleAttribute(attributeName) && !ENVIRONMENT_REF.equals(attributeName) && !LAZY_INIT_ATTRIBUTE .equals(attributeName)); }
/** * Parse the supplied {@link Element} and populate the supplied * {@link BeanDefinitionBuilder} as required. * <p>This implementation maps any attributes present on the * supplied element to {@link org.springframework.beans.PropertyValue} * instances, and * {@link BeanDefinitionBuilder#addPropertyValue(String, Object) adds them} * to the * {@link org.springframework.beans.factory.config.BeanDefinition builder}. * <p>The {@link #extractPropertyName(String)} method is used to * reconcile the name of an attribute with the name of a JavaBean * property. * @param element the XML element being parsed * @param builder used to define the {@code BeanDefinition} * @see #extractPropertyName(String) */ @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { NamedNodeMap attributes = element.getAttributes(); for (int x = 0; x < attributes.getLength(); x++) { Attr attribute = (Attr) attributes.item(x); if (isEligibleAttribute(attribute, parserContext)) { String propertyName = extractPropertyName(attribute.getLocalName()); Assert.state(StringUtils.hasText(propertyName), "Illegal property name returned from 'extractPropertyName(String)': cannot be null or empty."); builder.addPropertyValue(propertyName, attribute.getValue()); } } postProcess(builder, element); }
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { super.doParse(element, parserContext, builder); // set beans for ConnectionFactory and DestinationResolver String connectionFactoryRef = element.getAttribute(CONNECTION_FACTORY_REFERENCE); if (StringUtils.hasText(connectionFactoryRef)) { builder.addPropertyValue(CONNECTION_FACTORY_REFERENCE, connectionFactoryRef); builder.addPropertyReference(CONNECTION_FACTORY_PROPERTY, connectionFactoryRef); } String destinationResolverRef = element.getAttribute(DESTINATION_RESOLVER_REFERENCE); if (StringUtils.hasText(destinationResolverRef)) { builder.addPropertyValue(DESTINATION_RESOLVER_REFERENCE, destinationResolverRef); builder.addPropertyReference(DESTINATION_RESOLVER_PROPERTY, destinationResolverRef); } }
@Override protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) { String id = super.resolveId(element, definition, parserContext); if (!StringUtils.hasText(id)) { id = element.getAttribute("static-field"); } return id; } }
protected boolean isEligibleAttribute(String attributeName) { return super.isEligibleAttribute(attributeName) && (!"template".equals(attributeName)); } }
/** * Parse the supplied {@link Element} and populate the supplied * {@link BeanDefinitionBuilder} as required. * <p>This implementation maps any attributes present on the * supplied element to {@link org.springframework.beans.PropertyValue} * instances, and * {@link BeanDefinitionBuilder#addPropertyValue(String, Object) adds them} * to the * {@link org.springframework.beans.factory.config.BeanDefinition builder}. * <p>The {@link #extractPropertyName(String)} method is used to * reconcile the name of an attribute with the name of a JavaBean * property. * @param element the XML element being parsed * @param builder used to define the <code>BeanDefinition</code> * @see #extractPropertyName(String) */ @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { NamedNodeMap attributes = element.getAttributes(); for (int x = 0; x < attributes.getLength(); x++) { Attr attribute = (Attr) attributes.item(x); if (isEligibleAttribute(attribute, parserContext)) { String propertyName = extractPropertyName(attribute.getLocalName()); Assert.state(StringUtils.hasText(propertyName), "Illegal property name returned from 'extractPropertyName(String)': cannot be null or empty."); builder.addPropertyValue(propertyName, attribute.getValue()); } } postProcess(builder, element); }
@Override protected void doParse(final Element element, final ParserContext parserContext, final BeanDefinitionBuilder builder) { super.doParse(element, parserContext, builder); Properties parsedProps = parserContext.getDelegate().parsePropsElement(element); builder.addPropertyValue("properties", parsedProps); String scope = element.getAttribute(SCOPE_ATTRIBUTE); if (StringUtils.hasLength(scope)) { builder.setScope(scope); } final String encryptorBeanName = element.getAttribute(ENCRYPTOR_ATTRIBUTE); if (StringUtils.hasText(encryptorBeanName)) { builder.addPropertyReference("encryptor", encryptorBeanName); } }
@Override protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) { String id = super.resolveId(element, definition, parserContext); if (!StringUtils.hasText(id)) { id = element.getAttribute("static-field"); } return id; } }
/** * Determine whether the given attribute is eligible for being * turned into a corresponding bean property value. * <p>The default implementation considers any attribute as eligible, * except for the "id" attribute and namespace declaration attributes. * @param attribute the XML attribute to check * @param parserContext the {@code ParserContext} * @see #isEligibleAttribute(String) */ protected boolean isEligibleAttribute(Attr attribute, ParserContext parserContext) { String fullName = attribute.getName(); return (!fullName.equals("xmlns") && !fullName.startsWith("xmlns:") && isEligibleAttribute(parserContext.getDelegate().getLocalName(attribute))); }
/** * Parse the supplied {@link Element} and populate the supplied * {@link BeanDefinitionBuilder} as required. * <p>This implementation maps any attributes present on the * supplied element to {@link org.springframework.beans.PropertyValue} * instances, and * {@link BeanDefinitionBuilder#addPropertyValue(String, Object) adds them} * to the * {@link org.springframework.beans.factory.config.BeanDefinition builder}. * <p>The {@link #extractPropertyName(String)} method is used to * reconcile the name of an attribute with the name of a JavaBean * property. * @param element the XML element being parsed * @param builder used to define the {@code BeanDefinition} * @see #extractPropertyName(String) */ @Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { NamedNodeMap attributes = element.getAttributes(); for (int x = 0; x < attributes.getLength(); x++) { Attr attribute = (Attr) attributes.item(x); if (isEligibleAttribute(attribute, parserContext)) { String propertyName = extractPropertyName(attribute.getLocalName()); Assert.state(StringUtils.hasText(propertyName), "Illegal property name returned from 'extractPropertyName(String)': cannot be null or empty."); builder.addPropertyValue(propertyName, attribute.getValue()); } } postProcess(builder, element); }
@Override protected void doParse(final Element element, final ParserContext parserContext, final BeanDefinitionBuilder builder) { super.doParse(element, parserContext, builder); Properties parsedProps = parserContext.getDelegate().parsePropsElement(element); builder.addPropertyValue("properties", parsedProps); String scope = element.getAttribute(SCOPE_ATTRIBUTE); if (StringUtils.hasLength(scope)) { builder.setScope(scope); } final String encryptorBeanName = element.getAttribute(ENCRYPTOR_ATTRIBUTE); if (StringUtils.hasText(encryptorBeanName)) { builder.addPropertyReference("encryptor", encryptorBeanName); } }
@Override protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) throws BeanDefinitionStoreException { String id = super.resolveId(element, definition, parserContext); if (!StringUtils.hasText(id)) { id = element.getAttribute("name"); } if (!StringUtils.hasText(id)) { id = parserContext.getReaderContext().generateBeanName(definition); } return id; }
/** * Determine whether the given attribute is eligible for being * turned into a corresponding bean property value. * <p>The default implementation considers any attribute as eligible, * except for the "id" attribute and namespace declaration attributes. * @param attribute the XML attribute to check * @param parserContext the {@code ParserContext} * @see #isEligibleAttribute(String) */ protected boolean isEligibleAttribute(Attr attribute, ParserContext parserContext) { String fullName = attribute.getName(); return (!fullName.equals("xmlns") && !fullName.startsWith("xmlns:") && isEligibleAttribute(parserContext.getDelegate().getLocalName(attribute))); }
@Override protected void doParse(final Element element, final ParserContext parserContext, final BeanDefinitionBuilder builder) { super.doParse(element, parserContext, builder); Properties parsedProps = parserContext.getDelegate().parsePropsElement(element); builder.addPropertyValue("properties", parsedProps); String scope = element.getAttribute(SCOPE_ATTRIBUTE); if (StringUtils.hasLength(scope)) { builder.setScope(scope); } final String encryptorBeanName = element.getAttribute(ENCRYPTOR_ATTRIBUTE); if (StringUtils.hasText(encryptorBeanName)) { builder.addPropertyReference("encryptor", encryptorBeanName); } }