List of usage examples for org.springframework.beans.factory.support BeanDefinitionBuilder getRawBeanDefinition
public AbstractBeanDefinition getRawBeanDefinition()
From source file:org.jdal.vaadin.beans.DefaultsBeanDefinitionParser.java
/** * Register default TablePanel Actions// w w w .j a v a2 s. c o m * @param element current element * @param parserContext parserContext * @return a new ComponentDefinition with default table action list. */ private ComponentDefinition registerDefaultTableActions(Element element, ParserContext parserContext) { ManagedList<Object> actions = new ManagedList<Object>(7); actions.add(createBeanDefinition(AddAction.class, parserContext)); actions.add(createBeanDefinition(RefreshAction.class, parserContext)); actions.add(createBeanDefinition(RemoveAction.class, parserContext)); actions.add(createBeanDefinition(FindAction.class, parserContext)); actions.add(createBeanDefinition(ClearFilterAction.class, parserContext)); BeanDefinitionBuilder bdb = BeanDefinitionBuilder.genericBeanDefinition(ListFactoryBean.class); bdb.getRawBeanDefinition().setSource(parserContext.extractSource(element)); bdb.addPropertyValue("sourceList", actions); bdb.setScope(BeanDefinition.SCOPE_PROTOTYPE); BeanComponentDefinition bcd = new BeanComponentDefinition(bdb.getBeanDefinition(), DEFAULT_TABLE_ACTIONS); registerBeanComponentDefinition(element, parserContext, bcd); return bcd; }
From source file:org.jdal.beans.CustomBeanDefinitionParser.java
/** * Parse bean like a real bean definition. * @param ele element/*from w w w. j a va2 s. c o m*/ * @param parserContext parserContext * @param builder builder */ protected void parseBeanDefinition(Element ele, ParserContext parserContext, BeanDefinitionBuilder builder) { BeanDefinitionParserDelegate delegate = parserContext.getDelegate(); AbstractBeanDefinition bd = builder.getRawBeanDefinition(); XmlReaderContext reader = parserContext.getReaderContext(); try { delegate.parseBeanDefinitionAttributes(ele, beanName, null, bd); bd.setDescription(DomUtils.getChildElementValueByTagName(ele, "description")); delegate.parseMetaElements(ele, bd); delegate.parseLookupOverrideSubElements(ele, bd.getMethodOverrides()); delegate.parseReplacedMethodSubElements(ele, bd.getMethodOverrides()); delegate.parseConstructorArgElements(ele, bd); delegate.parsePropertyElements(ele, bd); delegate.parseQualifierElements(ele, bd); } catch (NoClassDefFoundError err) { reader.error("Class that bean class [" + this.beanClass + "] depends on not found", ele, err); } catch (Throwable ex) { reader.error("Unexpected failure during bean definition parsing", ele, ex); } }
From source file:com.tacitknowledge.flip.spring.config.FeatureServiceHandlerParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder factoryBuilder = BeanDefinitionBuilder .rootBeanDefinition(FeatureServiceDirectFactory.class); RootBeanDefinition factoryBean = (RootBeanDefinition) factoryBuilder.getBeanDefinition(); parserContext.getRegistry().registerBeanDefinition(FlipSpringAspect.FEATURE_SERVICE_FACTORY_BEAN_NAME, factoryBean);/*from w w w . jav a2 s.co m*/ MutablePropertyValues factoryPropertyValues = new MutablePropertyValues(); factoryBean.setPropertyValues(factoryPropertyValues); String environmentBean = element.getAttribute("environment"); if (environmentBean != null && !environmentBean.isEmpty()) { factoryPropertyValues.addPropertyValue("environment", new RuntimeBeanNameReference(environmentBean)); } Element contextProvidersElement = DomUtils.getChildElementByTagName(element, "context-providers"); if (contextProvidersElement != null) { List contextProvidersList = parserContext.getDelegate().parseListElement(contextProvidersElement, factoryBean); if (contextProvidersList != null && !contextProvidersList.isEmpty()) { factoryPropertyValues.addPropertyValue("contextProviders", contextProvidersList); } } Element propertyReadersElement = DomUtils.getChildElementByTagName(element, "property-readers"); if (propertyReadersElement != null && propertyReadersElement.hasChildNodes()) { List propertyReadersList = parserContext.getDelegate().parseListElement(propertyReadersElement, factoryBean); if (propertyReadersList != null && !propertyReadersList.isEmpty()) { factoryPropertyValues.addPropertyValue("propertyReaders", propertyReadersList); } } Element propertiesElement = DomUtils.getChildElementByTagName(element, "properties"); if (propertiesElement != null && propertiesElement.hasChildNodes()) { Properties properties = parserContext.getDelegate().parsePropsElement(propertiesElement); if (properties != null && !properties.isEmpty()) { factoryPropertyValues.addPropertyValue("properties", properties); } } BeanDefinitionBuilder featureServiceBuilder = BeanDefinitionBuilder.genericBeanDefinition(); BeanDefinition featureServiceRawBean = featureServiceBuilder.getRawBeanDefinition(); featureServiceRawBean.setFactoryBeanName(FlipSpringAspect.FEATURE_SERVICE_FACTORY_BEAN_NAME); featureServiceRawBean.setFactoryMethodName("createFeatureService"); parserContext.getRegistry().registerBeanDefinition(FlipSpringAspect.FEATURE_SERVICE_BEAN_NAME, featureServiceBuilder.getBeanDefinition()); return null; }
From source file:org.agilemicroservices.autoconfigure.orm.RepositoryBeanDefinitionBuilder.java
/** * Builds a new {@link BeanDefinitionBuilder} from the given {@link BeanDefinitionRegistry} and {@link ResourceLoader} * .//from ww w . j ava 2 s .c om * * @param configuration must not be {@literal null}. * @return */ public BeanDefinitionBuilder build(RepositoryConfiguration<?> configuration) { Assert.notNull(registry, "BeanDefinitionRegistry must not be null!"); Assert.notNull(resourceLoader, "ResourceLoader must not be null!"); String factoryBeanName = configuration.getRepositoryFactoryBeanName(); factoryBeanName = StringUtils.hasText(factoryBeanName) ? factoryBeanName : extension.getRepositoryFactoryClassName(); BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(factoryBeanName); builder.getRawBeanDefinition().setSource(configuration.getSource()); builder.addPropertyValue("repositoryInterface", configuration.getRepositoryInterface()); builder.addPropertyValue("queryLookupStrategyKey", configuration.getQueryLookupStrategyKey()); builder.addPropertyValue("lazyInit", configuration.isLazyInit()); builder.addPropertyValue("repositoryBaseClass", configuration.getRepositoryBaseClassName()); NamedQueriesBeanDefinitionBuilder definitionBuilder = new NamedQueriesBeanDefinitionBuilder( extension.getDefaultNamedQueryLocation()); if (StringUtils.hasText(configuration.getNamedQueriesLocation())) { definitionBuilder.setLocations(configuration.getNamedQueriesLocation()); } builder.addPropertyValue("namedQueries", definitionBuilder.build(configuration.getSource())); String customImplementationBeanName = registerCustomImplementation(configuration); if (customImplementationBeanName != null) { builder.addPropertyReference("customImplementation", customImplementationBeanName); builder.addDependsOn(customImplementationBeanName); } RootBeanDefinition evaluationContextProviderDefinition = new RootBeanDefinition( ExtensionAwareEvaluationContextProvider.class); evaluationContextProviderDefinition.setSource(configuration.getSource()); builder.addPropertyValue("evaluationContextProvider", evaluationContextProviderDefinition); return builder; }
From source file:org.codehaus.grepo.core.config.GenericRepositoryBeanDefinitionParser.java
/** * {@inheritDoc}/* www. jav a 2 s . c o m*/ */ @Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { Object source = parserContext.extractSource(element); GenericRepositoryConfigContext configContext = new GenericRepositoryConfigContext(element); // init bean defintion parse delegate... BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(parserContext.getReaderContext()); delegate.initDefaults(element.getOwnerDocument().getDocumentElement()); BeanDefinitionBuilder builder = BeanDefinitionParserHelper.createBuilderFromConfigContext(configContext, source, defaultGenericRepositoryFactoryType); delegate.parsePropertyElements(configContext.getElement(), builder.getRawBeanDefinition()); builder.addPropertyValue(GenericRepositoryConfigContext.PROXY_CLASS_PROPERTY, configContext.getProxyClass()); return builder.getBeanDefinition(); }
From source file:fr.xebia.management.config.SpringManagedConnectionFactoryDefinitionParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder .rootBeanDefinition(SpringManagedConnectionFactory.class); // Mark as infrastructure bean and attach source location. builder.setRole(BeanDefinition.ROLE_APPLICATION); builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); builder.addPropertyReference("connectionFactory", element.getAttribute(CONNECTION_FACTORY_ATTRIBUTE)); builder.addPropertyValue("trackLeaks", element.getAttribute(TRACK_LEAKS_ATTRIBUTE)); return builder.getBeanDefinition(); }
From source file:de.itsvs.cwtrpc.controller.config.AutowiredRemoteServiceGroupConfigBeanDefinitionParser.java
protected BeanDefinition parseFilter(Element element, ParserContext parserContext) { final BeanDefinitionBuilder bdd; final Object type; final String expression; bdd = BeanDefinitionBuilder.rootBeanDefinition(PatternFactory.class); bdd.getRawBeanDefinition().setSource(parserContext.extractSource(element)); if (parserContext.isDefaultLazyInit()) { bdd.setLazyInit(true);//from w ww . ja v a 2 s.c om } if (element.hasAttribute(XmlNames.TYPE_ATTR)) { type = element.getAttribute(XmlNames.TYPE_ATTR); } else { type = DEFAULT_PATTERN_TYPE; } expression = element.getAttribute(XmlNames.EXPRESSION_ATTR); if (!StringUtils.hasText(expression)) { parserContext.getReaderContext().error("Filter expression must not be empty", parserContext.extractSource(element)); } bdd.setFactoryMethod("compile"); bdd.addConstructorArgValue(type); bdd.addConstructorArgValue(MatcherType.PACKAGE); bdd.addConstructorArgValue(expression); return bdd.getBeanDefinition(); }
From source file:net.phoenix.thrift.xml.ComplexBeanDefinitionParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(); String parentName = getParentName(element); if (parentName != null) { builder.getRawBeanDefinition().setParentName(parentName); }/*from ww w.jav a 2 s .c o m*/ Class<?> beanClass = getBeanClass(element); if (beanClass != null) { builder.getRawBeanDefinition().setBeanClass(beanClass); } else { String beanClassName = getBeanClassName(element); if (beanClassName != null) { builder.getRawBeanDefinition().setBeanClassName(beanClassName); } } builder.getRawBeanDefinition().setSource(parserContext.extractSource(element)); if (parserContext.isNested()) { // Inner bean definition must receive same scope as containing bean. builder.setScope(parserContext.getContainingBeanDefinition().getScope()); } if (parserContext.isDefaultLazyInit()) { // Default-lazy-init applies to custom bean definitions as well. builder.setLazyInit(true); } preParse(element, parserContext, builder); AbstractBeanDefinition target = builder.getBeanDefinition(); postParse(element, parserContext, target); return target; }
From source file:org.jolokia.jvmagent.spring.config.AgentBeanDefinitionParser.java
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { Element config = DomUtils.getChildElementByTagName(element, "config"); if (config != null) { builder.addPropertyValue("config", parserContext.getDelegate().parseCustomElement(config, builder.getRawBeanDefinition())); }//from w w w. j ava 2 s .co m String lookupConfig = element.getAttribute("lookupConfig"); if (StringUtils.hasLength(lookupConfig)) { builder.addPropertyValue("lookupConfig", Boolean.parseBoolean(lookupConfig)); } else { builder.addPropertyValue("lookupConfig", false); } String systemPropertiesMode = element.getAttribute("systemPropertiesMode"); if (StringUtils.hasLength(systemPropertiesMode)) { builder.addPropertyValue("systemPropertiesMode", systemPropertiesMode); } }
From source file:com.mtgi.analytics.aop.config.v11.BtJdbcPersisterBeanDefinitionParser.java
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { //configure ID generator settings NodeList children = element.getElementsByTagNameNS("*", ELT_ID_SQL); if (children.getLength() == 1) { BeanDefinition def = builder.getRawBeanDefinition(); MutablePropertyValues props = def.getPropertyValues(); Element child = (Element) children.item(0); String sql = child.getTextContent(); if (StringUtils.hasText(sql)) props.addPropertyValue("idSql", sql); if (child.hasAttribute(ATT_INCREMENT)) props.addPropertyValue("idIncrement", child.getAttribute(ATT_INCREMENT)); }// w w w .j a va 2 s.co m //configure nested dataSource NodeList nodes = element.getElementsByTagNameNS("*", "data-source"); if (nodes.getLength() == 1) { Element ds = (Element) nodes.item(0); ds.setAttribute("name", "dataSource"); parserContext.getDelegate().parsePropertyElement(ds, builder.getRawBeanDefinition()); } //push persister into parent manager bean, if applicable if (parserContext.isNested()) { AbstractBeanDefinition def = builder.getBeanDefinition(); String id = element.hasAttribute("id") ? element.getAttribute("id") : BeanDefinitionReaderUtils.generateBeanName(def, parserContext.getReaderContext().getRegistry(), true); BeanDefinitionHolder holder = new BeanDefinitionHolder(def, id); BtManagerBeanDefinitionParser.registerNestedBean(holder, "persister", parserContext); } }