DATAJPA-319 - Use default CDI repository scope (application).

Don't inherit the scope of the repository from the EntityManager but let it be the default (application scope singleton).
This commit is contained in:
Oliver Gierke
2013-03-20 17:03:48 +01:00
parent 40caa97808
commit d364b441b4
5 changed files with 28 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011 the original author or authors.
* Copyright 2011-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,14 @@
*/
package org.springframework.data.jpa.repository.cdi;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.util.Set;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.spi.Bean;
import org.apache.webbeans.cditest.CdiTestContainer;
import org.apache.webbeans.cditest.CdiTestContainerLoader;
import org.junit.BeforeClass;
@@ -36,6 +44,19 @@ public class CdiExtensionintegrationTests {
container.bootContainer();
}
/**
* @see DATAJPA-319
*/
@Test
@SuppressWarnings("rawtypes")
public void foo() {
Set<Bean<?>> beans = container.getBeanManager().getBeans(PersonRepository.class);
assertThat(beans, hasSize(1));
assertThat(beans.iterator().next().getScope(), is(equalTo((Class) ApplicationScoped.class)));
}
@Test
public void saveAndFindAll() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011 the original author or authors.
* Copyright 2011-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@ package org.springframework.data.jpa.repository.cdi;
import java.util.List;
interface PersonRepository {
public interface PersonRepository {
List<Person> findAll();

View File

@@ -18,6 +18,6 @@ package org.springframework.data.jpa.repository.cdi;
import org.springframework.data.repository.Repository;
@PersonDB
interface QualifiedPersonRepository extends PersonRepository, Repository<Person, Long> {
public interface QualifiedPersonRepository extends PersonRepository, Repository<Person, Long> {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011 the original author or authors.
* Copyright 2011-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,6 @@ package org.springframework.data.jpa.repository.cdi;
import org.springframework.data.repository.Repository;
interface UnqualifiedPersonRepository extends PersonRepository, Repository<Person, Long> {
public interface UnqualifiedPersonRepository extends PersonRepository, Repository<Person, Long> {
}