List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getWebApplicationContext
@Nullable public static WebApplicationContext getWebApplicationContext(ServletContext sc)
From source file:org.openmeetings.servlet.outputhandler.CalendarServlet.java
public AppointmentLogic getAppointmentLogic() { try {/* w w w . j av a 2 s .co m*/ if (ScopeApplicationAdapter.initComplete) { ApplicationContext context = WebApplicationContextUtils .getWebApplicationContext(getServletContext()); return (AppointmentLogic) context.getBean("appointmentLogic"); } } catch (Exception err) { log.error("[getAppointmentLogic]", err); } return null; }
From source file:org.hdiv.listener.InitListener.java
/** * Initialize servlet context objects.//from w w w. java2s . c om * * @param servletContextEvent * servlet context created event * @since HDIV 2.1.0 */ public void contextInitialized(ServletContextEvent servletContextEvent) { ServletContext servletContext = servletContextEvent.getServletContext(); WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(servletContext); if (wac != null) { this.initServletContext(servletContext); } else { if (log.isWarnEnabled()) { log.warn("Hdiv's InitListener is registered before Spring's ContextLoaderListener."); } } }
From source file:com.ewcms.component.online.web.servlate.JavaScriptServlet.java
private OnlineService getOnlineService() { ServletContext application = getServletContext(); WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(application); return (OnlineService) wac.getBean("onlineService"); }
From source file:com.ewcms.component.citizen.web.servlate.JavaScriptServlet.java
private CitizenService getCitizenService() { ServletContext application = getServletContext(); WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(application); return (CitizenService) wac.getBean("citizenService"); }
From source file:com.jaspersoft.jasperserver.rest.RESTServlet.java
/** * our initialize routine; subclasses should call this if they override it *///from ww w. j a v a 2s . com @Override public void init() throws javax.servlet.ServletException { applicationContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); servicesUtils = applicationContext.getBean(ServicesUtils.class); registry = (RESTServicRegistry) applicationContext.getBean(BEAN_NAME_REST_SERVICE_REGISTRY); utils = (Utils) applicationContext.getBean(BEAN_NAME_REST_UTILS); }
From source file:net.mlw.vlh.web.ValueListHandlerTilesAction.java
/** * @see org.apache.struts.tiles.Controller#perform(org.apache.struts.tiles.ComponentContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.ServletContext) *///w w w . ja va 2s . co m public void perform(ComponentContext componentContext, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) throws ServletException, IOException { String name = (String) componentContext.getAttribute(VALUE_LIST_NAME); String requestName = (String) componentContext.getAttribute(VALUE_LIST_REQUEST_NAME); WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext); ValueListHandler vlh = (ValueListHandler) context.getBean("valueListHandler", ValueListHandler.class); ValueListInfo info = ValueListRequestUtil.buildValueListInfo(request); ValueList valueList = vlh.getValueList(name, info); request.setAttribute(requestName, valueList); }
From source file:com.ewcms.component.hot.web.JavaScriptServlet.java
private HotService getHotService() { ServletContext application = getServletContext(); WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(application); return (HotService) wac.getBean("hotService"); }
From source file:net.mindengine.oculus.frontend.web.controllers.admin.user.UserEditController.java
@Override protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { verifyPermissions(request);//w w w. jav a 2 s.com Long id = new Long(request.getParameter("id")); if (id.intValue() == 1) throw new Exception("Admin account cannot be changed"); User user = (User) command; WebApplicationContext wac = WebApplicationContextUtils .getWebApplicationContext(request.getSession().getServletContext()); List<Permission> permissions = ((PermissionList) wac.getBean("permissionList")).getPermissions(); // Getting state of permission checkboxes List<Integer> newPermissionCodes = new ArrayList<Integer>(); for (Permission p : permissions) { int code = p.getCode(); String state = request.getParameter("p_" + code); if ("on".equals(state)) { newPermissionCodes.add(code); } user.getClass(); } BitCrypter bitCrypter = new BitCrypter(); String encryptedPermissions = bitCrypter.encrypt(newPermissionCodes); user.setPermissions(encryptedPermissions); if (user != null) { userDAO.updateUser(id, user); } return new ModelAndView(new RedirectView("../admin/edit-user?id=" + id)); }
From source file:io.github.benas.todolist.web.servlet.user.LoginServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { //initialize Spring user service ApplicationContext applicationContext = WebApplicationContextUtils .getWebApplicationContext(servletConfig.getServletContext()); userService = applicationContext.getBean(UserService.class); //initialize JSR 303 validator ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); validator = factory.getValidator();//from w ww. j ava 2 s . c om resourceBundle = ResourceBundle.getBundle("todolist"); }
From source file:org.tsm.concharto.web.filter.LoginFilter.java
public void init(FilterConfig filterConfig) throws ServletException { // this.filterConfig = filterConfig; ServletContext ctx = filterConfig.getServletContext(); WebApplicationContext webAppContext = WebApplicationContextUtils.getWebApplicationContext(ctx); userDao = (UserDao) webAppContext.getBean("userDao"); sessionHelper = (SessionHelper) webAppContext.getBean("sessionHelper"); }