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


Java ApplicationContext.getType方法代码示例

本文整理汇总了Java中org.springframework.context.ApplicationContext.getType方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationContext.getType方法的具体用法?Java ApplicationContext.getType怎么用?Java ApplicationContext.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.context.ApplicationContext的用法示例。


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

示例1: parseCacheDuration

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
private void parseCacheDuration(ApplicationContext applicationContext) {
    final Map<String, Long> cacheExpires = new HashMap<>();
    String[] beanNames = applicationContext.getBeanNamesForType(Object.class);
    for (String beanName : beanNames) {
        final Class clazz = applicationContext.getType(beanName);
        addCacheExpires(clazz, cacheExpires);
    }
    //设置有效期
    super.setExpires(cacheExpires);
}
 
开发者ID:DomKing,项目名称:busi-support,代码行数:11,代码来源:CustomerRedisCacheManager.java

示例2: parseCacheDuration

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
private void parseCacheDuration(ApplicationContext applicationContext) {
    final Map<String, Long> cacheExpires = new HashMap<>();
    String[] beanNames = applicationContext.getBeanNamesForType(Object.class);
    for (String beanName : beanNames) {
        final Class clazz = applicationContext.getType(beanName);
        Service service = findAnnotation(clazz, Service.class);
        if (null == service) {
            continue;
        }
        addCacheExpires(clazz, cacheExpires);
    }
    logger.debug("初始化redisCacheManager, 配置有过期时间的key, 内容如下:" + cacheExpires);
    //设置有效期
    super.setExpires(cacheExpires);
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:16,代码来源:CustomerRedisCacheManager.java

示例3: main

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public static void main(String args[]){
    ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"classpath:applicationContext-service.xml", "classpath:applicationContext-redis.xml"});
    String[] beanNames = ctx.getBeanDefinitionNames();
    int allBeansCount = ctx.getBeanDefinitionCount();
    System.out.println("所有beans的数量是:" + allBeansCount);
    for (String beanName : beanNames) {
        Class<?> beanType = ctx.getType(beanName);
        Package beanPackage = beanType.getPackage();
        //Object bean = ctx.getBean(beanName);
        System.out.println("BeanName:" + beanName);
        System.out.println("Bean的类型:" + beanType);
        System.out.println("Bean所在的包:" + beanPackage);
        System.out.println("\r\n");
    }
}
 
开发者ID:wanghan0501,项目名称:WiFiProbeAnalysis,代码行数:16,代码来源:ListBean.java

示例4: main

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public static void main(String args[]){
    ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"classpath:applicationContext-service.xml", "classpath:kafka-beans.xml"});
    String[] beanNames = ctx.getBeanDefinitionNames();
    int allBeansCount = ctx.getBeanDefinitionCount();
    System.out.println("所有beans的数量是:" + allBeansCount);
    for (String beanName : beanNames) {
        Class<?> beanType = ctx.getType(beanName);
        Package beanPackage = beanType.getPackage();
        //Object bean = ctx.getBean(beanName);
        System.out.println("BeanName:" + beanName);
        System.out.println("Bean的类型:" + beanType);
        System.out.println("Bean所在的包:" + beanPackage);
        System.out.println("\r\n");
    }
}
 
开发者ID:wanghan0501,项目名称:WiFiProbeAnalysis,代码行数:16,代码来源:ListBean.java


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