org.springframework.context.annotation.AnnotationConfigApplicationContext#start ( )源码实例Demo

下面列出了org.springframework.context.annotation.AnnotationConfigApplicationContext#start ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: j360-dubbo-app-all   文件: ApplicationBootstrap.java
public static void main(String[] args) throws InterruptedException {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfiguration.class);
    context.start();

    UserRepository userRepository = (UserRepository) context.getBean("userRepository");
    CacheConfiguration cacheConfiguration = (CacheConfiguration) context.getBean("cacheConfiguration");

    while (true) {
        String name = userRepository.getUserCacheable(1L);
        System.out.println(String.format("name=%s", name));

        System.out.println(String.format("timeout=%s", cacheConfiguration.getTimeout()));
        TimeUnit.SECONDS.sleep(5);
    }

}
 
源代码2 项目: spring-vertx-ext   文件: SpringVerticleFactory.java
private static void addPostprocessorAndUpdateContext(Class<?> currentVerticleClass,
    AnnotationConfigApplicationContext annotationConfigApplicationContext) {
    annotationConfigApplicationContext.addBeanFactoryPostProcessor(new SpringSingleVerticleConfiguration(currentVerticleClass));
    annotationConfigApplicationContext.refresh();
    annotationConfigApplicationContext.start();
    annotationConfigApplicationContext.registerShutdownHook();
}
 
源代码3 项目: dubbo-2.6.5   文件: AnnotationConsumer.java
public static void main(String[] args) throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
    context.start();
    final AnnotationAction annotationAction = (AnnotationAction) context.getBean("annotationAction");
    String hello = annotationAction.doSayHello("world");
    System.out.println("result :" + hello);
    System.in.read();
}
 
源代码4 项目: dubbox   文件: JavaConfigContainer.java
public void start() {
    String configPath = ConfigUtils.getProperty(SPRING_JAVACONFIG);
    if (configPath == null || configPath.length() == 0) {
        configPath = DEFAULT_SPRING_JAVACONFIG;
    }
    context = new AnnotationConfigApplicationContext(configPath);
    context.start();
}
 
源代码5 项目: dubbo-samples   文件: ProviderBootstrap.java
public static void main(String[] args) throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
    context.start();

    System.out.println("dubbo service started");
    new CountDownLatch(1).await();
}
 
源代码6 项目: dubbox   文件: JavaConfigContainer.java
public void start() {
    String configPath = ConfigUtils.getProperty(SPRING_JAVACONFIG);
    if (configPath == null || configPath.length() == 0) {
        configPath = DEFAULT_SPRING_JAVACONFIG;
    }
    context = new AnnotationConfigApplicationContext(configPath);
    context.start();
}
 
public static void main(String[] args) throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
    context.start();

    AnnotationAction annotationAction = context.getBean("annotationAction", AnnotationAction.class);
    printServiceData();

    String hello = annotationAction.doSayHello("world");
    System.out.println("result :" + hello);
}
 
public static void main(String[] args) throws Exception {
    new EmbeddedZooKeeper(2181, false).start();

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
    context.start();

    System.out.println("dubbo service started");
    new CountDownLatch(1).await();
}
 
public static void main(String[] args) throws Exception {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();

        AnnotationAction annotationAction = (AnnotationAction) context.getBean("annotationAction");
        String hello = annotationAction.doSayHello("world");
        System.out.println("result :" + hello);
//        annotationAction.sayCircuitBreaker("circuitBreaker");
        annotationAction.sayRateLimiter("rateLimiter", "Just Happy!");
    }
 
public static void main(String[] args) throws Exception {
    new EmbeddedZooKeeper(2181, false).start();

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
    context.start();

    printServiceData();

    System.out.println("dubbo service started");
    new CountDownLatch(1).await();
}
 
public static void main(String[] args) throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
    context.start();

    printServiceData();

    AnnotationAction annotationAction = context.getBean("annotationAction", AnnotationAction.class);
    String hello = annotationAction.doSayHello("world");
    System.out.println("result :" + hello);
}
 
源代码12 项目: dubbox   文件: JavaConfigContainer.java
public void start() {
    String configPath = ConfigUtils.getProperty(SPRING_JAVACONFIG);
    if (configPath == null || configPath.length() == 0) {
        configPath = DEFAULT_SPRING_JAVACONFIG;
    }
    context = new AnnotationConfigApplicationContext(configPath);
    context.start();
}
 
public static void main(String[] args) throws Exception {
    new EmbeddedZooKeeper(2181, false).start();
    ZKTools.generateDubboProperties();

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
    context.start();

    printServiceData();

    System.out.println("dubbo service started");
    new CountDownLatch(1).await();
}
 
源代码14 项目: dubbo-samples   文件: AnnotationProvider.java
public static void main(String[] args) throws Exception {
    new EmbeddedZooKeeper(2181, false).start();

    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
    context.start();

    System.out.println("dubbo service started");
}
 
源代码15 项目: ShedLock   文件: AopCleanupTest.java
@Test
public void shouldCloseTaskExecutor() {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
    context.start();
    context.close();
    assertThat(context.isActive()).isFalse();
}
 
源代码16 项目: chassis   文件: MetadataCollectorTest.java
@Before
public void setup() {
    ConfigurationManager.getConfigInstance().setProperty("chassis.eureka.disable","true");
    ConfigurationManager.getConfigInstance().setProperty("eureka.metadata.prop1", "propValue");
    ConfigurationManager.getConfigInstance().setProperty("eureka.datacenter", "default");

    StandardEnvironment environment = new StandardEnvironment();
    environment.getPropertySources().addFirst(new ArchaiusSpringPropertySource());
    context = new AnnotationConfigApplicationContext();
    context.setEnvironment(environment);
    context.register(MetadataCollectorConfiguration.class);
    context.refresh();
    context.start();
}
 
源代码17 项目: dubbo-samples   文件: AnnotationConsumer.java
public static void main(String[] args) throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
    context.start();
    final AnnotationAction annotationAction = (AnnotationAction) context.getBean("annotationAction");
    String hello = annotationAction.doSayHello("world");
    System.out.println("result :" + hello);
}
 
源代码18 项目: j360-dubbo-app-all   文件: ApplicationBootstrap.java
public static void main(String[] args) throws InterruptedException {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfiguration.class);
    context.start();

    log.info("service started successfully!");
    Runtime.getRuntime().addShutdownHook(new Thread(){
        @Override
        public void run() {
            log.info("Shutdown hook was invoked. Shutting down Service.");
            context.close();
        }
    });
    CountDownLatch countDownLatch = new CountDownLatch(1);
    countDownLatch.await();
}
 
源代码19 项目: dubbo-samples   文件: AnnotationConsumer.java
public static void main(String[] args) throws Exception {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
    context.start();
    final AnnotationAction annotationAction = (AnnotationAction) context.getBean("annotationAction");
    String hello = annotationAction.doSayHello("world");
    System.out.println("result: " + hello);
}
 
源代码20 项目: dubbo-samples   文件: ConsumerBootstrap.java
public static void main(String[] args) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
    context.start();
    GreetingServiceConsumer greetingServiceConsumer = context.getBean(GreetingServiceConsumer.class);
    String hello = greetingServiceConsumer.doSayHello("nacos");
    System.out.println("result: " + hello);
}