/** {@inheritDoc} */ @Override protected RepositoryMetadata getRepositoryMetadata(Class<?> repoItf) { Assert.notNull(repoItf, "Repository interface must be set."); Assert.isAssignable(IgniteRepository.class, repoItf, "Repository must implement IgniteRepository interface."); RepositoryConfig annotation = repoItf.getAnnotation(RepositoryConfig.class); Assert.notNull(annotation, "Set a name of an Apache Ignite cache using @RepositoryConfig annotation to map " + "this repository to the underlying cache."); Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite cache using @RepositoryConfig " + "annotation to map this repository to the underlying cache."); repoToCache.put(repoItf, annotation.cacheName()); return super.getRepositoryMetadata(repoItf); }
/** {@inheritDoc} */ @Override protected RepositoryMetadata getRepositoryMetadata(Class<?> repoItf) { Assert.notNull(repoItf, "Repository interface must be set."); Assert.isAssignable(IgniteRepository.class, repoItf, "Repository must implement IgniteRepository interface."); RepositoryConfig annotation = repoItf.getAnnotation(RepositoryConfig.class); Assert.notNull(annotation, "Set a name of an Apache Ignite cache using @RepositoryConfig annotation to map " + "this repository to the underlying cache."); Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite cache using @RepositoryConfig " + "annotation to map this repository to the underlying cache."); repoToCache.put(repoItf, annotation.cacheName()); return super.getRepositoryMetadata(repoItf); }
public RepositoryInformation getRepositoryInformation() { RepositoryMetadata metadata = factory.getRepositoryMetadata(repositoryInterface); return this.factory.getRepositoryInformation(metadata, customImplementation == null ? null : customImplementation.getClass()); }
@SuppressWarnings("unchecked") public EntityInformation<S, ID> getEntityInformation() { RepositoryMetadata repositoryMetadata = factory.getRepositoryMetadata(repositoryInterface); return (EntityInformation<S, ID>) factory.getEntityInformation(repositoryMetadata.getDomainType()); }
public void afterPropertiesSet() { this.factory = createRepositoryFactory(); this.factory.setQueryLookupStrategyKey(queryLookupStrategyKey); this.factory.setNamedQueries(namedQueries); this.factory.setEvaluationContextProvider(evaluationContextProvider); this.factory.setRepositoryBaseClass(repositoryBaseClass); this.factory.setBeanClassLoader(classLoader); this.factory.setBeanFactory(beanFactory); if (publisher != null) { RepositoryProxyPostProcessor repositoryProxyPostProcessor = null; try { repositoryProxyPostProcessor = (RepositoryProxyPostProcessor) Class.forName("org.springframework.data.repository.core.support.EventPublishingRepositoryProxyPostProcessor").getConstructor(ApplicationEventPublisher.class).newInstance(publisher); } catch (Exception e) { // ignore } if (repositoryProxyPostProcessor != null) { this.factory.addRepositoryProxyPostProcessor(repositoryProxyPostProcessor); } } this.repositoryMetadata = this.factory.getRepositoryMetadata(repositoryInterface); if (!lazyInit) { initAndReturn(); } }
public void afterPropertiesSet() { this.factory = createRepositoryFactory(); this.factory.setQueryLookupStrategyKey(queryLookupStrategyKey); this.factory.setNamedQueries(namedQueries); this.factory.setEvaluationContextProvider( evaluationContextProvider.orElseGet(() -> QueryMethodEvaluationContextProvider.DEFAULT)); 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); // Make sure the aggregate root type is present in the MappingContext (e.g. for auditing) this.mappingContext.ifPresent(it -> it.getPersistentEntity(repositoryMetadata.getDomainType())); this.repository = Lazy.of(() -> this.factory.getRepository(repositoryInterface, repositoryFragmentsToUse)); if (!lazyInit) { this.repository.get(); } }
/** * Returns a repository instance for the given interface backed by an instance providing implementation logic for * custom logic. * * @param <T> * @param repositoryInterface * @param customImplementation * @return */ @SuppressWarnings({ "unchecked" }) public <T> T getRepository(Class<T> repositoryInterface, Object customImplementation) { RepositoryMetadata metadata = getRepositoryMetadata(repositoryInterface); Class<?> customImplementationClass = null == customImplementation ? null : customImplementation.getClass(); RepositoryInformation information = getRepositoryInformation(metadata, customImplementationClass); validate(information, customImplementation); Object target = getTargetRepository(information); // Create proxy ProxyFactory result = new ProxyFactory(); result.setTarget(target); result.setInterfaces(new Class[] { repositoryInterface, Repository.class }); for (RepositoryProxyPostProcessor processor : postProcessors) { processor.postProcess(result); } result.addAdvice(new QueryExecutorMethodInterceptor(information, customImplementation, target)); return (T) result.getProxy(); }
Assert.notNull(fragments, "RepositoryFragments must not be null!"); RepositoryMetadata metadata = getRepositoryMetadata(repositoryInterface); RepositoryComposition composition = getRepositoryComposition(metadata, fragments); RepositoryInformation information = getRepositoryInformation(metadata, composition);