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.ewcms.component.comment.web.CounterServlet.java

protected CommentServiceable getCommentService() {
    ServletContext application = getServletContext();
    WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(application);

    return (CommentServiceable) wac.getBean("commentService");
}

From source file:gov.nih.nci.ncicb.cadsr.admintool.struts.action.BaseDispatchAction.java

public void setServlet(ActionServlet servlet) {
    super.setServlet(servlet);
    ServletContext servletContext = servlet.getServletContext();
    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    conceptService = (ConceptService) wac.getBean("conceptService");
    contextService = (ContextService) wac.getBean("contextService");
    this.printAllContexts();
}

From source file:com.ewcms.plugin.vote.manager.web.ResultServlet.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    ServletOutputStream out = null;//w  ww.  ja v  a 2  s.c  om
    StringBuffer output = new StringBuffer();
    try {
        String id = req.getParameter("id");

        if (!id.equals("") && StringUtils.isNumeric(id)) {
            Long questionnaireId = new Long(id);

            ServletContext application = getServletContext();
            WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(application);
            VoteFacable voteFac = (VoteFacable) wac.getBean("voteFac");

            String ipAddr = req.getRemoteAddr();

            output = voteFac.getQuestionnaireResultClientToHtml(questionnaireId,
                    getServletContext().getContextPath(), ipAddr);
        }
        out = resp.getOutputStream();
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html; charset=UTF-8");
        out.write(output.toString().getBytes("UTF-8"));
        out.flush();
    } finally {
        if (out != null) {
            out.close();
            out = null;
        }
    }
}

From source file:gov.nih.nci.ncicb.cadsr.admintool.struts.action.BaseAction.java

public void setServlet(ActionServlet actionServlet) {
    super.setServlet(actionServlet);
    ServletContext servletContext = actionServlet.getServletContext();
    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    conceptService = (ConceptService) wac.getBean("conceptService");
    contextService = (ContextService) wac.getBean("contextService");
    this.printAllContexts();
}

From source file:org.openxdata.server.rpc.OxdPersistentRemoteService.java

/**
 * Servlet initialisation//w w  w .j av a 2 s.c om
 */
@Override
public void init() throws ServletException {
    super.init();

    WebApplicationContext ctx = getApplicationContext();

    HibernateUtil hibernateUtil = new HibernateUtil();
    hibernateUtil.setSessionFactory((SessionFactory) ctx.getBean("sessionFactory"));
    PersistentBeanManager persistentBeanManager = GwtConfigurationHelper
            .initGwtStatelessBeanManager(hibernateUtil);
    setBeanManager(persistentBeanManager);
}

From source file:com.sbu.controller.Feed_Form_Startup_Edit_Contorller.java

@Override
public void init() throws ServletException {
    WebApplicationContext context = WebApplicationContextUtils
            .getRequiredWebApplicationContext(getServletContext());
    startupService = context.getBean(StartupManager.class);
    memberService = context.getBean(MemberManager.class);

}

From source file:com.telefonica.euro_iaas.paasmanager.bootstrap.PropertiesLoaderBootstrap.java

/**
 * {@inheritDoc}/*from w w w.ja v  a2  s  .  c om*/
 */
public void contextInitialized(ServletContextEvent event) {
    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
    EntityManagerFactory emf = (EntityManagerFactory) ctx.getBean("entityManagerFactory");

    PropertiesProvider propertiesProvider = new PropertiesProviderFactoryImpl().createPropertiesProvider(emf);
    Properties properties = propertiesProvider.load(NAMESPACE);
    try {
        log.info("store namespace: " + NAMESPACE);
        propertiesProvider.store(properties, NAMESPACE);
    } catch (Exception e) {
        throw new PaasManagerServerRuntimeException(e);
    }
}

From source file:com.telefonica.euro_iaas.sdc.bootstrap.PropertiesLoaderBootstrap.java

/**
 * {@inheritDoc}//from ww  w  .  j  av  a2 s .co  m
 */

public void contextInitialized(ServletContextEvent event) {
    WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
    EntityManagerFactory emf = (EntityManagerFactory) ctx.getBean("entityManagerFactory");

    PropertiesProvider propertiesProvider = new PropertiesProviderFactoryImpl().createPropertiesProvider(emf);
    Properties properties = propertiesProvider.load(NAMESPACE);
    try {
        log.info("store namespace: " + NAMESPACE);
        propertiesProvider.store(properties, NAMESPACE);
    } catch (Exception e) {
        throw new SdcRuntimeException(e);
    }
}

From source file:org.fcrepo.indexer.webapp.FedoraIndexer.java

/**
 * Servlet initialization./*  ww  w. j ava2s. co  m*/
**/
public void init(final ServletConfig sc) throws ServletException {
    super.init(sc);
    final WebApplicationContext ctx = WebApplicationContextUtils
            .getRequiredWebApplicationContext(getServletContext());
    indexer = (IndexerGroup) ctx.getBean(sc.getInitParameter("beanName"));
}

From source file:com.ewcms.component.counter.web.CounterServlet.java

private CounterServiceable getCountSerivce() {
    ServletContext application = getServletContext();
    WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(application);

    return (CounterServiceable) wac.getBean("counterService");
}