List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getWebApplicationContext
@Nullable public static WebApplicationContext getWebApplicationContext(ServletContext sc)
From source file:org.jmesa.web.HttpServletRequestSpringWebContext.java
@Override public ApplicationContext getApplicationContext() { return WebApplicationContextUtils .getWebApplicationContext(getHttpServletRequest().getSession().getServletContext()); }
From source file:org.vaadin.webinars.springandvaadin.i18n.ui.createTask.CreateTaskServlet.java
@Override protected void servletInitialized() throws ServletException { final ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); getService().addSessionInitListener(new SessionInitListener() { @Override/*w ww.java2 s .c om*/ public void sessionInit(SessionInitEvent sessionInitEvent) throws ServiceException { sessionInitEvent.getSession().addUIProvider(new UIProvider() { @Override public Class<? extends UI> getUIClass(UIClassSelectionEvent uiClassSelectionEvent) { return CreateTaskUi.class; } @Override public UI createInstance(UICreateEvent event) { return context.getBean(event.getUIClass()); } }); } }); }
From source file:com.reignite.messaging.server.SpringWebInitializer.java
@Override protected RAMFServer getServerFromServletContext(ServletContext servletContext) { WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(servletContext); String beanName = servletContext.getInitParameter("RAMFServerBeanName"); if (beanName == null || beanName.trim().length() == 0) { beanName = "ramfServer"; }//from w ww.j ava 2 s. co m return (RAMFServer) wac.getBean(beanName); }
From source file:com.anhao.market.web.listener.ServletListener.java
@Override public void contextInitialized(ServletContextEvent sce) { logger.info("ServletListener Starting..."); springContext = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext()); //start/*from w w w . ja v a 2s .c o m*/ ServletContext sc = sce.getServletContext(); //? ConfigService configService = (ConfigService) springContext.getBean("configService"); logger.info("this is config {}", configService.getSystemConfig()); sc.setAttribute("systemName", "??"); sc.setAttribute("systemConfig", configService.getSystemConfig()); logger.info("ServletListener Started now"); }
From source file:rights.HasAllRightsTag.java
private boolean hasCommonRights() { WebInvocationPrivilegeEvaluator wipe = (WebInvocationPrivilegeEvaluator) WebApplicationContextUtils .getWebApplicationContext(pageContext.getServletContext()) .getBean(WebInvocationPrivilegeEvaluator.class); return wipe.isAllowed(url, SecurityContextHolder.getContext().getAuthentication()); }
From source file:info.joseluismartin.gtc.admin.AdminApplication.java
/** * {@inheritDoc}//from ww w. j a va 2 s .c om */ @Override public void init() { ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext( ((WebApplicationContext) getContext()).getHttpSession().getServletContext()); TilaGuiFactory guiFactory = (TilaGuiFactory) ctx.getBean("guiFactory"); setTheme("tila"); Window mainWindow = new Window("Tila Administration"); CustomLayout cl = new CustomLayout("main"); Component main = guiFactory.getComponent("main"); cl.addComponent(main, "main"); cl.setSizeFull(); mainWindow.setContent(cl); setMainWindow(mainWindow); }
From source file:io.lavagna.web.helper.Redirector.java
public static void sendRedirect(HttpServletRequest req, HttpServletResponse resp, String page, Map<String, List<String>> params) throws IOException { WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(req.getServletContext()); String baseApplicationUrl = ctx.getBean(ConfigurationRepository.class).getValue(Key.BASE_APPLICATION_URL); UriComponents urlToRedirect = UriComponentsBuilder.fromHttpUrl(baseApplicationUrl).path(page) .queryParams(new LinkedMultiValueMap<>(params)).build(); resp.sendRedirect(urlToRedirect.toUriString()); }
From source file:net.arnx.jsonic.web.SpringContainer.java
@Override public void init(ServletConfig config) { super.init(config); appContext = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext()); }
From source file:com.googlecode.jeeunit.spring.impl.TestRunnerServlet.java
@Override protected Injector createInjector() { ServletContext context = getServletContext(); WebApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(context); SpringInjector injector = new SpringInjector(appContext.getAutowireCapableBeanFactory()); return injector; }
From source file:se.vgregion.pubsub.websocket.JettyWebsocketServlet.java
@Override protected WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) { ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); PubSubEngine pubSubEngine = ctx.getBean(PubSubEngine.class); String topic = request.getParameter("topic"); if (topic != null) { return new WebsocketSubscriber(pubSubEngine, URI.create(topic)); } else {//from w w w .j av a 2 s.c o m // invalid request return null; } }