Polish mongo changes
Restore formatting and fixup doc comments.
This commit is contained in:
		
							parent
							
								
									2adf30950e
								
							
						
					
					
						commit
						a7f5cbf7d0
					
				|  | @ -16,16 +16,17 @@ | ||||||
| 
 | 
 | ||||||
| package org.springframework.boot.autoconfigure.mongo; | package org.springframework.boot.autoconfigure.mongo; | ||||||
| 
 | 
 | ||||||
|  | import java.net.UnknownHostException; | ||||||
|  | 
 | ||||||
|  | import org.springframework.boot.context.properties.ConfigurationProperties; | ||||||
|  | 
 | ||||||
| import com.mongodb.DBPort; | import com.mongodb.DBPort; | ||||||
| import com.mongodb.MongoClient; | import com.mongodb.MongoClient; | ||||||
| import com.mongodb.MongoClientURI; | import com.mongodb.MongoClientURI; | ||||||
| import org.springframework.boot.context.properties.ConfigurationProperties; |  | ||||||
| 
 |  | ||||||
| import java.net.UnknownHostException; |  | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Configuration properties for Mongo. |  * Configuration properties for Mongo. | ||||||
|  * |  *  | ||||||
|  * @author Dave Syer |  * @author Dave Syer | ||||||
|  * @author Phillip Webb |  * @author Phillip Webb | ||||||
|  * @author Josh Long |  * @author Josh Long | ||||||
|  | @ -33,69 +34,68 @@ import java.net.UnknownHostException; | ||||||
| @ConfigurationProperties(prefix = "spring.data.mongodb") | @ConfigurationProperties(prefix = "spring.data.mongodb") | ||||||
| public class MongoProperties { | public class MongoProperties { | ||||||
| 
 | 
 | ||||||
|     private String host; | 	private String host; | ||||||
| 
 | 
 | ||||||
|     private int port = DBPort.PORT; | 	private int port = DBPort.PORT; | ||||||
| 
 | 
 | ||||||
|     private String uri = "mongodb://localhost/test"; | 	private String uri = "mongodb://localhost/test"; | ||||||
| 
 | 
 | ||||||
|     private String database; | 	private String database; | ||||||
| 
 | 
 | ||||||
|     private String gridFsDatabase; | 	private String gridFsDatabase; | ||||||
| 
 | 
 | ||||||
|  | 	public String getHost() { | ||||||
|  | 		return this.host; | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
|     public String getHost() { | 	public void setHost(String host) { | ||||||
|         return this.host; | 		this.host = host; | ||||||
|     } | 	} | ||||||
| 
 | 
 | ||||||
|     public void setHost(String host) { | 	public String getDatabase() { | ||||||
|         this.host = host; | 		return this.database; | ||||||
|     } | 	} | ||||||
| 
 | 
 | ||||||
|     public String getDatabase() { | 	public void setDatabase(String database) { | ||||||
|         return this.database; | 		this.database = database; | ||||||
|     } | 	} | ||||||
| 
 | 
 | ||||||
|     public void setDatabase(String database) { | 	public String getUri() { | ||||||
|         this.database = database; | 		return this.uri; | ||||||
|     } | 	} | ||||||
| 
 | 
 | ||||||
|     public String getUri() { | 	public void setUri(String uri) { | ||||||
|         return this.uri; | 		this.uri = uri; | ||||||
|     } | 	} | ||||||
| 
 | 
 | ||||||
|     public void setUri(String uri) { | 	public int getPort() { | ||||||
|         this.uri = uri; | 		return this.port; | ||||||
|     } | 	} | ||||||
| 
 | 
 | ||||||
|     public int getPort() { | 	public void setPort(int port) { | ||||||
|         return this.port; | 		this.port = port; | ||||||
|     } | 	} | ||||||
| 
 | 
 | ||||||
|     public void setPort(int port) { | 	public String getGridFsDatabase() { | ||||||
|         this.port = port; | 		return this.gridFsDatabase; | ||||||
|     } | 	} | ||||||
| 
 | 
 | ||||||
|     public String getGridFsDatabase() { | 	public void setGridFsDatabase(String gridFsDatabase) { | ||||||
|         return gridFsDatabase; | 		this.gridFsDatabase = gridFsDatabase; | ||||||
|     } | 	} | ||||||
| 
 | 
 | ||||||
|     public void setGridFsDatabase(String gridFsDatabase) { | 	public String getMongoClientDatabase() { | ||||||
|         this.gridFsDatabase = gridFsDatabase; | 		if (this.database != null) { | ||||||
|     } | 			return this.database; | ||||||
|  | 		} | ||||||
|  | 		return new MongoClientURI(this.uri).getDatabase(); | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
|     public String getMongoClientDatabase() { | 	public MongoClient createMongoClient() throws UnknownHostException { | ||||||
|         if (this.database != null) { | 		if (this.host != null) { | ||||||
|             return this.database; | 			return new MongoClient(this.host, this.port); | ||||||
|         } | 		} | ||||||
|         return new MongoClientURI(this.uri).getDatabase(); | 		return new MongoClient(new MongoClientURI(this.uri)); | ||||||
|     } | 	} | ||||||
| 
 |  | ||||||
|     public MongoClient createMongoClient() throws UnknownHostException { |  | ||||||
|         if (this.host != null) { |  | ||||||
|             return new MongoClient(this.host, this.port); |  | ||||||
|         } |  | ||||||
|         return new MongoClient(new MongoClientURI(this.uri)); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -33,11 +33,10 @@ import org.springframework.util.StringUtils; | ||||||
| import com.mongodb.Mongo; | import com.mongodb.Mongo; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's |  * {@link EnableAutoConfiguration Auto-configuration} for Spring Data's mongo support. | ||||||
|  * {@link MongoTemplate}. |  | ||||||
|  * <p> |  * <p> | ||||||
|  * Registers a {@link org.springframework.data.mongodb.core.MongoTemplate} bean if no |  * Registers a {@link MongoTemplate} and {@link GridFsTemplate} beans if no other beans of | ||||||
|  * other bean of the same type is configured. |  * the same type are configured. | ||||||
|  * <P> |  * <P> | ||||||
|  * Honors the {@literal spring.data.mongodb.database} property if set, otherwise connects |  * Honors the {@literal spring.data.mongodb.database} property if set, otherwise connects | ||||||
|  * to the {@literal test} database. |  * to the {@literal test} database. | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| /* | /* | ||||||
|  * Copyright 2012-2013 the original author or authors. |  * Copyright 2012-2014 the original author or authors. | ||||||
|  * |  * | ||||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); |  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
|  * you may not use this file except in compliance with the License. |  * you may not use this file except in compliance with the License. | ||||||
|  | @ -25,12 +25,11 @@ import org.springframework.data.mongodb.gridfs.GridFsTemplate; | ||||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Tests for |  * Tests for {@link MongoTemplateAutoConfiguration}. | ||||||
|  * {@link org.springframework.boot.autoconfigure.mongo.MongoTemplateAutoConfiguration}. |  *  | ||||||
|  * |  | ||||||
|  * @author Josh Long |  * @author Josh Long | ||||||
|  */ |  */ | ||||||
| public class GridFsTemplateAutoConfigurationTests { | public class MongoTemplateAutoConfigurationTests { | ||||||
| 
 | 
 | ||||||
| 	private AnnotationConfigApplicationContext context; | 	private AnnotationConfigApplicationContext context; | ||||||
| 
 | 
 | ||||||
		Loading…
	
		Reference in New Issue