org.springframework.context.event.ContextRefreshedEvent.getApplicationContext()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中org.springframework.context.event.ContextRefreshedEvent.getApplicationContext()方法的一些代码示例,展示了ContextRefreshedEvent.getApplicationContext()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ContextRefreshedEvent.getApplicationContext()方法的具体详情如下:
包路径:org.springframework.context.event.ContextRefreshedEvent
类名称:ContextRefreshedEvent
方法名:getApplicationContext

ContextRefreshedEvent.getApplicationContext介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  if (event.getApplicationContext() == this.applicationContext) {
    this.contextRefreshed = true;
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Callback that receives refresh events from this servlet's WebApplicationContext.
 * <p>The default implementation calls {@link #onRefresh},
 * triggering a refresh of this servlet's context-dependent state.
 * @param event the incoming ApplicationContext event
 */
public void onApplicationEvent(ContextRefreshedEvent event) {
  this.refreshEventReceived = true;
  synchronized (this.onRefreshMonitor) {
    onRefresh(event.getApplicationContext());
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  if (event.getApplicationContext() == this.applicationContext) {
    // Running in an ApplicationContext -> register tasks this late...
    // giving other ContextRefreshedEvent listeners a chance to perform
    // their work at the same time (e.g. Spring Batch's job registration).
    finishRegistration();
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  if (this.handlerMap.isEmpty()) {
    detectResourceHandlers(event.getApplicationContext());
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  if (isAutodetect()) {
    this.handlerMap.clear();
    detectResourceHandlers(event.getApplicationContext());
    if (!this.handlerMap.isEmpty()) {
      this.autodetect = false;
    }
  }
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

@EventListener(ContextRefreshedEvent.class)
public void init(ContextRefreshedEvent event) {
  try {
    springSecurity = (FilterChainProxy) event.getApplicationContext().getBean("springSecurityFilterChain");
  } catch (BeansException e) {
    //do nothing
  }
}

代码示例来源:origin: org.springframework/spring-context

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  if (event.getApplicationContext() == this.applicationContext) {
    // Running in an ApplicationContext -> register tasks this late...
    // giving other ContextRefreshedEvent listeners a chance to perform
    // their work at the same time (e.g. Spring Batch's job registration).
    finishRegistration();
  }
}

代码示例来源:origin: spring-cloud-incubator/spring-cloud-alibaba

@Override
public void handleEvent(ContextRefreshedEvent event) {
  ApplicationContext applicationContext = event.getApplicationContext();
  AliCloudProperties aliCloudProperties = applicationContext
      .getBean(AliCloudProperties.class);
  EdasProperties edasProperties = applicationContext.getBean(EdasProperties.class);
  AnsProperties ansProperties = applicationContext.getBean(AnsProperties.class);
  AliCloudEdasSdk aliCloudEdasSdk = applicationContext
      .getBean(AliCloudEdasSdk.class);
  AliCloudAnsInitializer.initialize(aliCloudProperties, edasProperties,
      ansProperties, aliCloudEdasSdk);
}

代码示例来源:origin: org.springframework/spring-webmvc

/**
 * Callback that receives refresh events from this servlet's WebApplicationContext.
 * <p>The default implementation calls {@link #onRefresh},
 * triggering a refresh of this servlet's context-dependent state.
 * @param event the incoming ApplicationContext event
 */
public void onApplicationEvent(ContextRefreshedEvent event) {
  this.refreshEventReceived = true;
  synchronized (this.onRefreshMonitor) {
    onRefresh(event.getApplicationContext());
  }
}

代码示例来源:origin: shuzheng/zheng

@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
  if(null == contextRefreshedEvent.getApplicationContext().getParent()) {
    LOGGER.debug(">>>>> spring初始化完毕 <<<<<");
    Map<String, Object> baseServices = contextRefreshedEvent.getApplicationContext().getBeansWithAnnotation(BaseService.class);
    for(Object service : baseServices.values()) {
      LOGGER.debug(">>>>> {}.initMapper()", service.getClass().getName());
    Map<String, BaseInterface> baseInterfaceBeans = contextRefreshedEvent.getApplicationContext().getBeansOfType(BaseInterface.class);
    for(Object service : baseInterfaceBeans.values()) {
      LOGGER.debug(">>>>> {}.init()", service.getClass().getName());

代码示例来源:origin: org.springframework/spring-webmvc

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  if (isAutodetect()) {
    this.handlerMap.clear();
    detectResourceHandlers(event.getApplicationContext());
    if (!this.handlerMap.isEmpty()) {
      this.autodetect = false;
    }
  }
}

代码示例来源:origin: changmingxie/tcc-transaction

@Override
  public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
    ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext();

    if (applicationContext.getParent() == null) {
      FactoryBuilder.registerBeanFactory(applicationContext.getBean(BeanFactory.class));
    }
  }
}

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

@Override
public void onApplicationEvent(ApplicationEvent event) {
  if (event instanceof ContextRefreshedEvent) {
    if (log.isDebugEnabled()) {
      log.debug("Context successfully refreshed");
    }
    ContextRefreshedEvent contextRefreshedEvent = (ContextRefreshedEvent) event;
    ApplicationContext context = contextRefreshedEvent.getApplicationContext();
    BeanFactory beanFactory = context;
    if (context instanceof ConfigurableApplicationContext) {
      beanFactory = ((ConfigurableApplicationContext) context).getBeanFactory();
    }
    ContextRefreshedListener listener = CACHE.getOrDefault(beanFactory, this);
    listener.set(true);
    CACHE.put(beanFactory, listener);
  }
}

代码示例来源:origin: org.springframework.boot/spring-boot

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  ApplicationContext context = event.getApplicationContext();
  if (context instanceof ConfigurableApplicationContext
      && context == event.getSource()) {
    context.publishEvent(new ParentContextAvailableEvent(
        (ConfigurableApplicationContext) context));
  }
}

代码示例来源:origin: stackoverflow.com

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  if (event.getApplicationContext() == this.applicationContext) {
    try {
      scheduler.clear();

代码示例来源:origin: zhegexiaohuozi/SeimiCrawler

ApplicationContext context = event.getApplicationContext();
if (isSpringBoot){
  CrawlerProperties crawlerProperties = context.getBean(CrawlerProperties.class);

代码示例来源:origin: spring-projects/spring-kafka

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  if (event.getApplicationContext().equals(this.applicationContext)) {
    this.contextRefreshed = true;
  }
}

代码示例来源:origin: gocd/gocd

@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
  if (!isRootApplicationContext(contextRefreshedEvent.getApplicationContext())) {
    return;

代码示例来源:origin: spring-projects/spring-integration

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  if (event.getApplicationContext().equals(this.applicationContext)) {
    buildGraph();
  }
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-context

public void start(ContextRefreshedEvent event) {
  if (event.getApplicationContext() == this.context && this.eager
      && this.registry != null) {
    eagerlyInitialize();
  }
}

相关文章

微信公众号

最新文章

更多