Java Code Examples for org.springframework.beans.factory.support.BeanDefinitionBuilder#childBeanDefinition()

The following examples show how to use org.springframework.beans.factory.support.BeanDefinitionBuilder#childBeanDefinition() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AttributeBeanDefinitionParser.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
protected BeanDefinition processUserControlElement( Element ele ) {
    BeanDefinitionBuilder controlBean = BeanDefinitionBuilder.childBeanDefinition( "KualiUserControlDefinition" );
    
    String universalIdAttribute = ele.getAttribute("universalIdAttribute");
    if ( StringUtils.hasText(universalIdAttribute) ) {
        controlBean.addPropertyValue("universalIdAttributeName", universalIdAttribute );
    }
    String userObjectAttribute = ele.getAttribute("userObjectAttribute");
    if ( StringUtils.hasText(userObjectAttribute) ) {
        controlBean.addPropertyValue("userIdAttributeName", userObjectAttribute + "." + KFSPropertyConstants.PERSON_USER_ID );
        controlBean.addPropertyValue("personNameAttributeName", userObjectAttribute + "." + KFSPropertyConstants.PERSON_NAME );
    }
    parseEmbeddedPropertyElements(ele, controlBean);
    
    return controlBean.getBeanDefinition();
}
 
Example 2
Source File: AttributeBeanDefinitionParser.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
protected BeanDefinition processValidationPatternElement( Element ele ) {
    BeanDefinitionBuilder validatorBean = null;
    String parent = ele.getAttribute( "parent" );
    String validationPatternClass = ele.getAttribute( "validationPatternClass" );
    if ( StringUtils.hasText(parent) ) {
        validatorBean = BeanDefinitionBuilder.childBeanDefinition( parent );
    } else if ( StringUtils.hasText(validationPatternClass)) {
        try {
            validatorBean = BeanDefinitionBuilder.rootBeanDefinition(Class.forName(validationPatternClass));
        } catch ( ClassNotFoundException ex ) {
            LOG.fatal( "Invalid class name given for validationPattern bean: " + validationPatternClass );
            throw new RuntimeException( "Invalid class name given for validationPattern bean: " + validationPatternClass, ex );
        }
    }
    
    parseEmbeddedPropertyElements(ele, validatorBean);
               
    return validatorBean.getBeanDefinition();
}
 
Example 3
Source File: AttributeBeanDefinitionParser.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
protected BeanDefinition processTextControlElement( Element ele ) {
    BeanDefinitionBuilder controlBean = BeanDefinitionBuilder.childBeanDefinition( "TextControlDefinition" );
    
    String size = ele.getAttribute("size");
    if ( StringUtils.hasText(size) ) {
        controlBean.addPropertyValue("size", Integer.valueOf(size) );
    }
    parseEmbeddedPropertyElements(ele, controlBean);
    
    return controlBean.getBeanDefinition();
}
 
Example 4
Source File: AttributeBeanDefinitionParser.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
protected BeanDefinition processTextareaControlElement( Element ele ) {
    BeanDefinitionBuilder controlBean = BeanDefinitionBuilder.childBeanDefinition( "TextareaControlDefinition" );
    
    String rows = ele.getAttribute("rows");
    if ( StringUtils.hasText(rows) ) {
        controlBean.addPropertyValue("rows", Integer.valueOf(rows) );
    }
    String cols = ele.getAttribute("rows");
    if ( StringUtils.hasText(cols) ) {
        controlBean.addPropertyValue("cols", Integer.valueOf(cols) );
    }
    parseEmbeddedPropertyElements(ele, controlBean);
    
    return controlBean.getBeanDefinition();
}
 
Example 5
Source File: AttributeBeanDefinitionParser.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
protected BeanDefinition processSelectControlElement( Element ele ) {
    BeanDefinitionBuilder controlBean = BeanDefinitionBuilder.childBeanDefinition( "SelectControlDefinition" );
    
    setMultiValueControlAttributes( ele, controlBean );
    parseEmbeddedPropertyElements(ele, controlBean);
              
    return controlBean.getBeanDefinition();
}
 
Example 6
Source File: AttributeBeanDefinitionParser.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
protected BeanDefinition processRadioControlElement( Element ele ) {
    BeanDefinitionBuilder controlBean = BeanDefinitionBuilder.childBeanDefinition( "RadioControlDefinition" );

    setMultiValueControlAttributes( ele, controlBean );
    parseEmbeddedPropertyElements(ele, controlBean);
    
    return controlBean.getBeanDefinition();
}
 
Example 7
Source File: KualiBeanDefinitionParserBase.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates a {@link BeanDefinitionBuilder} instance for the
 * {@link #getBeanClass bean Class} and passes it to the
 * {@link #doParse} strategy method.
 * @param element the element that is to be parsed into a single BeanDefinition
 * @param parserContext the object encapsulating the current state of the parsing process
 * @return the BeanDefinition resulting from the parsing of the supplied {@link Element}
 * @throws IllegalStateException if the bean {@link Class} returned from
 * {@link #getBeanClass(org.w3c.dom.Element)} is <code>null</code>
 * @see #doParse
 */
@SuppressWarnings("unchecked")
protected final AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder builder = null;
    
    String parent = element.getAttribute("parent");
    String beanClass = element.getAttribute("class");
    if ( StringUtils.hasText(beanClass) ) {
        try {
            builder = BeanDefinitionBuilder.rootBeanDefinition(Class.forName(beanClass));
        } catch (Exception ex) {
            LOG.fatal( "Unable to resolve class given in class element of a " + element.getLocalName() + " element with id " + element.getAttribute("id"), ex );
            throw new RuntimeException(ex);
        }
    } else  if ( StringUtils.hasText(parent)) {
        builder = BeanDefinitionBuilder.childBeanDefinition(parent);
    } else if ( getBeanClass(element) != null ) {
        builder = BeanDefinitionBuilder.rootBeanDefinition(getBeanClass(element));
    } else {
        builder = BeanDefinitionBuilder.childBeanDefinition(getBaseBeanTypeParent(element)); 
    }
    builder.setSource(parserContext.extractSource(element));
    if (parserContext.isNested()) {
        // Inner bean definition must receive same singleton status as containing bean.
        builder.setSingleton(parserContext.getContainingBeanDefinition().isSingleton());
    }
    if (parserContext.isDefaultLazyInit()) {
        // Default-lazy-init applies to custom bean definitions as well.
        builder.setLazyInit(true);
    }
    doParse(element, parserContext, builder);
    return builder.getBeanDefinition();
}
 
Example 8
Source File: AttributeBeanDefinitionParser.java    From kfs with GNU Affero General Public License v3.0 4 votes vote down vote up
protected BeanDefinition processHiddenControlElement( Element ele ) {
    BeanDefinitionBuilder controlBean = BeanDefinitionBuilder.childBeanDefinition( "HiddenControlDefinition" );
    parseEmbeddedPropertyElements(ele, controlBean);
    return controlBean.getBeanDefinition();
}
 
Example 9
Source File: AttributeBeanDefinitionParser.java    From kfs with GNU Affero General Public License v3.0 4 votes vote down vote up
protected BeanDefinition processCheckboxControlElement( Element ele ) {
    BeanDefinitionBuilder controlBean = BeanDefinitionBuilder.childBeanDefinition( "CheckboxControlDefinition" );
    parseEmbeddedPropertyElements(ele, controlBean);
    return controlBean.getBeanDefinition();
}