/** {@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); }
@Override public void setBeanClassLoader(ClassLoader classLoader) { super.setBeanClassLoader(classLoader); this.crudMethodMetadataPostProcessor.setBeanClassLoader(classLoader); }
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(); } }
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(); } }
Assert.notNull(fragments, "RepositoryFragments must not be null!"); RepositoryMetadata metadata = getRepositoryMetadata(repositoryInterface); RepositoryComposition composition = getRepositoryComposition(metadata, fragments); RepositoryInformation information = getRepositoryInformation(metadata, composition); validate(information, composition); Object target = getTargetRepository(information); ProjectionFactory projectionFactory = getProjectionFactory(classLoader, beanFactory); result.addAdvice(new QueryExecutorMethodInterceptor(information, projectionFactory));
/** * 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(); }
/** * Returns a repository instance for the given interface. * * @param <T> * @param repositoryInterface * @return */ public <T> T getRepository(Class<T> repositoryInterface) { return getRepository(repositoryInterface, null); }
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()); }
/** * Creates a repository of the repository base class defined in the given {@link RepositoryInformation} using * reflection. * * @param information * @param constructorArguments * @return */ protected final <R> R getTargetRepositoryViaReflection(RepositoryInformation information, Object... constructorArguments) { Class<?> baseClass = information.getRepositoryBaseClass(); return getTargetRepositoryViaReflection(baseClass, constructorArguments); }
public void afterPropertiesSet() { this.factory = createRepositoryFactory(); this.factory.setQueryLookupStrategyKey(queryLookupStrategyKey); this.factory.setNamedQueries(namedQueries); }
/** * Returns the {@link RepositoryInformation} for the given {@link RepositoryMetadata} and custom * {@link RepositoryFragments}. * * @param metadata must not be {@literal null}. * @param fragments must not be {@literal null}. * @return will never be {@literal null}. */ protected RepositoryInformation getRepositoryInformation(RepositoryMetadata metadata, RepositoryFragments fragments) { return getRepositoryInformation(metadata, getRepositoryComposition(metadata, fragments)); }
/** * Delegates {@link RepositoryFactorySupport} creation to {@link #doCreateRepositoryFactory()} and applies the * {@link TransactionalRepositoryProxyPostProcessor} to the created instance. * * @see BlazeRepositoryFactoryBeanSupport #createRepositoryFactory() */ @Override protected final RepositoryFactorySupport createRepositoryFactory() { RepositoryFactorySupport factory = doCreateRepositoryFactory(); factory.addRepositoryProxyPostProcessor(exceptionPostProcessor); factory.addRepositoryProxyPostProcessor(txPostProcessor); return factory; }
public List<QueryMethod> getQueryMethods() { return factory.getQueryMethods(); }
@SuppressWarnings("unchecked") public EntityInformation<S, ID> getEntityInformation() { return (EntityInformation<S, ID>) factory.getEntityInformation(repositoryMetadata.getDomainType()); }
public RepositoryInformation getRepositoryInformation() { return this.factory.getRepositoryInformation(repositoryMetadata, customImplementation == null ? null : customImplementation.getClass()); }
/** * Creates the actual repository instance. * * @param repositoryType will never be {@literal null}. * @param repositoryFragments will never be {@literal null}. * @return */ protected static <T> T create(RepositoryFactorySupport repositoryFactory, Class<T> repositoryType, RepositoryFragments repositoryFragments) { return repositoryFactory.getRepository(repositoryType, repositoryFragments); }
@Override protected Object getTargetRepository(RepositoryInformation repositoryInformation) { EntityInformation<?, ?> entityInformation = getEntityInformation(repositoryInformation.getDomainType()); return super.getTargetRepositoryViaReflection(repositoryInformation, entityInformation, keyValueOperations); }
/** * Delegates {@link RepositoryFactorySupport} creation to {@link #doCreateRepositoryFactory()} and applies the * {@link TransactionalRepositoryProxyPostProcessor} to the created instance. * * @see org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport #createRepositoryFactory() */ @Override protected final RepositoryFactorySupport createRepositoryFactory() { RepositoryFactorySupport factory = doCreateRepositoryFactory(); RepositoryProxyPostProcessor exceptionPostProcessor = this.exceptionPostProcessor; if (exceptionPostProcessor != null) { factory.addRepositoryProxyPostProcessor(exceptionPostProcessor); } RepositoryProxyPostProcessor txPostProcessor = this.txPostProcessor; if (txPostProcessor != null) { factory.addRepositoryProxyPostProcessor(txPostProcessor); } return factory; }
public List<QueryMethod> getQueryMethods() { return factory.getQueryMethods(); }