Example usage for org.springframework.context ConfigurableApplicationContext getBean

List of usage examples for org.springframework.context ConfigurableApplicationContext getBean

Introduction

In this page you can find the example usage for org.springframework.context ConfigurableApplicationContext getBean.

Prototype

Object getBean(String name) throws BeansException;

Source Link

Document

Return an instance, which may be shared or independent, of the specified bean.

Usage

From source file:org.s1p.app1.S1pKafkaApplication.java

public static void main(String[] args) {
    ConfigurableApplicationContext context = new SpringApplicationBuilder(S1pKafkaApplication.class).web(false)
            .run(args);//from ww w  .j  a va  2  s.c o m
    TestBean testBean = context.getBean(TestBean.class);
    testBean.send("foo");
}

From source file:com.rr.autobot1.Application.java

public static void main(String arg[]) {
    ConfigurableApplicationContext context = new SpringApplicationBuilder().sources(Application.class)
            .bannerMode(Banner.Mode.CONSOLE).run(arg);
    Application app = context.getBean(Application.class);
    app.start();//from ww  w . jav a  2 s . co  m
}

From source file:pkg.ContextEventHandlerMain.java

public static void main(String[] args) {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");

    // Let us raise a start event.
    context.start();//from w w w .  j a  v  a  2 s.  com

    HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
    obj.getMessage();

    // Let us raise a stop event.
    context.stop();

    /*
    ContextStartedEvent Received
    Your Message : Hello World!
    ContextStoppedEvent Received
    */
}

From source file:piazza.services.ingest.IngestServiceApplication.java

public static void main(String[] args) {

    ConfigurableApplicationContext context = SpringApplication.run(IngestServiceApplication.class, args); //NOSONAR
    //Controller cont = new Controller();
    try {/*from w  ww. j ava  2  s.  c om*/
        context.getBean(Controller.class).init();
        //cont.init();
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}

From source file:com.javiermoreno.springboot.mvc.users.App.java

public static void main(String[] args) {
    ConfigurableApplicationContext context = new SpringApplicationBuilder().showBanner(true).sources(App.class)
            .run(args);/*from   w  w  w .  ja v  a 2  s.c o  m*/

    UserManagementService userService = context.getBean(UserManagementService.class);

    for (int i = 0; i < 105; i++) {
        DailyUser user = new DailyUser(i + "_alice@wonderland.com", new Date());
        userService.registerNewUser(user, "secret-" + i, true);
    }
}

From source file:soap.client.Application.java

public static void main(String[] args) {
    ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args);
    TempConverter converter = ctx.getBean(TempConverter.class);

    GetCreditRate getCreditRate = new GetCreditRate();
    getCreditRate.setArg0(1000.00);/*from   w  ww  .ja  v a 2 s .co  m*/
    getCreditRate.setArg1(5);
    getCreditRate.setArg2("a");

    System.out.println("Result: " + converter.fahrenheitToCelcius(getCreditRate));
    ctx.close();
}

From source file:org.openmhealth.schema.configuration.Application.java

public static void main(String[] args) throws IOException, ProcessingException {

    ConfigurableApplicationContext applicationContext = SpringApplication.run(Application.class, args);

    Application application = applicationContext.getBean(Application.class);
    application.validateTestDataFiles();
}

From source file:com.ethercamp.harmony.Application.java

/**
 * Does one of:/*  w  w w.  j  a v  a 2  s.  c  o m*/
 * - start Harmony peer;
 * - perform action and exit on completion.
 */
public static void main(String[] args) throws Exception {
    final List<String> actions = asList("importBlocks");

    final Optional<String> foundAction = asList(args).stream().filter(arg -> actions.contains(arg)).findFirst();

    if (foundAction.isPresent()) {
        foundAction.ifPresent(action -> System.out.println("Performing action: " + action));
        Start.main(args);
        // system is expected to exit after action performed
    } else {
        if (!SystemProperties.getDefault().blocksLoader().equals("")) {
            SystemProperties.getDefault().setSyncEnabled(false);
            SystemProperties.getDefault().setDiscoveryEnabled(false);
        }

        ConfigurableApplicationContext context = SpringApplication.run(new Object[] { Application.class },
                args);

        Ethereum ethereum = context.getBean(Ethereum.class);

        if (!SystemProperties.getDefault().blocksLoader().equals("")) {
            ethereum.getBlockLoader().loadBlocks();
        }
    }
}

From source file:org.jimsey.projects.turbine.condenser.Application.java

public static void main(final String... args) {
    ConfigurableApplicationContext spring = SpringApplication.run(Application.class, args);

    // logBeanNames(spring);
    Ping ping = (Ping) spring.getBean("ping");
    long message = ping.ping();
    logger.info(String.format("ping=%s", message));
}

From source file:com.zbum.example.socket.server.Application.java

public static void main(String[] args) throws Exception {
    ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
    TCPServer tcpServer = context.getBean(TCPServer.class);
    tcpServer.start();//from w w  w . j a va  2s  .c  o m

}