本文整理汇总了Java中org.springframework.data.repository.core.RepositoryInformation类的典型用法代码示例。如果您正苦于以下问题:Java RepositoryInformation类的具体用法?Java RepositoryInformation怎么用?Java RepositoryInformation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RepositoryInformation类属于org.springframework.data.repository.core包,在下文中一共展示了RepositoryInformation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTargetRepository
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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;
}
示例2: save
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
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;
}
示例3: getTargetRepository
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
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;
}
示例4: getTargetRepository
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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;
}
开发者ID:lordlothar99,项目名称:strategy-spring-security-acl,代码行数:20,代码来源:AclElasticsearchRepositoryFactoryBean.java
示例5: convert
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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()));
}
示例6: getTargetRepository
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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;
}
示例7: getTargetRepository
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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);
}
示例8: getEntityInformation
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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);
}
示例9: getTargetRepository
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@Override
protected Object getTargetRepository(RepositoryInformation information) {
EntityInformation<?, Serializable> entityInformation = getEntityInformation(
information.getDomainType());
return getTargetRepositoryViaReflection(information, entityInformation,
this.datastoreOptions);
}
示例10: GenericJpaRepositoryFactory
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
/**
* 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);
}
});
}
示例11: repositoryPath
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
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;
}
示例12: findOne
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
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;
}
示例13: findAll
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
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;
}
示例14: findRepositoryInformation
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
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;
}
示例15: getTargetRepository
import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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);
}