Example usage for org.springframework.beans.factory BeanFactory getBean

List of usage examples for org.springframework.beans.factory BeanFactory getBean

Introduction

In this page you can find the example usage for org.springframework.beans.factory BeanFactory getBean.

Prototype

<T> T getBean(Class<T> requiredType) throws BeansException;

Source Link

Document

Return the bean instance that uniquely matches the given object type, if any.

Usage

From source file:edu.harvard.i2b2.crc.datavo.CRCJAXBUtil.java

public static JAXBUtil getJAXBUtil() {
    if (jaxbUtil == null) {
        BeanFactory springBean = QueryProcessorUtil.getInstance().getSpringBeanFactory();
        List jaxbPackageName = (List) springBean.getBean("jaxbPackage");
        String[] jaxbPackageNameArray = (String[]) jaxbPackageName.toArray(new String[] {

        });/*  ww  w.  ja  va 2s.c  om*/
        jaxbUtil = new JAXBUtil(jaxbPackageNameArray);
    }

    return jaxbUtil;
}

From source file:cn.vlabs.umt.services.account.ICoreMailClient.java

public static void init(BeanFactory factory) {
    if (config == null) {
        config = (Config) factory.getBean("Config");
        useable = config.getBooleanProp("umt.coremail.enable", false);
    }/*  ww  w  .j  ava  2  s . c  o m*/
}

From source file:main.MiniGenSystemTest.java

/**
 * @throws java.lang.Exception/*from  ww w  . ja  v  a  2 s. c o  m*/
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    System.setProperty(AJPropertyConstants.FILES_LOCATION.getKey(),
            System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator
                    + "resources" + File.separator + "mini_report_system_test");

    System.setProperty(AJPropertyConstants.GENERATOR_NAME.getKey(), "minigen");

    // Initialise dependency injection with Spring
    ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/aj_spring_test_context.xml");
    BeanFactory factory = context;
    config = (Configuration) factory.getBean("configuration");

    String[] args = new String[] { "--console" };
    AJMainConsole.main(args);
}

From source file:cn.vlabs.umt.services.account.ICoreMailClient.java

public static ICoreMailClient getInstance() {
    BeanFactory factory = UMTContext.getFactory();
    init(factory);//from   w  w w .  j a v  a 2 s .c o m
    if (useable) {
        return (ICoreMailClient) factory.getBean(USEABLE_BEAN_ID);
    } else {
        return (ICoreMailClient) factory.getBean(UN_USEABLE_BEAN_ID);
    }

}

From source file:main.BasicGenSystemTest.java

/**
 * @throws java.lang.Exception/*from w w  w.j a v  a 2  s  .co  m*/
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    System.setProperty(AJPropertyConstants.FILES_LOCATION.getKey(),
            System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator
                    + "resources" + File.separator + "basic_report_system_test");

    System.setProperty(AJPropertyConstants.GENERATOR_NAME.getKey(), "basicgen");

    // Initialise dependency injection with Spring
    ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/aj_spring_test_context.xml");
    BeanFactory factory = context;
    config = (Configuration) factory.getBean("configuration");

    String[] args = new String[] { "--console" };
    AJMainConsole.main(args);
}

From source file:main.ExtGenSystemTest.java

/**
 * @throws java.lang.Exception//from  w  ww.j  a v a 2  s.co m
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    System.setProperty(AJPropertyConstants.FILES_LOCATION.getKey(),
            System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator
                    + "resources" + File.separator + "ext_report_system_test");

    System.setProperty(AJPropertyConstants.GENERATOR_NAME.getKey(), "extgen");

    // Initialise dependency injection with Spring
    ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/aj_spring_test_context.xml");
    BeanFactory factory = context;
    config = (Configuration) factory.getBean("configuration");

    String[] args = new String[] { "--console" };
    AJMainConsole.main(args);
}

From source file:ch.systemsx.cisd.openbis.generic.server.dataaccess.db.IndexCreationUtil.java

/**
 * Performs a full text index because the test database has been migrated.
 *//*w  w w  . j ava 2s .c om*/
private final static void performFullTextIndex() throws Exception {
    final BeanFactory factory = getBeanFactory();
    final FullTextIndexerRunnable fullTextIndexer = new FullTextIndexerRunnable(
            (SessionFactory) factory.getBean("hibernate-session-factory"), hibernateSearchContext);
    fullTextIndexer.run();
}

From source file:main.MiniTSVImporterTest.java

/**
 * @throws java.lang.Exception/*from  w  w w  . j a  va 2 s.  c  o  m*/
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    System.setProperty(AJPropertyConstants.FILES_LOCATION.getKey(),
            System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator
                    + "resources" + File.separator + "mini_tsv_importer_test");

    // Initialise dependency injection with Spring
    ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/aj_spring_test_context.xml");
    BeanFactory factory = context;
    Configuration config = (Configuration) factory.getBean("configuration");

    // Load the new properties
    config.loadSystemProperties();

    Importer importer = new MiniTSVImporter();

    importer.setFilesLocation(config.getProperty(AJPropertyConstants.FILES_LOCATION.getKey()));
    importer.setRawReportFolder(config.getProperty(AJPropertyConstants.RAW_REPORTS_FOLDER.getKey()));

    reports = importer.importReports();

}

From source file:org.bigtester.ate.GlobalUtils.java

/**
 * Find data source bean.//  w ww. ja v  a2  s  .co  m
 *
 * @param beanFac
 *            the bean factory
 * @return the data source
 * @throws NoSuchBeanDefinitionException
 *             the no such bean definition exception
 */
public static DataSource findDataSourceBean(BeanFactory beanFac) {
    DataSource dataSrc = beanFac.getBean(DataSource.class);

    if (null == dataSrc) {
        throw new NoSuchBeanDefinitionException(DataSource.class);
    } else {
        return dataSrc;
    }

}

From source file:main.BasicTSVImporterTest.java

/**
 * @throws java.lang.Exception/* ww  w  .  j a v a  2  s .  co  m*/
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    System.setProperty(AJPropertyConstants.FILES_LOCATION.getKey(),
            System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator
                    + "resources" + File.separator + "basic_tsv_importer_test");

    // Initialise dependency injection with Spring
    ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/aj_spring_test_context.xml");
    BeanFactory factory = context;
    Configuration config = (Configuration) factory.getBean("configuration");

    // Load the new properties
    config.loadSystemProperties();

    Importer importer = new BasicTSVImporter();

    importer.setFilesLocation(config.getProperty(AJPropertyConstants.FILES_LOCATION.getKey()));
    importer.setRawReportFolder(config.getProperty(AJPropertyConstants.RAW_REPORTS_FOLDER.getKey()));

    reports = importer.importReports();

}