Example usage for org.springframework.context ApplicationContext getBean

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

Introduction

In this page you can find the example usage for org.springframework.context ApplicationContext 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:com.spring.tutorial.configuration.beansconfig.javaconfig.App.java

public static void main(String[] args) {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
    Foo foo = ctx.getBean(Foo.class);
    ((AnnotationConfigApplicationContext) ctx).close();
}

From source file:DanielPractice.MainApp.java

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

    App obj = (App) context.getBean("helloWorld");

    obj.getMessage();//  w  ww  .  j  a  v a2  s  .  c  o  m
}

From source file:com.mycompany.dao.StudentManager.java

public static void main(String[] args) {

    ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
    Student std = (Student) context.getBean("student");
    std.displayStudent();//w  w  w .  j  a  va2  s .c  o m

}

From source file:org.ala.lucene.OptimizeIndex.java

public static void main(String[] args) throws Exception {
    ApplicationContext context = SpringUtils.getContext();
    SolrUtils solrUtils = (SolrUtils) context.getBean(SolrUtils.class);
    solrUtils.getSolrServer().optimize();
    System.exit(0);/*from  ww w . j  a v  a 2 s  .com*/
}

From source file:com.mycompany.texteditorinnerbean.MainApp.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
    TextEditor te = (TextEditor) context.getBean("textEditor");
    te.spellCheck();// w  ww  . jav  a2 s .  c  om
}

From source file:com.mc.SpringEventHandling.java

/**
 * @param args the command line arguments
 *///  www  .  jav  a2  s.  c  o  m
public static void main(String[] args) {
    // TODO code application logic here
    ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
    Shape shape = (Shape) context.getBean("circleId");
    shape.draw();

}

From source file:com.rationaldevelopers.oss.Application.java

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

    log.info("Let's inspect the beans provided by Spring Boot:");
    String[] beanNames = ctx.getBeanDefinitionNames();
    Arrays.sort(beanNames);/*  www . j  ava  2s .c  o  m*/
    for (String beanName : beanNames) {
        log.info("=======> {}", beanName);
    }

}

From source file:com.mac.holdempoker.Application.java

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

    HoldemEndpoint server = ctx.getBean(HoldemEndpoint.class);
    server.start();/*from  ww  w  .  j av  a2  s. c  o m*/
}

From source file:com.mycompany.texteditorconfig.MainApp.java

public static void main(String[] args) {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(TextEditorConfig.class);

    TextEditor te = ctx.getBean(TextEditor.class);

    te.spellCheck();//from   w w  w .j av  a2  s  . c o  m
}

From source file:com.solomon.finance.Main.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("financeContext.xml");
    Inplay bean = (Inplay) context.getBean("inplay");
    //        String response = bean.getInplayDoc("http://finance.yahoo.com/news/inplay-briefing-com-055139997.html?bypass=true#");
    //        bean.saveResponse(response, "/Users/zhao0677/Projects/solomon/finance/output/09-26-2016.txt");
}