Example usage for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext

List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext

Introduction

In this page you can find the example usage for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext.

Prototype

public ClassPathXmlApplicationContext(String... configLocations) throws BeansException 

Source Link

Document

Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML files and automatically refreshing the context.

Usage

From source file:pkg.BeanMain.java

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

    BeanInheritance objA = (BeanInheritance) context.getBean("beanInheritance");
    objA.getMessage1();//from  w ww.  j  a v  a 2 s.c  o  m
    objA.getMessage2();

    BeanChild objB = (BeanChild) context.getBean("beanChild");
    objB.getMessage1();
    objB.getMessage2();
    objB.getMessage3();

    /*
    World Message1 : Hello World!
    World Message2 : Hello Second World!
    India Message1 : Hello India!
    India Message2 : Hello Second World!
    India Message3 : Namaste India!
    */
}

From source file:pkg.ConstructorBasedDIMain.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
    ConstructorBasedDITextEditor te = (ConstructorBasedDITextEditor) context.getBean("textEditor");
    te.spellCheck();/*from  w ww.  j a  v a2 s. c  o  m*/

    // output order:
    /*
    Inside SpellChecker constructor.
    Inside setSpellChecker.
    Inside checkSpelling.
            
    */
}

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();//www  .j  av  a2 s .c o  m

}

From source file:pkg.SetterbasedDIMain.java

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

    jc.getAddressList();/*from   ww  w.jav  a 2s. c o  m*/
    jc.getAddressSet();
    jc.getAddressMap();
    jc.getAddressProp();

    /*
    List Elements :[INDIA, Pakistan, USA, USA]
    Set Elements :[INDIA, Pakistan, USA]
    ap Elements :{1=INDIA, 2=Pakistan, 3=USA, 4=USA}
    Property Elements :{two=Pakistan, one=INDIA, three=USA, four=USA}
    */
}

From source file:com.checkup.hadoop.Main.java

public static void main(String[] args) {

    AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml");
    ctx.registerShutdownHook();/*from  w w  w . ja v a 2  s  .co m*/
}

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();/*from   w  w w  . j av  a2s .  c om*/
}

From source file:com.spring.tutorial.configuration.xml.App.java

public static void main(String[] args) {
    ApplicationContext ctx = new ClassPathXmlApplicationContext(
            "com/spring/tutorial/configuration/xml/applicationContext.xml");
    ((ClassPathXmlApplicationContext) ctx).close();
}

From source file:test.TesterApp.java

public static void main(String[] args) {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("appconfig.xml");
    Soldier rambo = (Soldier) ctx.getBean("rambo");
    rambo.firing();//from   w w w  . j  av  a2s .c  om
    rambo.firing();
    rambo.firing();
    rambo.firing();
    rambo.firing();
    rambo.firing();
    rambo.firing();
}

From source file:com.dobri.springldap.NewMain.java

public static void main(String[] args) {
    try {//from  ww  w.  j  a va  2 s. c  o  m
        ApplicationContext ac = new ClassPathXmlApplicationContext("config.xml");
    } catch (Exception ioe) {
        System.err.println("nema config fajla !");
    }

}

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

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("appContext.xml");
    MessageProducerBean mp = (MessageProducerBean) context.getBean("producer");
    mp.sendMessage(new MessageObject("1234", "Test Message"));
}