Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ec74185
init version implementation
Jul 4, 2012
116eda7
DATAMONGO-477 - Change upper bound of Guava dependency to 14.
rocketraman Jul 6, 2012
69493b6
DATAMONGO-475 - Fixed debug output in map-reduce operations.
odrotbohm Jul 16, 2012
83d0396
DATAMONGO-474 - Fixed criteria mapping for MongoTemplate.group(…).
odrotbohm Jul 16, 2012
5e81400
DATAMONGO-482 - Fixed typo in reference documentation.
odrotbohm Jul 16, 2012
3a3fefb
DATAMONGO-483 - Indexes now use the field name even if index name is …
odrotbohm Jul 16, 2012
0dcec2d
DATAMONGO-480 - Consider WriteResult for insert(…) and save(…) methods.
amolnayak311 Jul 10, 2012
fa7c1ea
DATAMONGO-476 - JavaConfig support for repositories.
odrotbohm Jul 6, 2012
c3b58c2
DATAMONGO-485 - Added test case to show complex id's are working.
odrotbohm Jul 17, 2012
73423c3
DATAMONGO-486 - Polished namespace implementation.
odrotbohm Jul 18, 2012
cdc1efe
DATAMONGO-489 - Ensure read collections get converted to appropriate …
odrotbohm Jul 23, 2012
281f8b3
DATAMONGO-490 - Fixed typos.
odrotbohm Jul 23, 2012
190422f
DATAMONGO-474 - Populating id's after save now inspects field only.
odrotbohm Jul 24, 2012
fc0fd14
DATAMONGO-491 - Upgrade to Spring Data Commons 1.4.0.M1.
odrotbohm Jul 24, 2012
7ae6d82
DATAMONGO-491 - Prepare 1.1.0.M2 release.
odrotbohm Jul 24, 2012
c91fb8c
DATAMONGO-491 - Release 1.1.0.M2.
spring-builds Jul 24, 2012
24e2f3b
DATAMONGO-491 - Prepare next development iteration.
spring-builds Jul 24, 2012
0ebfb90
DATAMONGO-493 - Added test case to show the described scenario is wor…
odrotbohm Jul 24, 2012
fff8998
DATAMONGO-493 - Fixed broken $ne handling in QueryMapper.
odrotbohm Jul 24, 2012
55a16a3
DATAMONGO-495 - Fixed debug output in MongoTemplate.doFind(…).
odrotbohm Jul 26, 2012
5e0bca9
DATAMONGO-494 - QueryMapper now forwards entity metadata into nested …
odrotbohm Jul 27, 2012
dd7222d
DATAMONGO-497 - Fixed reading of empty collections.
odrotbohm Jul 30, 2012
bf436cc
DATAMONGO-496 - AbstractMongoConfiguration now defaults mapping base …
odrotbohm Jul 30, 2012
5860a9d
DATAMONGO-499 - Fixed namespace reference to repository XSD.
odrotbohm Jul 31, 2012
697a96b
DATAMONGO-500 - Index creation is only done for the correct MappingCo…
odrotbohm Jul 31, 2012
4213be4
DATAMONGO-502 - QueryMapper now translates property names into field …
odrotbohm Aug 8, 2012
81d5bc8
DATAMONGO-472 - MongoQueryCreator now correctly translates Not keyword.
odrotbohm Aug 10, 2012
538bccd
DATAMONGO-476 - @EnableMongoRepositories is now inherited into sub-cl…
odrotbohm Aug 13, 2012
3cf7951
DATACMNS-212 - Apply refactorings in Spring Data Commons.
odrotbohm Aug 13, 2012
5e5df90
DATAMONGO-505 - Fixed handling of parameter binding of associations a…
odrotbohm Aug 15, 2012
9257f84
DATAMONGO-508 - Eagerly return DBRef creation if the given value alre…
odrotbohm Aug 15, 2012
b440b4e
DATAMONGO-509 - SimpleMongoRepository.exists(…) now avoids loading un…
odrotbohm Aug 15, 2012
c63dc00
DATAMONGO-510 - Criteria now only uses BasicDBList internally.
odrotbohm Aug 15, 2012
60769ef
DATAMONGO-511 - QueryMapper now maps associations correctly.
odrotbohm Aug 15, 2012
5a9aad9
DATAMONGO-506 - Added test case to show BasicQuery is working for nes…
odrotbohm Aug 15, 2012
ff7e897
DATACMNS-214 - Adapted API change in Spring Data Commons.
odrotbohm Aug 16, 2012
f00962a
DATAMONGO-519 - Make Spring 3.1.2.RELEASE default Spring dependency v…
odrotbohm Aug 20, 2012
cbdedd1
DATAMONGO-517 - Fixed complex keyword handling.
odrotbohm Aug 21, 2012
b412cf4
DATAMONGO-513 - Update to Spring Data Commons 1.4.0.RC1.
odrotbohm Aug 23, 2012
649572a
DATAMONGO-513 - Prepare changelog for 1.1.0.RC1.
odrotbohm Aug 24, 2012
0b91218
DATAMONGO-513 - Release 1.1.0.RC1.
spring-builds Aug 24, 2012
1c3b5c2
DATAMONGO-513 - Prepare next development iteration.
spring-builds Aug 24, 2012
95e44e2
DATAMONGO-526 - Polished README.md.
markpollack Aug 25, 2012
a5d7ce5
DATAMONGO-513 - Update to Spring Data Commons 1.4.0.BUILD-SNAPSHOT.
odrotbohm Aug 30, 2012
9bb3311
DATAMONGO-523 - Added test case to verify type alias detection.
odrotbohm Sep 3, 2012
3e4016c
DATAMONGO-279
noter Sep 4, 2012
58854af
DATAMONGO-521 - Added test case to show that repository AND query works.
odrotbohm Sep 3, 2012
1cf70f6
DATAMONGO-527 - Fixed Criteria.equals(…).
odrotbohm Sep 3, 2012
c5f5f64
DATAMONGO-279 - fix broken repository tests
noter Sep 4, 2012
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
DATAMONGO-476 - JavaConfig support for repositories.
  • Loading branch information
odrotbohm authored and noter committed Sep 3, 2012
commit fa7c1eaefe8977fe29c2f89d92b54422a368b92f
2 changes: 1 addition & 1 deletion spring-data-mongodb-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<org.springframework.version.30>3.0.7.RELEASE</org.springframework.version.30>
<org.springframework.version.40>4.0.0.RELEASE</org.springframework.version.40>
<org.springframework.version.range>[${org.springframework.version.30}, ${org.springframework.version.40})</org.springframework.version.range>
<data.commons.version>1.3.2.BUILD-SNAPSHOT</data.commons.version>
<data.commons.version>1.4.0.BUILD-SNAPSHOT</data.commons.version>
<aspectj.version>1.6.11.RELEASE</aspectj.version>
<bundlor.failOnWarnings>true</bundlor.failOnWarnings>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
package org.springframework.data.mongodb.config;

import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
import org.springframework.data.mongodb.repository.config.MongoRepositoryConfigParser;
import org.springframework.data.mongodb.repository.config.MongoRepositoryConfigurationExtension;
import org.springframework.data.repository.config.RepositoryBeanDefinitionParser;
import org.springframework.data.repository.config.RepositoryConfigurationExtension;

/**
* {@link org.springframework.beans.factory.xml.NamespaceHandler} for Mongo DB based repositories.
Expand All @@ -32,7 +34,10 @@ public class MongoNamespaceHandler extends NamespaceHandlerSupport {
*/
public void init() {

registerBeanDefinitionParser("repositories", new MongoRepositoryConfigParser());
RepositoryConfigurationExtension extension = new MongoRepositoryConfigurationExtension();
RepositoryBeanDefinitionParser repositoryBeanDefinitionParser = new RepositoryBeanDefinitionParser(extension);

registerBeanDefinitionParser("repositories", repositoryBeanDefinitionParser);
registerBeanDefinitionParser("mapping-converter", new MappingMongoConverterParser());
registerBeanDefinitionParser("mongo", new MongoParser());
registerBeanDefinitionParser("db-factory", new MongoDbFactoryParser());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/*
* Copyright 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.mongodb.repository.config;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Import;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.repository.support.MongoRepositoryFactoryBean;
import org.springframework.data.repository.query.QueryLookupStrategy;
import org.springframework.data.repository.query.QueryLookupStrategy.Key;

/**
* Annotation to activate MongoDB repositories. If no base package is configured through either {@link #value()},
* {@link #basePackages()} or {@link #basePackageClasses()} it will trigger scanning of the package of annotated class.
*
* @author Oliver Gierke
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import(MongoRepositoriesRegistrar.class)
public @interface EnableMongoRepositories {

/**
* Alias for the {@link #basePackages()} attribute. Allows for more concise annotation declarations e.g.:
* {@code @EnableJpaRepositories("org.my.pkg")} instead of {@code @EnableJpaRepositories(basePackages="org.my.pkg")}.
*/
String[] value() default {};

/**
* Base packages to scan for annotated components. {@link #value()} is an alias for (and mutually exclusive with) this
* attribute. Use {@link #basePackageClasses()} for a type-safe alternative to String-based package names.
*/
String[] basePackages() default {};

/**
* Type-safe alternative to {@link #basePackages()} for specifying the packages to scan for annotated components. The
* package of each class specified will be scanned. Consider creating a special no-op marker class or interface in
* each package that serves no purpose other than being referenced by this attribute.
*/
Class<?>[] basePackageClasses() default {};

/**
* Specifies which types are eligible for component scanning. Further narrows the set of candidate components from
* everything in {@link #basePackages()} to everything in the base packages that matches the given filter or filters.
*/
Filter[] includeFilters() default {};

/**
* Specifies which types are not eligible for component scanning.
*/
Filter[] excludeFilters() default {};

/**
* Returns the postfix to be used when looking up custom repository implementations. Defaults to {@literal Impl}. So
* for a repository named {@code PersonRepository} the corresponding implementation class will be looked up scanning
* for {@code PersonRepositoryImpl}.
*
* @return
*/
String repositoryImplementationPostfix() default "";

/**
* Configures the location of where to find the Spring Data named queries properties file. Will default to
* {@code META-INFO/mongo-named-queries.properties}.
*
* @return
*/
String namedQueriesLocation() default "";

/**
* Returns the key of the {@link QueryLookupStrategy} to be used for lookup queries for query methods. Defaults to
* {@link Key#CREATE_IF_NOT_FOUND}.
*
* @return
*/
Key queryLookupStrategy() default Key.CREATE_IF_NOT_FOUND;

/**
* Returns the {@link FactoryBean} class to be used for each repository instance. Defaults to
* {@link MongoRepositoryFactoryBean}.
*
* @return
*/
Class<?> repositoryFactoryBeanClass() default MongoRepositoryFactoryBean.class;

/**
* Configures the name of the {@link MongoTemplate} bean to be used with the repositories detected.
*
* @return
*/
String mongoTemplateRef() default "mongoTemplate";

/**
* Whether to automatically create indexes for query methods defined in the repository interface.
*
* @return
*/
boolean createIndexesForQueryMethods() default false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.mongodb.repository.config;

import java.lang.annotation.Annotation;

import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport;
import org.springframework.data.repository.config.RepositoryConfigurationExtension;

/**
* Mongo-specific {@link ImportBeanDefinitionRegistrar}.
*
* @author Oliver Gierke
*/
class MongoRepositoriesRegistrar extends RepositoryBeanDefinitionRegistrarSupport {

/*
* (non-Javadoc)
* @see org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport#getAnnotation()
*/
@Override
protected Class<? extends Annotation> getAnnotation() {
return EnableMongoRepositories.class;
}

/*
* (non-Javadoc)
* @see org.springframework.data.repository.config.RepositoryBeanDefinitionRegistrarSupport#getExtension()
*/
@Override
protected RepositoryConfigurationExtension getExtension() {
return new MongoRepositoryConfigurationExtension();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.mongodb.repository.config;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.data.mongodb.repository.support.MongoRepositoryFactoryBean;
import org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource;
import org.springframework.data.repository.config.RepositoryConfigurationExtension;
import org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport;
import org.springframework.data.repository.config.XmlRepositoryConfigurationSource;
import org.w3c.dom.Element;

/**
* {@link RepositoryConfigurationExtension} for MongoDB.
*
* @author Oliver Gierke
*/
public class MongoRepositoryConfigurationExtension extends RepositoryConfigurationExtensionSupport {

private static final String MONGO_TEMPLATE_REF = "mongo-template-ref";
private static final String CREATE_QUERY_INDEXES = "create-query-indexes";

/*
* (non-Javadoc)
* @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#getModulePrefix()
*/
@Override
protected String getModulePrefix() {
return "mongo";
}

/*
* (non-Javadoc)
* @see org.springframework.data.repository.config.RepositoryConfigurationExtension#getRepositoryFactoryClassName()
*/
public String getRepositoryFactoryClassName() {
return MongoRepositoryFactoryBean.class.getName();
}

/*
* (non-Javadoc)
* @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#postProcess(org.springframework.beans.factory.support.BeanDefinitionBuilder, org.springframework.data.repository.config.XmlRepositoryConfigurationSource)
*/
@Override
public void postProcess(BeanDefinitionBuilder builder, XmlRepositoryConfigurationSource config) {

Element element = config.getElement();

String attribute = element.getAttribute(MONGO_TEMPLATE_REF);
builder.addPropertyReference("mongoOperations", attribute);

attribute = element.getAttribute(CREATE_QUERY_INDEXES);
builder.addPropertyValue("createIndexesForQueryMethods", attribute);
}

/*
* (non-Javadoc)
* @see org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport#postProcess(org.springframework.beans.factory.support.BeanDefinitionBuilder, org.springframework.data.repository.config.AnnotationRepositoryConfigurationSource)
*/
@Override
public void postProcess(BeanDefinitionBuilder builder, AnnotationRepositoryConfigurationSource config) {

AnnotationAttributes attributes = config.getAttributes();

builder.addPropertyReference("mongoOperations", attributes.getString("mongoTemplateRef"));
builder.addPropertyValue("createIndexesForQueryMethods", attributes.getBoolean("createIndexesForQueryMethods"));
}
}
Loading