List of usage examples for org.springframework.web.context WebApplicationContext getBean
Object getBean(String name) throws BeansException;
From source file:com.morevaadin.vaadin7.springsecurity.service.AuthenticationService.java
public void handleAuthentication(String login, String password, HttpServletRequest httpRequest) { UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(login, password); token.setDetails(new WebAuthenticationDetails(httpRequest)); ServletContext servletContext = httpRequest.getSession().getServletContext(); WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); AuthenticationManager authManager = wac.getBean(AuthenticationManager.class); Authentication authentication = authManager.authenticate(token); SecurityContextHolder.getContext().setAuthentication(authentication); }
From source file:com.application.model.dao.AuthenticationService.java
public void handleAuthentication(String login, String password, HttpServletRequest httpRequest) { UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(login, password); token.setDetails(new WebAuthenticationDetails(httpRequest)); ServletContext servletContext = httpRequest.getSession().getServletContext(); WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); AuthenticationManager authManager = wac.getBean(AuthenticationManager.class); Authentication authentication = authManager.authenticate(token); SecurityContextHolder.getContext().setAuthentication(authentication); }
From source file:com.enonic.cms.web.portal.PortalServlet.java
@Override public void init(final ServletConfig config) throws ServletException { super.init(config); final ServletContext context = config.getServletContext(); final WebApplicationContext springContext = WebApplicationContextUtils .getRequiredWebApplicationContext(context); this.dispatcher = springContext.getBean(RequestDispatcher.class); }
From source file:org.workingonit.gwtbridge.GwtBridgeServlet.java
protected RemoteService findRemoteService(String url) { WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); GwtServicesRegistrar registrar = context.getBean(GwtServicesRegistrar.class); if (registrar == null) { throw new RuntimeException("No bean of class GwtServicesRegistrar defined in the Spring context!"); }/* www . j a v a 2 s . c o m*/ String serviceName = url.substring(url.lastIndexOf("/") + 1); return registrar.retrieveGwtService(serviceName); }
From source file:com.sbu.controller.Feed_Personal_Startup_View_Controller.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:org.hdiv.phaseListeners.ComponentMessagesPhaseListener.java
public void beforePhase(PhaseEvent event) { if (this.messagesLog == null) { if (log.isDebugEnabled()) { log.debug("Initialize ComponentMessagesPhaseListener dependencies."); }// w w w . j ava 2 s. c o m WebApplicationContext wac = FacesContextUtils.getRequiredWebApplicationContext(event.getFacesContext()); Logger logger = (Logger) wac.getBean("logger"); this.messagesLog = new ComponentMessagesLog(logger); } }
From source file:io.lavagna.web.security.HSTSFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { WebApplicationContext ctx = getRequiredWebApplicationContext(filterConfig.getServletContext()); config = ctx.getBean(ConfigurationRepository.class); if ("true".equals(config.getValueOrNull(Key.USE_HTTPS))) { filterConfig.getServletContext().getSessionCookieConfig().setSecure(true); }//ww w .jav a 2 s .com }
From source file:org.bytesoft.openjtcc.supports.spring.web.TransactionResourceAdapterListener.java
public void contextDestroyed(ServletContextEvent event) { ServletContext servletContext = event.getServletContext(); WebApplicationContext applicationContext = WebApplicationContextUtils .getRequiredWebApplicationContext(servletContext); ResourceAdapter resourceAdapter = (ResourceAdapter) applicationContext.getBean(ResourceAdapter.class); resourceAdapter.stop();/*from w w w .j ava2 s . co m*/ }
From source file:org.openxdata.server.servlet.ImportServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); ServletContext sctx = this.getServletContext(); WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(sctx); userService = (UserService) ctx.getBean("userService"); }
From source file:org.hdiv.phaselisteners.LogMessageListener.java
public void beforePhase(PhaseEvent event) { if (log.isDebugEnabled()) { log.debug("MESSAGEVALIDATION - BEFORE"); }/*from w w w.j a v a 2s .c o m*/ if (this.logMessages == null) { WebApplicationContext wac = FacesContextUtils.getRequiredWebApplicationContext(event.getFacesContext()); Logger logger = (Logger) wac.getBean("logger"); this.logMessages = new LogMessages(); this.logMessages.init(logger); } }