Search in sources :

Example 66 with BeanDefinitionHolder

use of org.springframework.beans.factory.config.BeanDefinitionHolder in project camunda-bpm-platform by camunda.

the class Scopifier method createScopedProxy.

public static BeanDefinitionHolder createScopedProxy(String beanName, BeanDefinition definition, BeanDefinitionRegistry registry, boolean proxyTargetClass) {
    BeanDefinitionHolder proxyHolder = ScopedProxyUtils.createScopedProxy(new BeanDefinitionHolder(definition, beanName), registry, proxyTargetClass);
    registry.registerBeanDefinition(beanName, proxyHolder.getBeanDefinition());
    return proxyHolder;
}
Also used : BeanDefinitionHolder(org.springframework.beans.factory.config.BeanDefinitionHolder)

Example 67 with BeanDefinitionHolder

use of org.springframework.beans.factory.config.BeanDefinitionHolder in project camunda-bpm-platform by camunda.

the class Scopifier method resolveValue.

@Override
protected Object resolveValue(Object value) {
    BeanDefinition definition = null;
    String beanName = null;
    if (value instanceof BeanDefinition) {
        definition = (BeanDefinition) value;
        beanName = BeanDefinitionReaderUtils.generateBeanName(definition, registry);
    } else if (value instanceof BeanDefinitionHolder) {
        BeanDefinitionHolder holder = (BeanDefinitionHolder) value;
        definition = holder.getBeanDefinition();
        beanName = holder.getBeanName();
    }
    if (definition != null) {
        boolean nestedScoped = scope.equals(definition.getScope());
        boolean scopeChangeRequiresProxy = !scoped && nestedScoped;
        if (scopeChangeRequiresProxy) {
            // analysed
            return createScopedProxy(beanName, definition, registry, proxyTargetClass);
        }
    }
    // Nested inner bean definitions are recursively analysed here
    value = super.resolveValue(value);
    return value;
}
Also used : BeanDefinitionHolder(org.springframework.beans.factory.config.BeanDefinitionHolder) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition)

Example 68 with BeanDefinitionHolder

use of org.springframework.beans.factory.config.BeanDefinitionHolder in project ff4j by ff4j.

the class FF4JPlaceHolderBeanDefinitionParser method parse.

/**
 * {@inheritDoc}
 */
public final BeanDefinition parse(Element element, ParserContext parserContext) {
    logger.debug("Initialization from <ff4j:" + TAG_PLACEHOLDER + "> TAG");
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition();
    builder.getRawBeanDefinition().setBeanClass(FF4jPropertiesPlaceHolderConfigurer.class);
    builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
    // Reference to FF4J bean
    RuntimeBeanReference refFF4j = new RuntimeBeanReference("ff4j");
    builder.getBeanDefinition().getPropertyValues().addPropertyValue("id", BEANID_PLACEHOLDER_CONF);
    builder.getBeanDefinition().getPropertyValues().addPropertyValue("ff4j", refFF4j);
    builder.getBeanDefinition().getPropertyValues().addPropertyValue("order", 2);
    AbstractBeanDefinition def = builder.getBeanDefinition();
    if (def != null && !parserContext.isNested()) {
        BeanDefinitionHolder holder = new BeanDefinitionHolder(def, BEANID_PLACEHOLDER, new String[0]);
        BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
    }
    return def;
}
Also used : BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition) BeanDefinitionHolder(org.springframework.beans.factory.config.BeanDefinitionHolder) RuntimeBeanReference(org.springframework.beans.factory.config.RuntimeBeanReference)

Example 69 with BeanDefinitionHolder

use of org.springframework.beans.factory.config.BeanDefinitionHolder in project hazelcast by hazelcast.

the class HazelcastClientBeanDefinitionParser method registerCPSubsystemBean.

private void registerCPSubsystemBean(Element element, ParserContext parserContext) {
    String instanceBeanRef = element.getAttribute("id");
    BeanDefinitionBuilder cpBeanDefBuilder = BeanDefinitionBuilder.rootBeanDefinition(CPSubsystem.class);
    cpBeanDefBuilder.setFactoryMethodOnBean("getCPSubsystem", instanceBeanRef);
    cpBeanDefBuilder.setLazyInit(true);
    BeanDefinitionHolder holder = new BeanDefinitionHolder(cpBeanDefBuilder.getBeanDefinition(), instanceBeanRef + CP_SUBSYSTEM_SUFFIX);
    registerBeanDefinition(holder, parserContext.getRegistry());
}
Also used : BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) BeanDefinitionHolder(org.springframework.beans.factory.config.BeanDefinitionHolder)

Example 70 with BeanDefinitionHolder

use of org.springframework.beans.factory.config.BeanDefinitionHolder in project geronimo-xbean by apache.

the class XBeanNamespaceHandler method parse.

public BeanDefinition parse(Element element, ParserContext parserContext) {
    this.parserContext = parserContext;
    this.qnameHelper = new XBeanQNameHelper(parserContext.getReaderContext());
    BeanDefinitionHolder holder = parseBeanFromExtensionElement(element);
    // a 2nd level could be a nested <beans> from Spring 3.1 onwards
    if (element.getParentNode() == element.getOwnerDocument() || element.getParentNode().getParentNode() == element.getOwnerDocument() || element.getParentNode().getParentNode().getParentNode() == element.getOwnerDocument()) {
        BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
        BeanComponentDefinition componentDefinition = new BeanComponentDefinition(holder);
        parserContext.getReaderContext().fireComponentRegistered(componentDefinition);
    }
    return holder.getBeanDefinition();
}
Also used : BeanDefinitionHolder(org.springframework.beans.factory.config.BeanDefinitionHolder) BeanComponentDefinition(org.springframework.beans.factory.parsing.BeanComponentDefinition)

Aggregations

BeanDefinitionHolder (org.springframework.beans.factory.config.BeanDefinitionHolder)94 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)30 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)20 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)18 Element (org.w3c.dom.Element)18 BeanComponentDefinition (org.springframework.beans.factory.parsing.BeanComponentDefinition)16 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)16 RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)12 ManagedList (org.springframework.beans.factory.support.ManagedList)11 Node (org.w3c.dom.Node)11 ArrayList (java.util.ArrayList)8 ManagedMap (org.springframework.beans.factory.support.ManagedMap)6 LinkedHashSet (java.util.LinkedHashSet)5 Test (org.junit.jupiter.api.Test)5 BeanDefinitionStoreException (org.springframework.beans.factory.BeanDefinitionStoreException)5 AnnotatedGenericBeanDefinition (org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition)5 NamedNodeMap (org.w3c.dom.NamedNodeMap)5 NodeList (org.w3c.dom.NodeList)5 Method (java.lang.reflect.Method)4 HashSet (java.util.HashSet)4