本文整理汇总了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);
}
示例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);
}
示例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");
}
}
示例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");
}
}