Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2011-2013 the original author or authors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.springframework.data.mongodb.config;
 
 import static org.springframework.data.config.ParsingUtils.*;
 
 import java.util.Map;
 
 import  org.springframework.beans.factory.config.BeanDefinition;
 import  org.springframework.beans.factory.config.CustomEditorConfigurer;
 import  org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import  org.springframework.beans.factory.support.ManagedMap;
 import  org.springframework.beans.factory.xml.BeanDefinitionParser;
 import  org.springframework.util.xml.DomUtils;
Utility methods for BeanDefinitionParser implementations for MongoDB.

Author(s):
Mark Pollack
Oliver Gierke
Thomas Darimont
 
 abstract class MongoParsingUtils {
 
 	private MongoParsingUtils() {
 
 	}

Parses the mongo replica-set element.

Parameters:
parserContext the parser context
element the mongo element
mongoBuilder the bean definition builder to populate
Returns:
 
 	static void parseReplicaSet(Element element, BeanDefinitionBuilder mongoBuilder) {
 		setPropertyValue(mongoBuilderelement"replica-set""replicaSetSeeds");
 	}

Parses the mongo:options sub-element. Populates the given attribute factory with the proper attributes.

Returns:
true if parsing actually occured, false otherwise
 
 	static boolean parseMongoOptions(Element element, BeanDefinitionBuilder mongoBuilder) {
 		Element optionsElement = DomUtils.getChildElementByTagName(element"options");
 		if (optionsElement == null) {
 			return false;
 		}
 
 		BeanDefinitionBuilder optionsDefBuilder = BeanDefinitionBuilder
 				.genericBeanDefinition(MongoOptionsFactoryBean.class);
 
 		setPropertyValue(optionsDefBuilderoptionsElement"connections-per-host""connectionsPerHost");
 		setPropertyValue(optionsDefBuilderoptionsElement"threads-allowed-to-block-for-connection-multiplier",
 				"threadsAllowedToBlockForConnectionMultiplier");
 		setPropertyValue(optionsDefBuilderoptionsElement"max-wait-time""maxWaitTime");
 		setPropertyValue(optionsDefBuilderoptionsElement"connect-timeout""connectTimeout");
 		setPropertyValue(optionsDefBuilderoptionsElement"socket-timeout""socketTimeout");
 		setPropertyValue(optionsDefBuilderoptionsElement"socket-keep-alive""socketKeepAlive");
 		setPropertyValue(optionsDefBuilderoptionsElement"auto-connect-retry""autoConnectRetry");
 		setPropertyValue(optionsDefBuilderoptionsElement"max-auto-connect-retry-time""maxAutoConnectRetryTime");
 		setPropertyValue(optionsDefBuilderoptionsElement"write-number""writeNumber");
 		setPropertyValue(optionsDefBuilderoptionsElement"write-timeout""writeTimeout");
 		setPropertyValue(optionsDefBuilderoptionsElement"write-fsync""writeFsync");
 		setPropertyValue(optionsDefBuilderoptionsElement"slave-ok""slaveOk");
 		setPropertyValue(optionsDefBuilderoptionsElement"ssl""ssl");
 		setPropertyReference(optionsDefBuilderoptionsElement"ssl-socket-factory-ref""sslSocketFactory");
 
 		mongoBuilder.addPropertyValue("mongoOptions"optionsDefBuilder.getBeanDefinition());
 		return true;
 	}

Returns the BeanDefinitionBuilder to build a BeanDefinition for a WriteConcernPropertyEditor.

Returns:
 
 	static BeanDefinitionBuilder getWriteConcernPropertyEditorBuilder() {
 
 		Map<StringClass<?>> customEditors = new ManagedMap<StringClass<?>>();
 		customEditors.put("com.mongodb.WriteConcern"WriteConcernPropertyEditor.class);
		BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CustomEditorConfigurer.class);
		builder.addPropertyValue("customEditors"customEditors);
		return builder;
	}
New to GrepCode? Check out our FAQ X