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:edu.eci.arsw.exam.Main.java

public static void main(String a[]) {
    ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
    final MainFrame mf = ac.getBean(MainFrame.class);
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            mf.setVisible(true);/*  w ww.j a v  a  2 s .c o  m*/
        }
    });

}

From source file:cz.moz.java.contactmanager.Application.java

public static void main(String args[]) {
    ApplicationContext appContX = new ClassPathXmlApplicationContext("spring/applicationContext.xml");
    JFrame appFrame = appContX.getBean(AppFrame.class);
    appFrame.setVisible(true);//from   w  w w.  j  av  a  2s  .  co m
}

From source file:org.nekorp.workflow.desktop.control.MainClass.java

public static void main(String arg[]) {
    try {/*from  w  w w .  j av  a2 s .c  om*/
        ApplicationContext ctx = new ClassPathXmlApplicationContext("spring/applicationContext.xml");
        ctx.getBean(WorkflowApp.class).startAplicacion();
    } catch (Exception e) {
        MainClass.LOGGER.error("No se logro inicializar la aplicacion", e);
        System.exit(1);
    }
}

From source file:br.com.gumga.academia.MainService.java

public static void main(String[] args) {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(Aplicacao.class);
    MainService ms = ctx.getBean(MainService.class);
    ms.run();/*from ww w.jav a  2 s .c o  m*/
}

From source file:inheritancespring.InheritanceSpring.java

/**
 * @param args the command line arguments
 *///from   w  w w . j a v a2s  .co  m
public static void main(String[] args) {
    // TODO code application logic here

    ApplicationContext context = new ClassPathXmlApplicationContext("Classes/beans.xml");

    User user = (User) context.getBean("employee");
    System.out.println(user.getName() + user.getPhone());

}

From source file:pkg.AnnotationsMain.java

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

    Annotations annotation = ctx.getBean(Annotations.class);

    annotation.setMessage("Hello World!");
    annotation.getMessage();//from  w  w w .  j  a v  a  2 s  .co  m
}

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

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

    HelloWorld helloWorld = ctx.getBean(HelloWorld.class);

    helloWorld.setMessage("Hello World!");
    helloWorld.getMessage();//w w  w.j  a  va2  s .  co m
}

From source file:tes.TesterApp.java

public static void main(String[] args) {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("appconfig.xml");
    DepartemenDAO dao = (DepartemenDAO) ctx.getBean("departemenDAO");
    for (Departemen dep : dao.getAll()) {
        System.out.println(dep.getNama());
    }// w ww  .  ja  v a  2 s . co  m
}

From source file:com.anton.dev.tqrbs2.test.TestApp.java

public static void main(String[] args) {
    LOGGER.info("Iniciacion App.");
    ApplicationContext context = new ClassPathXmlApplicationContext("test-spring-config.xml");
    final TestSender bean = context.getBean(TestSender.class);
    bean.sendMessage();/*from  w w w . j  a  v a  2  s. co m*/
}

From source file:com.mycompany.rmispringclient.Main.java

public static void main(String[] args) {
    ApplicationContext ctx = new FileSystemXmlApplicationContext("src/main/resources/beans.xml");
    ClientObj obj = (ClientObj) ctx.getBean("clientObj");
    System.out.println("" + obj.getDao().getSalary(new User(1, "dksjk", 12, 1000)));
}