Example usage for org.springframework.web.context WebApplicationContext getBean

List of usage examples for org.springframework.web.context WebApplicationContext getBean

Introduction

In this page you can find the example usage for org.springframework.web.context WebApplicationContext 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.bennavetta.appsite.serve.ResourceServlet.java

@Override
public void init() throws ServletException {
    WebApplicationContext ctx = WebApplicationContextUtils
            .getRequiredWebApplicationContext(getServletContext());
    processor = ctx.getBean(ProcessingController.class);
}

From source file:ar.com.zauber.commons.spring.beans.factory.impl.ContextPathRegexCaseBlockTest.java

/** test */
public final void testCtxHouse() {
    final MockServletContext servletCtx = new MockServletContext("/house");
    servletCtx.addInitParameter("contextConfigLocation", "classpath:/spring-test-switch-regex.xml");
    final TestFriendlyContextLoaderListener listener = new TestFriendlyContextLoaderListener();
    listener.contextInitialized(new ServletContextEvent(servletCtx));

    final WebApplicationContext ctx = ((TestFriendlyContextLoader) listener.getContextLoader()).getCtx();

    assertEquals("house", ctx.getBean("test1"));
}

From source file:org.openxdata.server.servlet.BirtImagesServlet.java

@Override
public void init() throws ServletException {
    ServletContext sctx = this.getServletContext();
    WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sctx);
    settingService = (SettingService) ctx.getBean("settingService");
}

From source file:com.thoughtworks.go.server.websocket.ConsoleLogSocketServlet.java

@Override
public void init() throws ServletException {
    WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());

    socketCreator = wac.getBean(ConsoleLogSocketCreator.class);
    securityService = wac.getBean(SecurityService.class);

    super.init();
}

From source file:org.ujorm.orm.support.OpenSessionInViewFilter.java

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    ServletContext sc = filterConfig.getServletContext();
    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
    ujoSessionFactoryFilter = (UjoSessionFactoryFilter) wac.getBean("ujoSessionFactory");
}

From source file:ar.com.zauber.commons.spring.beans.factory.impl.ContextPathRegexCaseBlockTest.java

/** test */
public final void testCtxDefault() {
    final MockServletContext servletCtx = new MockServletContext("/laralara");
    servletCtx.addInitParameter("contextConfigLocation", "classpath:/spring-test-switch-regex.xml");
    final TestFriendlyContextLoaderListener listener = new TestFriendlyContextLoaderListener();
    listener.contextInitialized(new ServletContextEvent(servletCtx));

    final WebApplicationContext ctx = ((TestFriendlyContextLoader) listener.getContextLoader()).getCtx();

    assertEquals("default", ctx.getBean("test1"));
}

From source file:org.openxdata.server.servlet.ReportServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    super.init(config);

    ServletContext sctx = this.getServletContext();
    WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sctx);
    reportService = (ReportService) ctx.getBean("reportService");
}

From source file:org.tsm.concharto.web.filter.NotificationFilter.java

public void init(FilterConfig filterConfig) throws ServletException {
    this.filterConfig = filterConfig;
    ServletContext ctx = filterConfig.getServletContext();
    WebApplicationContext webAppContext = WebApplicationContextUtils.getWebApplicationContext(ctx);
    notificationDao = (NotificationDao) webAppContext.getBean("notificationDao");
}

From source file:com.ewcms.component.checkcode.web.ImageCaptchaServlet.java

protected CaptchaService getCaptchaService() {
    ServletContext application = getServletContext();
    WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(application);
    return (CaptchaService) wac.getBean("captchaService");
}

From source file:com.solab.alarms.servlet.AlarmServlet.java

public void init(ServletConfig config) throws ServletException {
    super.init(config);
    WebApplicationContext ctxt = WebApplicationContextUtils
            .getWebApplicationContext(config.getServletContext());
    sender = ctxt.getBean(AlarmSenderImpl.class);
    auth = ctxt.getBean(PasswordVerifier.class);
}