Java 类org.springframework.data.annotation.Persistent 实例源码

项目:spring-data-documentdb    文件:DocumentDbConfigurationSupport.java   
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;
}
项目:spring-data-documentdb    文件:DocumentDbTemplateIT.java   
@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);
}
项目:lodsve-framework    文件:MongoBeanDefinitionRegistrar.java   
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;
}
项目:graviteeio-access-management    文件:AbstractRepositoryConfiguration.java   
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;
    }
项目:spring-boot-concourse    文件:MongoDataAutoConfiguration.java   
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;
}
项目:contestparser    文件:MongoDataAutoConfiguration.java   
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;
}
项目:welshare    文件:BaseNeo4jDao.java   
@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;
}
项目:spring-data-crate    文件:AbstractCrateConfiguration.java   
/**
 * 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;
}
项目:spring-multitenancy    文件:MultitenancyAutoConfiguration.java   
@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;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MongoDataAutoConfiguration.java   
@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;
}
项目:spring-data-mybatis    文件:MybatisRepositoryConfigExtension.java   
@Override
protected Collection<Class<? extends Annotation>> getIdentifyingAnnotations() {
    return Arrays.asList(Entity.class, Persistent.class);

}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringBootCouchbaseDataConfiguration.java   
@Override
protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException {
    return new EntityScanner(this.applicationContext).scan(Document.class,
            Persistent.class);
}
项目:spring-data-simpledb    文件:ReflectionUtils.java   
public static boolean isPersistentField(Field field) {
    return field.isAnnotationPresent(Persistent.class);
}