本文整理汇总了Java中org.springframework.data.annotation.Persistent类的典型用法代码示例。如果您正苦于以下问题:Java Persistent类的具体用法?Java Persistent怎么用?Java Persistent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Persistent类属于org.springframework.data.annotation包,在下文中一共展示了Persistent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanForEntities
import org.springframework.data.annotation.Persistent; //导入依赖的package包/类
protected Set<Class<?>> scanForEntities(String basePackage) throws ClassNotFoundException {
if (!StringUtils.hasText(basePackage)) {
return Collections.emptySet();
}
final Set<Class<?>> initialEntitySet = new HashSet<Class<?>>();
if (StringUtils.hasText(basePackage)) {
final ClassPathScanningCandidateComponentProvider componentProvider =
new ClassPathScanningCandidateComponentProvider(false);
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
for (final BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
initialEntitySet
.add(ClassUtils.forName(candidate.getBeanClassName(),
DocumentDbConfigurationSupport.class.getClassLoader()));
}
}
return initialEntitySet;
}
示例2: setup
import org.springframework.data.annotation.Persistent; //导入依赖的package包/类
@Before
public void setup() {
mappingContext = new DocumentDbMappingContext();
try {
mappingContext.setInitialEntitySet(new EntityScanner(this.applicationContext)
.scan(Persistent.class));
} catch (ClassNotFoundException e) {
throw new RuntimeException(e.getMessage());
}
dbConverter = new MappingDocumentDbConverter(mappingContext);
documentClient = new DocumentClient(documentDbUri, documentDbKey,
ConnectionPolicy.GetDefault(), ConsistencyLevel.Session);
dbTemplate = new DocumentDbTemplate(documentClient, dbConverter, TEST_DB_NAME);
dbTemplate.createCollectionIfNotExists(Person.class.getSimpleName(), null, null);
dbTemplate.insert(Person.class.getSimpleName(), TEST_PERSON, null);
}
示例3: getInititalEntityClasses
import org.springframework.data.annotation.Persistent; //导入依赖的package包/类
private static Set<String> getInititalEntityClasses(String[] domainPackages) {
if (ArrayUtils.isEmpty(domainPackages)) {
return null;
}
ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(false);
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class));
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
Set<String> classes = new ManagedSet<>();
for (String domainPackage : domainPackages) {
if (StringUtils.isBlank(domainPackage)) {
continue;
}
for (BeanDefinition candidate : componentProvider.findCandidateComponents(domainPackage)) {
classes.add(candidate.getBeanClassName());
}
}
return classes;
}
示例4: getInitialEntitySet
import org.springframework.data.annotation.Persistent; //导入依赖的package包/类
protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException {
String basePackage = getMappingBasePackage();
Set<Class<?>> initialEntitySet = new HashSet<Class<?>>();
if (StringUtils.hasText(basePackage)) {
ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(
false);
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class));
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
initialEntitySet.add(ClassUtils.forName(candidate.getBeanClassName(),
this.getClass().getClassLoader()));
}
}
return initialEntitySet;
}
开发者ID:gravitee-io,项目名称:graviteeio-access-management,代码行数:20,代码来源:AbstractRepositoryConfiguration.java
示例5: getInitialEntitySet
import org.springframework.data.annotation.Persistent; //导入依赖的package包/类
private Set<Class<?>> getInitialEntitySet(BeanFactory beanFactory)
throws ClassNotFoundException {
Set<Class<?>> entitySet = new HashSet<Class<?>>();
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
false);
scanner.setEnvironment(this.environment);
scanner.setResourceLoader(this.resourceLoader);
scanner.addIncludeFilter(new AnnotationTypeFilter(Document.class));
scanner.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
for (String basePackage : getMappingBasePackages(beanFactory)) {
if (StringUtils.hasText(basePackage)) {
for (BeanDefinition candidate : scanner
.findCandidateComponents(basePackage)) {
entitySet.add(ClassUtils.forName(candidate.getBeanClassName(),
this.classLoader));
}
}
}
return entitySet;
}
示例6: persist
import org.springframework.data.annotation.Persistent; //导入依赖的package包/类
@Override
public <T> T persist(T e) {
BeanProperty id = ReflectionUtils.getAnnotatedProperty(e, Id.class);
if (id == null) {
throw new IllegalArgumentException("The bean must have an @Id field");
}
List<BeanProperty> persistentProperties = ReflectionUtils
.getAnnotatedProperties(e, Persistent.class);
Property[] properties = new Property[persistentProperties.size() + 1];
properties[0] = new Property(e.getClass().getName() + ID_SUFFIX, id.getValue());
int i = 1;
for (BeanProperty property : persistentProperties) {
properties[i] = new Property(property.getName(), property.getValue());
i++;
}
Node node = template.createNode(properties);
index.index(node, e.getClass().getName() + ID_SUFFIX, id.getValue());
return e;
}
示例7: getInitialEntitySet
import org.springframework.data.annotation.Persistent; //导入依赖的package包/类
/**
* Scans the mapping base package for classes annotated with {@link Table}.
*
* @see #getMappingBasePackage()
* @return
* @throws ClassNotFoundException
*/
protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException {
String basePackage = getMappingBasePackage();
Set<Class<?>> initialEntitySet = new HashSet<>();
if (hasText(basePackage)) {
ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(false);
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Table.class));
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Persistent.class));
for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
initialEntitySet.add(ClassUtils.forName(candidate.getBeanClassName(), AbstractCrateConfiguration.class.getClassLoader()));
}
}
return initialEntitySet;
}
示例8: mongoMappingContext
import org.springframework.data.annotation.Persistent; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public MongoMappingContext mongoMappingContext(BeanFactory beanFactory, ApplicationContext applicationContext) throws ClassNotFoundException {
MongoMappingContext context = new MongoMappingContext();
context.setInitialEntitySet(new EntityScanner(applicationContext).scan(Document.class, Persistent.class));
return context;
}
示例9: mongoMappingContext
import org.springframework.data.annotation.Persistent; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public MongoMappingContext mongoMappingContext(BeanFactory beanFactory)
throws ClassNotFoundException {
MongoMappingContext context = new MongoMappingContext();
context.setInitialEntitySet(new EntityScanner(this.applicationContext)
.scan(Document.class, Persistent.class));
Class<?> strategyClass = this.properties.getFieldNamingStrategy();
if (strategyClass != null) {
context.setFieldNamingStrategy(
(FieldNamingStrategy) BeanUtils.instantiate(strategyClass));
}
return context;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:MongoDataAutoConfiguration.java
示例10: getIdentifyingAnnotations
import org.springframework.data.annotation.Persistent; //导入依赖的package包/类
@Override
protected Collection<Class<? extends Annotation>> getIdentifyingAnnotations() {
return Arrays.asList(Entity.class, Persistent.class);
}
示例11: getInitialEntitySet
import org.springframework.data.annotation.Persistent; //导入依赖的package包/类
@Override
protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException {
return new EntityScanner(this.applicationContext).scan(Document.class,
Persistent.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:6,代码来源:SpringBootCouchbaseDataConfiguration.java
示例12: isPersistentField
import org.springframework.data.annotation.Persistent; //导入依赖的package包/类
public static boolean isPersistentField(Field field) {
return field.isAnnotationPresent(Persistent.class);
}