当前位置: 首页>>代码示例>>Java>>正文


Java Repository类代码示例

本文整理汇总了Java中org.springframework.stereotype.Repository的典型用法代码示例。如果您正苦于以下问题:Java Repository类的具体用法?Java Repository怎么用?Java Repository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Repository类属于org.springframework.stereotype包,在下文中一共展示了Repository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBeanName

import org.springframework.stereotype.Repository; //导入依赖的package包/类
private String getBeanName(Class<?> clazz) {
    Component component = clazz.getAnnotation(Component.class);
    if (component != null)
        return component.value();

    Repository repository = clazz.getAnnotation(Repository.class);
    if (repository != null)
        return repository.value();

    Service service = clazz.getAnnotation(Service.class);
    if (service != null)
        return service.value();

    Controller controller = clazz.getAnnotation(Controller.class);
    if (controller != null)
        return controller.value();

    return null;
}
 
开发者ID:heisedebaise,项目名称:tephra,代码行数:20,代码来源:ClassReloaderImpl.java

示例2: postProcessBeforeInitialization

import org.springframework.stereotype.Repository; //导入依赖的package包/类
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
    Repository annotation = AnnotationUtils.findAnnotation(bean.getClass(), Repository.class);
    if (annotation == null) {
        return bean;
    }
    Class<?> supperClass = bean.getClass().getSuperclass();
    if (!LodsveMongoRepository.class.equals(supperClass)) {
        return bean;
    }

    Class<?> domainClass = GenericUtils.getGenericParameter0(bean.getClass());
    MongoRepositoryFactory repositoryFactory = context.getBean(MongoRepositoryFactory.class);
    MongoEntityInformation information = repositoryFactory.getEntityInformation(domainClass);

    BeanWrapper beanWrapper = new BeanWrapperImpl(bean);
    beanWrapper.setPropertyValue("entityInformation", information);

    return bean;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:21,代码来源:MongoRepositoryBeanPostProcessor.java

示例3: resetAndReconfigure

import org.springframework.stereotype.Repository; //导入依赖的package包/类
public void resetAndReconfigure(boolean debug) {
    SingularContextSetup.reset();
    ApplicationContextMock applicationContext = new ApplicationContextMock();
    ServiceRegistryLocator.setup(new SpringServiceRegistry());
    new ApplicationContextProvider().setApplicationContext(applicationContext);
    registerBeanFactories(applicationContext);
    registerAnnotated(applicationContext, Named.class);
    registerAnnotated(applicationContext, Service.class);
    registerAnnotated(applicationContext, Component.class);
    registerAnnotated(applicationContext, Repository.class);
    registerMockitoTestClassMocksAndSpies(applicationContext);
    getLogger().info("Contexto configurado com os beans: ");
    if (debug) {
        applicationContext.listAllBeans().forEach(
                b -> getLogger().info(b)
        );
    }
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:19,代码来源:SingularServerSpringMockitoTestConfig.java

示例4: getBeanName

import org.springframework.stereotype.Repository; //导入依赖的package包/类
private String getBeanName(final Class<?> clazz) {
    
    final Component componentAnno = clazz.getAnnotation(Component.class);
    if(componentAnno != null && !componentAnno.value().isEmpty()) {
        return componentAnno.value();
    }
    
    final Service serviceAnno = clazz.getAnnotation(Service.class);
    if(serviceAnno != null && !serviceAnno.value().isEmpty()) {
        return serviceAnno.value();
    }
    
    final Repository repositoryAnno = clazz.getAnnotation(Repository.class);
    if(repositoryAnno != null && !repositoryAnno.value().isEmpty()) {
        return repositoryAnno.value();
    }
    
    final Controller controllerAnno = clazz.getAnnotation(Controller.class);
    if(controllerAnno != null && !controllerAnno.value().isEmpty()) {
        return controllerAnno.value();
    }
    
    // ステレオタイプのアノテーションでBean名の指定がない場合は、クラス名の先頭を小文字にした名称とする。
    return uncapitalize(clazz.getSimpleName());
}
 
开发者ID:mygreen,项目名称:super-csv-annotation,代码行数:26,代码来源:SpringBeanFactory.java

示例5: getSpringClassAnnotation

import org.springframework.stereotype.Repository; //导入依赖的package包/类
private Annotation getSpringClassAnnotation(Class clazz) {
    Annotation classAnnotation = AnnotationUtils.findAnnotation(clazz, Component.class);

    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Controller.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, RestController.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Service.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Repository.class);
    }

    return classAnnotation;
}
 
开发者ID:exteso,项目名称:parkingfriends,代码行数:19,代码来源:SpringReloader.java

示例6: DwrClassPathBeanDefinitionScanner

import org.springframework.stereotype.Repository; //导入依赖的package包/类
public DwrClassPathBeanDefinitionScanner(BeanDefinitionRegistry registry)
{
    super(registry, false);
    addExcludeFilter(new AnnotationTypeFilter(Component.class));
    addExcludeFilter(new AnnotationTypeFilter(Service.class));
    addExcludeFilter(new AnnotationTypeFilter(Repository.class));
    addExcludeFilter(new AnnotationTypeFilter(Controller.class));
    setScopedProxyMode(ScopedProxyMode.INTERFACES);
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:10,代码来源:DwrClassPathBeanDefinitionScanner.java

示例7: copyE5Data

import org.springframework.stereotype.Repository; //导入依赖的package包/类
private URI copyE5Data(URI contextUri, EntityManager em) {
    final URI targetContext = generateContextUri();
    try {
        final org.eclipse.rdf4j.repository.Repository targetRepository = em
                .unwrap(org.eclipse.rdf4j.repository.Repository.class);
        try (final RepositoryConnection targetConnection = targetRepository.getConnection()) {
            targetConnection.begin();
            dataDao.getRepositoryData(contextUri, new StatementCopyingHandler(targetConnection, targetContext));
            targetConnection.commit();
        }
    } catch (RepositoryException e) {
        LOG.error("Unable to copy E5Data.", e);
    }
    return targetContext;
}
 
开发者ID:kbss-cvut,项目名称:reporting-tool,代码行数:16,代码来源:OccurrenceReportFormGenDao.java

示例8: testWithComponentAnnotationOnly

import org.springframework.stereotype.Repository; //导入依赖的package包/类
@Test
public void testWithComponentAnnotationOnly() {
	ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
	provider.addIncludeFilter(new AnnotationTypeFilter(Component.class));
	provider.addExcludeFilter(new AnnotationTypeFilter(Repository.class));
	provider.addExcludeFilter(new AnnotationTypeFilter(Service.class));
	provider.addExcludeFilter(new AnnotationTypeFilter(Controller.class));
	Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_BASE_PACKAGE);
	assertEquals(2, candidates.size());
	assertTrue(containsBeanClass(candidates, NamedComponent.class));
	assertTrue(containsBeanClass(candidates, ServiceInvocationCounter.class));
	assertFalse(containsBeanClass(candidates, FooServiceImpl.class));
	assertFalse(containsBeanClass(candidates, StubFooDao.class));
	assertFalse(containsBeanClass(candidates, NamedStubDao.class));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:ClassPathScanningCandidateComponentProviderTests.java

示例9: addPersistenceExceptionTranslation

import org.springframework.stereotype.Repository; //导入依赖的package包/类
@Override
protected void addPersistenceExceptionTranslation(ProxyFactory pf, PersistenceExceptionTranslator pet) {
	if (AnnotationUtils.findAnnotation(pf.getTargetClass(), Repository.class) != null) {
		DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
		bf.registerBeanDefinition("peti", new RootBeanDefinition(PersistenceExceptionTranslationInterceptor.class));
		bf.registerSingleton("pet", pet);
		pf.addAdvice((PersistenceExceptionTranslationInterceptor) bf.getBean("peti"));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:PersistenceExceptionTranslationInterceptorTests.java

示例10: getRepositoryId

import org.springframework.stereotype.Repository; //导入依赖的package包/类
public static String getRepositoryId(Annotation[] annotations) {
	String repoId = "";
	if (annotations == null) {
		return repoId;
	}
	for (Annotation anno : annotations) {
		if (anno instanceof Repository) {
			repoId = ((Repository)anno).value();
		}
	}
	return repoId;
}
 
开发者ID:billchen198318,项目名称:bamboobsc,代码行数:13,代码来源:AspectConstants.java

示例11: getTargetType

import org.springframework.stereotype.Repository; //导入依赖的package包/类
private String getTargetType(MethodInvocation methodInvocation) {

        Class<?> targetType = methodInvocation.getThis().getClass();

        if (hasAnnotation(targetType, Controller.class)) {
            return "Controller";
        } else if (hasAnnotation(targetType, Service.class)) {
            return "Service";
        } else if (hasAnnotation(targetType, Repository.class)) {
            return "Repository";
        } else {
            return "Trace";
        }
    }
 
开发者ID:acupple,项目名称:stormv-spring-tracer,代码行数:15,代码来源:TraceAopInterceptor.java

示例12: getSpringClassAnnotation

import org.springframework.stereotype.Repository; //导入依赖的package包/类
private Annotation getSpringClassAnnotation(Class clazz){
    Annotation classAnnotation = AnnotationUtils.findAnnotation(clazz, Component.class);

    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Controller.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Service.class);
    }
    if (classAnnotation == null) {
        classAnnotation = AnnotationUtils.findAnnotation(clazz, Repository.class);
    }

    return classAnnotation;
}
 
开发者ID:nithril,项目名称:spring-loaded-spring-plugin,代码行数:16,代码来源:ReloadPlugin.java

示例13: getRepostoryGenericInterfaces

import org.springframework.stereotype.Repository; //导入依赖的package包/类
private Type[] getRepostoryGenericInterfaces(final RepositoryMetadata metadata) {
    final Type[] repositoryGenericInterfaces = metadata.getRepositoryInterface().getGenericInterfaces();
    if (repositoryGenericInterfaces.length < 1) {
        throw new RuntimeException("Don't recognize " + metadata.getRepositoryInterface() + " as a Repository (does it extend " + Repository.class.getName() + "?)");
    }
    return repositoryGenericInterfaces;
}
 
开发者ID:jelford,项目名称:richobjects,代码行数:8,代码来源:RichObjectRepositoryFactory.java

示例14: findMyBatisBeanDefinitions

import org.springframework.stereotype.Repository; //导入依赖的package包/类
private Map<String, BeanDefinition> findMyBatisBeanDefinitions() {
    String[] enumsLocations = attributes.getStringArray(Constant.ENUMS_LOCATIONS_ATTRIBUTE_NAME);
    String[] basePackages = attributes.getStringArray(Constant.BASE_PACKAGES_ATTRIBUTE_NAME);
    AnnotationAttributes[] plugins = attributes.getAnnotationArray(Constant.PLUGINS_ATTRIBUTE_NAME);

    if (ArrayUtils.isEmpty(enumsLocations)) {
        enumsLocations = findDefaultPackage(metadata);
    }
    if (ArrayUtils.isEmpty(basePackages)) {
        basePackages = findDefaultPackage(metadata);
    }

    Map<String, BeanDefinition> beanDefinitions = new HashMap<>(16);

    BeanDefinitionBuilder sqlSessionFactoryBean = BeanDefinitionBuilder.genericBeanDefinition(SqlSessionFactoryBean.class);

    if (useFlyway) {
        sqlSessionFactoryBean.addDependsOn(Constant.FLYWAY_BEAN_NAME);
    }

    sqlSessionFactoryBean.addPropertyReference("dataSource", Constant.DATA_SOURCE_BEAN_NAME);
    sqlSessionFactoryBean.addPropertyValue("mapperLocations", "classpath*:/META-INF/mybatis/**/*Mapper.xml");
    sqlSessionFactoryBean.addPropertyValue("configLocation", "classpath:/META-INF/mybatis/mybatis.xml");
    TypeHandlerScanner scanner = new TypeHandlerScanner();
    sqlSessionFactoryBean.addPropertyValue("typeHandlers", scanner.find(StringUtils.join(enumsLocations, ",")));
    List<Interceptor> pluginsList = new ArrayList<>(plugins.length);
    List<Class<? extends Interceptor>> clazz = new ArrayList<>(plugins.length);
    for (AnnotationAttributes plugin : plugins) {
        Class<? extends Interceptor> pluginClass = plugin.getClass("value");
        AnnotationAttributes[] params = plugin.getAnnotationArray("params");

        clazz.add(pluginClass);
        Interceptor interceptor = BeanUtils.instantiate(pluginClass);
        BeanWrapper beanWrapper = new BeanWrapperImpl(interceptor);
        for (AnnotationAttributes param : params) {
            String key = param.getString("key");
            String value = param.getString("value");

            PropertyDescriptor descriptor = beanWrapper.getPropertyDescriptor(key);
            Method writeMethod = descriptor.getWriteMethod();
            Method readMethod = descriptor.getReadMethod();
            writeMethod.setAccessible(true);
            try {
                Class<?> returnType = readMethod.getReturnType();
                Object valueObject = value;
                if (Integer.class.equals(returnType) || int.class.equals(returnType)) {
                    valueObject = Integer.valueOf(value);
                } else if (Long.class.equals(returnType) || long.class.equals(returnType)) {
                    valueObject = Long.valueOf(value);
                } else if (Boolean.class.equals(returnType) || boolean.class.equals(returnType)) {
                    valueObject = Boolean.valueOf(value);
                } else if (Double.class.equals(returnType) || double.class.equals(returnType)) {
                    valueObject = Double.valueOf(value);
                }

                writeMethod.invoke(interceptor, valueObject);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        pluginsList.add(interceptor);
    }
    if (!clazz.contains(PaginationInterceptor.class)) {
        pluginsList.add(BeanUtils.instantiate(PaginationInterceptor.class));
    }

    sqlSessionFactoryBean.addPropertyValue("plugins", pluginsList);

    BeanDefinitionBuilder scannerConfigurerBean = BeanDefinitionBuilder.genericBeanDefinition(MapperScannerConfigurer.class);
    scannerConfigurerBean.addPropertyValue("basePackage", StringUtils.join(basePackages, ","));
    scannerConfigurerBean.addPropertyValue("annotationClass", Repository.class);
    scannerConfigurerBean.addPropertyValue("sqlSessionFactoryBeanName", "sqlSessionFactory");

    beanDefinitions.put("sqlSessionFactory", sqlSessionFactoryBean.getBeanDefinition());
    beanDefinitions.put("mapperScannerConfigurer", scannerConfigurerBean.getBeanDefinition());

    return beanDefinitions;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:80,代码来源:MyBatisConfigurationBuilder.java

示例15: addPersistenceExceptionTranslation

import org.springframework.stereotype.Repository; //导入依赖的package包/类
protected void addPersistenceExceptionTranslation(ProxyFactory pf, PersistenceExceptionTranslator pet) {
	pf.addAdvisor(new PersistenceExceptionTranslationAdvisor(pet, Repository.class));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:PersistenceExceptionTranslationAdvisorTests.java


注:本文中的org.springframework.stereotype.Repository类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。