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

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

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

ContextRefreshedEvent.getSource介绍

暂无

代码示例

代码示例来源: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: Kixeye/chassis

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  logger.debug("Received ContextRefreshedEvent {}", event);
  if (event.getSource().equals(getBootstrapApplicationContext())) {
    //the root context is fully started
    appMetadata = bootstrapApplicationContext.getBean(AppMetadata.class);
    configuration = bootstrapApplicationContext.getBean(AbstractConfiguration.class);
    configurationProvider = bootstrapApplicationContext.getBean(ConfigurationProvider.class);
    logger.debug("Root context started");
    initClientApplication();
    return;
  }
  if (event.getSource() instanceof ApplicationContext && ((ApplicationContext) event.getSource()).getId().equals(appMetadata.getName())) {
    //the child context is fully started
    this.applicationContext = (AbstractApplicationContext) event.getSource();
    logger.debug("Child context started");
  }
  state.compareAndSet(State.STARTING, State.RUNNING);
}

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

@Override
  public void onApplicationEvent(ContextRefreshedEvent event) {
    ConfigurableApplicationContext source = (ConfigurableApplicationContext) event.getSource();
    if (source == this.applicationContext && !source.isRunning()) {
      source.start();
    }
  }
}

代码示例来源:origin: io.macgyver/macgyver-core

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  try {
  if (kernel.getApplicationContext() != event.getSource()) {
    return;
  }
  logger.info("STARTED: {}", event);
  
  registry.startAfterSpringContextInitialized();
  runInitScripts();
  }
  catch (IOException e) {
    throw new MacGyverException(e);
  }
  
}

代码示例来源:origin: ralscha/extdirectspring

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
  ApplicationContext context = (ApplicationContext) event.getSource();

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

public void onApplicationEvent(ContextRefreshedEvent event) {
  this.exportProperties.clear();
  ConfigurableApplicationContext ctx = (ConfigurableApplicationContext) event.getSource();
  ConfigurableEnvironment environment = ctx.getEnvironment();
  BeanExpressionResolver beanExpressionResolver = ctx.getBeanFactory().getBeanExpressionResolver();

相关文章

微信公众号

最新文章

更多