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:Main.MainS.java

public static void main(String[] args) {
    ApplicationContext actx = new ClassPathXmlApplicationContext("bean.xml");
    IPrintf ptr = (IPrintf) actx.getBean("print1");//new Printer("Hello word!!!!");
    ptr.printf();// w  w  w .j  a  va 2s.c o m
    ptr.printList();
    ptr.printList();

    Single single = (Single) actx.getBean("proxy");
    single.print();
    Single singleNew = (Single) actx.getBean("sigle");
    singleNew.print();

    InitClass initClass = (InitClass) actx.getBean("initClass");
    System.out.println(initClass);

    InnerClass innerClass = (InnerClass) actx.getBean("idInnerClass1");//new InnerClass("Inner Class Hello!!!");

    System.out.println(innerClass);

    CloseClass closeClass = /*(CloseClass) actx.getBean("close_class");*/FactoryClass.getInstance();
}

From source file:yangqi.spring3.aop.AopMain.java

/**
 * @param args/*  www  .  j  a  v a  2 s  .c  o m*/
 */
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("aop.xml");

    Performer performer = (Performer) context.getBean("performer");

    System.out.println("START NOW");

    performer.perform();

    System.out.println("shit");
}

From source file:com.example.spring.app.JavaConfig.java

public static void main(String[] args) {

    ApplicationContext ctx = new AnnotationConfigApplicationContext(HelloWorldConfig.class);

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

    helloWorld.setMessage("Hello World!");
    System.out.println("########## Message ######### " + helloWorld.getMessage());

    TextEditor te = ctx.getBean(TextEditor.class);
    te.spellCheck();//ww  w . j  a  v a 2 s.c  o m
}

From source file:com.nuevebit.miroculus.mrna.cli.MiRNATestApplication.java

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

    MiRNATestApplication app = context.getBean(MiRNATestApplication.class);
    app.generateList();/* www  .  j ava 2  s  . c o  m*/
}

From source file:edu.eci.arsw.aop.spring.idol.MainProgram.java

/**
 * @param args the command line arguments
 *///  ww  w. j  av a  2  s . co  m
public static void main(String[] args) {
    ApplicationContext ac = new ClassPathXmlApplicationContext("spring-simple-idol.xml");
    Performer pf = (Performer) ac.getBean("eddie");
    try {
        pf.perform();
    } catch (PerformanceException ex) {
        Logger.getLogger(MainProgram.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.allogy.amazonaws.elasticbeanstalk.worker.simulator.application.Application.java

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

    BridgeService bridgeService = applicationContext.getBean(BridgeService.class);
    bridgeService.start();/* w ww .j av a 2  s.c om*/
}

From source file:cz.moz.ctmanager.main.Application.java

public static void main(String args[]) {
    ApplicationContext appContX = new ClassPathXmlApplicationContext("spring/applicationContext.xml");
    MainAppFrame mainAppFrame = appContX.getBean(MainAppFrame.class);
    mainAppFrame.setVisible(true);//from  w  w w . j a  va  2  s .  c o m
    mainAppFrame.initializeComponents();
}

From source file:flooringmastery.Main.java

public static void main(String[] args) {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
    FlooringController fc = (FlooringController) ctx.getBean("PROD");
    fc.startFlooring();//from   w w w  . java  2  s  .  c o m
}

From source file:com.apress.prospringintegration.corespring.namespaces.MainNS.java

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

    StringNormalizer stringNormalizer = context.getBean(StringNormalizer.class);
    String myStr = "Welcome to The WoRLD OF SpRiNG!";
    System.out.println("The context String normalizer says: " + stringNormalizer.normalize(myStr));
}

From source file:com.santika.hendi.activeMQ.ConsumerTest.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("appContext.xml");
    MessageConsumerBean mc = (MessageConsumerBean) context.getBean("consumer");
    MessageObject messageObj = mc.receiveMessage();
    System.out.println("Message from : " + messageObj.getMailId() + "\n" + messageObj.getMessage() + "\n"
            + "has beeen received");
}