From da23133327c85e4480ce5737a787729973a57715 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Fri, 26 Aug 2011 20:26:06 +0200 Subject: [PATCH] Yet another round of formatting. Added Eclipse formatter settings. --- spring-data-mongodb/etc/eclipse-formatter.xml | 291 ++++++++++++++++++ .../InvalidMongoDbApiUsageException.java | 10 +- .../data/mongodb/MongoCollectionUtils.java | 6 +- .../data/mongodb/MongoDbFactory.java | 4 +- .../UncategorizedMongoDbException.java | 4 +- .../config/AbstractMongoConfiguration.java | 26 +- .../config/MappingMongoConverterParser.java | 34 +- .../mongodb/config/MongoDbFactoryParser.java | 2 +- .../data/mongodb/config/MongoParser.java | 2 +- .../MongoRepositoryNamespaceHandler.java | 2 +- .../data/mongodb/config/ParsingUtils.java | 139 +++++---- .../SimpleMongoRepositoryConfiguration.java | 10 +- .../data/mongodb/core/CollectionOptions.java | 11 +- .../data/mongodb/core/MongoAdmin.java | 6 +- .../data/mongodb/core/MongoDbUtils.java | 27 +- .../data/mongodb/core/MongoFactoryBean.java | 10 +- .../data/mongodb/core/MongoOperations.java | 275 +++++++---------- .../mongodb/core/MongoOptionsFactoryBean.java | 143 ++++----- .../data/mongodb/core/MongoTemplate.java | 23 +- .../data/mongodb/core/QueryMapper.java | 16 +- .../mongodb/core/SimpleMongoDbFactory.java | 8 +- .../core/convert/AbstractMongoConverter.java | 3 +- .../core/convert/ConfigurableTypeMapper.java | 4 +- .../core/convert/CustomConversions.java | 6 +- .../core/convert/DefaultTypeMapper.java | 10 +- .../core/convert/MappingMongoConverter.java | 30 +- .../mongodb/core/convert/MongoConverter.java | 4 +- .../mongodb/core/convert/MongoConverters.java | 9 +- .../mongodb/core/convert/MongoWriter.java | 8 +- .../data/mongodb/core/convert/TypeMapper.java | 8 +- .../core/convert/TypeMapperProvider.java | 2 +- .../data/mongodb/core/geo/GeoResults.java | 4 +- .../data/mongodb/core/geo/Metrics.java | 2 +- .../data/mongodb/core/geo/Point.java | 2 +- .../mongodb/core/index/GeospatialIndex.java | 2 +- .../MongoPersistentEntityIndexCreator.java | 23 +- .../mapping/BasicMongoPersistentEntity.java | 12 +- .../data/mongodb/core/mapping/Field.java | 6 +- .../core/mapping/MongoMappingContext.java | 2 +- .../core/mapping/MongoPersistentProperty.java | 6 +- .../core/mapping/MongoSimpleTypes.java | 4 +- .../mapping/SimpleMongoMappingContext.java | 9 +- .../data/mongodb/core/query/BasicQuery.java | 8 +- .../data/mongodb/core/query/Criteria.java | 21 +- .../data/mongodb/core/query/NearQuery.java | 6 +- .../data/mongodb/monitor/AbstractMonitor.java | 6 +- .../repository/AbstractMongoQuery.java | 2 +- .../ConvertingParameterAccessor.java | 20 +- .../MappingMongoEntityInformation.java | 2 +- .../mongodb/repository/MongoParameters.java | 16 +- .../MongoParametersParameterAccessor.java | 6 +- .../mongodb/repository/MongoQueryCreator.java | 11 +- .../mongodb/repository/MongoQueryMethod.java | 8 +- .../repository/QueryDslMongoRepository.java | 2 +- .../data/mongodb/repository/QueryUtils.java | 2 +- .../repository/QuerydslRepositorySupport.java | 2 +- .../repository/SimpleMongoRepository.java | 2 +- .../repository/StringBasedMongoQuery.java | 2 +- 58 files changed, 768 insertions(+), 553 deletions(-) create mode 100644 spring-data-mongodb/etc/eclipse-formatter.xml diff --git a/spring-data-mongodb/etc/eclipse-formatter.xml b/spring-data-mongodb/etc/eclipse-formatter.xml new file mode 100644 index 000000000..c74468778 --- /dev/null +++ b/spring-data-mongodb/etc/eclipse-formatter.xml @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/InvalidMongoDbApiUsageException.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/InvalidMongoDbApiUsageException.java index 1d224c535..a67b6c7a9 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/InvalidMongoDbApiUsageException.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/InvalidMongoDbApiUsageException.java @@ -22,10 +22,10 @@ public class InvalidMongoDbApiUsageException extends InvalidDataAccessApiUsageEx private static final long serialVersionUID = 2034770973290508041L; public InvalidMongoDbApiUsageException(String msg) { - super(msg); - } + super(msg); + } - public InvalidMongoDbApiUsageException(String msg, Throwable cause) { - super(msg, cause); - } + public InvalidMongoDbApiUsageException(String msg, Throwable cause) { + super(msg, cause); + } } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoCollectionUtils.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoCollectionUtils.java index 5c2374173..db9a4f30c 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoCollectionUtils.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoCollectionUtils.java @@ -18,14 +18,12 @@ package org.springframework.data.mongodb; import org.springframework.util.StringUtils; - - /** * Helper class featuring helper methods for working with MongoDb collections. *

*

* Mainly intended for internal use within the framework. - * + * * @author Thomas Risberg * @since 1.0 */ @@ -40,7 +38,7 @@ public abstract class MongoCollectionUtils { /** * Obtains the collection name to use for the provided class - * + * * @param entityClass The class to determine the preferred collection name for * @return The preferred collection name */ diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoDbFactory.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoDbFactory.java index 1db0daf12..0276928a1 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoDbFactory.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/MongoDbFactory.java @@ -6,7 +6,7 @@ import com.mongodb.DB; /** * Interface for factories creating {@link DB} instances. - * + * * @author Mark Pollack */ public interface MongoDbFactory { @@ -18,7 +18,7 @@ public interface MongoDbFactory { * @throws DataAccessException */ DB getDb() throws DataAccessException; - + /** * Creates a {@link DB} instance to access the database with the given name. * diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/UncategorizedMongoDbException.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/UncategorizedMongoDbException.java index 1006f3664..7d33b0871 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/UncategorizedMongoDbException.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/UncategorizedMongoDbException.java @@ -22,6 +22,6 @@ public class UncategorizedMongoDbException extends UncategorizedDataAccessExcept private static final long serialVersionUID = -2336595514062364929L; public UncategorizedMongoDbException(String msg, Throwable cause) { - super(msg, cause); - } + super(msg, cause); + } } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/AbstractMongoConfiguration.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/AbstractMongoConfiguration.java index fe9d3e8f3..7280b374b 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/AbstractMongoConfiguration.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/AbstractMongoConfiguration.java @@ -46,24 +46,24 @@ public abstract class AbstractMongoConfiguration { @Bean public MongoTemplate mongoTemplate() throws Exception { - return new MongoTemplate(mongoDbFactory(), mappingMongoConverter()); + return new MongoTemplate(mongoDbFactory(), mappingMongoConverter()); } @Bean - public MongoDbFactory mongoDbFactory() throws Exception { - if (getUserCredentials() == null) { - return new SimpleMongoDbFactory(mongo(), getDatabaseName()); - } else { - return new SimpleMongoDbFactory(mongo(), getDatabaseName(), getUserCredentials()); - } + public MongoDbFactory mongoDbFactory() throws Exception { + if (getUserCredentials() == null) { + return new SimpleMongoDbFactory(mongo(), getDatabaseName()); + } else { + return new SimpleMongoDbFactory(mongo(), getDatabaseName(), getUserCredentials()); + } } public String getMappingBasePackage() { return ""; } - + public UserCredentials getUserCredentials() { - return null; + return null; } @Bean @@ -71,13 +71,15 @@ public abstract class AbstractMongoConfiguration { MongoMappingContext mappingContext = new MongoMappingContext(); String basePackage = getMappingBasePackage(); if (StringUtils.hasText(basePackage)) { - ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(false); + ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider( + false); componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class)); componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class)); Set> initialEntitySet = new HashSet>(); for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) { - initialEntitySet.add(ClassUtils.forName(candidate.getBeanClassName(), mappingContext.getClass().getClassLoader())); + initialEntitySet.add(ClassUtils.forName(candidate.getBeanClassName(), mappingContext.getClass() + .getClassLoader())); } mappingContext.setInitialEntitySet(initialEntitySet); } @@ -93,7 +95,7 @@ public abstract class AbstractMongoConfiguration { /** * Hook that allows post-processing after the MappingMongoConverter has been successfully created. - * + * * @param converter */ protected void afterMappingMongoConverterCreation(MappingMongoConverter converter) { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MappingMongoConverterParser.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MappingMongoConverterParser.java index ddec9c765..3866d15eb 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MappingMongoConverterParser.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MappingMongoConverterParser.java @@ -66,7 +66,7 @@ public class MappingMongoConverterParser extends AbstractBeanDefinitionParser { @Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionRegistry registry = parserContext.getRegistry(); - + BeanDefinition conversionsDefinition = getCustomConversions(element, parserContext); String ctxRef = potentiallyCreateMappingContext(element, parserContext, conversionsDefinition); @@ -100,7 +100,8 @@ public class MappingMongoConverterParser extends AbstractBeanDefinitionParser { if (!StringUtils.hasText(dbFactoryRef)) { dbFactoryRef = DB_FACTORY; } - BeanDefinitionBuilder indexHelperBuilder = BeanDefinitionBuilder.genericBeanDefinition(MongoPersistentEntityIndexCreator.class); + BeanDefinitionBuilder indexHelperBuilder = BeanDefinitionBuilder + .genericBeanDefinition(MongoPersistentEntityIndexCreator.class); indexHelperBuilder.addConstructorArgValue(new RuntimeBeanReference(ctxRef)); indexHelperBuilder.addConstructorArgValue(new RuntimeBeanReference(dbFactoryRef)); registry.registerBeanDefinition(INDEX_HELPER, indexHelperBuilder.getBeanDefinition()); @@ -108,9 +109,10 @@ public class MappingMongoConverterParser extends AbstractBeanDefinitionParser { return converterBuilder.getBeanDefinition(); } - - private String potentiallyCreateMappingContext(Element element, ParserContext parserContext, BeanDefinition conversionsDefinition) { - + + private String potentiallyCreateMappingContext(Element element, ParserContext parserContext, + BeanDefinition conversionsDefinition) { + String ctxRef = element.getAttribute("mapping-context-ref"); if (!StringUtils.hasText(ctxRef)) { BeanDefinitionBuilder mappingContextBuilder = BeanDefinitionBuilder @@ -120,26 +122,26 @@ public class MappingMongoConverterParser extends AbstractBeanDefinitionParser { if (classesToAdd != null) { mappingContextBuilder.addPropertyValue("initialEntitySet", classesToAdd); } - + if (conversionsDefinition != null) { AbstractBeanDefinition simpleTypesDefinition = new GenericBeanDefinition(); simpleTypesDefinition.setFactoryBeanName("customConversions"); simpleTypesDefinition.setFactoryMethodName("getSimpleTypeHolder"); - + mappingContextBuilder.addPropertyValue("simpleTypeHolder", simpleTypesDefinition); } parserContext.getRegistry().registerBeanDefinition(MAPPING_CONTEXT, mappingContextBuilder.getBeanDefinition()); ctxRef = MAPPING_CONTEXT; } - + return ctxRef; } - + private BeanDefinition getCustomConversions(Element element, ParserContext parserContext) { - + List customConvertersElements = DomUtils.getChildElementsByTagName(element, "custom-converters"); - + if (customConvertersElements.size() == 1) { Element customerConvertersElement = customConvertersElements.get(0); ManagedList converterBeans = new ManagedList(); @@ -149,18 +151,18 @@ public class MappingMongoConverterParser extends AbstractBeanDefinitionParser { converterBeans.add(parseConverter(listenerElement, parserContext)); } } - + BeanDefinitionBuilder conversionsBuilder = BeanDefinitionBuilder.rootBeanDefinition(CustomConversions.class); conversionsBuilder.addConstructorArgValue(converterBeans); - + AbstractBeanDefinition conversionsBean = conversionsBuilder.getBeanDefinition(); conversionsBean.setSource(parserContext.extractSource(element)); - + parserContext.getRegistry().registerBeanDefinition("customConversions", conversionsBean); - + return conversionsBean; } - + return null; } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoDbFactoryParser.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoDbFactoryParser.java index 3366f0f8f..8e57f0964 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoDbFactoryParser.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoDbFactoryParser.java @@ -74,7 +74,7 @@ public class MongoDbFactoryParser extends AbstractBeanDefinitionParser { if (userCredentials != null) { dbFactoryBuilder.addConstructorArgValue(userCredentials); } - + ParsingUtils.setPropertyValue(element, dbFactoryBuilder, "write-concern", "writeConcern"); return dbFactoryBuilder.getBeanDefinition(); diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoParser.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoParser.java index 42c52bb56..96af81427 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoParser.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoParser.java @@ -27,7 +27,7 @@ import org.w3c.dom.Element; /** * Parser for <mongo;gt; definitions. If no name - * + * * @author Mark Pollack */ public class MongoParser extends AbstractSingleBeanDefinitionParser { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoRepositoryNamespaceHandler.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoRepositoryNamespaceHandler.java index 15d111218..643ee23ab 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoRepositoryNamespaceHandler.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MongoRepositoryNamespaceHandler.java @@ -19,7 +19,7 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport; /** * {@link org.springframework.beans.factory.xml.NamespaceHandler} for Mongo DB based repositories. - * + * * @author Oliver Gierke */ public class MongoRepositoryNamespaceHandler extends NamespaceHandlerSupport { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/ParsingUtils.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/ParsingUtils.java index 1cfe5ed3d..b94ab5c7e 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/ParsingUtils.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/ParsingUtils.java @@ -28,75 +28,74 @@ import com.mongodb.ServerAddress; abstract class ParsingUtils { - /** - * Parses the mongo replica-set element. - * @param parserContext the parser context - * @param element the mongo element - * @param mongoBuilder the bean definition builder to populate - * @return true if parsing actually occured, false otherwise - */ - static boolean parseReplicaSet(ParserContext parserContext, Element element, BeanDefinitionBuilder mongoBuilder) { - - - String replicaSetString = element.getAttribute("replica-set"); - if (StringUtils.hasText(replicaSetString)) { - ManagedList serverAddresses = new ManagedList(); - String[] replicaSetStringArray = StringUtils.commaDelimitedListToStringArray(replicaSetString); - for (String element2 : replicaSetStringArray) { - String[] hostAndPort = StringUtils.delimitedListToStringArray(element2, ":"); - BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.genericBeanDefinition(ServerAddress.class); - defBuilder.addConstructorArgValue(hostAndPort[0]); - defBuilder.addConstructorArgValue(hostAndPort[1]); - serverAddresses.add(defBuilder.getBeanDefinition()); - } - if (!serverAddresses.isEmpty()) { - mongoBuilder.addPropertyValue("replicaSetSeeds", serverAddresses); - } - } - return true; - - } - /** - * Parses the mongo:options sub-element. Populates the given attribute factory with the proper attributes. - * - * @return true if parsing actually occured, false otherwise - */ - static boolean parseMongoOptions(ParserContext parserContext, Element element, BeanDefinitionBuilder mongoBuilder) { - Element optionsElement = DomUtils.getChildElementByTagName(element, "options"); - if (optionsElement == null) { + /** + * Parses the mongo replica-set element. + * + * @param parserContext the parser context + * @param element the mongo element + * @param mongoBuilder the bean definition builder to populate + * @return true if parsing actually occured, false otherwise + */ + static boolean parseReplicaSet(ParserContext parserContext, Element element, BeanDefinitionBuilder mongoBuilder) { + + String replicaSetString = element.getAttribute("replica-set"); + if (StringUtils.hasText(replicaSetString)) { + ManagedList serverAddresses = new ManagedList(); + String[] replicaSetStringArray = StringUtils.commaDelimitedListToStringArray(replicaSetString); + for (String element2 : replicaSetStringArray) { + String[] hostAndPort = StringUtils.delimitedListToStringArray(element2, ":"); + BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.genericBeanDefinition(ServerAddress.class); + defBuilder.addConstructorArgValue(hostAndPort[0]); + defBuilder.addConstructorArgValue(hostAndPort[1]); + serverAddresses.add(defBuilder.getBeanDefinition()); + } + if (!serverAddresses.isEmpty()) { + mongoBuilder.addPropertyValue("replicaSetSeeds", serverAddresses); + } + } + return true; + + } + + /** + * Parses the mongo:options sub-element. Populates the given attribute factory with the proper attributes. + * + * @return true if parsing actually occured, false otherwise + */ + static boolean parseMongoOptions(ParserContext parserContext, Element element, BeanDefinitionBuilder mongoBuilder) { + Element optionsElement = DomUtils.getChildElementByTagName(element, "options"); + if (optionsElement == null) { return false; } - BeanDefinitionBuilder optionsDefBuilder = BeanDefinitionBuilder - .genericBeanDefinition(MongoOptionsFactoryBean.class); + BeanDefinitionBuilder optionsDefBuilder = BeanDefinitionBuilder + .genericBeanDefinition(MongoOptionsFactoryBean.class); - setPropertyValue(optionsElement, optionsDefBuilder, "connections-per-host", "connectionsPerHost"); - setPropertyValue(optionsElement, optionsDefBuilder, "threads-allowed-to-block-for-connection-multiplier", - "threadsAllowedToBlockForConnectionMultiplier"); - setPropertyValue(optionsElement, optionsDefBuilder, "max-wait-time", "maxWaitTime"); - setPropertyValue(optionsElement, optionsDefBuilder, "connect-timeout", "connectTimeout"); - setPropertyValue(optionsElement, optionsDefBuilder, "socket-timeout", "socketTimeout"); - setPropertyValue(optionsElement, optionsDefBuilder, "socket-keep-alive", "socketKeepAlive"); - setPropertyValue(optionsElement, optionsDefBuilder, "auto-connect-retry", "autoConnectRetry"); - setPropertyValue(optionsElement, optionsDefBuilder, "write-number", "writeNumber"); - setPropertyValue(optionsElement, optionsDefBuilder, "write-timeout", "writeTimeout"); - setPropertyValue(optionsElement, optionsDefBuilder, "write-fsync", "writeFsync"); - setPropertyValue(optionsElement, optionsDefBuilder, "slave-ok", "slaveOk"); - - + setPropertyValue(optionsElement, optionsDefBuilder, "connections-per-host", "connectionsPerHost"); + setPropertyValue(optionsElement, optionsDefBuilder, "threads-allowed-to-block-for-connection-multiplier", + "threadsAllowedToBlockForConnectionMultiplier"); + setPropertyValue(optionsElement, optionsDefBuilder, "max-wait-time", "maxWaitTime"); + setPropertyValue(optionsElement, optionsDefBuilder, "connect-timeout", "connectTimeout"); + setPropertyValue(optionsElement, optionsDefBuilder, "socket-timeout", "socketTimeout"); + setPropertyValue(optionsElement, optionsDefBuilder, "socket-keep-alive", "socketKeepAlive"); + setPropertyValue(optionsElement, optionsDefBuilder, "auto-connect-retry", "autoConnectRetry"); + setPropertyValue(optionsElement, optionsDefBuilder, "write-number", "writeNumber"); + setPropertyValue(optionsElement, optionsDefBuilder, "write-timeout", "writeTimeout"); + setPropertyValue(optionsElement, optionsDefBuilder, "write-fsync", "writeFsync"); + setPropertyValue(optionsElement, optionsDefBuilder, "slave-ok", "slaveOk"); - mongoBuilder.addPropertyValue("mongoOptions", optionsDefBuilder.getBeanDefinition()); - return true; - } - - static void setPropertyValue(Element element, BeanDefinitionBuilder builder, String attrName, String propertyName) { - String attr = element.getAttribute(attrName); - if (StringUtils.hasText(attr)) { - builder.addPropertyValue(propertyName, attr); - } - } - - /** + mongoBuilder.addPropertyValue("mongoOptions", optionsDefBuilder.getBeanDefinition()); + return true; + } + + static void setPropertyValue(Element element, BeanDefinitionBuilder builder, String attrName, String propertyName) { + String attr = element.getAttribute(attrName); + if (StringUtils.hasText(attr)) { + builder.addPropertyValue(propertyName, attr); + } + } + + /** * Sets the property with the given attribute name on the given {@link BeanDefinitionBuilder} to the value of the * attribute with the given name. * @@ -104,10 +103,10 @@ abstract class ParsingUtils { * @param builder must not be {@literal null}. * @param attrName must not be {@literal null} or empty. */ - static void setPropertyValue(Element element, BeanDefinitionBuilder builder, String attrName) { - String attr = element.getAttribute(attrName); - if (StringUtils.hasText(attr)) { - builder.addPropertyValue(attrName, attr); - } - } + static void setPropertyValue(Element element, BeanDefinitionBuilder builder, String attrName) { + String attr = element.getAttribute(attrName); + if (StringUtils.hasText(attr)) { + builder.addPropertyValue(attrName, attr); + } + } } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/SimpleMongoRepositoryConfiguration.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/SimpleMongoRepositoryConfiguration.java index 714f69da2..73df4fd2e 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/SimpleMongoRepositoryConfiguration.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/SimpleMongoRepositoryConfiguration.java @@ -88,7 +88,7 @@ public class SimpleMongoRepositoryConfiguration public String getNamedQueriesLocation() { return "classpath*:META-INF/mongo-named-queries.properties"; } - + /* * (non-Javadoc) * @@ -110,7 +110,7 @@ public class SimpleMongoRepositoryConfiguration SingleRepositoryConfigInformation { String getMongoTemplateRef(); - + boolean getCreateQueryIndexes(); } @@ -144,12 +144,12 @@ public class SimpleMongoRepositoryConfiguration return getAttribute(MONGO_TEMPLATE_REF); } - + /* (non-Javadoc) * @see org.springframework.data.mongodb.config.SimpleMongoRepositoryConfiguration.MongoRepositoryConfiguration#getCreateQueryIndexes() */ public boolean getCreateQueryIndexes() { - + String attribute = getAttribute(CREATE_QUERY_INDEXES); return attribute == null ? false : Boolean.parseBoolean(attribute); } @@ -185,7 +185,7 @@ public class SimpleMongoRepositoryConfiguration return getParent().getMongoTemplateRef(); } - + /* (non-Javadoc) * @see org.springframework.data.mongodb.config.SimpleMongoRepositoryConfiguration.MongoRepositoryConfiguration#getCreateQueryIndexes() */ diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CollectionOptions.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CollectionOptions.java index 672a51476..756e2863e 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CollectionOptions.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CollectionOptions.java @@ -31,13 +31,10 @@ public class CollectionOptions { /** * Constructs a new CollectionOptions instance. * - * @param size - * the collection size in bytes, this data space is preallocated - * @param maxDocuments - * the maximum number of documents in the collection. - * @param capped - * true to created a "capped" collection (fixed size with auto-FIFO behavior based on insertion order), false - * otherwise. + * @param size the collection size in bytes, this data space is preallocated + * @param maxDocuments the maximum number of documents in the collection. + * @param capped true to created a "capped" collection (fixed size with auto-FIFO behavior based on insertion order), + * false otherwise. */ public CollectionOptions(Integer size, Integer maxDocuments, Boolean capped) { super(); diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoAdmin.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoAdmin.java index adc3798fb..3456c657f 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoAdmin.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoAdmin.java @@ -71,8 +71,7 @@ public class MongoAdmin implements MongoAdminOperations { /** * Sets the username to use to connect to the Mongo database * - * @param username - * The username to use + * @param username The username to use */ public void setUsername(String username) { this.username = username; @@ -81,8 +80,7 @@ public class MongoAdmin implements MongoAdminOperations { /** * Sets the password to use to authenticate with the Mongo database. * - * @param password - * The password to use + * @param password The password to use */ public void setPassword(String password) { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoDbUtils.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoDbUtils.java index 501b57a91..6dfdc0991 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoDbUtils.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoDbUtils.java @@ -48,10 +48,8 @@ public abstract class MongoDbUtils { /** * Obtains a {@link DB} connection for the given {@link Mongo} instance and database name * - * @param mongo - * The {@link Mongo} instance - * @param databaseName - * The database name + * @param mongo The {@link Mongo} instance + * @param databaseName The database name * @return The {@link DB} connection */ public static DB getDB(Mongo mongo, String databaseName) { @@ -61,14 +59,10 @@ public abstract class MongoDbUtils { /** * Obtains a {@link DB} connection for the given {@link Mongo} instance and database name * - * @param mongo - * The {@link Mongo} instance - * @param databaseName - * The database name - * @param username - * The username to authenticate with - * @param password - * The password to authenticate with + * @param mongo The {@link Mongo} instance + * @param databaseName The database name + * @param username The username to authenticate with + * @param password The password to authenticate with * @return The {@link DB} connection */ public static DB getDB(Mongo mongo, String databaseName, String username, char[] password) { @@ -140,10 +134,8 @@ public abstract class MongoDbUtils { * Return whether the given DB instance is transactional, that is, bound to the current thread by Spring's transaction * facilities. * - * @param db - * the DB to check - * @param mongo - * the Mongo instance that the DB was created with (may be null) + * @param db the DB to check + * @param mongo the Mongo instance that the DB was created with (may be null) * @return whether the DB is transactional */ public static boolean isDBTransactional(DB db, Mongo mongo) { @@ -157,8 +149,7 @@ public abstract class MongoDbUtils { /** * Perform actual closing of the Mongo DB object, catching and logging any cleanup exceptions thrown. * - * @param db - * the DB to close (may be null) + * @param db the DB to close (may be null) */ public static void closeDB(DB db) { if (db != null) { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoFactoryBean.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoFactoryBean.java index 5445aa020..e70304865 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoFactoryBean.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoFactoryBean.java @@ -91,18 +91,18 @@ public class MongoFactoryBean implements FactoryBean, PersistenceExceptio Mongo mongo; if (host == null) { - + logger.debug("Property host not specified. Using default configuration"); mongo = new Mongo(); - + } else { - + ServerAddress defaultOptions = new ServerAddress(); - + if (mongoOptions == null) { mongoOptions = new MongoOptions(); } - + if (replicaPair != null) { if (replicaPair.size() < 2) { throw new CannotGetMongoDbConnectionException("A replica pair must have two server entries"); diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java index a21638f21..008047928 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java @@ -55,8 +55,7 @@ public interface MongoOperations { * MongoDB driver to convert the JSON string to a DBObject. Any errors that result from executing this command will be * converted into Spring's DAO exception hierarchy. * - * @param jsonCommand - * a MongoDB command expressed as a JSON string. + * @param jsonCommand a MongoDB command expressed as a JSON string. */ CommandResult executeCommand(String jsonCommand); @@ -64,8 +63,7 @@ public interface MongoOperations { * Execute a MongoDB command. Any errors that result from executing this command will be converted into Spring's DAO * exception hierarchy. * - * @param command - * a MongoDB command + * @param command a MongoDB command */ CommandResult executeCommand(DBObject command); @@ -74,10 +72,8 @@ public interface MongoOperations { *

* Allows for returning a result object, that is a domain object or a collection of domain objects. * - * @param - * return type - * @param action - * callback object that specifies the MongoDB actions to perform on the passed in DB instance. + * @param return type + * @param action callback object that specifies the MongoDB actions to perform on the passed in DB instance. * @return a result object returned by the action or null */ T execute(DbCallback action); @@ -87,12 +83,9 @@ public interface MongoOperations { *

* Allows for returning a result object, that is a domain object or a collection of domain objects. * - * @param entityClass - * class that determines the collection to use - * @param - * return type - * @param action - * callback object that specifies the MongoDB action + * @param entityClass class that determines the collection to use + * @param return type + * @param action callback object that specifies the MongoDB action * @return a result object returned by the action or null */ T execute(Class entityClass, CollectionCallback action); @@ -102,12 +95,9 @@ public interface MongoOperations { *

* Allows for returning a result object, that is a domain object or a collection of domain objects. * - * @param - * return type - * @param collectionName - * the name of the collection that specifies which DBCollection instance will be passed into - * @param action - * callback object that specifies the MongoDB action the callback action. + * @param return type + * @param collectionName the name of the collection that specifies which DBCollection instance will be passed into + * @param action callback object that specifies the MongoDB action the callback action. * @return a result object returned by the action or null */ T execute(String collectionName, CollectionCallback action); @@ -119,10 +109,8 @@ public interface MongoOperations { *

* Allows for returning a result object, that is a domain object or a collection of domain objects. * - * @param - * return type - * @param action - * callback that specified the MongoDB actions to perform on the DB instance + * @param return type + * @param action callback that specified the MongoDB actions to perform on the DB instance * @return a result object returned by the action or null */ T executeInSession(DbCallback action); @@ -130,8 +118,7 @@ public interface MongoOperations { /** * Create an uncapped collection with a name based on the provided entity class. * - * @param entityClass - * class that determines the collection to create + * @param entityClass class that determines the collection to create * @return the created collection */ DBCollection createCollection(Class entityClass); @@ -139,10 +126,8 @@ public interface MongoOperations { /** * Create a collect with a name based on the provided entity class using the options. * - * @param entityClass - * class that determines the collection to create - * @param collectionOptions - * options to use when creating the collection. + * @param entityClass class that determines the collection to create + * @param collectionOptions options to use when creating the collection. * @return the created collection */ DBCollection createCollection(Class entityClass, CollectionOptions collectionOptions); @@ -150,8 +135,7 @@ public interface MongoOperations { /** * Create an uncapped collection with the provided name. * - * @param collectionName - * name of the collection + * @param collectionName name of the collection * @return the created collection */ DBCollection createCollection(String collectionName); @@ -159,10 +143,8 @@ public interface MongoOperations { /** * Create a collect with the provided name and options. * - * @param collectionName - * name of the collection - * @param collectionOptions - * options to use when creating the collection. + * @param collectionName name of the collection + * @param collectionOptions options to use when creating the collection. * @return the created collection */ DBCollection createCollection(String collectionName, CollectionOptions collectionOptions); @@ -179,8 +161,7 @@ public interface MongoOperations { *

* Translate any exceptions as necessary. * - * @param collectionName - * name of the collection + * @param collectionName name of the collection * @return an existing collection or a newly created one. */ DBCollection getCollection(String collectionName); @@ -190,8 +171,7 @@ public interface MongoOperations { *

* Translate any exceptions as necessary. * - * @param entityClass - * class that determines the name of the collection + * @param entityClass class that determines the name of the collection * @return true if a collection with the given name is found, false otherwise. */ boolean collectionExists(Class entityClass); @@ -201,8 +181,7 @@ public interface MongoOperations { *

* Translate any exceptions as necessary. * - * @param collectionName - * name of the collection + * @param collectionName name of the collection * @return true if a collection with the given name is found, false otherwise. */ boolean collectionExists(String collectionName); @@ -212,8 +191,7 @@ public interface MongoOperations { *

* Translate any exceptions as necessary. * - * @param entityClass - * class that determines the collection to drop/delete. + * @param entityClass class that determines the collection to drop/delete. */ void dropCollection(Class entityClass); @@ -222,8 +200,7 @@ public interface MongoOperations { *

* Translate any exceptions as necessary. * - * @param collectionName - * name of the collection to drop/delete. + * @param collectionName name of the collection to drop/delete. */ void dropCollection(String collectionName); @@ -236,8 +213,7 @@ public interface MongoOperations { * If your collection does not contain a homogeneous collection of types, this operation will not be an efficient way * to map objects since the test for class type is done in the client and not on the server. * - * @param entityClass - * the parameterized type of the returned list + * @param entityClass the parameterized type of the returned list * @return the converted collection */ List findAll(Class entityClass); @@ -251,14 +227,12 @@ public interface MongoOperations { * If your collection does not contain a homogeneous collection of types, this operation will not be an efficient way * to map objects since the test for class type is done in the client and not on the server. * - * @param entityClass - * the parameterized type of the returned list. - * @param collectionName - * name of the collection to retrieve the objects from + * @param entityClass the parameterized type of the returned list. + * @param collectionName name of the collection to retrieve the objects from * @return the converted collection */ List findAll(Class entityClass, String collectionName); - + /** * Returns {@link GeoResult} for all entities matching the given {@link NearQuery}. Will consider entity mapping * information to determine the collection the query is ran against. @@ -268,24 +242,24 @@ public interface MongoOperations { * @return */ GeoResults geoNear(NearQuery near, Class entityClass); - + /** * Returns {@link GeoResult} for all entities matching the given {@link NearQuery}. * * @param near must not be {@literal null}. * @param entityClass must not be {@literal null}. - * @param collectionName the collection to trigger the query against. If no collection name is given the entity class will be inspected. + * @param collectionName the collection to trigger the query against. If no collection name is given the entity class + * will be inspected. * @return */ GeoResults geoNear(NearQuery near, Class entityClass, String collectionName); /** - * Ensure that an index for the provided {@link IndexDefinition} exists for the collection indicated by the entity class. - * If not it will be created. + * Ensure that an index for the provided {@link IndexDefinition} exists for the collection indicated by the entity + * class. If not it will be created. * * @param indexDefinition - * @param entityClass - * class that determines the collection to use + * @param entityClass class that determines the collection to use */ void ensureIndex(IndexDefinition indexDefinition, Class entityClass); @@ -298,8 +272,8 @@ public interface MongoOperations { void ensureIndex(IndexDefinition indexDefinition, String collectionName); /** - * Map the results of an ad-hoc query on the collection for the entity class to a single instance of an object - * of the specified type. + * Map the results of an ad-hoc query on the collection for the entity class to a single instance of an object of the + * specified type. *

* The object is converted from the MongoDB native representation using an instance of {@see MongoConverter}. Unless * configured otherwise, an instance of SimpleMongoConverter will be used. @@ -307,11 +281,9 @@ public interface MongoOperations { * The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * feature rich {@link Query}. * - * @param query - * the query class that specifies the criteria used to find a record and also an optional fields + * @param query the query class that specifies the criteria used to find a record and also an optional fields * specification - * @param entityClass - * the parameterized type of the returned list. + * @param entityClass the parameterized type of the returned list. * @return the converted object */ T findOne(Query query, Class entityClass); @@ -325,13 +297,11 @@ public interface MongoOperations { *

* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * feature rich {@link Query}. - * @param query - * the query class that specifies the criteria used to find a record and also an optional fields + * + * @param query the query class that specifies the criteria used to find a record and also an optional fields * specification - * @param entityClass - * the parameterized type of the returned list. - * @param collectionName - * name of the collection to retrieve the objects from + * @param entityClass the parameterized type of the returned list. + * @param collectionName name of the collection to retrieve the objects from * * @return the converted object */ @@ -346,11 +316,9 @@ public interface MongoOperations { * The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * feature rich {@link Query}. * - * @param query - * the query class that specifies the criteria used to find a record and also an optional fields + * @param query the query class that specifies the criteria used to find a record and also an optional fields * specification - * @param entityClass - * the parameterized type of the returned list. + * @param entityClass the parameterized type of the returned list. * @return the List of converted objects */ List find(Query query, Class entityClass); @@ -363,13 +331,11 @@ public interface MongoOperations { *

* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * feature rich {@link Query}. - * @param query - * the query class that specifies the criteria used to find a record and also an optional fields + * + * @param query the query class that specifies the criteria used to find a record and also an optional fields * specification - * @param entityClass - * the parameterized type of the returned list. - * @param collectionName - * name of the collection to retrieve the objects from + * @param entityClass the parameterized type of the returned list. + * @param collectionName name of the collection to retrieve the objects from * * @return the List of converted objects */ @@ -383,16 +349,13 @@ public interface MongoOperations { *

* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * feature rich {@link Query}. - * @param query - * the query class that specifies the criteria used to find a record and also an optional fields + * + * @param query the query class that specifies the criteria used to find a record and also an optional fields * specification - * @param entityClass - * the parameterized type of the returned list. - * @param preparer - * allows for customization of the DBCursor used when iterating over the result set, (apply limits, skips and - * so on). - * @param collectionName - * name of the collection to retrieve the objects from + * @param entityClass the parameterized type of the returned list. + * @param preparer allows for customization of the DBCursor used when iterating over the result set, (apply limits, + * skips and so on). + * @param collectionName name of the collection to retrieve the objects from * * @return the List of converted objects. */ @@ -408,9 +371,10 @@ public interface MongoOperations { * @return the document with the given id mapped onto the given target class. */ T findById(Object id, Class entityClass); - + /** * Returns the document with the given id from the given collection mapped onto the given target class. + * * @param id the id of the document to return * @param entityClass the type to convert the document to * @param collectionName the collection to query for the document @@ -421,20 +385,18 @@ public interface MongoOperations { T findById(Object id, Class entityClass, String collectionName); /** - * Map the results of an ad-hoc query on the collection for the entity type to a single instance of an - * object of the specified type. The first document that matches the query is returned and also removed from - * the collection in the database. + * Map the results of an ad-hoc query on the collection for the entity type to a single instance of an object of the + * specified type. The first document that matches the query is returned and also removed from the collection in the + * database. *

* The object is converted from the MongoDB native representation using an instance of {@see MongoConverter}. *

* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * feature rich {@link Query}. * - * @param query - * the query class that specifies the criteria used to find a - * record and also an optional fields specification - * @param entityClass - * the parameterized type of the returned list. + * @param query the query class that specifies the criteria used to find a record and also an optional fields + * specification + * @param entityClass the parameterized type of the returned list. * @return the converted object */ T findAndRemove(Query query, Class entityClass); @@ -448,13 +410,11 @@ public interface MongoOperations { *

* The query is specified as a {@link Query} which can be created either using the {@link BasicQuery} or the more * feature rich {@link Query}. - * @param query - * the query class that specifies the criteria used to find a record and also an optional fields + * + * @param query the query class that specifies the criteria used to find a record and also an optional fields * specification - * @param entityClass - * the parameterized type of the returned list. - * @param collectionName - * name of the collection to retrieve the objects from + * @param entityClass the parameterized type of the returned list. + * @param collectionName name of the collection to retrieve the objects from * * @return the converted object */ @@ -474,8 +434,7 @@ public interface MongoOperations { *

* Insert is used to initially store the object into the database. To update an existing object use the save method. * - * @param objectToSave - * the object to store in the collection. + * @param objectToSave the object to store in the collection. */ void insert(Object objectToSave); @@ -486,44 +445,39 @@ public interface MongoOperations { * configured otherwise, an instance of SimpleMongoConverter will be used. *

* Insert is used to initially store the object into the database. To update an existing object use the save method. - * @param objectToSave - * the object to store in the collection - * @param collectionName - * name of the collection to store the object in + * + * @param objectToSave the object to store in the collection + * @param collectionName name of the collection to store the object in */ void insert(Object objectToSave, String collectionName); /** * Insert a Collection of objects into a collection in a single batch write to the database. * - * @param batchToSave - * the list of objects to save. - * @param entityClass - * class that determines the collection to use + * @param batchToSave the list of objects to save. + * @param entityClass class that determines the collection to use */ void insert(Collection batchToSave, Class entityClass); /** * Insert a list of objects into the specified collection in a single batch write to the database. - * @param batchToSave - * the list of objects to save. - * @param collectionName - * name of the collection to store the object in + * + * @param batchToSave the list of objects to save. + * @param collectionName name of the collection to store the object in */ void insert(Collection batchToSave, String collectionName); /** - * Insert a mixed Collection of objects into a database collection determining the - * collection name to use based on the class. + * Insert a mixed Collection of objects into a database collection determining the collection name to use based on the + * class. * - * @param collectionToSave - * the list of objects to save. + * @param collectionToSave the list of objects to save. */ void insertAll(Collection objectsToSave); /** - * Save the object to the collection for the entity type of the object to save. This will perform an - * insert if the object is not already present, that is an 'upsert'. + * Save the object to the collection for the entity type of the object to save. This will perform an insert if the + * object is not already present, that is an 'upsert'. *

* The object is converted to the MongoDB native representation using an instance of {@see MongoConverter}. Unless * configured otherwise, an instance of SimpleMongoConverter will be used. @@ -534,8 +488,7 @@ public interface MongoOperations { * See Spring 3 Type * Conversion" for more details. * - * @param objectToSave - * the object to store in the collection + * @param objectToSave the object to store in the collection */ void save(Object objectToSave); @@ -551,58 +504,53 @@ public interface MongoOperations { * property type will be handled by Spring's BeanWrapper class that leverages Spring 3.0's new Type Cobnversion API. * See Spring 3 Type * Conversion" for more details. - * @param objectToSave - * the object to store in the collection - * @param collectionName - * name of the collection to store the object in + * + * @param objectToSave the object to store in the collection + * @param collectionName name of the collection to store the object in */ void save(Object objectToSave, String collectionName); /** * Updates the first object that is found in the collection of the entity class that matches the query document with * the provided update document. - * @param query - * the query document that specifies the criteria used to select a record to be updated - * @param update - * the update document that contains the updated object or $ operators to manipulate the existing object. - * @param entityClass - * class that determines the collection to use + * + * @param query the query document that specifies the criteria used to select a record to be updated + * @param update the update document that contains the updated object or $ operators to manipulate the existing + * object. + * @param entityClass class that determines the collection to use */ WriteResult updateFirst(Query query, Update update, Class entityClass); /** * Updates the first object that is found in the specified collection that matches the query document criteria with * the provided updated document. - * @param query - * the query document that specifies the criteria used to select a record to be updated - * @param update - * the update document that contains the updated object or $ operators to manipulate the existing object. - * @param collectionName - * name of the collection to update the object in + * + * @param query the query document that specifies the criteria used to select a record to be updated + * @param update the update document that contains the updated object or $ operators to manipulate the existing + * object. + * @param collectionName name of the collection to update the object in */ WriteResult updateFirst(Query query, Update update, String collectionName); /** * Updates all objects that are found in the collection for the entity class that matches the query document criteria * with the provided updated document. - * @param query - * the query document that specifies the criteria used to select a record to be updated - * @param update - * the update document that contains the updated object or $ operators to manipulate the existing object. - * @param entityClass - * class that determines the collection to use + * + * @param query the query document that specifies the criteria used to select a record to be updated + * @param update the update document that contains the updated object or $ operators to manipulate the existing + * object. + * @param entityClass class that determines the collection to use */ WriteResult updateMulti(Query query, Update update, Class entityClass); /** * Updates all objects that are found in the specified collection that matches the query document criteria with the * provided updated document. - * @param query - * the query document that specifies the criteria used to select a record to be updated - * @param update - * the update document that contains the updated object or $ operators to manipulate the existing object. - * @param collectionName - * name of the collection to update the object in + * + * @param query the query document that specifies the criteria used to select a record to be updated + * @param update the update document that contains the updated object or $ operators to manipulate the existing + * object. + * @param collectionName name of the collection to update the object in */ WriteResult updateMulti(Query query, Update update, String collectionName); @@ -614,10 +562,8 @@ public interface MongoOperations { void remove(Object object); /** - * Remove all documents that match the provided query document criteria from - * the the collection used to store the entityClass. The Class parameter is - * also used to help convert the Id of the object if it is present in the - * query. + * Remove all documents that match the provided query document criteria from the the collection used to store the + * entityClass. The Class parameter is also used to help convert the Id of the object if it is present in the query. * * @param * @param query @@ -626,12 +572,11 @@ public interface MongoOperations { void remove(Query query, Class entityClass); /** - * Remove all documents from the specified collection that match the provided query document criteria. - * There is no conversion/mapping done for any criteria using the id field. - * @param query - * the query document that specifies the criteria used to remove a record - * @param collectionName - * name of the collection where the objects will removed + * Remove all documents from the specified collection that match the provided query document criteria. There is no + * conversion/mapping done for any criteria using the id field. + * + * @param query the query document that specifies the criteria used to remove a record + * @param collectionName name of the collection where the objects will removed */ void remove(Query query, String collectionName); diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOptionsFactoryBean.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOptionsFactoryBean.java index 721f4ca54..82a268334 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOptionsFactoryBean.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOptionsFactoryBean.java @@ -55,47 +55,44 @@ public class MongoOptionsFactoryBean implements FactoryBean, Initi * socket timeout. 0 is default and infinite */ private int socketTimeout = MONGO_OPTIONS.socketTimeout; - - /** - * This controls whether or not to have socket keep alive - * turned on (SO_KEEPALIVE). - * - * defaults to false - */ - public boolean socketKeepAlive = MONGO_OPTIONS.socketKeepAlive; + /** + * This controls whether or not to have socket keep alive turned on (SO_KEEPALIVE). + * + * defaults to false + */ + public boolean socketKeepAlive = MONGO_OPTIONS.socketKeepAlive; /** * this controls whether or not on a connect, the system retries automatically */ private boolean autoConnectRetry = MONGO_OPTIONS.autoConnectRetry; - /** - * This specifies the number of servers to wait for on the write operation, and exception raising behavior. - * - * Defaults to 0. - */ - private int writeNumber; - - /** - * This controls timeout for write operations in milliseconds. - * - * Defaults to 0 (indefinite). Greater than zero is number of milliseconds to wait. - */ - private int writeTimeout; - - /** - * This controls whether or not to fsync. - * - * Defaults to false. - */ - private boolean writeFsync; - /** - * Specifies if the driver is allowed to read from secondaries - * or slaves. - * - * Defaults to false + * This specifies the number of servers to wait for on the write operation, and exception raising behavior. + * + * Defaults to 0. + */ + private int writeNumber; + + /** + * This controls timeout for write operations in milliseconds. + * + * Defaults to 0 (indefinite). Greater than zero is number of milliseconds to wait. + */ + private int writeTimeout; + + /** + * This controls whether or not to fsync. + * + * Defaults to false. + */ + private boolean writeFsync; + + /** + * Specifies if the driver is allowed to read from secondaries or slaves. + * + * Defaults to false */ private boolean slaveOk = MONGO_OPTIONS.slaveOk; @@ -135,60 +132,64 @@ public class MongoOptionsFactoryBean implements FactoryBean, Initi public void setSocketTimeout(int socketTimeout) { this.socketTimeout = socketTimeout; } - + /** * This controls whether or not to have socket keep alive + * * @param socketKeepAlive */ - public void setSocketKeepAlive(boolean socketKeepAlive) { - this.socketKeepAlive = socketKeepAlive; - } - - /** - * This specifies the number of servers to wait for on the write operation, and exception raising behavior. - * The 'w' option to the getlasterror command. Defaults to 0. - *

    - *
  • -1 = don't even report network errors
  • - *
  • 0 = default, don't call getLastError by default
  • - *
  • 1 = basic, call getLastError, but don't wait for slaves
  • - *
  • 2+= wait for slaves
  • - *
- * @param writeNumber the number of servers to wait for on the write operation, and exception raising behavior. - */ - public void setWriteNumber(int writeNumber) { - this.writeNumber = writeNumber; - } + public void setSocketKeepAlive(boolean socketKeepAlive) { + this.socketKeepAlive = socketKeepAlive; + } /** - * This controls timeout for write operations in milliseconds. The 'wtimeout' option to the getlasterror command. - * - * @param writeTimeout Defaults to 0 (indefinite). Greater than zero is number of milliseconds to wait. + * This specifies the number of servers to wait for on the write operation, and exception raising behavior. The 'w' + * option to the getlasterror command. Defaults to 0. + *
    + *
  • -1 = don't even report network errors
  • + *
  • 0 = default, don't call getLastError by default
  • + *
  • 1 = basic, call getLastError, but don't wait for slaves
  • + *
  • 2+= wait for slaves
  • + *
+ * + * @param writeNumber the number of servers to wait for on the write operation, and exception raising behavior. */ - public void setWriteTimeout(int writeTimeout) { - this.writeTimeout = writeTimeout; - } + public void setWriteNumber(int writeNumber) { + this.writeNumber = writeNumber; + } - /** - * This controls whether or not to fsync. The 'fsync' option to the getlasterror command. Defaults to false. - * @param writeFsync to fsync on write (true), otherwise false. - */ - public void setWriteFsync(boolean writeFsync) { - this.writeFsync = writeFsync; - } + /** + * This controls timeout for write operations in milliseconds. The 'wtimeout' option to the getlasterror command. + * + * @param writeTimeout Defaults to 0 (indefinite). Greater than zero is number of milliseconds to wait. + */ + public void setWriteTimeout(int writeTimeout) { + this.writeTimeout = writeTimeout; + } - /** + /** + * This controls whether or not to fsync. The 'fsync' option to the getlasterror command. Defaults to false. + * + * @param writeFsync to fsync on write (true), otherwise false. + */ + public void setWriteFsync(boolean writeFsync) { + this.writeFsync = writeFsync; + } + + /** * this controls whether or not on a connect, the system retries automatically */ public void setAutoConnectRetry(boolean autoConnectRetry) { this.autoConnectRetry = autoConnectRetry; } - + /** - * Specifies if the driver is allowed to read from secondaries or slaves. Defaults to false. + * Specifies if the driver is allowed to read from secondaries or slaves. Defaults to false. + * * @param slaveOk true if the driver should read from secondaries or slaves. */ public void setSlaveOk(boolean slaveOk) { - this.slaveOk = slaveOk; + this.slaveOk = slaveOk; } public void afterPropertiesSet() { @@ -198,8 +199,8 @@ public class MongoOptionsFactoryBean implements FactoryBean, Initi MONGO_OPTIONS.connectTimeout = connectTimeout; MONGO_OPTIONS.socketTimeout = socketTimeout; MONGO_OPTIONS.socketKeepAlive = socketKeepAlive; - MONGO_OPTIONS.autoConnectRetry = autoConnectRetry; - MONGO_OPTIONS.slaveOk = slaveOk; + MONGO_OPTIONS.autoConnectRetry = autoConnectRetry; + MONGO_OPTIONS.slaveOk = slaveOk; MONGO_OPTIONS.w = writeNumber; MONGO_OPTIONS.wtimeout = writeTimeout; MONGO_OPTIONS.fsync = writeFsync; diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java index 14bf789e2..37a023d57 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java @@ -440,27 +440,27 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware { public GeoResults geoNear(NearQuery near, Class entityClass) { return geoNear(near, entityClass, determineCollectionName(entityClass)); } - + public GeoResults geoNear(NearQuery near, Class entityClass, String collectionName) { - + String collection = StringUtils.hasText(collectionName) ? collectionName : determineCollectionName(entityClass); BasicDBObject command = new BasicDBObject("geoNear", collection); command.putAll(near.toDBObject()); - + CommandResult commandResult = executeCommand(command); BasicDBList results = (BasicDBList) commandResult.get("results"); - DbObjectCallback> callback = new GeoNearResultDbObjectCallback(new ReadDbObjectCallback(mongoConverter, entityClass), near.getMetric()); + DbObjectCallback> callback = new GeoNearResultDbObjectCallback(new ReadDbObjectCallback( + mongoConverter, entityClass), near.getMetric()); List> result = new ArrayList>(results.size()); - + for (Object element : results) { result.add(callback.doWith((DBObject) element)); } - + double averageDistance = (Double) ((DBObject) commandResult.get("stats")).get("avgDistance"); return new GeoResults(result, new Distance(averageDistance, near.getMetric())); } - - + // Find methods that take a Query to express the query and that return a single object that is also removed from the // collection in the database. @@ -707,10 +707,11 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware { return execute(collectionName, new CollectionCallback() { public WriteResult doInCollection(DBCollection collection) throws MongoException, DataAccessException { - + MongoPersistentEntity entity = entityClass == null ? null : getPersistentEntity(entityClass); - - DBObject queryObj = query == null ? new BasicDBObject() : mapper.getMappedObject(query.getQueryObject(), entity); + + DBObject queryObj = query == null ? new BasicDBObject() + : mapper.getMappedObject(query.getQueryObject(), entity); DBObject updateObj = update.getUpdateObject(); for (String key : updateObj.keySet()) { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/QueryMapper.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/QueryMapper.java index 8860dfb02..e6aec821b 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/QueryMapper.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/QueryMapper.java @@ -33,7 +33,7 @@ import com.mongodb.DBObject; /** * A helper class to encapsulate any modifications of a Query object before it gets submitted to the database. - * + * * @author Jon Brisbin * @author Oliver Gierke */ @@ -43,7 +43,7 @@ public class QueryMapper { /** * Creates a new {@link QueryMapper} with the given {@link ConversionService}. - * + * * @param conversionService must not be {@literal null}. */ public QueryMapper(ConversionService conversionService) { @@ -54,7 +54,7 @@ public class QueryMapper { /** * Replaces the property keys used in the given {@link DBObject} with the appropriate keys by using the * {@link PersistentEntity} metadata. - * + * * @param query * @param entity * @return @@ -87,7 +87,7 @@ public class QueryMapper { value = getMappedObject((DBObject) value, entity); } } else { - + value = convertId(value); } newKey = "_id"; @@ -116,20 +116,20 @@ public class QueryMapper { */ @SuppressWarnings("unchecked") public Object convertId(Object id) { - + for (Class type : Arrays.asList(ObjectId.class, String.class)) { - + if (id.getClass().isAssignableFrom(type)) { return id; } - + try { return conversionService.convert(id, type); } catch (ConversionException e) { // Ignore } } - + return id; } } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/SimpleMongoDbFactory.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/SimpleMongoDbFactory.java index cf4c5cf54..0db2b51ef 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/SimpleMongoDbFactory.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/SimpleMongoDbFactory.java @@ -91,15 +91,15 @@ public class SimpleMongoDbFactory implements DisposableBean, MongoDbFactory { * @see org.springframework.data.mongodb.MongoDbFactory#getDb(java.lang.String) */ public DB getDb(String dbName) throws DataAccessException { - + Assert.hasText(dbName, "Database name must not be empty."); - + DB db = MongoDbUtils.getDB(mongo, dbName, username, password == null ? null : password.toCharArray()); - + if (writeConcern != null) { db.setWriteConcern(writeConcern); } - + return db; } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/AbstractMongoConverter.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/AbstractMongoConverter.java index 31ab6e670..2cbb2dc59 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/AbstractMongoConverter.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/AbstractMongoConverter.java @@ -86,11 +86,10 @@ public abstract class AbstractMongoConverter implements MongoConverter, Initiali if (!conversionService.canConvert(String.class, BigInteger.class)) { conversionService.addConverter(StringToBigIntegerConverter.INSTANCE); } - + conversions.registerConvertersIn(conversionService); } - /* * (non-Javadoc) * @see org.springframework.data.mongodb.core.core.convert.MongoConverter#getConversionService() diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/ConfigurableTypeMapper.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/ConfigurableTypeMapper.java index 4a914a5cc..9f215e033 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/ConfigurableTypeMapper.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/ConfigurableTypeMapper.java @@ -24,7 +24,7 @@ import org.springframework.data.util.TypeInformation; import org.springframework.util.Assert; /** - * {@link TypeMapper} allowing to configure a {@link Map} containing {@link String} to {@link Class} mappings that will + * {@link TypeMapper} allowing to configure a {@link Map} containing {@link Class} to {@link String} mappings that will * be used to map the values found under the configured type key (see {@link DefaultTypeMapper#setTypeKey(String)}. This * allows declarative type mapping in a Spring config file for example. * @@ -81,7 +81,7 @@ public class ConfigurableTypeMapper extends DefaultTypeMapper { return entry.getKey(); } } - + return handleUnmappedClasses ? super.getTypeInformation(value) : null; } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/CustomConversions.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/CustomConversions.java index 312515e50..139a40622 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/CustomConversions.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/CustomConversions.java @@ -49,10 +49,10 @@ import com.mongodb.DBObject; * @author Oliver Gierke */ public class CustomConversions { - + @SuppressWarnings({ "unchecked" }) - private static final List> MONGO_TYPES = Arrays.asList(Number.class, Date.class, ObjectId.class, String.class, - DBObject.class); + private static final List> MONGO_TYPES = Arrays.asList(Number.class, Date.class, ObjectId.class, + String.class, DBObject.class); private final Set readingPairs; private final Set writingPairs; diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultTypeMapper.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultTypeMapper.java index d2b640430..9ee82e0c9 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultTypeMapper.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/DefaultTypeMapper.java @@ -98,13 +98,13 @@ public class DefaultTypeMapper implements TypeMapper { public void writeType(TypeInformation info, DBObject dbObject) { Assert.notNull(info); - + if (typeKey == null) { return; } - + String string = getTypeString(info); - + if (string != null) { dbObject.put(typeKey, getTypeString(info)); } @@ -133,11 +133,11 @@ public class DefaultTypeMapper implements TypeMapper { * class cannot be loaded. */ protected TypeInformation getTypeInformation(String value) { - + if (!StringUtils.hasText(value)) { return null; } - + try { return ClassTypeInformation.from(ClassUtils.forName(value, null)); } catch (ClassNotFoundException e) { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java index 56491ff7c..6012514fb 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java @@ -72,7 +72,8 @@ import org.springframework.util.StringUtils; * @author Jon Brisbin * @author Oliver Gierke */ -public class MappingMongoConverter extends AbstractMongoConverter implements ApplicationContextAware, TypeMapperProvider { +public class MappingMongoConverter extends AbstractMongoConverter implements ApplicationContextAware, + TypeMapperProvider { @SuppressWarnings("rawtypes") private static final TypeInformation MAP_TYPE_INFORMATION = ClassTypeInformation.from(Map.class); @@ -116,7 +117,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App public void setTypeMapper(TypeMapper typeMapper) { this.typeMapper = typeMapper == null ? new DefaultTypeMapper() : typeMapper; } - + /* * (non-Javadoc) * @see org.springframework.data.mongodb.core.convert.MongoConverter#getTypeMapper() @@ -124,7 +125,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App public TypeMapper getTypeMapper() { return this.typeMapper; } - + /* * (non-Javadoc) * @see org.springframework.data.mongodb.core.core.convert.MongoConverter#getMappingContext() @@ -143,7 +144,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App public void setUseFieldAccessOnly(boolean useFieldAccessOnly) { this.useFieldAccessOnly = useFieldAccessOnly; } - + /* * (non-Javadoc) * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) @@ -785,7 +786,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App protected Map readMap(TypeInformation type, DBObject dbObject) { Assert.notNull(dbObject); - + Class mapType = getMoreConcreteTargetType(dbObject, type).getType(); Map map = CollectionFactory.createMap(mapType, dbObject.keySet().size()); Map sourceMap = dbObject.toMap(); @@ -829,15 +830,15 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App protected TypeInformation findTypeToBeUsed(DBObject dbObject) { return typeMapper.readType(dbObject); } - + private Class getDefaultedTypeToBeUsed(DBObject dbObject) { - TypeInformation result = findTypeToBeUsed(dbObject); - - if (result != null) { - return result.getType(); - } - - return dbObject instanceof BasicDBList ? List.class : Map.class; + TypeInformation result = findTypeToBeUsed(dbObject); + + if (result != null) { + return result.getType(); + } + + return dbObject instanceof BasicDBList ? List.class : Map.class; } /** @@ -854,7 +855,8 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App Class documentsTargetType = getDefaultedTypeToBeUsed(dbObject); Class rawType = basicType == null ? null : basicType.getType(); - boolean isMoreConcreteCustomType = rawType == null ? true : rawType.isAssignableFrom(documentsTargetType) && !rawType.equals(documentsTargetType); + boolean isMoreConcreteCustomType = rawType == null ? true : rawType.isAssignableFrom(documentsTargetType) + && !rawType.equals(documentsTargetType); return isMoreConcreteCustomType ? (TypeInformation) ClassTypeInformation.from(documentsTargetType) : basicType; } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConverter.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConverter.java index d80dcaf50..2b96328f4 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConverter.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConverter.java @@ -22,7 +22,7 @@ import org.springframework.data.mongodb.core.mapping.MongoPersistentProperty; /** * Central Mongo specific converter interface which combines {@link MongoWriter} and {@link MongoReader}. - * + * * @author Oliver Gierke */ public interface MongoConverter extends MongoWriter, MongoReader { @@ -33,7 +33,7 @@ public interface MongoConverter extends MongoWriter, MongoReader * @return never {@literal null} */ MappingContext, MongoPersistentProperty> getMappingContext(); - + /** * Returns the underlying {@link ConversionService} used by the converter. * diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConverters.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConverters.java index bd5608976..e70fc14ce 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConverters.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoConverters.java @@ -88,7 +88,6 @@ abstract class MongoConverters { } } - public static enum BigDecimalToStringConverter implements Converter { INSTANCE; @@ -96,10 +95,10 @@ abstract class MongoConverters { return source == null ? null : source.toString(); } } - + public static enum StringToBigDecimalConverter implements Converter { INSTANCE; - + public BigDecimal convert(String source) { return StringUtils.hasText(source) ? new BigDecimal(source) : null; } @@ -112,10 +111,10 @@ abstract class MongoConverters { return source == null ? null : source.toString(); } } - + public static enum StringToBigIntegerConverter implements Converter { INSTANCE; - + public BigInteger convert(String source) { return StringUtils.hasText(source) ? new BigInteger(source) : null; } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoWriter.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoWriter.java index 72a68c84c..6d9d1a554 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoWriter.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MongoWriter.java @@ -30,13 +30,11 @@ public interface MongoWriter { /** * Write the given object of type T to the native MongoDB object representation DBObject. * - * @param t - * The object to convert to a DBObject - * @param dbo - * The DBObject to use for writing. + * @param t The object to convert to a DBObject + * @param dbo The DBObject to use for writing. */ void write(T t, DBObject dbo); - + /** * Converts the given object into one Mongo will be able to store natively. If the given object can already be stored * as is, no conversion will happen. diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/TypeMapper.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/TypeMapper.java index 90723817b..18f155e89 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/TypeMapper.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/TypeMapper.java @@ -21,7 +21,7 @@ import com.mongodb.DBObject; /** * Interface to define strategies how to store type information in a {@link DBObject}. - * + * * @author Oliver Gierke */ public interface TypeMapper { @@ -33,7 +33,7 @@ public interface TypeMapper { * @return */ boolean isTypeKey(String key); - + /** * Reads the {@link TypeInformation} from the given {@link DBObject}. * @@ -41,7 +41,7 @@ public interface TypeMapper { * @return */ TypeInformation readType(DBObject dbObject); - + /** * Writes type information for the given type into the given {@link DBObject}. * @@ -49,7 +49,7 @@ public interface TypeMapper { * @param dbObject must not be {@literal null}. */ void writeType(Class type, DBObject dbObject); - + /** * Writes type information for the given {@link TypeInformation} into the given {@link DBObject}. * diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/TypeMapperProvider.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/TypeMapperProvider.java index 23a8130d8..ff95fb81d 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/TypeMapperProvider.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/TypeMapperProvider.java @@ -17,7 +17,7 @@ package org.springframework.data.mongodb.core.convert; /** * Interfaces for components being able to provide a {@link TypeMapper}. - * + * * @author Oliver Gierke */ public interface TypeMapperProvider { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoResults.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoResults.java index 33270c0a7..3827ceb00 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoResults.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoResults.java @@ -42,7 +42,7 @@ public class GeoResults implements Iterable> { public GeoResults(List> results) { this(results, (Metric) null); } - + public GeoResults(List> results, Metric metric) { this(results, calculateAverageDistance(results, metric)); } @@ -117,7 +117,7 @@ public class GeoResults implements Iterable> { result += 31 * averageDistance.hashCode(); return result; } - + /* * (non-Javadoc) * @see java.lang.Object#toString() diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Metrics.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Metrics.java index 3a04995fa..882bb2656 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Metrics.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Metrics.java @@ -4,7 +4,7 @@ import org.springframework.data.mongodb.core.query.NearQuery; /** * Commonly used {@link Metrics} for {@link NearQuery}s. - * + * * @author Oliver Gierke */ public enum Metrics implements Metric { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Point.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Point.java index ccc990462..16f3c8793 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Point.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Point.java @@ -58,7 +58,7 @@ public class Point { public double[] asArray() { return new double[] { x, y }; } - + public List asList() { return Arrays.asList(x, y); } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/GeospatialIndex.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/GeospatialIndex.java index bee0641eb..b1b5bb5c8 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/GeospatialIndex.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/GeospatialIndex.java @@ -22,7 +22,7 @@ import com.mongodb.DBObject; /** * Value object to capture data to create a geo index. - * + * * @author Jon Brisbin * @author Oliver Gierke */ diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexCreator.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexCreator.java index b5c036167..a0d8d2bbd 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexCreator.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexCreator.java @@ -40,11 +40,12 @@ import org.springframework.util.StringUtils; /** * Component that inspects {@link BasicMongoPersistentEntity} instances contained in the given * {@link MongoMappingContext} for indexing metadata and ensures the indexes to be available. - * + * * @author Jon Brisbin * @author Oliver Gierke */ -public class MongoPersistentEntityIndexCreator implements ApplicationListener, MongoPersistentProperty>> { +public class MongoPersistentEntityIndexCreator implements + ApplicationListener, MongoPersistentProperty>> { private static final Log log = LogFactory.getLog(MongoPersistentEntityIndexCreator.class); @@ -52,7 +53,8 @@ public class MongoPersistentEntityIndexCreator implements ApplicationListener, MongoPersistentProperty> event) { + public void onApplicationEvent( + MappingContextEvent, MongoPersistentProperty> event) { checkForIndexes(event.getPersistentEntity()); } @@ -130,7 +133,8 @@ public class MongoPersistentEntityIndexCreator implements ApplicationListener extends BasicPersistentEntity { - + INSTANCE; /* @@ -80,15 +80,15 @@ public class BasicMongoPersistentEntity extends BasicPersistentEntity, MongoPersistentProperty> { - + /** * Creates a new {@link MongoMappingContext}. */ diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/MongoPersistentProperty.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/MongoPersistentProperty.java index a390ac0ef..345ebaa35 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/MongoPersistentProperty.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/MongoPersistentProperty.java @@ -23,14 +23,14 @@ import org.springframework.data.mapping.PersistentProperty; * @author Oliver Gierke */ public interface MongoPersistentProperty extends PersistentProperty { - + /** * Returns the name of the field a property is persisted to. * * @return */ String getFieldName(); - + /** * Returns the order of the field if defined. Will return -1 if undefined. * @@ -45,7 +45,7 @@ public interface MongoPersistentProperty extends PersistentProperty> MONGO_SIMPLE_TYPES = new HashSet>(); static { @@ -38,7 +38,7 @@ public abstract class MongoSimpleTypes { MONGO_SIMPLE_TYPES.add(ObjectId.class); MONGO_SIMPLE_TYPES.add(CodeWScope.class); } - + public static final SimpleTypeHolder HOLDER = new SimpleTypeHolder(MONGO_SIMPLE_TYPES, true); private MongoSimpleTypes() { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/SimpleMongoMappingContext.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/SimpleMongoMappingContext.java index 9373ea0bc..57c02c1b3 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/SimpleMongoMappingContext.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/SimpleMongoMappingContext.java @@ -64,7 +64,8 @@ public class SimpleMongoMappingContext extends * @param propertyDescriptor * @param information */ - public SimplePersistentProperty(Field field, PropertyDescriptor propertyDescriptor, MongoPersistentEntity owner, SimpleTypeHolder simpleTypeHolder) { + public SimplePersistentProperty(Field field, PropertyDescriptor propertyDescriptor, MongoPersistentEntity owner, + SimpleTypeHolder simpleTypeHolder) { super(field, propertyDescriptor, owner, simpleTypeHolder); } @@ -81,7 +82,7 @@ public class SimpleMongoMappingContext extends public String getFieldName() { return isIdProperty() ? "_id" : getName(); } - + /* * (non-Javadoc) * @see org.springframework.data.mongodb.core.core.mapping.MongoPersistentProperty#getFieldOrder() @@ -97,14 +98,14 @@ public class SimpleMongoMappingContext extends protected Association createAssociation() { return new Association(this, null); } - + /* (non-Javadoc) * @see org.springframework.data.mongodb.core.core.mapping.MongoPersistentProperty#isDbReference() */ public boolean isDbReference() { return false; } - + /* (non-Javadoc) * @see org.springframework.data.mongodb.core.core.mapping.MongoPersistentProperty#getDBRef() */ diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/BasicQuery.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/BasicQuery.java index 91b8ea300..396a236a0 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/BasicQuery.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/BasicQuery.java @@ -21,7 +21,7 @@ import com.mongodb.util.JSON; /** * Custom {@link Query} implementation to setup a basic query from some arbitrary JSON query string. - * + * * @author Thomas Risberg * @author Oliver Gierke */ @@ -67,17 +67,17 @@ public class BasicQuery extends Query { @Override public DBObject getSortObject() { - + BasicDBObject result = new BasicDBObject(); if (sortObject != null) { result.putAll(sortObject); } - + DBObject overrides = super.getSortObject(); if (overrides != null) { result.putAll(overrides); } - + return result; } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java index 22f9c96fc..2e4c538b0 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java @@ -89,8 +89,7 @@ public class Criteria implements CriteriaDefinition { "Multiple 'is' values declared. You need to use 'and' with multiple criteria"); } if (this.criteria.size() > 0 && "$not".equals(this.criteria.keySet().toArray()[this.criteria.size() - 1])) { - throw new InvalidMongoDbApiUsageException( - "Invalid query: 'not' can't be used with 'is' - use 'ne' instead."); + throw new InvalidMongoDbApiUsageException("Invalid query: 'not' can't be used with 'is' - use 'ne' instead."); } this.isValue = o; return this; @@ -154,8 +153,7 @@ public class Criteria implements CriteriaDefinition { /** * Creates a criterion using the $in operator * - * @param o - * the values to match against + * @param o the values to match against * @return */ public Criteria in(Object... o) { @@ -170,8 +168,7 @@ public class Criteria implements CriteriaDefinition { /** * Creates a criterion using the $in operator * - * @param c - * the collection containing the values to match against + * @param c the collection containing the values to match against * @return */ public Criteria in(Collection c) { @@ -288,8 +285,7 @@ public class Criteria implements CriteriaDefinition { /** * Creates a geospatial criterion using a $within $center operation * - * @param circle - * must not be {@literal null} + * @param circle must not be {@literal null} * @return */ public Criteria withinCenter(Circle circle) { @@ -304,8 +300,7 @@ public class Criteria implements CriteriaDefinition { /** * Creates a geospatial criterion using a $within $center operation. This is only available for Mongo 1.7 and higher. * - * @param circle - * must not be {@literal null} + * @param circle must not be {@literal null} * @return */ public Criteria withinCenterSphere(Circle circle) { @@ -335,8 +330,7 @@ public class Criteria implements CriteriaDefinition { /** * Creates a geospatial criterion using a $near operation * - * @param point - * must not be {@literal null} + * @param point must not be {@literal null} * @return */ public Criteria near(Point point) { @@ -348,8 +342,7 @@ public class Criteria implements CriteriaDefinition { /** * Creates a geospatial criterion using a $nearSphere operation. This is only available for Mongo 1.7 and higher. * - * @param point - * must not be {@literal null} + * @param point must not be {@literal null} * @return */ public Criteria nearSphere(Point point) { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/NearQuery.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/NearQuery.java index afebdbe33..4159d40bf 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/NearQuery.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/NearQuery.java @@ -103,7 +103,7 @@ public class NearQuery { Assert.notNull(point); return new NearQuery(point, metric); } - + /** * Returns the {@link Metric} underlying the actual query. * @@ -149,7 +149,7 @@ public class NearQuery { this.spherical(true); return maxDistance(getNormalizedDistance(maxDistance, metric)); } - + /** * Sets the maximum distance to the given {@link Distance}. * @@ -259,7 +259,7 @@ public class NearQuery { return dbObject; } - + private double getNormalizedDistance(double distance, Metric metric) { return metric == null ? distance : distance / metric.getMultiplier(); } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/monitor/AbstractMonitor.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/monitor/AbstractMonitor.java index 528cb31d0..fde9c6271 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/monitor/AbstractMonitor.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/monitor/AbstractMonitor.java @@ -39,8 +39,7 @@ public abstract class AbstractMonitor { /** * Sets the username to use to connect to the Mongo database * - * @param username - * The username to use + * @param username The username to use */ public void setUsername(String username) { this.username = username; @@ -49,8 +48,7 @@ public abstract class AbstractMonitor { /** * Sets the password to use to authenticate with the Mongo database. * - * @param password - * The password to use + * @param password The password to use */ public void setPassword(String password) { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/AbstractMongoQuery.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/AbstractMongoQuery.java index 5561e7322..46f2daacd 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/AbstractMongoQuery.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/AbstractMongoQuery.java @@ -188,7 +188,7 @@ public abstract class AbstractMongoQuery implements RepositoryQuery { */ @Override Object execute(Query query) { - + MongoEntityInformation entityInformation = method.getEntityInformation(); return template.findOne(query, entityInformation.getJavaType()); } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/ConvertingParameterAccessor.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/ConvertingParameterAccessor.java index 0c4e00760..5ecc8c0fe 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/ConvertingParameterAccessor.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/ConvertingParameterAccessor.java @@ -82,7 +82,7 @@ public class ConvertingParameterAccessor implements MongoParameterAccessor { return getConvertedValue(delegate.getBindableValue(index)); } - + /* * (non-Javadoc) * @see org.springframework.data.mongodb.repository.MongoParameterAccessor#getMaxDistance() @@ -98,15 +98,15 @@ public class ConvertingParameterAccessor implements MongoParameterAccessor { * @return */ private Object getConvertedValue(Object value) { - + if (!(writer instanceof TypeMapperProvider)) { return value; } - + TypeMapper mapper = ((TypeMapperProvider) writer).getTypeMapper(); return removeTypeInfoRecursively(writer.convertToMongoType(value), mapper); } - + /** * Removes the type information from the conversion result. * @@ -114,19 +114,19 @@ public class ConvertingParameterAccessor implements MongoParameterAccessor { * @return */ private Object removeTypeInfoRecursively(Object object, TypeMapper mapper) { - + if (!(object instanceof DBObject) || mapper == null) { return object; } - + DBObject dbObject = (DBObject) object; String keyToRemove = null; for (String key : dbObject.keySet()) { - + if (mapper.isTypeKey(key)) { keyToRemove = key; } - + Object value = dbObject.get(key); if (value instanceof BasicDBList) { for (Object element : (BasicDBList) value) { @@ -136,11 +136,11 @@ public class ConvertingParameterAccessor implements MongoParameterAccessor { removeTypeInfoRecursively(value, mapper); } } - + if (keyToRemove != null) { dbObject.removeField(keyToRemove); } - + return dbObject; } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MappingMongoEntityInformation.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MappingMongoEntityInformation.java index 410be7fab..55571bd3a 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MappingMongoEntityInformation.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MappingMongoEntityInformation.java @@ -42,7 +42,7 @@ public class MappingMongoEntityInformation extends A public MappingMongoEntityInformation(MongoPersistentEntity entity) { this(entity, null); } - + /** * Creates a new {@link MappingMongoEntityInformation} for the given {@link MongoPersistentEntity} and custom * collection name. diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoParameters.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoParameters.java index d6e6ea66d..63a587060 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoParameters.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoParameters.java @@ -25,19 +25,19 @@ import org.springframework.data.repository.query.Parameters; /** * Custom extension of {@link Parameters} discovering additional - * + * * @author Oliver Gierke */ public class MongoParameters extends Parameters { private int distanceIndex = -1; - + public MongoParameters(Method method) { - + super(method); this.distanceIndex = Arrays.asList(method.getParameterTypes()).indexOf(Distance.class); } - + /* (non-Javadoc) * @see org.springframework.data.repository.query.Parameters#createParameter(org.springframework.core.MethodParameter) */ @@ -49,14 +49,14 @@ public class MongoParameters extends Parameters { public int getDistanceIndex() { return distanceIndex; } - + /** * Custom {@link Parameter} implementation adding parameters of type {@link Distance} to the special ones. - * + * * @author Oliver Gierke */ static class MongoParameter extends Parameter { - + /** * * @param parameter @@ -65,7 +65,7 @@ public class MongoParameters extends Parameters { MongoParameter(MethodParameter parameter, Parameters parameters) { super(parameter, parameters); } - + /* * (non-Javadoc) * @see org.springframework.data.repository.query.Parameter#isSpecialParameter() diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoParametersParameterAccessor.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoParametersParameterAccessor.java index f35e03546..dccf9bad8 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoParametersParameterAccessor.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoParametersParameterAccessor.java @@ -20,13 +20,13 @@ import org.springframework.data.repository.query.ParametersParameterAccessor; /** * Mongo-specific {@link ParametersParameterAccessor} to allow access to the {@link Distance} parameter. - * + * * @author Oliver Gierke */ public class MongoParametersParameterAccessor extends ParametersParameterAccessor implements MongoParameterAccessor { private final MongoParameters parameters; - + /** * @param parameters * @param values @@ -35,7 +35,7 @@ public class MongoParametersParameterAccessor extends ParametersParameterAccesso super(parameters, values); this.parameters = parameters; } - + /* * (non-Javadoc) * @see org.springframework.data.mongodb.repository.MongoParameterAccessor#getMaxDistance() diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoQueryCreator.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoQueryCreator.java index bd3ecb30f..3894864e2 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoQueryCreator.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoQueryCreator.java @@ -109,7 +109,7 @@ class MongoQueryCreator extends AbstractQueryCreator { protected Query complete(Query query, Sort sort) { QueryUtils.applySorting(query, sort); - + if (LOG.isDebugEnabled()) { LOG.debug("Created query " + query.getQueryObject()); } @@ -146,10 +146,10 @@ class MongoQueryCreator extends AbstractQueryCreator { String value = parameters.next().toString(); return criteria.is(toLikeRegex(value)); case NEAR: - + Distance distance = accessor.getMaxDistance(); Point point = nextAs(parameters, Point.class); - + if (distance == null) { return criteria.near(point); } else { @@ -161,7 +161,7 @@ class MongoQueryCreator extends AbstractQueryCreator { criteria.maxDistance(distance.getNormalizedValue()); } return criteria; - + case WITHIN: Object parameter = parameters.next(); if (parameter instanceof Box) { @@ -185,8 +185,7 @@ class MongoQueryCreator extends AbstractQueryCreator { * @param * @param iterator * @param type - * @throws IllegalArgumentException - * in case the next element in the iterator is not of the given type. + * @throws IllegalArgumentException in case the next element in the iterator is not of the given type. * @return */ @SuppressWarnings("unchecked") diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoQueryMethod.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoQueryMethod.java index 3ead5214b..2f15dfd22 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoQueryMethod.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/MongoQueryMethod.java @@ -44,10 +44,10 @@ class MongoQueryMethod extends QueryMethod { public MongoQueryMethod(Method method, RepositoryMetadata metadata, EntityInformationCreator entityInformationCreator) { super(method, metadata); this.method = method; - this.entityInformation = entityInformationCreator.getEntityInformation( - ClassUtils.getReturnedDomainClass(method), getDomainClass()); + this.entityInformation = entityInformationCreator.getEntityInformation(ClassUtils.getReturnedDomainClass(method), + getDomainClass()); } - + /* * (non-Javadoc) * @see org.springframework.data.repository.query.QueryMethod#getParameters(java.lang.reflect.Method) @@ -98,7 +98,7 @@ class MongoQueryMethod extends QueryMethod { return entityInformation; } - + /* * (non-Javadoc) * @see org.springframework.data.repository.query.QueryMethod#getParameters() diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/QueryDslMongoRepository.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/QueryDslMongoRepository.java index 702548ac6..ee604efb3 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/QueryDslMongoRepository.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/QueryDslMongoRepository.java @@ -154,7 +154,7 @@ public class QueryDslMongoRepository extends SimpleM * @return */ private MongodbQuery createQueryFor(Predicate predicate) { - + DBCollection collection = getMongoOperations().getCollection(getEntityInformation().getCollectionName()); MongodbQuery query = new MongodbQuery(collection, new Transformer() { public T transform(DBObject input) { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/QueryUtils.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/QueryUtils.java index 19485d548..f76860aee 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/QueryUtils.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/QueryUtils.java @@ -73,7 +73,7 @@ abstract class QueryUtils { return query; } - + public static org.springframework.data.mongodb.core.query.Order toOrder(Order order) { return order.isAscending() ? org.springframework.data.mongodb.core.query.Order.ASCENDING : org.springframework.data.mongodb.core.query.Order.DESCENDING; diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/QuerydslRepositorySupport.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/QuerydslRepositorySupport.java index 7b6f93ce6..10e04ab86 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/QuerydslRepositorySupport.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/QuerydslRepositorySupport.java @@ -71,7 +71,7 @@ public abstract class QuerydslRepositorySupport { * @return */ protected MongodbQuery from(final EntityPath path, String collection) { - + Assert.notNull(path); Assert.hasText(collection); diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/SimpleMongoRepository.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/SimpleMongoRepository.java index 197dc956f..013ba0e11 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/SimpleMongoRepository.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/SimpleMongoRepository.java @@ -114,7 +114,7 @@ public class SimpleMongoRepository implements Paging * ) */ public boolean exists(final ID id) { - + return template.findOne(new Query(Criteria.where("_id").is(id)), Object.class, entityInformation.getCollectionName()) != null; } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/StringBasedMongoQuery.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/StringBasedMongoQuery.java index ff16f8f66..8127125f5 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/StringBasedMongoQuery.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/StringBasedMongoQuery.java @@ -49,7 +49,7 @@ public class StringBasedMongoQuery extends AbstractMongoQuery { this.query = query; this.fieldSpec = method.getFieldSpecification(); } - + public StringBasedMongoQuery(MongoQueryMethod method, MongoTemplate template) { this(method.getAnnotatedQuery(), method, template); }