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:com.mc.JDBCwithSpring.java

/**
 * @param args the command line arguments
 *///from   w  w  w  .ja va 2  s.c  o  m
public static void main(String[] args) {
    // TODO code application logic here
    //WITHOUT SPRING
    //        JdbcDaoImpl circleDao = new JdbcDaoImpl();
    //        System.out.println(circleDao.getCircle(1));
    //        System.out.println(circleDao.getCircle(2).getName());

    ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
    JdbcDaoImpl circleDao = context.getBean("jdbcDaoImpl", JdbcDaoImpl.class);
    System.out.println(circleDao.getCircleForId(1));
    System.out.println("Circle count" + circleDao.getCircleCount());
    System.out.println(circleDao.getCircleName(2));
    //  circleDao.insertCircle(new Circle(5,"Fifth Circle"));
    System.out.println(circleDao.getAllCircles());

}

From source file:com.amazonaws.services.simpleworkflow.flow.examples.deployment.DeploymentHost.java

/**
 * @param args//from  w w  w.jav a  2 s.c  o m
 * @throws MalformedURLException
 */
public static void main(String[] args) {
    new ClassPathXmlApplicationContext(
            "/com/amazonaws/services/simpleworkflow/flow/examples/deployment/DeploymentHost-context.xml");
}

From source file:samples.ProducerApplication.java

public static void main(String[] args) {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    context.registerShutdownHook();/*from  w w  w .j a  va 2s.  c o  m*/

    SpringJmsProducer producer = (SpringJmsProducer) context.getBean("springJmsProducer");
    producer.run();

    ((org.springframework.jms.connection.CachingConnectionFactory) context.getBean("connectionFactory"))
            .resetConnection();
}

From source file:com.gvmax.server.ServerMain.java

public static void main(String[] args) {
    logger.info("Starting server");
    try {//from ww w .j a v a  2  s. c o  m
        new ClassPathXmlApplicationContext("/server-context.xml");
    } catch (Exception e) {
        logger.error(e);
    }
}

From source file:com.apress.prospringintegration.customadapters.inbound.eventdriven.Main.java

public static void main(String[] args) throws Throwable {
    ClassPathXmlApplicationContext cax = new ClassPathXmlApplicationContext(
            "com/apress/prospringintegration/customadapters/inbound/eventdriven/MainWithNamespace-context.xml");
}

From source file:net.tirasa.blog.ilgrosso.dynamicspringtransactional.App.java

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

    TransactionalClass txClass = ctx.getBean(TransactionalClass.class);

    AuthContextUtils.setDomain("domain1");
    txClass.transactionalMethod();//from   w  ww  .ja  v  a  2  s .  co  m

    AuthContextUtils.setDomain("domain2");
    txClass.transactionalMethod();
}

From source file:com.apress.prospringintegration.customadapters.inbound.pollerdriven.Main.java

static public void main(String[] args) throws Throwable {
    ClassPathXmlApplicationContext cax = new ClassPathXmlApplicationContext(
            "com/apress/prospringintegration/customadapters/inbound/pollerdriven/MainWithNamespace-context.xml");
}

From source file:com.apress.prospringintegration.file.FileCopy.java

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

From source file:freylis.shapes.shapes.Shapes.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    Shapes shapes = (Shapes) context.getBean("shapesRunner");
    shapes.runShapes();/* w  ww  .j  a  v  a2 s  .  c  om*/
}

From source file:uk.co.techsols.mentis.worker.Main.java

public static void main(String args[]) {

    if (args.length != 3) {
        System.out.println(/* w  w w  .j a  v a2s  . c  o  m*/
                "Usage: type url cores\n\ttype:\n\t\tr - renderer\n\t\tt - transformer\n\turl: the url to Eiocha.\n\tcores: the number of cores to use\n\n\te.g. node.jar t http://localhost:8080/server 4\n\n");
        System.exit(1);
        return;
    }

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("/applicationContext.xml");
    Worker worker;
    switch (args[0]) {
    case "r":
        worker = applicationContext.getBean("renderWorker", Worker.class);
        break;
    case "t":
        worker = applicationContext.getBean("transformWorker", Worker.class);
        break;
    default:
        System.out.println("Error: unreconised worker type.");
        System.exit(1);
        return;
    }

    worker.setup(URI.create(args[1]), Integer.parseInt(args[2]));
}