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