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

项目:spring-data-jdbc    文件:JdbcRepositoryFactory.java   
@Override
protected Object getTargetRepository(RepositoryInformation metadata) {
    entityClass = metadata.getDomainType();
    @SuppressWarnings("rawtypes")
    ReflectionJdbcRepository repository = getTargetRepositoryViaReflection(metadata, entityClass);
    repository.setDataSource(datasource);
    repository.afterPropertiesSet();
    this.repository = repository;

    generator = SqlGeneratorFactory.getInstance().getGenerator(datasource);
    template = new NamedParameterJdbcTemplate((JdbcOperations) extractRepositoryField(repository, FIELD_JDBC_OPS));
    rowMapper = extractRepositoryField(repository, FIELD_ROWMAPPER);
    tableDescription = extractRepositoryField(repository, FIELD_TABLE_DESCRIPTION);

    return repository;
}
项目:spring-content    文件:AbstractContentPropertyController.java   
public static Object save(Repositories repositories, Object domainObj) 
        throws HttpRequestMethodNotSupportedException {

    RepositoryInformation ri = findRepositoryInformation(repositories, domainObj.getClass());

    if (ri == null) {
        throw new ResourceNotFoundException();
    }

    Class<?> domainObjClazz = ri.getDomainType();

    if (domainObjClazz != null) {
        Method saveMethod = ri.getCrudMethods().getSaveMethod();
        if (saveMethod == null) {
            throw new HttpRequestMethodNotSupportedException("save");
        }
        domainObj = ReflectionUtils.invokeMethod(saveMethod, repositories.getRepositoryFor(domainObjClazz), domainObj);
    }

    return domainObj;
}
项目:strategy-spring-security-acl    文件:AclJpaRepositoryFactoryBean.java   
protected SimpleJpaRepository<?, ?> getTargetRepository(RepositoryInformation information,
    EntityManager entityManager) {
  Class<?> domainType = information.getDomainType();
  if (!hasAclStrategyAnnotation(domainType)) {
    return super.getTargetRepository(information, entityManager);
  }

  JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(domainType);

  // invokes
  // com.github.lothar.security.acl.jpa.repository.AclJpaRepository.AclJpaRepository(JpaEntityInformation<T,
  // ?>, EntityManager, JpaSpecProvider<T>)
  SimpleJpaRepository<?, ?> repository = getTargetRepositoryViaReflection(information,
      entityInformation, entityManager, jpaSpecProvider);
  logger.debug("Created {}", repository);

  return repository;
}
项目:strategy-spring-security-acl    文件:AclElasticsearchRepositoryFactoryBean.java   
@Override
protected Object getTargetRepository(RepositoryInformation metadata) {
  Class<?> domainType = metadata.getDomainType();
  ElasticsearchEntityInformation<?, Serializable> entityInformation =
      getEntityInformation(domainType);
  if (!hasAclStrategyAnnotation(domainType)) {
    return getTargetRepositoryViaReflection(metadata, entityInformation,
        elasticsearchOperations);
  }

  // invokes
  // com.github.lothar.security.acl.elasticsearch.repository.AclElasticsearchRepository.AclNumberKeyedRepository(ElasticsearchEntityInformation<T,
  // ID>, ElasticsearchOperations, AclFilterProvider)
  ElasticsearchRepository<?, ?> repository = getTargetRepositoryViaReflection(metadata,
      entityInformation, elasticsearchOperations, filterProvider);
  logger.debug("Created {}", repository);

  return repository;
}
项目:iVIS    文件:IdToDomainClassConverter.java   
@Override
        public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {

            if (source == null || !StringUtils.hasText(source.toString())) {
                return null;
            }

//            if (sourceType.equals(targetType)) {
            if (isTypesEqual(sourceType, targetType)) {
                return source;
            }

            Class<?> domainType = targetType.getType();

            RepositoryInformation info = repositories.getRepositoryInformationFor(domainType);
            RepositoryInvoker invoker = repositoryInvokerFactory.getInvokerFor(domainType);

            return invoker.invokeFindOne(conversionService.convert(source, info.getIdType()));
        }
项目:dubbox-solr    文件:SolrRepositoryFactory.java   
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Object getTargetRepository(RepositoryInformation metadata) {

    SolrOperations operations = this.solrOperations;
    if (factory != null) {
        SolrTemplate template = new SolrTemplate(factory);
        if (this.solrOperations.getConverter() != null) {
            template.setMappingContext(this.solrOperations.getConverter().getMappingContext());
        }
        template.setSolrCore(SolrClientUtils.resolveSolrCoreName(metadata.getDomainType()));
        addSchemaCreationFeaturesIfEnabled(template);
        template.afterPropertiesSet();
        operations = template;
    }

    SimpleSolrRepository repository = getTargetRepositoryViaReflection(metadata,
            getEntityInformation(metadata.getDomainType()), operations);
    repository.setEntityClass(metadata.getDomainType());

    this.templateHolder.add(metadata.getDomainType(), operations);
    return repository;
}
项目:os    文件:DefaultRepositoryFactory.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected <T, ID extends Serializable> SimpleJpaRepository<?, ?> getTargetRepository(
        RepositoryInformation information, EntityManager entityManager) {
    JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(information.getDomainType());
    return new GenericRepositoryImpl(entityInformation, entityManager);
}
项目:spring-data-spanner    文件:SpannerRepositoryFactory.java   
@SuppressWarnings("unchecked")
private <T, ID extends Serializable> SpannerEntityInformation<T, ID> getEntityInformation(Class<T> domainClass,
                                                                                          RepositoryInformation information) {
  SpannerPersistentEntity<?> entity = mappingContext.getPersistentEntity(domainClass);

  if (entity == null) {
    throw new MappingException(
        String.format("Could not lookup mapping metadata for domain class %s!", domainClass.getName()));
  }

  BasicSpannerPersistentEntity<T> persistentEntity = (BasicSpannerPersistentEntity<T>) mappingContext.getPersistentEntity(domainClass);
  return new MappingSpannerEntityInformation<T, ID>(persistentEntity);
}
项目:spring-data-gclouddatastore    文件:GcloudDatastoreRepositoryFactory.java   
@Override
protected Object getTargetRepository(RepositoryInformation information) {
    EntityInformation<?, Serializable> entityInformation = getEntityInformation(
            information.getDomainType());
    return getTargetRepositoryViaReflection(information, entityInformation,
            this.datastoreOptions);
}
项目: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);
        }
    });
}
项目:spring-content    文件:RepositoryUtils.java   
public static String repositoryPath(RepositoryInformation info) {
    Class<?> clazz = info.getRepositoryInterface();
    RepositoryRestResource annotation = AnnotationUtils.findAnnotation(clazz, RepositoryRestResource.class);
    String path = annotation == null ? null : annotation.path().trim();
    path = StringUtils.hasText(path) ? path : English.plural(StringUtils.uncapitalize(info.getDomainType().getSimpleName()));
    return path;
}
项目:spring-content    文件:AbstractContentPropertyController.java   
public static Object findOne(Repositories repositories, String repository, String id) 
        throws HttpRequestMethodNotSupportedException {

    Object domainObj = null;

    RepositoryInformation ri = findRepositoryInformation(repositories, repository);

    if (ri == null) {
        throw new ResourceNotFoundException();
    }

    Class<?> domainObjClazz = ri.getDomainType();
    Class<?> idClazz = ri.getIdType();

    Method findOneMethod = ri.getCrudMethods().getFindOneMethod();
    if (findOneMethod == null) {
        throw new HttpRequestMethodNotSupportedException("fineOne");
    }

    Object oid = new DefaultConversionService().convert(id, idClazz);
    domainObj = ReflectionUtils.invokeMethod(findOneMethod, repositories.getRepositoryFor(domainObjClazz), oid);

    if (null == domainObj) {
        throw new ResourceNotFoundException();
    }

    return domainObj;
}
项目:spring-content    文件:AbstractContentPropertyController.java   
public static Object findOne(Repositories repositories, Class<?> domainObjClass, String id) 
        throws HttpRequestMethodNotSupportedException {

    Object domainObj = null;

    RepositoryInformation ri = findRepositoryInformation(repositories, domainObjClass);

    if (ri == null) {
        throw new ResourceNotFoundException();
    }

    Class<?> domainObjClazz = ri.getDomainType();
    Class<?> idClazz = ri.getIdType();

    Method findOneMethod = ri.getCrudMethods().getFindOneMethod();
    if (findOneMethod == null) {
        throw new HttpRequestMethodNotSupportedException("fineOne");
    }

    Object oid = new DefaultConversionService().convert(id, idClazz);
    domainObj = ReflectionUtils.invokeMethod(findOneMethod, repositories.getRepositoryFor(domainObjClazz), oid);

    if (null == domainObj) {
        throw new ResourceNotFoundException();
    }

    return domainObj;
}
项目:spring-content    文件:AbstractContentPropertyController.java   
public static Iterable findAll(Repositories repositories, String repository) 
        throws HttpRequestMethodNotSupportedException {

    Iterable entities = null;

    RepositoryInformation ri = findRepositoryInformation(repositories, repository);

    if (ri == null) {
        throw new ResourceNotFoundException();
    }

    Class<?> domainObjClazz = ri.getDomainType();
    Class<?> idClazz = ri.getIdType();

    Method findAllMethod = ri.getCrudMethods().getFindAllMethod();
    if (findAllMethod == null) {
        throw new HttpRequestMethodNotSupportedException("fineAll");
    }

    entities = (Iterable)ReflectionUtils.invokeMethod(findAllMethod, repositories.getRepositoryFor(domainObjClazz));

    if (null == entities) {
        throw new ResourceNotFoundException();
    }

    return entities;
}
项目:spring-content    文件:AbstractContentPropertyController.java   
public static RepositoryInformation findRepositoryInformation(Repositories repositories, String repository) {
    RepositoryInformation ri = null;
    for (Class<?> clazz : repositories) {
        RepositoryInformation candidate = repositories.getRepositoryInformationFor(clazz);
        if (candidate == null) {
            continue;
        }
        if (repository.equals(RepositoryUtils.repositoryPath(candidate))) {
            ri = repositories.getRepositoryInformationFor(clazz);
            break;
        }
    }
    return ri;
}
项目:spring-content    文件:AbstractContentPropertyController.java   
public static RepositoryInformation findRepositoryInformation(Repositories repositories, Class<?> domainObjectClass) {
    RepositoryInformation ri = null;
    for (Class<?> clazz : repositories) {
        if (clazz.equals(domainObjectClass)) {
            return repositories.getRepositoryInformationFor(clazz);
        }
    }
    return ri;
}
项目:java-platform    文件:CustomRepositoryFactoryBean.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected Object getTargetRepository(RepositoryInformation information) {
    return isBaseRepository(information.getRepositoryInterface())
            ? (isTreeRepository(information.getRepositoryInterface())
                    ? new TreeRepositoryImpl(getEntityInformation(information.getDomainType()), entityManager)
                    : new BaseRepositoryImpl<>(getEntityInformation(information.getDomainType()),
                            entityManager))
            : super.getTargetRepository(information);
}
项目:spring-data-documentdb    文件:DocumentDbRepositoryFactory.java   
@Override
protected Object getTargetRepository(RepositoryInformation information) {
    final EntityInformation<?, Serializable> entityInformation = getEntityInformation(information.getDomainType());
    return getTargetRepositoryViaReflection(information, entityInformation, this.applicationContext);
}
项目:tasfe-framework    文件:BaseRepositoryFactoryBean.java   
@Override
protected SimpleJpaRepository getTargetRepository(RepositoryInformation metadata) {
    return new BaseRepositoryImpl<T, I>((Class<T>) metadata.getDomainType(), entityManager);
}
项目:spring-data-spanner    文件:SpannerRepositoryFactory.java   
@Override
protected Object getTargetRepository(RepositoryInformation information) {
  SpannerEntityInformation<?, Serializable> entityInformation = getEntityInformation(information.getDomainType(),
      information);
  return getTargetRepositoryViaReflection(information, entityInformation, operations);
}
项目:spring-data-snowdrop    文件:SnowdropRepositoryProxyPostProcessor.java   
@Override
public void postProcess(ProxyFactory factory, RepositoryInformation repositoryInformation) {
    factory.addAdvice(INFO_ADVICE);
}
项目:spring-data-snowdrop    文件:SnowdropRepositoryFactory.java   
@Override
protected Object getTargetRepository(RepositoryInformation info) {
    return getTargetRepositoryViaReflection(info, snowdropOperations, getEntityInformation(info.getDomainType()));
}
项目:itweet-boot    文件:BaseRepositoryFactoryBean.java   
@Override
protected Object getTargetRepository(RepositoryInformation information) {
    return new BaseRepositoryImpl<T, I>((Class<T>) information.getDomainType(), em);
}
项目:spring-multitenancy    文件:MongoRepositoryFactory.java   
@Override
protected Object getTargetRepository(RepositoryInformation metadata) {
    return getTargetRepositoryViaReflection(metadata, getEntityInformation(metadata.getDomainType()), operation);
}
项目:spring-boot-gae    文件:ObjectifyRepositoryFactory.java   
@Override
@SuppressWarnings("unchecked")
protected Object getTargetRepository(RepositoryInformation information) {
    return new AbstractObjectifyRepository(objectify, searchService, information.getDomainType(), information.getIdType());
}
项目:spring-data-jdbc-template    文件:JdbcTemplateRepositoryFactoryBean.java   
@Override
protected Object getTargetRepository(RepositoryInformation metadata) {
    return new JdbcTemplateRepositoryInternal<>(beanFactory, configuration, metadata.getDomainType());
}
项目:spring-cloud-samples    文件:RepositoryFactoryBean.java   
@SuppressWarnings("unchecked")
@Override
protected Object getTargetRepository(RepositoryInformation information) {
    return new BaseRepositoryImpl<T, I>((Class<T>) information.getDomainType(), entityManager);
}
项目:spring-data-objectify    文件:ObjectifyRepositoryFactory.java   
@Override
protected Object getTargetRepository(RepositoryInformation repositoryInformation) {
    EntityInformation<?, Serializable> entityInformation = getEntityInformation(repositoryInformation.getDomainType());
    return super.getTargetRepositoryViaReflection(repositoryInformation, entityInformation);
}
项目:spring-data-ebean    文件:EbeanRepositoryFactory.java   
@Override
protected Object getTargetRepository(RepositoryInformation information) {
    SimpleEbeanRepository<?, ?> repository = getTargetRepository(information, ebeanServer);
    return repository;
}
项目:spring-data-arangodb    文件:ArangoDbRepositoryFactory.java   
@Override
protected Object getTargetRepository(RepositoryInformation information) {
    return getTargetRepositoryViaReflection(information, information.getDomainType());
}
项目:spring-boot-jpa-data-rest-soft-delete    文件:CustomJpaRepositoryFactoryBean.java   
@Override
@SuppressWarnings("unchecked")
protected Object getTargetRepository(RepositoryInformation information) {
    return new SoftDeletesRepositoryImpl<T, ID>((Class<T>) information.getDomainType(), entityManager);
}
项目:abixen-platform    文件:PlatformJpaRepositoryFactoryBean.java   
@Override
protected PlatformJpaRepositoryImpl getTargetRepository(RepositoryInformation information) {
    JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(information.getDomainType());
    return new PlatformJpaRepositoryImpl(entityInformation, em);
}
项目:spring-boot-starter-mybatis    文件:MyBatisRepositoryFactory.java   
@Override
@SuppressWarnings("unchecked")
protected Object getTargetRepository(final RepositoryInformation metadata) {
    final MyBatisEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType());
    return new SimpleMyBatisRepository(entityInformation, mapperProvider.getSqlSessionTemplate());
}
项目:spring-data-jpa-entity-graph    文件:RepositoryMethodEntityGraphExtractor.java   
@Override
public void postProcess(ProxyFactory factory, RepositoryInformation repositoryInformation) {
  factory.addAdvice(
      new JpaEntityGraphMethodInterceptor(entityManager, repositoryInformation.getDomainType()));
}
项目:sdcct    文件:SdcctRepositoryFactoryBean.java   
@Override
protected Object getTargetRepository(RepositoryInformation repoInfo) {
    return this.getTargetRepositoryViaReflection(repoInfo, entityManager, SdcctRepositoryFactoryBean.this.entityClass,
        SdcctRepositoryFactoryBean.this.entityImplClass, SdcctRepositoryFactoryBean.this.entityMetadata);
}
项目:ignite    文件:IgniteRepositoryFactory.java   
/** {@inheritDoc} */
@Override protected Object getTargetRepository(RepositoryInformation metadata) {
    return getTargetRepositoryViaReflection(metadata,
        ignite.getOrCreateCache(repoToCache.get(metadata.getRepositoryInterface())));
}
项目:ppl-commons    文件:FetchableJpaRepositoryFactoryBean.java   
@Override
protected Object getTargetRepository(RepositoryInformation information) {
    return new FetchableJpaRepositoryImpl<T, ID>((Class<T>) information.getDomainType(), em);
}
项目:centromere    文件:CentromereJpaRepositoryFactoryBean.java   
@Override 
protected Object getTargetRepository(RepositoryInformation information) {
    JpaEntityInformation entityInformation = getEntityInformation(information.getDomainType());
    return new CentromereJpaRepository<>(entityInformation, entityManager);
}
项目:centromere    文件:CentromereMongoRepositoryFactoryBean.java   
@Override 
protected Object getTargetRepository(RepositoryInformation information) {
    MongoEntityInformation entityInformation = getEntityInformation(information.getDomainType());
    return new CentromereMongoRepository<>(entityInformation, mongoOperations);
}
项目:spring-boot-starter-mybatis    文件:MyBatisRepositoryFactory.java   
@Override
@SuppressWarnings("unchecked")
protected Object getTargetRepository(final RepositoryInformation metadata) {
    final MyBatisEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType());
    return new SimpleMyBatisRepository(entityInformation, mapperProvider.getSqlSessionTemplate());
}