List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getRequiredWebApplicationContext
public static WebApplicationContext getRequiredWebApplicationContext(ServletContext sc) throws IllegalStateException
From source file:org.hdiv.listener.InitListener.java
/** * For each user session, a new cipher key is created if the cipher strategy has been chosen, and a new cache is * created to store the data to be validated. * // ww w . jav a 2s . co m * @see javax.servlet.http.HttpSessionListener#void (javax.servlet.http.HttpSessionEvent) */ public void sessionCreated(HttpSessionEvent httpSessionEvent) { ServletContext servletContext = httpSessionEvent.getSession().getServletContext(); if (!this.servletContextInitialized) { this.initServletContext(servletContext); } WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); this.initStrategies(wac, httpSessionEvent.getSession()); this.initCache(wac, httpSessionEvent.getSession()); this.initPageIdGenerator(wac, httpSessionEvent.getSession()); this.initHDIVStateParameters(wac, httpSessionEvent.getSession()); if (log.isInfoEnabled()) { log.info("HDIV's session created:" + httpSessionEvent.getSession().getId()); } }
From source file:com.impetus.ankush.common.controller.listener.StartupListener.java
/** * {@inheritDoc}// www . j ava 2 s . co m */ @Override @SuppressWarnings("unchecked") public void contextInitialized(final ServletContextEvent event) { log.info("Initializing context..."); ServletContext context = event.getServletContext(); applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(context); try { // setting application context. AppStoreWrapper.setApplicationContext(applicationContext); // setting servlet context. AppStoreWrapper.setServletContext(context); // setting ankush config reader and config properties reader. setAnkushConfigurator(); // set ankush confiration classes. // AppStoreWrapper.setAnkushConfigurableClassNames(); AppStoreWrapper.setComponentConfiguration(); AppStoreWrapper.setCompConfigClasses(); // Read VERSION.txt file in agent.tar.gz and set current agent // version in server context setAgentVersion(); // For Reading ankush-hadoop-config.xml // HadoopUtils.setHadoopConfigClasses(); // setting mail manager setupMailManager(); // setting App access URL setupAppAccessURL(); // setting asyc executor. setAsyncExecutor(); addDefaultAdminUser(); setServerHost(); // initialising the application dependencies. initializeAppDependency(); // process inconsistent operations in the operation table,which have // op-status as "InProgress",set to "Failed" processInconsistentOperation(); // Start Agent Upgrade procedure new AgentUpgrader().asyncUpgradeAgent(); } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:ejportal.webapp.listener.StartupListener.java
/** * This method uses the LookupManager to lookup available roles from the * data layer./*from ww w. j a v a2 s . co m*/ * * @param context * The servlet context */ public static void setupContext(final ServletContext context) { final ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context); final LookupManager mgr = (LookupManager) ctx.getBean("lookupManager"); // get list of possible roles context.setAttribute(Constants.AVAILABLE_ROLES, mgr.getAllRoles()); StartupListener.log.debug("Drop-down initialization complete [OK]"); }
From source file:de.fhg.igd.vaadin.util.servlets.AutowiringApplicationServlet.java
/** * Initialize this servlet./*from w w w. java2 s.co m*/ * * @throws ServletException if there is no {@link WebApplicationContext} associated with this servlet's context */ @Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); // initApplicationClass(servletConfig); try { webApplicationContext = WebApplicationContextUtils .getRequiredWebApplicationContext(servletConfig.getServletContext()); } catch (final IllegalStateException e) { throw new ServletException("could not locate containing WebApplicationContext"); } }
From source file:org.lightadmin.core.config.bootstrap.LightAdminBeanDefinitionRegistryPostProcessor.java
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { WebApplicationContext rootContext = WebApplicationContextUtils .getRequiredWebApplicationContext(servletContext); EntityManager entityManager = findEntityManager(rootContext); ResourceLoader resourceLoader = newResourceLoader(servletContext); Set<Class> administrationConfigs = scanPackageForAdministrationClasses(); Set<ConfigurationUnits> configurationUnits = configurationUnits(rootContext, administrationConfigs); registry.registerBeanDefinition(JPA_MAPPPING_CONTEXT_BEAN, mappingContext(entityManager)); registry.registerBeanDefinition(CONFIGURATION_UNITS_VALIDATOR_BEAN, configurationUnitsValidator(resourceLoader)); for (Class<?> managedEntityType : managedEntities(entityManager)) { Class repoInterface = createDynamicRepositoryClass(managedEntityType, entityManager); registry.registerBeanDefinition(beanName(repoInterface), repositoryFactory(repoInterface, entityManager)); }// ww w . ja v a 2 s. co m registerRepositoryEventListeners(configurationUnits, registry); registry.registerBeanDefinition(beanName(GlobalAdministrationConfiguration.class), globalAdministrationConfigurationFactoryBeanDefinition(configurationUnits)); registry.registerBeanDefinition(beanName(DomainTypeAdministrationConfigurationFactory.class), domainTypeAdministrationConfigurationFactoryDefinition(entityManager)); }
From source file:org.hdiv.listener.InitWebSphereListener.java
/** * For each user session, a new cipher key is created if the cipher strategy has * been chosen, and a new cache is created to store the data to be validated. * /*from w ww . j a v a 2 s .c o m*/ * @see javax.servlet.http.HttpSessionListener#void * (javax.servlet.http.HttpSessionEvent) */ public void sessionCreated(HttpSessionEvent arg0) { ServletContext servletContext = arg0.getSession().getServletContext(); WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); this.initStrategies(wac, arg0); this.initCache(wac, arg0); this.initHDIVState(wac, arg0); // HDIVUtil.setHttpSession(arg0.getSession()); if (log.isInfoEnabled()) { log.info("HDIV's session created:" + arg0.getSession().getId()); } }
From source file:com.wdeanmedical.portal.service.AppService.java
public AppService() throws MalformedURLException { context = Core.servletContext;/*from ww w . java 2 s.com*/ wac = WebApplicationContextUtils.getRequiredWebApplicationContext(context); appDAO = (AppDAO) wac.getBean("appDAO"); activityLogService = new ActivityLogService(); }
From source file:nl.tue.gale.ae.GaleServlet.java
protected final void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ApplicationContext applicationContext = WebApplicationContextUtils .getRequiredWebApplicationContext(getServletContext()); GaleServletBean gsb = (GaleServletBean) applicationContext.getBean("galeServletBean"); gsb.service(req, resp);// ww w. j av a 2 s .co m }
From source file:kz.supershiny.web.wicket.TiresApplication.java
private void createInitialUser() { User user = new User(); user.setPhone(Constants.ADMIN_PHONE); user.setPassword(Constants.ADMIN_PASS); user.setUsername(Constants.ADMIN_UNAME); ApplicationContext applicationContext = WebApplicationContextUtils .getRequiredWebApplicationContext(getServletContext()); UserService us = applicationContext.getBean(UserService.class); try {/*from w w w . java 2 s .com*/ us.saveUser(user); } catch (Exception ex) { LOG.error("Failed to save initial user from TiresApplication"); } }
From source file:com.enonic.cms.server.service.dwr.DwrServletWrapper.java
private ConfigProperties getConfigProperties(final ServletContext servletContext) { final WebApplicationContext context = WebApplicationContextUtils .getRequiredWebApplicationContext(servletContext); return context.getBean(ConfigProperties.class); }