本文整理匯總了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");
}
}