Search in sources :

Example 26 with CompositeComponentDefinition

use of org.springframework.beans.factory.parsing.CompositeComponentDefinition in project spring-data-mongodb by spring-projects.

the class MongoClientParser method parse.

/*
	 * (non-Javadoc)
	 * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
	 */
public BeanDefinition parse(Element element, ParserContext parserContext) {
    Object source = parserContext.extractSource(element);
    String id = element.getAttribute("id");
    BeanComponentDefinitionBuilder helper = new BeanComponentDefinitionBuilder(element, parserContext);
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MongoClientFactoryBean.class);
    ParsingUtils.setPropertyValue(builder, element, "port", "port");
    ParsingUtils.setPropertyValue(builder, element, "host", "host");
    ParsingUtils.setPropertyValue(builder, element, "credentials", "credentials");
    MongoParsingUtils.parseMongoClientOptions(element, builder);
    MongoParsingUtils.parseReplicaSet(element, builder);
    String defaultedId = StringUtils.hasText(id) ? id : BeanNames.MONGO_BEAN_NAME;
    parserContext.pushContainingComponent(new CompositeComponentDefinition("Mongo", source));
    BeanComponentDefinition mongoComponent = helper.getComponent(builder, defaultedId);
    parserContext.registerBeanComponent(mongoComponent);
    BeanComponentDefinition serverAddressPropertyEditor = helper.getComponent(MongoParsingUtils.getServerAddressPropertyEditorBuilder());
    parserContext.registerBeanComponent(serverAddressPropertyEditor);
    BeanComponentDefinition writeConcernEditor = helper.getComponent(MongoParsingUtils.getWriteConcernPropertyEditorBuilder());
    parserContext.registerBeanComponent(writeConcernEditor);
    BeanComponentDefinition readPreferenceEditor = helper.getComponent(MongoParsingUtils.getReadPreferencePropertyEditorBuilder());
    parserContext.registerBeanComponent(readPreferenceEditor);
    BeanComponentDefinition credentialsEditor = helper.getComponent(MongoParsingUtils.getMongoCredentialPropertyEditor());
    parserContext.registerBeanComponent(credentialsEditor);
    parserContext.popAndRegisterContainingComponent();
    return mongoComponent.getBeanDefinition();
}
Also used : BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) CompositeComponentDefinition(org.springframework.beans.factory.parsing.CompositeComponentDefinition) BeanComponentDefinition(org.springframework.beans.factory.parsing.BeanComponentDefinition) BeanComponentDefinitionBuilder(org.springframework.data.config.BeanComponentDefinitionBuilder)

Example 27 with CompositeComponentDefinition

use of org.springframework.beans.factory.parsing.CompositeComponentDefinition in project spring-data-mongodb by spring-projects.

the class MongoJmxParser method registerJmxComponents.

protected void registerJmxComponents(String mongoRefName, Element element, ParserContext parserContext) {
    Object eleSource = parserContext.extractSource(element);
    CompositeComponentDefinition compositeDef = new CompositeComponentDefinition(element.getTagName(), eleSource);
    createBeanDefEntry(AssertMetrics.class, compositeDef, mongoRefName, eleSource, parserContext);
    createBeanDefEntry(BackgroundFlushingMetrics.class, compositeDef, mongoRefName, eleSource, parserContext);
    createBeanDefEntry(BtreeIndexCounters.class, compositeDef, mongoRefName, eleSource, parserContext);
    createBeanDefEntry(ConnectionMetrics.class, compositeDef, mongoRefName, eleSource, parserContext);
    createBeanDefEntry(GlobalLockMetrics.class, compositeDef, mongoRefName, eleSource, parserContext);
    createBeanDefEntry(MemoryMetrics.class, compositeDef, mongoRefName, eleSource, parserContext);
    createBeanDefEntry(OperationCounters.class, compositeDef, mongoRefName, eleSource, parserContext);
    createBeanDefEntry(ServerInfo.class, compositeDef, mongoRefName, eleSource, parserContext);
    createBeanDefEntry(MongoAdmin.class, compositeDef, mongoRefName, eleSource, parserContext);
    parserContext.registerComponent(compositeDef);
}
Also used : CompositeComponentDefinition(org.springframework.beans.factory.parsing.CompositeComponentDefinition)

Aggregations

CompositeComponentDefinition (org.springframework.beans.factory.parsing.CompositeComponentDefinition)27 BeanComponentDefinition (org.springframework.beans.factory.parsing.BeanComponentDefinition)18 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)13 RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)10 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)9 Element (org.w3c.dom.Element)8 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)6 Test (org.junit.Test)5 ComponentDefinition (org.springframework.beans.factory.parsing.ComponentDefinition)5 BeanDefinitionRegistry (org.springframework.beans.factory.support.BeanDefinitionRegistry)5 ManagedList (org.springframework.beans.factory.support.ManagedList)4 BeanReference (org.springframework.beans.factory.config.BeanReference)3 BeanMetadataElement (org.springframework.beans.BeanMetadataElement)2 BeanDefinitionHolder (org.springframework.beans.factory.config.BeanDefinitionHolder)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)1