Java 类org.springframework.data.repository.core.support.RepositoryProxyPostProcessor 实例源码

项目:spring-data-jpa-extra    文件:GenericJpaRepositoryFactory.java   
/**
 * Creates a new {@link JpaRepositoryFactory}.
 *
 * @param entityManager must not be {@literal null}
 */
public GenericJpaRepositoryFactory(EntityManager entityManager) {
    super(entityManager);
    this.entityManager = entityManager;
    this.extractor = PersistenceProvider.fromEntityManager(entityManager);

    final AssemblerInterceptor assemblerInterceptor = new AssemblerInterceptor();
    addRepositoryProxyPostProcessor(new RepositoryProxyPostProcessor() {
        @Override
        public void postProcess(ProxyFactory factory, RepositoryInformation repositoryInformation) {
            factory.addAdvice(assemblerInterceptor);
        }
    });
}
项目:parkingfriends    文件:SpringReloader.java   
@Override
public void afterPropertiesSet() {
    applicationContext.getAutowireCapableBeanFactory().autowireBean(this);
    this.jpaRepositoryFactory = new JpaRepositoryFactory(entityManager);
    try {
        // Make sure calls to the repository instance are intercepted for annotated transactions
        Class transactionalRepositoryProxyPostProcessor = Class.forName("org.springframework.data.repository.core.support.TransactionalRepositoryProxyPostProcessor");
        final Constructor constructor = transactionalRepositoryProxyPostProcessor.getConstructor(ListableBeanFactory.class, String.class);
        final RepositoryProxyPostProcessor repositoryProxyPostProcessor = (RepositoryProxyPostProcessor)
                constructor.newInstance(applicationContext.getBeanFactory(), TxUtils.DEFAULT_TRANSACTION_MANAGER);
        jpaRepositoryFactory.addRepositoryProxyPostProcessor(repositoryProxyPostProcessor);
    } catch (Exception e) {
        log.error("Failed to initialize the TransactionalRepositoryProxyPostProcessor class", e);
    }
}