Example usage for org.springframework.beans.factory.config BeanDefinitionHolder getBeanDefinition

List of usage examples for org.springframework.beans.factory.config BeanDefinitionHolder getBeanDefinition

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config BeanDefinitionHolder getBeanDefinition.

Prototype

public BeanDefinition getBeanDefinition() 

Source Link

Document

Return the wrapped BeanDefinition.

Usage

From source file:org.bigtester.ate.xmlschema.SendKeysActionBeanDefinitionParser.java

/**
 * {@inheritDoc}//from  w w  w  . j  a  va2  s  .  com
 */
@Override
protected @Nullable AbstractBeanDefinition parseInternal(@Nullable Element element,
        @Nullable ParserContext parserContext) {
    // Here we parse the Spring elements such as < property>
    if (parserContext == null || element == null)
        throw GlobalUtils.createNotInitializedException("element and parserContext");
    // Here we parse the Spring elements such as < property>
    BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(element);
    BeanDefinition bDef = holder.getBeanDefinition();
    bDef.setBeanClassName(SendKeysAction.class.getName());

    String data = element.getAttribute(XsdElementConstants.ATTR_SENDKEYSACTION_DATAVALUE);
    if (StringUtils.hasText(data)) {
        //               ConstructorArgumentValues inputDataValueConstrs = new ConstructorArgumentValues();
        //               inputDataValueConstrs.addGenericArgumentValue(data);
        //               BeanDefinition inputDataValueDef = new ChildBeanDefinition(
        //                     XsdElementConstants.ELEMENT_ID_BASEINPUTDATAVALUE,
        //                     StepInputDataValue.class, inputDataValueConstrs, null);
        //
        //               parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id") + "_ELEMENTINPUTDATA_ID", inputDataValueDef);
        bDef.setAttribute(XsdElementConstants.ATTR_SENDKEYSACTION_DATAVALUE, data);
        bDef.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference(data));
    } else {
        bDef.setAttribute(XsdElementConstants.ATTR_SENDKEYSACTION_DATAVALUE, "");
    }

    bDef.setParentName(XsdElementConstants.ELEMENT_ID_BASEELEMENTACTION);

    bDef.setAttribute("id", element.getAttribute("id"));
    parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id"), bDef);
    return (AbstractBeanDefinition) bDef;
}

From source file:org.bigtester.ate.xmlschema.PagePropertyCorrectBeanDefinitionParser.java

/**
 * {@inheritDoc}//from w ww. j ava 2s. c  o  m
 */
@Override
protected AbstractBeanDefinition parseInternal(@Nullable Element element,
        @Nullable ParserContext parserContext) {
    // Here we parse the Spring elements such as < property>
    if (parserContext == null || element == null)
        throw GlobalUtils.createNotInitializedException("element and parserContext");
    // Here we parse the Spring elements such as < property>
    BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(element);
    BeanDefinition bDef = holder.getBeanDefinition();
    bDef.setBeanClassName(PagePropertyCorrectnessAsserter.class.getName());
    String resultPage = element
            .getAttribute(XsdElementConstants.ATTR_ABSTRACTEXPECTEDRESULTASSERTER_RESULTPAGE);
    if (StringUtils.hasText(resultPage)) {
        bDef.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference(resultPage));
    }
    String stepERValue = element
            .getAttribute(XsdElementConstants.ATTR_ABSTRACTEXPECTEDRESULTASSERTER_STEPERVALUE);
    if (StringUtils.hasText(stepERValue)) {
        ConstructorArgumentValues erValueDefConstrs = new ConstructorArgumentValues();
        erValueDefConstrs.addGenericArgumentValue(stepERValue);
        BeanDefinition erValueDef = new ChildBeanDefinition(XsdElementConstants.ELEMENT_ID_BASEERVALUE,
                StepErPagePropertyValue.class, erValueDefConstrs, null);

        parserContext.getRegistry()
                .registerBeanDefinition(element.getAttribute("id") + "_ASSERTER_STEPERVALUE_ID", erValueDef);

        bDef.getConstructorArgumentValues().addGenericArgumentValue(
                new RuntimeBeanReference(element.getAttribute("id") + "_ASSERTER_STEPERVALUE_ID"));
    }

    parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id"), bDef);
    return (AbstractBeanDefinition) bDef;

}

From source file:org.xeustechnologies.jcl.spring.JclBeanDefinitionParser.java

public BeanDefinition parse(Element element, ParserContext parserContext) {
    BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(element);

    String beanName = holder.getBeanName();

    BeanDefinition bd = holder.getBeanDefinition();
    bd.setBeanClassName(JarClassLoader.class.getName());

    logger.info("Registering JarClassLoader bean: " + beanName);

    parserContext.getRegistry().registerBeanDefinition(beanName, bd);

    return bd;/*from w w  w. j a v a  2 s.c  o m*/
}

From source file:org.bigtester.ate.xmlschema.PageElementExistBeanDefinitionParser.java

/**
 * {@inheritDoc}/*from  w  w w . ja  va2s  .co m*/
 */
@Override
protected AbstractBeanDefinition parseInternal(@Nullable Element element,
        @Nullable ParserContext parserContext) {
    // Here we parse the Spring elements such as < property>
    if (parserContext == null || element == null)
        throw GlobalUtils.createNotInitializedException("element and parserContext");
    // Here we parse the Spring elements such as < property>
    BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(element);
    BeanDefinition bDef = holder.getBeanDefinition();
    bDef.setBeanClassName(PageElementExistenceAsserter.class.getName());
    String resultPage = element
            .getAttribute(XsdElementConstants.ATTR_ABSTRACTEXPECTEDRESULTASSERTER_RESULTPAGE);
    if (StringUtils.hasText(resultPage)) {
        bDef.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference(resultPage));
    }
    String stepERValue = element
            .getAttribute(XsdElementConstants.ATTR_ABSTRACTEXPECTEDRESULTASSERTER_STEPERVALUE);

    if (StringUtils.hasText(stepERValue)) {
        ConstructorArgumentValues erValueDefConstrs = new ConstructorArgumentValues();
        erValueDefConstrs.addGenericArgumentValue(stepERValue);
        BeanDefinition erValueDef = new ChildBeanDefinition(XsdElementConstants.ELEMENT_ID_BASEERVALUE,
                StepErElementExistenceValue.class, erValueDefConstrs, null);

        parserContext.getRegistry()
                .registerBeanDefinition(element.getAttribute("id") + "_ASSERTER_STEPERVALUE_ID", erValueDef);

        bDef.getConstructorArgumentValues().addGenericArgumentValue(
                new RuntimeBeanReference(element.getAttribute("id") + "_ASSERTER_STEPERVALUE_ID"));
    }

    parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id"), bDef);

    return (AbstractBeanDefinition) bDef;

}

From source file:darks.orm.spring.MapperClassDefinitionScanner.java

@Override
protected Set<BeanDefinitionHolder> doScan(String... scanPackages) {
    Set<BeanDefinitionHolder> definitions = super.doScan(scanPackages);
    if (definitions.isEmpty()) {
        log.warn("No bean definition found in target packages " + Arrays.toString(scanPackages));
    } else {//  ww  w .  j  a  v a2 s  . c o  m
        for (BeanDefinitionHolder holder : definitions) {
            GenericBeanDefinition definition = (GenericBeanDefinition) holder.getBeanDefinition();
            processBeanDefinition(definition);
        }
    }
    return definitions;
}

From source file:org.xeustechnologies.jcl.spring.JclBeanDefinitionDecorator.java

@SuppressWarnings("unchecked")
private void createDependencyOnJcl(Node node, BeanDefinitionHolder holder, ParserContext parserContext) {
    AbstractBeanDefinition definition = ((AbstractBeanDefinition) holder.getBeanDefinition());
    String jclRef = node.getAttributes().getNamedItem(JCL_REF).getNodeValue();

    if (!parserContext.getRegistry().containsBeanDefinition(JCL_FACTORY)) {
        BeanDefinitionBuilder initializer = BeanDefinitionBuilder.rootBeanDefinition(JclObjectFactory.class,
                JCL_FACTORY_CONSTRUCTOR);
        parserContext.getRegistry().registerBeanDefinition(JCL_FACTORY, initializer.getBeanDefinition());
    }/* ww w. jav a 2s  .  c  o m*/

    if (parserContext.getRegistry().containsBeanDefinition(jclRef)) {
        String[] dependsOn = definition.getDependsOn();
        if (dependsOn == null) {
            dependsOn = new String[] { jclRef, JCL_FACTORY };
        } else {
            List dependencies = new ArrayList(Arrays.asList(dependsOn));
            dependencies.add(jclRef);
            dependencies.add(JCL_FACTORY);
            dependsOn = (String[]) dependencies.toArray(new String[0]);
        }
        definition.setDependsOn(dependsOn);
    } else
        throw new JclException("JCL Bean definition " + jclRef + "not found");
}

From source file:com.github.jmnarloch.spring.jaxrs.client.support.JaxRsClientClassPathScanner.java

/**
 * Process the bean definitions./*w w w  . j  a v a2  s.  c om*/
 *
 * @param beanDefinitions the bean definitions
 */
private void processBeanDefinitions(Set<BeanDefinitionHolder> beanDefinitions) {

    for (BeanDefinitionHolder beanDefinition : beanDefinitions) {
        GenericBeanDefinition definition = (GenericBeanDefinition) beanDefinition.getBeanDefinition();

        final String serviceClassName = definition.getBeanClassName();

        definition.setBeanClass(JaxRsClientProxyFactoryBean.class);
        definition.getPropertyValues().add("serviceClass", serviceClassName);
        definition.getPropertyValues().add("serviceUrl", serviceUrl);
        definition.getPropertyValues().add("serviceUrlProvider", serviceUrlProvider);
    }
}

From source file:org.cloudfoundry.reconfiguration.util.StandardPropertyAugmenter.java

private Properties extractProperties(BeanDefinitionHolder beanDefinitionHolder) {
    BeanDefinition beanDefinition = beanDefinitionHolder.getBeanDefinition();
    return getMapWrappingBeanProperties(beanDefinition);
}

From source file:com.bstek.dorado.spring.MapEntryShortCutDecorator.java

@SuppressWarnings({ "unchecked", "rawtypes" })
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
    AbstractBeanDefinition beanDef = (AbstractBeanDefinition) definition.getBeanDefinition();
    MutablePropertyValues propertyValues = (beanDef.getPropertyValues() == null) ? new MutablePropertyValues()
            : beanDef.getPropertyValues();

    ManagedMap map = null;//  www  .  j a v a2  s  . c om
    boolean firstPropertyValue = propertyValues.getPropertyValue(property) == null;

    if (!firstPropertyValue) {
        map = (ManagedMap) (propertyValues.getPropertyValue(property).getValue());
    } else {
        map = new ManagedMap();
        map.setSource(node);
        map.setMergeEnabled(true);
        propertyValues.addPropertyValue(property, map);
        beanDef.setPropertyValues(propertyValues);
    }

    Element el = (Element) node;
    String key = el.getAttribute("key");
    String value = el.getAttribute("value");
    String valueRef = el.getAttribute("value-ref");

    Object entryValue = null;
    if (StringUtils.isNotEmpty(value)) {
        entryValue = value;
    } else if (StringUtils.isNotEmpty(valueRef)) {
        RuntimeBeanReference ref = new RuntimeBeanReference(valueRef);
        ref.setSource(parserContext.getReaderContext().extractSource(el));
        entryValue = ref;
    } else {
        Element beanEl = DomUtils.getChildElementByTagName(el, "bean");
        if (beanEl != null) {
            entryValue = parserContext.getDelegate().parseBeanDefinitionElement(beanEl);
        }
    }

    if (supportsMultiKey && StringUtils.isNotEmpty(key)) {
        for (String k : StringUtils.split(key, KEY_DELIM)) {
            map.put(k, entryValue);
        }
    } else {
        map.put(key, entryValue);
    }
    return definition;
}

From source file:org.bigtester.ate.xmlschema.AutoIncrementalDataHolderBeanDefinitionParser.java

/**
 * {@inheritDoc}//  w w  w.  j  av  a  2 s . c  o  m
 */
@Override
protected @Nullable AbstractBeanDefinition parseInternal(@Nullable Element element,
        @Nullable ParserContext parserContext) {

    // Here we parse the Spring elements such as < property>
    if (parserContext == null || element == null)
        throw GlobalUtils.createNotInitializedException("element and parserContext");

    BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(element);
    BeanDefinition bDef = holder.getBeanDefinition();

    bDef.setBeanClassName(AutoIncrementalDataHolder.class.getName());

    String startValue = element.getAttribute(XsdElementConstants.ATTR_AUTOINCREMENTALDATAHOLDSER_STARTVALUE);
    if (StringUtils.hasText(startValue)) {
        try {
            int intStartValue = Integer.parseInt(startValue);
            bDef.getConstructorArgumentValues().addGenericArgumentValue(intStartValue);
        } catch (NumberFormatException nfe) {
            bDef.getConstructorArgumentValues().addGenericArgumentValue(0);
        }
    } else {
        bDef.getConstructorArgumentValues().addGenericArgumentValue(0);
    }

    String pacing = element.getAttribute(XsdElementConstants.ATTR_AUTOINCREMENTALDATAHOLDSER_PACING);
    if (StringUtils.hasText(pacing)) {
        try {
            int intPacing = Integer.parseInt(pacing);
            bDef.getConstructorArgumentValues().addGenericArgumentValue(intPacing);
        } catch (NumberFormatException nfe) {
            bDef.getConstructorArgumentValues().addGenericArgumentValue(1);
        }
    } else {
        bDef.getConstructorArgumentValues().addGenericArgumentValue(1);
    }
    String endValue = element.getAttribute(XsdElementConstants.ATTR_AUTOINCREMENTALDATAHOLDSER_ENDVALUE);
    if (StringUtils.hasText(endValue)) {
        try {
            int intEndValue = Integer.parseInt(endValue);
            bDef.getConstructorArgumentValues().addGenericArgumentValue(intEndValue);
        } catch (NumberFormatException nfe) {
            bDef.getConstructorArgumentValues().addGenericArgumentValue(Integer.MAX_VALUE);
        }
    } else {
        bDef.getConstructorArgumentValues().addGenericArgumentValue(Integer.MAX_VALUE);
    }

    parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id"), bDef);
    return (AbstractBeanDefinition) bDef;

}