Java Code Examples for org.springframework.context.ApplicationContext.getType()

The following are Jave code examples for showing how to use getType() of the org.springframework.context.ApplicationContext class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: busi-support   File: CustomerRedisCacheManager.java   View Source Code Vote up 6 votes
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);
}
 
Example 2
Project: springbootWeb   File: CustomerRedisCacheManager.java   View Source Code Vote up 6 votes
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);
}
 
Example 3
Project: WiFiProbeAnalysis   File: ListBean.java   View Source Code Vote up 5 votes
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");
    }
}
 
Example 4
Project: WiFiProbeAnalysis   File: ListBean.java   View Source Code Vote up 5 votes
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");
    }
}