Search in sources :

Example 1 with RepositoryFragmentDiscovery

use of org.springframework.data.repository.config.RepositoryFragmentDiscovery in project spring-data-commons by spring-projects.

the class CdiRepositoryContext method getRepositoryFragments.

/**
 * Discover {@link RepositoryFragmentConfiguration fragment configurations} for a {@link Class repository interface}.
 *
 * @param configuration must not be {@literal null}.
 * @param repositoryInterface must not be {@literal null}.
 * @return {@link Stream} of {@link RepositoryFragmentConfiguration fragment configurations}.
 */
Stream<RepositoryFragmentConfiguration> getRepositoryFragments(CdiRepositoryConfiguration configuration, Class<?> repositoryInterface) {
    ClassMetadata classMetadata = getClassMetadata(metadataReaderFactory, repositoryInterface.getName());
    RepositoryFragmentDiscovery fragmentConfiguration = new CdiRepositoryFragmentDiscovery(configuration);
    return // 
    Arrays.stream(classMetadata.getInterfaceNames()).filter(// 
    it -> FragmentMetadata.isCandidate(it, metadataReaderFactory)).map(// 
    it -> FragmentMetadata.of(it, fragmentConfiguration)).map(// 
    this::detectRepositoryFragmentConfiguration).flatMap(Optionals::toStream);
}
Also used : ClassMetadata(org.springframework.core.type.ClassMetadata) Arrays(java.util.Arrays) TypeFilter(org.springframework.core.type.filter.TypeFilter) UnsatisfiedResolutionException(javax.enterprise.inject.UnsatisfiedResolutionException) RequiredArgsConstructor(lombok.RequiredArgsConstructor) AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition) ClassMetadata(org.springframework.core.type.ClassMetadata) NoRepositoryBean(org.springframework.data.repository.NoRepositoryBean) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) RepositoryFragmentDiscovery(org.springframework.data.repository.config.RepositoryFragmentDiscovery) Optionals(org.springframework.data.util.Optionals) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) CustomRepositoryImplementationDetector(org.springframework.data.repository.config.CustomRepositoryImplementationDetector) AnnotationTypeFilter(org.springframework.core.type.filter.AnnotationTypeFilter) RepositoryFragmentConfiguration(org.springframework.data.repository.config.RepositoryFragmentConfiguration) ResourceLoader(org.springframework.core.io.ResourceLoader) ClassUtils(org.springframework.util.ClassUtils) CachingMetadataReaderFactory(org.springframework.core.type.classreading.CachingMetadataReaderFactory) IOException(java.io.IOException) StandardEnvironment(org.springframework.core.env.StandardEnvironment) CreationException(javax.enterprise.inject.CreationException) FragmentMetadata(org.springframework.data.repository.config.FragmentMetadata) Stream(java.util.stream.Stream) MetadataReaderFactory(org.springframework.core.type.classreading.MetadataReaderFactory) Environment(org.springframework.core.env.Environment) Streamable(org.springframework.data.util.Streamable) Optional(java.util.Optional) Collections(java.util.Collections) Assert(org.springframework.util.Assert) Optionals(org.springframework.data.util.Optionals) RepositoryFragmentDiscovery(org.springframework.data.repository.config.RepositoryFragmentDiscovery)

Aggregations

IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Optional (java.util.Optional)1 Stream (java.util.stream.Stream)1 CreationException (javax.enterprise.inject.CreationException)1 UnsatisfiedResolutionException (javax.enterprise.inject.UnsatisfiedResolutionException)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)1 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)1 Environment (org.springframework.core.env.Environment)1 StandardEnvironment (org.springframework.core.env.StandardEnvironment)1 ResourceLoader (org.springframework.core.io.ResourceLoader)1 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)1 ClassMetadata (org.springframework.core.type.ClassMetadata)1 CachingMetadataReaderFactory (org.springframework.core.type.classreading.CachingMetadataReaderFactory)1 MetadataReaderFactory (org.springframework.core.type.classreading.MetadataReaderFactory)1 AnnotationTypeFilter (org.springframework.core.type.filter.AnnotationTypeFilter)1 TypeFilter (org.springframework.core.type.filter.TypeFilter)1 NoRepositoryBean (org.springframework.data.repository.NoRepositoryBean)1