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:org.springframework.samples.hadoop.hive.HiveClientApp.java

public static void main(String[] args) throws Exception {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/hive-context.xml",
            HiveClientApp.class);
    log.info("Hive Application Running");
    context.registerShutdownHook();//from  w  w  w .j a  va  2  s .co  m

    HiveTemplate template = context.getBean(HiveTemplate.class);
    template.query("show tables;");

    PasswordRepository repository = context.getBean(HiveClientPasswordRepository.class);
    repository.processPasswordFile("/user/hive/input/passwd");
    log.info("Count of password entries = " + repository.count());
    context.close();
    log.info("Hive Application Completed");
}

From source file:org.springframework.samples.hadoop.hive.HiveJdbcApp.java

public static void main(String[] args) throws Exception {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/hive-context.xml",
            HiveJdbcApp.class);
    log.info("Hive Application Running");
    context.registerShutdownHook();// w w w.j a v  a 2s.  c o  m

    HiveTemplate template = context.getBean(HiveTemplate.class);
    template.query("show tables;");

    JdbcPasswordRepository repo = context.getBean(JdbcPasswordRepository.class);
    repo.processPasswordFile("password-analysis.hql");
    log.info("Count of password entrires = " + repo.count());

}

From source file:org.springframework.samples.hadoop.mapreduce.MrBatchApp.java

public static void main(String[] args) throws JobParametersInvalidException,
        JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException {
    System.out.println("TEST");
    AbstractApplicationContext context = new ClassPathXmlApplicationContext(
            "classpath:/META-INF/spring/*-context.xml");
    log.info("Batch Tweet Hashtag MR Job Running");
    context.registerShutdownHook();//w  w  w . j a  v a  2 s  .c  o  m

    JobLauncher jobLauncher = context.getBean(JobLauncher.class);
    Job job = context.getBean(Job.class);
    jobLauncher.run(job, new JobParameters());

}

From source file:org.springframework.samples.hadoop.runtime.HiveApp.java

public static void main(String[] args) throws Exception {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("/hive/hive-context.xml");
    log.info("Hive Application Running");
    context.registerShutdownHook();//from ww w .  j  a  v  a  2  s  . c  o m

    HiveTemplate template = context.getBean(HiveTemplate.class);
    template.query("show tables;");

    PasswordRepository repository = context.getBean(HiveTemplatePasswordRepository.class);
    repository.processPasswordFile("/etc/passwd");
    log.info("Count of password entries = " + repository.count());
}

From source file:org.springframework.samples.hadoop.runtime.HiveAppWithApacheLogs.java

public static void main(String[] args) throws Exception {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext(
            "/hive/hive-apache-log-context.xml");
    log.info("Hive Application Running");
    context.registerShutdownHook();/*  w w w  .ja  va2 s.  c o  m*/

    HiveRunner runner = context.getBean(HiveRunner.class);
    runner.call();

    //org.w3c.dom.Element e; e.getNode

}

From source file:org.springframework.samples.hadoop.runtime.HiveJdbcApp.java

public static void main(String[] args) throws Exception {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("/hive/hive-context.xml");
    log.info("Hive Application Running");
    context.registerShutdownHook();/*from  w  w w  . j  av  a 2s .  c  o  m*/

    HiveTemplate template = context.getBean(HiveTemplate.class);
    template.query("show tables;");

    JdbcPasswordRepository repo = context.getBean(JdbcPasswordRepository.class);
    repo.processPasswordFile("hive/password-analysis.hql");
    log.info("Count of password entrires = " + repo.count());

}

From source file:org.treediagram.nina.console.Console.java

/**
 * ?/*ww  w  . j  av  a2 s .  c  om*/
 */
public Console(AbstractApplicationContext applicationContext) {
    //  JVM ShutdownHook
    applicationContext.registerShutdownHook();
    this.applicationContext = applicationContext;
    this.conversionService = applicationContext.getBean(ConversionService.class);
    registerCommand();
    commands.put(cmdStop.name(), cmdStop);
    commands.put(cmdList.name(), cmdList);
    if (logger.isDebugEnabled()) {
        logger.debug("???");
    }
}

From source file:ro.nextreports.server.web.ApplicationLoaderListener.java

private static void updateStorage() {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Update storage...");
    }/*from ww  w. ja v a  2s  .com*/
    try {
        long t = System.currentTimeMillis();

        String[] paths = { UPDATE_CONTEXT_PATH };
        AbstractApplicationContext updateContext = new ClassPathXmlApplicationContext(paths);

        updateContext.getBean("updater");
        updateContext.close();

        t = System.currentTimeMillis() - t;
        if (LOG.isDebugEnabled()) {
            LOG.debug("Updated storage in " + t + " ms");
        }

    } catch (Throwable tex) {
        LOG.error(tex.getMessage(), tex);
    }

}