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:py.una.pol.karaku.test.util.DatabaseUtils.java

private static HibernateTransactionManager getTransactionManager(ApplicationContext context) {

    return context.getBean(HibernateTransactionManager.class);
}

From source file:com.learn.spring.integration.file.FileCopyDemoCommon.java

public static void displayDirectories(ApplicationContext context) {
    File inDir = (File) new DirectFieldAccessor(context.getBean(FileReadingMessageSource.class))
            .getPropertyValue("directory");
    LiteralExpression expression = (LiteralExpression) new DirectFieldAccessor(
            context.getBean(FileWritingMessageHandler.class))
                    .getPropertyValue("destinationDirectoryExpression");
    File outDir = new File(expression.getValue());
    System.out.println("Input directory is: " + inDir.getAbsolutePath());
    System.out.println("Output directory is: " + outDir.getAbsolutePath());
    System.out.println("===================================================");
    LOGGER.info("aaaaaaaaaaaaaaaaa");
}

From source file:org.tsm.concharto.dao.BaseEventIntegrationTest.java

public static void baseSetUpClass() {
    ApplicationContext appCtx = ContextUtil.getCtx();
    eventDao = (EventDao) appCtx.getBean("eventDao");
    eventTesterDao = (EventTesterDao) appCtx.getBean("eventTesterDao");
    eventUtil = new EventUtil(eventTesterDao.getSessionFactory());
    eventTesterDao.deleteAll();//from ww  w  .  j  a  v  a 2  s.co m
    StyleUtil.setupStyle();
}

From source file:eu.wisebed.wiseui.persistence.PersistenceServiceProvider.java

/**
 * Provides an configured instance of the {@link eu.wisebed.wiseui.persistence.service.PersistenceServiceImpl}.
 * The instance will be a Singleton as defined in the Spring configuration (this the default for Beans).
 * @return Configured singleton instance of the {@link eu.wisebed.wiseui.persistence.service.PersistenceServiceImpl}
 *//*  w  ww  . j a  va  2 s.c o  m*/
public static PersistenceService newPersistenceService() {
    final String springConfig = "persistence-spring-config.xml";
    final ApplicationContext springContext = new ClassPathXmlApplicationContext(springConfig);
    return springContext.getBean(PersistenceService.class);
}

From source file:org.shareok.data.commons.CommonsUtil.java

public static BookRecipe getBookRecipeInstance() {
    ApplicationContext context = new ClassPathXmlApplicationContext("commonsContext.xml");
    return (BookRecipe) context.getBean("bookRecipe");
}

From source file:org.shareok.data.commons.CommonsUtil.java

public static PageRecipe getPageRecipeInstance() {
    ApplicationContext context = new ClassPathXmlApplicationContext("commonsContext.xml");
    return (PageRecipe) context.getBean("pageRecipe");
}

From source file:com.jrc.transport.pkage.db.Main.java

private static void testPackageRepo() {
    ApplicationContext context = new AnnotationConfigApplicationContext(PkageDBConfig.class);
    PkageRepository dao = context.getBean(PkageRepository.class);
    Pkage pkg = Pkage.builder().create().setPkageId("packageID1").setSenderName("Kepler")
            .setReceiverName("Tesla").setFromZipCode("54320").setToZipCode("MZ450").build();
    dao.save(pkg);//from ww w  .j av  a2  s.  c o  m
    System.out.println("Retrieved Pkage Details =" + dao.findAll().iterator().next());

}

From source file:org.tsm.concharto.dao.StyleUtil.java

public static Style setupStyle() {
    ApplicationContext appCtx = ContextUtil.getCtx();
    StyleDao styleDao = (StyleDao) appCtx.getBean("styleDao");
    styleDao.deleteAll();/*  w  ww  .ja v  a  2s . c o  m*/
    // The style has to be created before you create any features. It is
    // a many to one mapping.
    styleDao.save(style);
    return style;
}

From source file:com.totoland.web.factory.DaoFactory.java

public static GennericService createGennericService() {
    ApplicationContext bf = new ClassPathXmlApplicationContext("classpath:**/applicationContext.xml");
    return (GennericService) bf.getBean("gennericService");
}

From source file:com.wbss.mycoffee.ui.helper.spring.SpringUtil.java

/**
 * Get spring bean by name// w w  w  .  j a  v  a  2s. c o  m
 * @param beanName
 * @return
 */
public static Object getBean(String beanName) {

    ApplicationContext applicationContext = ApplicationContextProvider.getApplicationContext();

    return applicationContext.getBean(beanName);

}