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:com.garyclayburg.data.MainApp.java

public static void mainJunk(String[] args) {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(ServiceConfig.class);

    Mongo mongoClient = ctx.getBean(Mongo.class);
    log.info("wired mongo is " + mongoClient);

    UserService us = ctx.getBean(UserService.class);
    log.info("wired userservice: " + us);
}

From source file:Project6Test.java

@BeforeClass
public static void setUpClass() throws Exception {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
    service = (Addition) ctx.getBean("addition");
}

From source file:Project10Test.java

@BeforeClass
public static void setUpClass() throws Exception {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
    service = (Digits) ctx.getBean("simple addition");
}

From source file:Project5Test.java

@BeforeClass
public static void setUpClass() throws Exception {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(AppConfig.class);
    service = (Numbers) ctx.getBean("number array");
}

From source file:br.com.jreader.util.ServiceFinder.java

public static Object findBean(String beanName) {
    FacesContext context = FacesContext.getCurrentInstance();
    ExternalContext externalContext = context.getExternalContext();

    ServletContext servletContext = (ServletContext) externalContext.getContext();
    ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    Object object = applicationContext.getBean(beanName);
    return object;
}