Example usage for org.springframework.context.annotation AnnotationConfigApplicationContext getBean

List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext getBean

Introduction

In this page you can find the example usage for org.springframework.context.annotation AnnotationConfigApplicationContext getBean.

Prototype

@Override
    public Object getBean(String name) throws BeansException 

Source Link

Usage

From source file:ro.lmn.presos.di.emailsender.impl.spring.EmailSenderApp.java

public static void main(String[] args) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(EmailSenderApp.class);
    context.getBean(EmailSender.class).sendMail("Hello there", "Buy cheap $product");
    context.close();// www  .j ava2s  .  com
}

From source file:com.apress.prospringintegration.corespring.spel.MainSpEL.java

public static void main(String[] ars) throws Exception {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SpELConfig.class);

    EmailUtilities emailUtils = ctx.getBean(EmailUtilities.class);
    System.out.println(emailUtils.getHost());
}

From source file:com.khartec.waltz.jobs.EndUserAppHarness.java

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

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    EndUserAppDao dao = ctx.getBean(EndUserAppDao.class);

    System.out.println(dao.countByOrganisationalUnit());

}

From source file:org.cellcore.code.exec.db.UpdateAll.java

public static void main(String[] args) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ContextConfig.class);
    GeneralDao dao = context.getBean(GeneralDao.class);
    FetchUpdateData updateData = context.getBean(FetchUpdateData.class);
    List<CardPriceSource> cards = dao.list(CardPriceSource.class);
    for (CardPriceSource card : cards) {
        updateData.update(card.getUrl(), card.getSourceType().getPageDataExtractorClass());
    }//  w  ww .j av a  2  s  .c  o  m
}

From source file:com.mastermind.shell.Main.java

public static void main(String[] args) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
            ApplicationConfig.class);
    Shell shell = context.getBean(Shell.class);

    shell.start();/*from   w ww .  j  a  v  a 2  s.  c o  m*/
}

From source file:com.khartec.waltz.jobs.JobLogHarness.java

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

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);

    JobLogDao jobLogDao = ctx.getBean(JobLogDao.class);

    jobLogDao.findLatestSuccessful().forEach(System.out::println);

}

From source file:com.khartec.waltz.jobs.OrgUnitHarness.java

public static void main(String[] args) {

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);

    OrganisationalUnitDao dao = ctx.getBean(OrganisationalUnitDao.class);

}

From source file:com.khartec.waltz.jobs.AppGroupMemberHarness.java

public static void main(String[] args) {

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);

    AppGroupMemberDao dao = ctx.getBean(AppGroupMemberDao.class);

    dao.register(13, "1", AppGroupMemberRole.OWNER);

}

From source file:com.khartec.waltz.jobs.AccessLogHarness.java

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

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);

    AccessLogDao accessLogDao = ctx.getBean(AccessLogDao.class);

    accessLogDao.write(ImmutableAccessLog.builder().params("{b:2}").state("my.state").userId("bob").build());

    accessLogDao.findForUserId("bob").forEach(System.out::println);

}

From source file:com.khartec.waltz.jobs.PerformanceMetricPackHarness.java

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

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);

    PerformanceMetricPackDao dao = ctx.getBean(PerformanceMetricPackDao.class);

    System.out.println("Loading....");
    MetricPack pack = dao.getById(1L);//w w w .  j a  v a  2 s.com

    System.out.println(pack);
}