DATAES-45 - Prepare 1.0 M1 release.

Upgraded to Spring Data Build 1.3.0 RC1 and Spring Data Commons 1.7.0.RC1. Cleaned up pom accordingly.

Adapted repository setup to accommodate for changed lifecycle behavior of repository factories. Marked repositories explicitly created to check for the detection of misconfiguration as @Lazy to prevent them from being instantiated and causing the tests to fail. Added assertion in ElasticsearchEntityInformationCreatorImpl to eagerly fail in case of misconfiguration.

Marked ElasticsearchCrudRepository as @NoRepositoryBean as it should never be considered to be a repository interface to be instantiated.

Tweaked CDI implementation to benefit from new feature in Spring Data Commons to eagerly instantiate CDI repository beans. Fixed capitalization in CDI integration test sample repositories to let the code compile on case-sensitive file systems.
This commit is contained in:
Oliver Gierke 2014-02-07 10:00:46 +01:00
parent 06bfb6778b
commit a33a48a882
9 changed files with 39 additions and 38 deletions

19
pom.xml
View File

@ -10,7 +10,7 @@
<parent>
<groupId>org.springframework.data.build</groupId>
<artifactId>spring-data-parent</artifactId>
<version>1.2.0.RELEASE</version>
<version>1.3.0.RC1</version>
<relativePath>../spring-data-build/parent/pom.xml</relativePath>
</parent>
@ -25,8 +25,7 @@
<commonscollections>3.2.1</commonscollections>
<commonslang>2.6</commonslang>
<elasticsearch>0.90.11</elasticsearch>
<jackson>2.2.3</jackson>
<springdata.commons>1.6.0.BUILD-SNAPSHOT</springdata.commons>
<springdata.commons>1.7.0.RC1</springdata.commons>
</properties>
@ -36,7 +35,6 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
@ -48,15 +46,6 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring}</version>
</dependency>
<!-- For JavaConfig -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
<scope>test</scope>
</dependency>
<!-- SPRING DATA -->
@ -158,8 +147,8 @@
<repositories>
<repository>
<id>spring-libs-snapshot</id>
<url>http://repo.springsource.org/libs-snapshot-local</url>
<id>spring-libs-milestone</id>
<url>http://repo.spring.io/libs-mileston</url>
</repository>
</repositories>

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 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.
@ -15,10 +15,10 @@
*/
package org.springframework.data.elasticsearch.repository;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.io.Serializable;
import java.util.List;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
* @param <T>
@ -26,7 +26,9 @@ import java.util.List;
*
* @author Rizwan Idrees
* @author Mohsin Husen
* @author Oliver Gierke
*/
@NoRepositoryBean
public interface ElasticsearchCrudRepository<T, ID extends Serializable> extends PagingAndSortingRepository<T, ID> {
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 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.
@ -16,6 +16,7 @@
package org.springframework.data.elasticsearch.repository.cdi;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.repository.cdi.CdiRepositoryBean;
import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport;
import javax.enterprise.event.Observes;
@ -36,8 +37,8 @@ import java.util.Set;
*
* @author Rizwan Idrees
* @author Mohsin Husen
* @author Oliver Gierke
*/
public class ElasticsearchRepositoryExtension extends CdiRepositoryExtensionSupport {
private final Map<String, Bean<ElasticsearchOperations>> elasticsearchOperationsMap = new HashMap<String, Bean<ElasticsearchOperations>>();
@ -58,12 +59,14 @@ public class ElasticsearchRepositoryExtension extends CdiRepositoryExtensionSupp
Class<?> repositoryType = entry.getKey();
Set<Annotation> qualifiers = entry.getValue();
Bean<?> repositoryBean = createRepositoryBean(repositoryType, qualifiers, beanManager);
CdiRepositoryBean<?> repositoryBean = createRepositoryBean(repositoryType, qualifiers, beanManager);
afterBeanDiscovery.addBean(repositoryBean);
registerBean(repositoryBean);
}
}
private <T> Bean<T> createRepositoryBean(Class<T> repositoryType, Set<Annotation> qualifiers, BeanManager beanManager) {
private <T> CdiRepositoryBean<T> createRepositoryBean(Class<T> repositoryType, Set<Annotation> qualifiers, BeanManager beanManager) {
Bean<ElasticsearchOperations> elasticsearchOperationsBean = this.elasticsearchOperationsMap.get(qualifiers
.toString());
@ -71,7 +74,7 @@ public class ElasticsearchRepositoryExtension extends CdiRepositoryExtensionSupp
throw new UnsatisfiedResolutionException(String.format("Unable to resolve a bean for '%s' with qualifiers %s.",
ElasticsearchOperations.class.getName(), qualifiers));
}
return new ElasticsearchRepositoryBean<T>(elasticsearchOperationsBean, qualifiers, repositoryType, beanManager);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 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.
@ -27,6 +27,7 @@ import java.io.Serializable;
*
* @author Rizwan Idrees
* @author Mohsin Husen
* @author Oliver Gierke
*/
public class ElasticsearchEntityInformationCreatorImpl implements ElasticsearchEntityInformationCreator {
@ -41,9 +42,12 @@ public class ElasticsearchEntityInformationCreatorImpl implements ElasticsearchE
@Override
@SuppressWarnings("unchecked")
public <T, ID extends Serializable> ElasticsearchEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
ElasticsearchPersistentEntity<T> persistentEntity = (ElasticsearchPersistentEntity<T>) mappingContext
.getPersistentEntity(domainClass);
Assert.notNull(persistentEntity, String.format("Unable to obtain mapping metadata for %s!", domainClass));
return new MappingElasticsearchEntityInformation<T, ID>(persistentEntity);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2014 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.
@ -15,12 +15,15 @@
*/
package org.springframework.data.elasticsearch.repositories;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.elasticsearch.NonDocumentEntity;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
/**
* @author Rizwan Idrees
* @author Mohsin Husen
* @author Oliver Gierke
*/
@Lazy
public interface NonDocumentEntityRepository extends ElasticsearchRepository<NonDocumentEntity, String> {
}

View File

@ -20,10 +20,9 @@ import org.springframework.data.repository.CrudRepository;
/**
* @author Mohsin Husen
* @author Oliver Gierke
*/
public interface CDIProductRepository extends CrudRepository<Product, String> {
public interface CdiProductRepository extends CrudRepository<Product, String> {
Product findOne(String id);
}

View File

@ -19,17 +19,18 @@ import javax.inject.Inject;
/**
* @author Mohsin Husen
* @author Oliver Gierke
*/
class CDIRepositoryClient {
class CdiRepositoryClient {
private CDIProductRepository repository;
private CdiProductRepository repository;
public CDIProductRepository getRepository() {
public CdiProductRepository getRepository() {
return repository;
}
@Inject
public void setRepository(CDIProductRepository repository) {
public void setRepository(CdiProductRepository repository) {
this.repository = repository;
}

View File

@ -26,10 +26,10 @@ import static org.junit.Assert.*;
* @author Mohsin Husen
*/
public class CDIRepositoryTests {
public class CdiRepositoryTests {
private static CdiTestContainer cdiContainer;
private CDIProductRepository repository;
private CdiProductRepository repository;
@BeforeClass
public static void init() throws Exception {
@ -46,7 +46,7 @@ public class CDIRepositoryTests {
@Before
public void setUp() {
CDIRepositoryClient client = cdiContainer.getInstance(CDIRepositoryClient.class);
CdiRepositoryClient client = cdiContainer.getInstance(CdiRepositoryClient.class);
repository = client.getRepository();
}

View File

@ -14,7 +14,7 @@ Import-Template:
org.elasticsearch.*;version="${elasticsearch:[=.=.=,+1.0.0)}",
org.joda.time.*;version="${jodatime:[=.=.=,+1.0.0)}",
org.slf4j.*;version="${slf4j:[=.=.=,+1.0.0)}",
org.springframework.*;version="${spring30:[=.=.=.=,+1.0.0)}",
org.springframework.*;version="${spring:[=.=.=.=,+1.0.0)}",
org.springframework.data.*;version="${springdata.commons:[=.=.=.=,+1.0.0)}",
org.w3c.*;version="0.0.0"