Example usage for org.springframework.context.support AbstractApplicationContext getBean

List of usage examples for org.springframework.context.support AbstractApplicationContext getBean

Introduction

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

Prototype

@Override
    public <T> T getBean(Class<T> requiredType) throws BeansException 

Source Link

Usage

From source file:p1.Spring_3.java

public static void main(String[] args) {
    AbstractApplicationContext ac = new FileSystemXmlApplicationContext("src/one.xml");

    point p1 = (point) ac.getBean("pt1");
    point p2 = (point) ac.getBean("pt2");

    System.out.println(p1);// w  ww.  ja v  a  2  s. co  m
    System.out.println(p2);
}

From source file:persons.controller.Main.java

public static void main(String[] args) {
    AbstractApplicationContext ctx = new FileSystemXmlApplicationContext("beans.xml");
    Runnable test = (Runnable) ctx.getBean("test");
    test.run();//from   w w  w  . j  a  v a2 s  .co m
    ctx.close();
}

From source file:MainClass.MyMain.java

public static void main(String[] args) {
    //           BeanFactory fact = new XmlBeanFactory(new FileSystemResource("src/SpringConfig.xml"));
    AbstractApplicationContext con = new ClassPathXmlApplicationContext("SpringConfig.xml");
    MyReinder rend = (MyReinder) con.getBean("firstrendrer");
    rend.render();//from  w  w  w  .  java 2  s. c  o  m
    MyReinder rendTwo = (MyReinder) con.getBean("secondrendrer");
    rendTwo.render();
    con.registerShutdownHook();
}

From source file:com.anton.dev.tqrbs2.basic.BasicSpring.java

public static void main(String[] args) throws Exception {
    AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("basic-context.xml");
    RabbitTemplate template = ctx.getBean(RabbitTemplate.class);
    String msg = "Hello, world Rabbit!";
    LOGGER.info("Enviando Spring: " + msg);
    template.convertAndSend(msg);/*w  w w.  j a  v a 2  s . c  o m*/
    Thread.sleep(1000);
    ctx.destroy();
}

From source file:edu.hm.cs.goetz1.seminar.Main.java

public static void main(String[] args) {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
    UserService userService = (UserService) context.getBean(UserService.class);

    userService.addNewUser("test@email.de", "Max", "Mustermann", "totalGeheim", new Date());
    userService.changeUserPassword("test@email.de", "totalGeheim", "nochGeheimer");

    context.close();/*  w w w  .j  a v a2s. c  om*/
}

From source file:spring_4.Spring_4.java

/**
 * @param args the command line arguments
 *//*from  w  w w. ja v a2  s .  c om*/
public static void main(String[] args) {

    AbstractApplicationContext ac = new FileSystemXmlApplicationContext("/src/spring_4/one.xml");

    point p = (point) ac.getBean("pt1");
    segment s = (segment) ac.getBean("seg1");

    event1 e1 = new event1();

    ac.publishEvent(e1);

    event2 e2 = new event2();

    ac.publishEvent(e2);

    //System.out.println(p);

    // TODO code application logic here
}

From source file:com.delphix.appliance.host.example.client.ExampleClientLauncher.java

public static void main(String[] args) {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext(CONFIG_LOCATION);
    try {//from  w  ww  . j a  v  a 2 s .  c  o m
        ExampleClient client = (ExampleClient) context.getBean("client");
        client.executeRemoteCommand();
        client.fini();
    } finally {
        context.close();
    }
}

From source file:config.MainClass.java

/**
 * @param args the command line arguments
 *//*from  www  .  jav a 2s .  co  m*/
public static void main(String[] args) {
    // TODO code application logic here
    File file = new File("D:\\iti images\\Dish Party_6-11-2014\\IMG_5376.jpg");
    byte[] bFile = new byte[(int) file.length()];

    try {
        FileInputStream fileInputStream = new FileInputStream(file);
        //convert file into array of bytes
        fileInputStream.read(bFile);
        fileInputStream.close();
    } catch (Exception e) {
        System.out.println("Error in reading the image");
    }
    UserData data = new UserData();
    data.setUserName("hasby allah");
    data.setBirthday(new Date());
    data.setPhone("65656");
    data.setFullName("7asby allah w n3m el wakel");
    data.setAddress("haram");
    data.setPassword("password");
    data.setImage(bFile);
    AbstractApplicationContext fact = new ClassPathXmlApplicationContext("SpringConfig.xml");
    DaoService serviceInterface = fact.getBean(DaoService.class);
    serviceInterface.save(data);
}

From source file:com.aan.girsang.server.launcher.GenerateDatabase.java

public static void main(String[] args) throws SQLException {
    AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

    DataSource dataSource = (DataSource) ctx.getBean("dataSource");

    Configuration cfg = new AnnotationConfiguration().configure("hibernate.cfg.xml")
            .setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");

    try (Connection conn = dataSource.getConnection()) {
        new SchemaExport(cfg, conn).create(true, true);

        cfg.generateSchemaCreationScript(Dialect.getDialect(cfg.getProperties()));
        SchemaExport export = new SchemaExport(cfg, conn);
        export.create(true, true);//from   ww  w .j a v  a 2 s  . c om

        conn.close();

    }
    ctx.registerShutdownHook();

}

From source file:com.enterpriseios.push.spring.Main.java

/**
 *
 * @param args//from  w w  w. java  2  s.c o  m
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    final String config = args.length == 1 ? args[0] : "etc/spring/bean.xml";
    //        final String config = args.length == 1 ? args[0] : "jetty-push2/src/main/resources/etc/spring/bean.xml";
    final AbstractApplicationContext applicationContext = new FileSystemXmlApplicationContext(config);
    final ActiveSyncServer server = (ActiveSyncServer) applicationContext
            .getBean(args.length == 2 ? args[1] : "ActiveSyncServer");
    server.start();
}