List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getWebApplicationContext
@Nullable public static WebApplicationContext getWebApplicationContext(ServletContext sc)
From source file:ch.frankel.vaadin.spring.SpringApplicationServlet.java
/** * Get the application class from the bean configured in Spring's context. * //from w w w.j ava2 s .c om * @see AbstractApplicationServlet#getApplicationClass() */ @SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected Class<? extends Application> getApplicationClass() throws ClassNotFoundException { WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); if (wac == null) { throw new ClassNotFoundException("Cannot get an handle on Spring's context. Is Spring running? " + "Check there's an org.springframework.web.context.ContextLoaderListener configured."); } Object bean = wac.getBean(name); if (bean == null) { throw new ClassNotFoundException("No application bean found under name " + name); } return (Class) bean.getClass(); }
From source file:org.openmeetings.servlet.outputhandler.LangExport.java
public FieldLanguageDaoImpl getFieldLanguageDaoImpl() { try {//from ww w .j a v a 2 s. co m if (ScopeApplicationAdapter.initComplete) { ApplicationContext context = WebApplicationContextUtils .getWebApplicationContext(getServletContext()); return context.getBean("fieldLanguageDaoImpl", FieldLanguageDaoImpl.class); } } catch (Exception err) { log.error("[getFieldLanguageDaoImpl]", err); } return null; }
From source file:net.naijatek.myalumni.util.taglib.BuildDropdownTag.java
/** * doStartTag/*from w ww. ja v a 2 s.com*/ * * @exception JspException * @return int */ public final int doStartTag() throws JspException { WebApplicationContext wac = WebApplicationContextUtils .getWebApplicationContext(pageContext.getServletContext()); xlatService = (IXlatService) wac.getBean(BaseConstants.SERVICE_XLAT_LOOKUP); memberService = (IMemberService) wac.getBean(BaseConstants.SERVICE_MEMBER_LOOKUP); systemConfigService = (ISystemConfigService) wac.getBean(BaseConstants.SERVICE_SYSTEM_CONFIG); return EVAL_BODY_BUFFERED; }
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:com.openmeap.services.ApplicationManagementServlet.java
@Override public void init() { context = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); modelManager = (ModelManager) context.getBean("modelManager"); }
From source file:com.hazelcast.web.spring.SpringAwareWebFilter.java
@Override protected void destroySession(HazelcastHttpSession session, boolean invalidate) { super.destroySession(session, invalidate); if (invalidate) { ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); if (appContext != null) { ensureSessionRegistryInitialized(appContext); if (sessionRegistry != null) { String originalSessionId = session.getOriginalSessionId(); // If original session id is registered already, we don't need it. // So, we should remove it also. sessionRegistry.removeSessionInformation(originalSessionId); /**// w w w.j av a 2s. c om * Publish an event to notify * {@link org.springframework.security.core.session.SessionRegistry} instance. * So Spring clears information about our Hazelcast session. */ appContext.publishEvent(new HttpSessionDestroyedEvent(session)); LOGGER.finest( "Published destroy session event for Spring for session with id " + session.getId()); } } } }
From source file:org.jbpm.formbuilder.server.ExportTemplateServlet.java
protected FormDefinitionService createFormService(HttpServletRequest request) { return (FormDefinitionService) WebApplicationContextUtils .getWebApplicationContext(request.getSession().getServletContext()).getBean("guvnorFormService"); }
From source file:net.naijatek.myalumni.framework.spring.MyAlumniStartupServlet.java
private void setupCache() throws Exception { // @see:/* w w w . j av a 2s . co m*/ // net.naijatek.myalumni.util.date.DateConverterUtil::getDatePattern() getServletContext().setAttribute(BaseConstants.LOOKUP_DATE_FORMAT_PATTERN, SystemConfigConstants.DATE_FORMAT_JSP); getServletContext().setAttribute(BaseConstants.LOOKUP_DATE_TIME_FORMAT_PATTERN, SystemConfigConstants.DATE_TIME_FORMAT_JSP); WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); ISystemTaskService startupService = (ISystemTaskService) wac .getBean(BaseConstants.SERVICE_SYSTEM_TASK_LOOKUP); ISystemConfigService sysConfigService = (ISystemConfigService) wac .getBean(BaseConstants.SERVICE_SYSTEM_CONFIG); SystemConfigVO sysConfigVO = sysConfigService.getSystemConfig(); getServletContext().setAttribute(BaseConstants.ORGANIZATION_NAME, sysConfigVO.getOrganizationName()); getServletContext().setAttribute(BaseConstants.ORGANIZATION_SHORT_NAME, sysConfigVO.getOrganizationShortName()); getServletContext().setAttribute(BaseConstants.ALBUM_URL, sysConfigVO.getAlbumUrl()); getServletContext().setAttribute(BaseConstants.FORUM_URL, sysConfigVO.getForumUrl()); getServletContext().setAttribute(BaseConstants.SERVER_URL, sysConfigVO.getServerUrl()); getServletContext().setAttribute(BaseConstants.ORG_EMAIL, sysConfigVO.getOrgEmail()); getServletContext().setAttribute(BaseConstants.LOGO_NAME, sysConfigVO.getLogoFileName()); getServletContext().setAttribute(BaseConstants.CSS_TYPE, "default"); String hasDorm = sysConfigVO.getHasDormitory(); setupDatabaseCache(startupService, sysConfigService, hasDorm); setupOtherCache(hasDorm); if (sysConfigVO.getSystemConfigId() == null) { getServletContext().setAttribute(BaseConstants.FIRST_STARTUP, BaseConstants.BOOLEAN_YES); } else { getServletContext().setAttribute(BaseConstants.FIRST_STARTUP, BaseConstants.BOOLEAN_NO); } }
From source file:org.hdiv.config.multipart.SpringMVCMultipartConfig.java
/** * Obtain MultipartResolver instance for this application. * //w w w . j ava 2 s. c o m * @param servletContext * app ServletContext * @return MultipartResolver instance */ @SuppressWarnings("rawtypes") protected MultipartResolver lookupMultipartResolver(ServletContext servletContext) { MultipartResolver resolver = null; if (this.webApplicationContext == null) { this.webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); } try { resolver = this.webApplicationContext.getBean(MULTIPART_RESOLVER_BEAN_NAME, MultipartResolver.class); if (resolver != null) { return resolver; } } catch (NoSuchBeanDefinitionException ex) { // No MultipartResolver in this context. } if (resolver == null) { Enumeration e = servletContext.getAttributeNames(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); if (name.startsWith(FrameworkServlet.SERVLET_CONTEXT_PREFIX)) { this.webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext, name); break; } } } if (this.webApplicationContext != null) { try { resolver = this.webApplicationContext.getBean(MULTIPART_RESOLVER_BEAN_NAME, MultipartResolver.class); } catch (NoSuchBeanDefinitionException ex) { // No MultipartResolver in this context. } } if (log.isDebugEnabled() && resolver == null) { log.debug("Cant find MultipartResolver on any context."); } return resolver; }
From source file:com.square.client.gwt.server.servlet.ExporterRechercheServlet.java
@Override public void init() throws ServletException { super.init(); final WebApplicationContext context = WebApplicationContextUtils .getWebApplicationContext(getServletContext()); personnePhysiqueService = (PersonnePhysiqueService) context.getBean("personnePhysiqueService"); campagneService = (CampagneService) context.getBean("campagneService"); actionService = (ActionService) context.getBean("actionService"); ressourceService = (RessourceService) context.getBean("ressourceService"); personneMoraleService = (PersonneMoraleService) context.getBean("personneMoraleService"); }