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:org.keyboardplaying.xtt.ConstructApplication.java

/**
 * Main method for the application.//w  w  w.  ja v a2s. c  o m
 *
 * @param args
 *            unused arguments
 */
public static void main(String... args) {
    @SuppressWarnings("resource") // not closing, needed for prototypes
    ApplicationContext ctx = new AnnotationConfigApplicationContext(UIConfiguration.class);
    UIController controller = ctx.getBean(UIController.class);
    controller.startUI();
}

From source file:ro.fortsoft.pf4j.spring.demo.Boot.java

public static void main(String[] args) {
    // print logo
    printLogo();//from w w  w.ja va  2  s . c o  m

    // retrieves the spring application context
    ApplicationContext applicationContext = new AnnotationConfigApplicationContext(Boot.class);

    // print greetings in System.out
    Greetings greetings = applicationContext.getBean(Greetings.class);
    greetings.printGreetings();

    // stop plugins
    PluginManager pluginManager = applicationContext.getBean(PluginManager.class);
    pluginManager.stopPlugins();
}

From source file:org.ala.apps.RkColumnFamilyExporter.java

/**
 * Usage: outputFileName [option: cassandraAddress cassandraPort]
 * /*from   ww w .  j a  va  2 s. co  m*/
 * @param args
 */
public static void main(String[] args) throws Exception {
    ApplicationContext context = SpringUtils.getContext();
    RkColumnFamilyExporter loader = context.getBean(RkColumnFamilyExporter.class);

    try {
        loader.exportRanks();
    } catch (Exception e) {
        System.out.println("***** Fatal Error !!!.... shutdown cassandra connection.");
        e.printStackTrace();
        logger.error(e);
        System.exit(0);
    }
    System.exit(0);
}

From source file:com.joymove.service.impl.JOYNOrderServiceImpl.java

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

    JOYNOrderService service = (JOYNOrderService) context.getBean("JOYNOrderService");
    JOYOrder order = new JOYOrder();
    service.createNewOrder(order);//w  w w . j  a  v  a 2s . c o m

}

From source file:com.searchengine.test.MainApp.java

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

    DocumentJDBCTemplate documentJDBCTemplate = (DocumentJDBCTemplate) context.getBean("documentJDBCTemplate");

    System.out.println("------Records Creation--------");
    documentJDBCTemplate.create("ATITLE", "ANID");
    documentJDBCTemplate.create("ATITLE2", "ANID2");
    documentJDBCTemplate.create("ATITLE3", "ANID3");

    System.out.println("------Listing Multiple Records--------");
    List<Document> students = documentJDBCTemplate.listDocuments();
    for (Document record : students) {
        System.out.print("ID : " + record.getId());
        System.out.print(", Title : " + record.getTitle());
    }//from www  . j  a v a2 s. c  o m

    System.out.println("----Updating Record with ID = 2 -----");
    documentJDBCTemplate.update("ANID2", "TITLEEE");

    System.out.println("----Listing Record with ID = 2 -----");
    Document student = documentJDBCTemplate.getDocument("ANID2");
    System.out.print("ID : " + student.getId());
    System.out.print(", Name : " + student.getTitle());

    documentJDBCTemplate.delete("ANID");
    documentJDBCTemplate.delete("ANID2");
    documentJDBCTemplate.delete("ANID3");

}

From source file:org.lieuofs.extraction.commune.mutation.ExtracteurMutation.java

public static void main(String[] args) throws IOException {
    ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "beans_extraction.xml" });
    ExtracteurMutation extracteur = (ExtracteurMutation) context.getBean("extracteurMutation");
    Calendar cal = Calendar.getInstance();
    cal.set(2013, Calendar.JANUARY, 1);
    BufferedWriter writer = new BufferedWriter(
            new OutputStreamWriter(new FileOutputStream("MutationCommune2013.txt"), "Windows-1252"));
    extracteur.extraireMutation(cal.getTime(), writer);
}

From source file:com.mvdb.etl.actions.ScanDBChanges.java

public static void main(String[] args) throws IOException {

    String customerName = null;/* w w  w.  j  av  a  2 s .c om*/
    String snapshotDir = null;
    final CommandLineParser cmdLinePosixParser = new PosixParser();
    final Options posixOptions = constructPosixOptions();
    CommandLine commandLine;
    try {
        commandLine = cmdLinePosixParser.parse(posixOptions, args);
        if (commandLine.hasOption("customer")) {
            customerName = commandLine.getOptionValue("customer");
        }
        if (commandLine.hasOption("snapshotDir")) {
            snapshotDir = commandLine.getOptionValue("snapshotDir");
        }
    } catch (ParseException parseException) // checked exception
    {
        System.err.println(
                "Encountered exception while parsing using PosixParser:\n" + parseException.getMessage());
    }

    if (customerName == null) {
        System.err.println("Could not find customerName. Aborting...");
        System.exit(1);
    }
    if (snapshotDir == null) {
        System.err.println("Could not find snapshotDir. Aborting...");
        System.exit(1);
    }

    ApplicationContext context = Top.getContext();

    final ConfigurationDAO configurationDAO = (ConfigurationDAO) context.getBean("configurationDAO");
    final GenericDAO genericDAO = (GenericDAO) context.getBean("genericDAO");
    File snapshotDirectory = getSnapshotDirectory(configurationDAO, customerName, snapshotDir);
    //write file schema-orders.dat in snapshotDirectory
    Metadata metadata = genericDAO.getMetadata("orders", snapshotDirectory);
    //writes files: header-orders.dat, data-orders.dat in snapshotDirectory
    genericDAO.scan2("orders", snapshotDirectory);

}

From source file:org.slc.sli.ingestion.tool.OfflineTool.java

public static void main(String[] args) throws IOException {
    ApplicationContext context = new ClassPathXmlApplicationContext("spring/applicationContext.xml");

    OfflineTool main = context.getBean(OfflineTool.class);

    main.start(args);//from   ww w . j  av a2  s. c o m
}

From source file:org.ala.hbase.LimneticDataLoader.java

public static void main(String[] args) throws Exception {
    ApplicationContext context = SpringUtils.getContext();
    LimneticDataLoader l = context.getBean(LimneticDataLoader.class);
    l.load();/*from   www  .  ja  v a2  s  .c o  m*/
    System.exit(1);
}

From source file:org.ala.hbase.NTripleDataLoader.java

/**
 * @param args/*from ww w .ja va 2s  .co m*/
 */
public static void main(String[] args) throws Exception {

    String defaultFilePath = "/data/bie-staging/dbpedia/dbpedia.txt";
    String filePath = null;
    if (args.length == 0) {
        filePath = defaultFilePath;
    }
    FileReader fr = new FileReader(new File(filePath));
    NTripleDataLoader loader = new NTripleDataLoader();
    ApplicationContext context = SpringUtils.getContext();
    loader.taxonConceptDao = (TaxonConceptDao) context.getBean(TaxonConceptDao.class);
    loader.load(fr);
}