當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。