/** * 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(); }
Object target = getTargetRepository(information);