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


Java ApplicationContext.getParent方法代码示例

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


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

示例1: extract

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
private Map<String, Object> extract(ApplicationContext context, ObjectMapper mapper) {
    Map<String, Object> result = new LinkedHashMap<>();
    ConfigurationBeanFactoryMetaData beanFactoryMetaData = getBeanFactoryMetaData(
            context);
    Map<String, Object> beans = getConfigurationPropertiesBeans(context,
            beanFactoryMetaData);
    for (Map.Entry<String, Object> entry : beans.entrySet()) {
        String beanName = entry.getKey();
        Object bean = entry.getValue();
        Map<String, Object> root = new LinkedHashMap<String, Object>();
        String prefix = extractPrefix(context, beanFactoryMetaData, beanName, bean);
        root.put("prefix", prefix);
        root.put("properties", sanitize(prefix, safeSerialize(mapper, bean, prefix)));
        result.put(beanName, root);
    }
    if (context.getParent() != null) {
        result.put("parent", extract(context.getParent(), mapper));
    }
    return result;
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:21,代码来源:Gatherer.java

示例2: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext)
		throws BeansException {
	Map<String,IWebservice> bindingsMap=applicationContext.getBeansOfType(IWebservice.class);
	if(applicationContext.getParent()!=null){
		bindingsMap.putAll(applicationContext.getParent().getBeansOfType(IWebservice.class));			
	}
	if(bindingsMap.size()>0){
		List<Class<?>> list=new ArrayList<Class<?>>();
		for(IWebservice binding:bindingsMap.values()){
			Class<?>[] c=binding.bindClasses();
			if(c!=null){
				for(Class<?> clazz:c){
					list.add(clazz);
				}
			}
		}
		if(list.size()>0){
			this.setClassesToBeBound(list.toArray(new Class<?>[list.size()]));							
		}else{
			this.setClassesToBeBound(new Class[]{String.class});
		}
	}else{
		this.setClassesToBeBound(new Class[]{String.class});			
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:26,代码来源:WSJaxb2Marshaller.java

示例3: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
	this.applicationContext = applicationContext;
	Map<String, HibernateSessionFactoryRepository> map = applicationContext
			.getBeansOfType(HibernateSessionFactoryRepository.class);
	if (map.size() > 0) {
		this.sessionFactoryRepository = map.values().iterator().next();
	} else if (applicationContext.getParent() != null) {
		map = applicationContext.getParent().getBeansOfType(HibernateSessionFactoryRepository.class);
		if (map.size() > 0) {
			this.sessionFactoryRepository = map.values().iterator().next();
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:14,代码来源:HibernateDao.java

示例4: initialize

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public void initialize(ApplicationContext applicationContext) throws Exception {
	logger.info(">>> 初始化应用中不依赖于Servlet环境的系统常量!");
	ApplicationContext rootApplicationContext = applicationContext;
   	if(applicationContext instanceof WebApplicationContext && applicationContext.getParent() != null){//如果当前applicationContext是容器环境下SpringMVC Application上下文 
   		rootApplicationContext = applicationContext.getParent();
   	}
   	setFinalFieldValue(ApplicationConstants.class, "APPLICATION_CONTEXT", rootApplicationContext);
   	SpringUtils.setApplicationContext(rootApplicationContext);
   	try {
		Messages.setMessageSource(rootApplicationContext.getBean(AbstractMessageSource.class));
	} catch (Exception e) {
		logger.error(e.getMessage());
	}
}
 
开发者ID:penggle,项目名称:xproject,代码行数:15,代码来源:ApplicationBootingInitializer.java

示例5: handleEvent

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
/**
 * Implementation of the spring event listener interface.
 *
 * @param event the spring event from the application
 */
@EventListener
public void handleEvent(ApplicationEvent event) {
    // checking for start up event
    // order of events is BrokerAvailabilityEvent -> ContextRefreshedEvent[parent=null] -> ContextRefreshedEvent[with non-null parent]
    // so wait until the latest event is received: ContextRefreshedEvent[with non-null parent]

    // skip the BrokerAvailabilityEvent, and ignore all other events (SessionConnectedEvent, ServletRequestHandledEvent, ContextClosedEvent, etc.)
    if (!(event instanceof ContextRefreshedEvent)) {
        LOGGER.debug("Expecting ContextRefreshedEvent. Skipping.");
        return;
    }

    LOGGER.info("Received ContextRefreshedEvent {}", event);

    ContextRefreshedEvent crEvent = (ContextRefreshedEvent) event;
    final ApplicationContext applicationContext = crEvent.getApplicationContext();
    // skip the ContextRefreshedEvent[parent=null] but check for non-null context first
    if (null == applicationContext) {
        LOGGER.debug("Expecting non-null ApplicationContext. Skipping.");
        return;
    }
    if (null == applicationContext.getParent()) {
        LOGGER.debug("Expecting non-null ApplicationContext parent. Skipping.");
        return;
    }

    processBootstrapConfiguration();
}
 
开发者ID:cerner,项目名称:jwala,代码行数:34,代码来源:ApplicationContextListener.java

示例6: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext)
		throws BeansException {
	interceptors=applicationContext.getBeansOfType(IWebServiceInterceptor.class).values();
	if(interceptors.size()==0 && applicationContext.getParent()!=null){
		interceptors=applicationContext.getParent().getBeansOfType(IWebServiceInterceptor.class).values();
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:8,代码来源:GenericWebServiceInterceptor.java

示例7: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext)
		throws BeansException {
	this.applicationContext=applicationContext;
	Collection<DataSourceRepository> dataSourceRepositoryCollection=applicationContext.getBeansOfType(DataSourceRepository.class).values();
	if(dataSourceRepositoryCollection.size()>0){
		this.dataSourceRepository=dataSourceRepositoryCollection.iterator().next();			
	}else if(applicationContext.getParent()!=null){
		dataSourceRepositoryCollection=applicationContext.getParent().getBeansOfType(DataSourceRepository.class).values();
		if(dataSourceRepositoryCollection.size()>0){
			this.dataSourceRepository=dataSourceRepositoryCollection.iterator().next();		
		}
	}
	this.dialects=applicationContext.getBeansOfType(IDialect.class).values();
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:15,代码来源:JdbcDao.java

示例8: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext)
		throws BeansException {
	this.applicationContext=applicationContext;
	Map<String,HibernateSessionFactoryRepository> map=applicationContext.getBeansOfType(HibernateSessionFactoryRepository.class);
	if(map.size()>0){
		this.sessionFactoryRepository = map.values().iterator().next();
	}else if(applicationContext.getParent()!=null){
		map=applicationContext.getParent().getBeansOfType(HibernateSessionFactoryRepository.class);
		if(map.size()>0){
			this.sessionFactoryRepository = map.values().iterator().next();				
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:14,代码来源:HibernateDao.java

示例9: walkContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
private <T> Collection<T> walkContext(Function<ApplicationContext, T> contextProcessor) {
	final List<T> result = new LinkedList<>();
	ApplicationContext currentContext = applicationContext;
	while (currentContext != null) {
		T processingResult = contextProcessor.apply(currentContext);
		currentContext = currentContext.getParent();

		result.add(processingResult);
	}

	return result;
}
 
开发者ID:pchudzik,项目名称:springmock,代码行数:13,代码来源:ApplicationContextWalker.java

示例10: setApplicationContext

import org.springframework.context.ApplicationContext; //导入方法依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
	//如果参数applicationContext是容器环境下SpringMVC Application上下文,则取其parent (ROOT)
	if(applicationContext instanceof WebApplicationContext && applicationContext.getParent() != null){ 
   		this.applicationContext = applicationContext.getParent();
   	}
}
 
开发者ID:penggle,项目名称:xproject,代码行数:7,代码来源:AbstractSpringTypedBeanManager.java


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