List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getRequiredWebApplicationContext
public static WebApplicationContext getRequiredWebApplicationContext(ServletContext sc) throws IllegalStateException
From source file:grails.plugin.cache.web.filter.AbstractFilter.java
@SuppressWarnings("unchecked") protected <T> T getBean(String name) { ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); return (T) ctx.getBean(name); }
From source file:edu.du.penrose.systems.util.MyServletContextListener.java
/** * Return the web application context we are running in. * // w w w . j ava2s. c o m * @return WebApplicationContext */ private WebApplicationContext getWebAppContext() { WebApplicationContext wac = null; wac = WebApplicationContextUtils .getRequiredWebApplicationContext(MyServletContextListener.myServletContext); return null; }
From source file:no.dusken.common.plugin.velocity.RenderPluginDirective.java
private VelocityEngine getVelocityEngine(InternalContextAdapter context) { if (velocityEngine == null) { InternalContextAdapter ica = context.getBaseContext(); AbstractRefreshableWebApplicationContext webApplicationContext = (AbstractRefreshableWebApplicationContext) ica .get("org.springframework.web.servlet.DispatcherServlet.CONTEXT"); ServletContext sc = webApplicationContext.getServletContext(); WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(sc); velocityEngine = wac.getBean(VelocityEngine.class); }// w w w .j av a 2s . c o m return velocityEngine; }
From source file:com.ephesoft.dcma.gwt.core.server.DCMARemoteServiceServlet.java
protected <T> T getSingleBeanOfType(Class<T> type) throws NoSuchBeanDefinitionException { WebApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(this.getServletContext()); return ApplicationContextUtil.getSingleBeanOfType(ctx, type); }
From source file:com.ephesoft.dcma.gwt.core.server.DCMARemoteServiceServlet.java
protected <T> T getBeanByName(String name, Class<T> type) throws NoSuchBeanDefinitionException { WebApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(this.getServletContext()); return ApplicationContextUtil.getBeanFromContext(ctx, name, type); }
From source file:org.lamsfoundation.lams.admin.web.OrgSaveAction.java
private void writeAuditLog(Organisation org, DynaActionForm orgForm, OrganisationState newState, SupportedLocale newLocale) {//from w w w. ja v a2 s .co m WebApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(getServlet().getServletContext()); IAuditService auditService = (IAuditService) ctx.getBean("auditService"); MessageService messageService = (MessageService) ctx.getBean("adminMessageService"); String message; // audit log entries for organisation attribute changes if ((Integer) orgForm.get("orgId") != 0) { final String key = "audit.organisation.change"; String[] args = new String[4]; args[1] = org.getName() + "(" + org.getOrganisationId() + ")"; if (!org.getOrganisationState().getOrganisationStateId().equals((Integer) orgForm.get("stateId"))) { args[0] = "state"; args[2] = org.getOrganisationState().getDescription(); args[3] = newState.getDescription(); message = messageService.getMessage(key, args); auditService.log(AdminConstants.MODULE_NAME, message); } if (!StringUtils.equals(org.getName(), (String) orgForm.get("name"))) { args[0] = "name"; args[2] = org.getName(); args[3] = (String) orgForm.get("name"); message = messageService.getMessage(key, args); auditService.log(AdminConstants.MODULE_NAME, message); } if (!StringUtils.equals(org.getCode(), (String) orgForm.get("code"))) { args[0] = "code"; args[2] = org.getCode(); args[3] = (String) orgForm.get("code"); message = messageService.getMessage(key, args); auditService.log(AdminConstants.MODULE_NAME, message); } if (!StringUtils.equals(org.getDescription(), (String) orgForm.getString("description"))) { args[0] = "description"; args[2] = org.getDescription(); args[3] = (String) orgForm.get("description"); message = messageService.getMessage(key, args); auditService.log(AdminConstants.MODULE_NAME, message); } if (!org.getCourseAdminCanAddNewUsers().equals((Boolean) orgForm.get("courseAdminCanAddNewUsers"))) { args[0] = "courseAdminCanAddNewUsers"; args[2] = org.getCourseAdminCanAddNewUsers() ? "true" : "false"; args[3] = (Boolean) orgForm.get("courseAdminCanAddNewUsers") ? "true" : "false"; message = messageService.getMessage(key, args); auditService.log(AdminConstants.MODULE_NAME, message); } if (!org.getCourseAdminCanBrowseAllUsers() .equals((Boolean) orgForm.get("courseAdminCanBrowseAllUsers"))) { args[0] = "courseAdminCanBrowseAllUsers"; args[2] = org.getCourseAdminCanBrowseAllUsers() ? "true" : "false"; args[3] = (Boolean) orgForm.get("courseAdminCanBrowseAllUsers") ? "true" : "false"; message = messageService.getMessage(key, args); auditService.log(AdminConstants.MODULE_NAME, message); } if (!org.getCourseAdminCanChangeStatusOfCourse() .equals((Boolean) orgForm.get("courseAdminCanChangeStatusOfCourse"))) { args[0] = "courseAdminCanChangeStatusOfCourse"; args[2] = org.getCourseAdminCanChangeStatusOfCourse() ? "true" : "false"; args[3] = (Boolean) orgForm.get("courseAdminCanChangeStatusOfCourse") ? "true" : "false"; message = messageService.getMessage(key, args); auditService.log(AdminConstants.MODULE_NAME, message); } /* this field not set yet if(!org.getCourseAdminCanCreateGuestAccounts().equals((Boolean)orgForm.get("courseAdminCanCreateGuestAccounts"))) { args[0] = "courseAdminCanCreateGuestAccounts"; args[2] = org.getCourseAdminCanCreateGuestAccounts() ? "true" : "false"; args[3] = (Boolean)orgForm.get("courseAdminCanCreateGuestAccounts") ? "true" : "false"; message = messageService.getMessage(key, args); auditService.log(AdminConstants.MODULE_NAME, message); }*/ if (!org.getLocale().getLocaleId().equals((Integer) orgForm.get("localeId"))) { args[0] = "locale"; args[2] = org.getLocale().getDescription(); args[3] = newLocale.getDescription(); message = messageService.getMessage(key, args); auditService.log(AdminConstants.MODULE_NAME, message); } } else { String[] args = new String[2]; args[0] = org.getName() + "(" + org.getOrganisationId() + ")"; args[1] = org.getOrganisationType().getName(); message = messageService.getMessage("audit.organisation.create", args); auditService.log(AdminConstants.MODULE_NAME, message); } }
From source file:edu.du.penrose.systems.fedoraProxy.util.FedoraProxyServletContextListener.java
/** * Return the web application context we are running in. * /*from ww w. j a va2 s . c o m*/ * @return WebApplicationContext */ private WebApplicationContext getWebAppContext() { WebApplicationContext wac = null; wac = WebApplicationContextUtils .getRequiredWebApplicationContext(FedoraProxyServletContextListener.myServletContext); return null; }
From source file:gov.nih.nci.caIMAGE.util.NewDropdownUtil.java
private static WebApplicationContext getContext(HttpServletRequest inRequest) { return WebApplicationContextUtils .getRequiredWebApplicationContext(inRequest.getSession().getServletContext()); }
From source file:org.imsglobal.basiclti.provider.servlet.filter.BasicLTISecurityFilter.java
protected ConsumerSecretService getConsumerSecretService() throws ServletException { WebApplicationContext context = WebApplicationContextUtils .getRequiredWebApplicationContext(getServletContext()); ConsumerSecretService bean = (ConsumerSecretService) context.getBean(ConsumerSecretService.class.getName(), ConsumerSecretService.class); if (bean == null) { Map<String, ConsumerSecretService> beansOfType = context.getBeansOfType(ConsumerSecretService.class); if (beansOfType.size() == 1) { bean = beansOfType.values().iterator().next(); } else if (beansOfType.size() > 1) { throw new ServletException( "More than one bean found of type: " + ConsumerSecretService.class.getName()); }/* ww w . j av a2 s. c o m*/ } if (bean != null) return bean; throw new ServletException("Not able to locate a suitable bean to act as " + ConsumerSecretService.class.getName() + " please register an implementation of the " + ConsumerSecretService.class.getName() + "!"); }
From source file:org.lamsfoundation.lams.admin.web.action.ThemeManagementAction.java
private Configuration getConfiguration() { if (configurationService == null) { WebApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(getServlet().getServletContext()); configurationService = (Configuration) ctx.getBean("configurationService"); }/*from w w w . j av a2s . c om*/ return configurationService; }