use of org.springframework.data.repository.core.support.RepositoryComposition.RepositoryFragments in project spring-data-mongodb by spring-projects.
the class MongoRepositoryFactory method getRepositoryFragments.
/*
* (non-Javadoc)
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getRepositoryFragments(org.springframework.data.repository.core.RepositoryMetadata)
*/
@Override
protected RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata) {
RepositoryFragments fragments = RepositoryFragments.empty();
boolean isQueryDslRepository = QUERY_DSL_PRESENT && QuerydslPredicateExecutor.class.isAssignableFrom(metadata.getRepositoryInterface());
if (isQueryDslRepository) {
if (metadata.isReactiveRepository()) {
throw new InvalidDataAccessApiUsageException("Cannot combine Querydsl and reactive repository support in a single interface");
}
MongoEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType(), metadata);
fragments = fragments.append(RepositoryFragment.implemented(getTargetRepositoryViaReflection(QuerydslMongoPredicateExecutor.class, entityInformation, operations)));
}
return fragments;
}
use of org.springframework.data.repository.core.support.RepositoryComposition.RepositoryFragments in project spring-data-commons by spring-projects.
the class RepositoryFactoryBeanSupport method afterPropertiesSet.
/*
* (non-Javadoc)
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
public void afterPropertiesSet() {
this.factory = createRepositoryFactory();
this.factory.setQueryLookupStrategyKey(queryLookupStrategyKey);
this.factory.setNamedQueries(namedQueries);
this.factory.setEvaluationContextProvider(evaluationContextProvider);
this.factory.setBeanClassLoader(classLoader);
this.factory.setBeanFactory(beanFactory);
if (publisher != null) {
this.factory.addRepositoryProxyPostProcessor(new EventPublishingRepositoryProxyPostProcessor(publisher));
}
repositoryBaseClass.ifPresent(this.factory::setRepositoryBaseClass);
RepositoryFragments customImplementationFragment = //
customImplementation.map(//
RepositoryFragments::just).orElseGet(RepositoryFragments::empty);
RepositoryFragments repositoryFragmentsToUse = //
this.repositoryFragments.orElseGet(//
RepositoryFragments::empty).append(customImplementationFragment);
this.repositoryMetadata = this.factory.getRepositoryMetadata(repositoryInterface);
this.repository = Lazy.of(() -> this.factory.getRepository(repositoryInterface, repositoryFragmentsToUse));
if (!lazyInit) {
this.repository.get();
}
}
use of org.springframework.data.repository.core.support.RepositoryComposition.RepositoryFragments in project spring-data-commons by spring-projects.
the class CdiRepositoryBean method getRepositoryFragments.
private RepositoryFragments getRepositoryFragments(Class<T> repositoryType, CdiRepositoryConfiguration cdiRepositoryConfiguration) {
Optional<Bean<?>> customImplementationBean = getCustomImplementationBean(repositoryType, cdiRepositoryConfiguration);
Optional<Object> customImplementation = customImplementationBean.map(this::getDependencyInstance);
List<RepositoryFragment<?>> repositoryFragments = findRepositoryFragments(repositoryType, cdiRepositoryConfiguration);
RepositoryFragments customImplementationFragment = //
customImplementation.map(//
RepositoryFragments::just).orElseGet(RepositoryFragments::empty);
return //
RepositoryFragments.from(repositoryFragments).append(customImplementationFragment);
}
use of org.springframework.data.repository.core.support.RepositoryComposition.RepositoryFragments in project spring-data-mongodb by spring-projects.
the class ReactiveMongoRepositoryFactory method getRepositoryFragments.
/*
* (non-Javadoc)
* @see org.springframework.data.repository.core.support.RepositoryFactorySupport#getRepositoryFragments(org.springframework.data.repository.core.RepositoryMetadata)
*/
@Override
protected RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata) {
RepositoryFragments fragments = RepositoryFragments.empty();
boolean isQueryDslRepository = QUERY_DSL_PRESENT && ReactiveQuerydslPredicateExecutor.class.isAssignableFrom(metadata.getRepositoryInterface());
if (isQueryDslRepository) {
MongoEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType(), metadata);
fragments = fragments.append(RepositoryFragment.implemented(getTargetRepositoryViaReflection(ReactiveQuerydslMongoPredicateExecutor.class, entityInformation, operations)));
}
return fragments;
}
use of org.springframework.data.repository.core.support.RepositoryComposition.RepositoryFragments in project spring-data-commons by spring-projects.
the class RepositoryFactorySupport method getRepositoryComposition.
/**
* Returns the {@link RepositoryComposition} for the given {@link RepositoryMetadata} and extra
* {@link RepositoryFragments}.
*
* @param metadata must not be {@literal null}.
* @param fragments must not be {@literal null}.
* @return will never be {@literal null}.
*/
private RepositoryComposition getRepositoryComposition(RepositoryMetadata metadata, RepositoryFragments fragments) {
Assert.notNull(metadata, "RepositoryMetadata must not be null!");
Assert.notNull(fragments, "RepositoryFragments must not be null!");
RepositoryComposition composition = getRepositoryComposition(metadata);
RepositoryFragments repositoryAspects = getRepositoryFragments(metadata);
return composition.append(fragments).append(repositoryAspects);
}
Aggregations