List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getWebApplicationContext
@Nullable public static WebApplicationContext getWebApplicationContext(ServletContext sc)
From source file:se.vgregion.sitemap.servlet.DefaultSitemapServlet.java
/** * Override if you want to load/set other service bean than default "sitemapService" from Spring context. *//*from w w w.j a v a 2 s. c o m*/ protected void loadSitemapService() { WebApplicationContext springContext = WebApplicationContextUtils .getWebApplicationContext(getServletContext()); setSitemapService((SitemapService<?>) springContext.getBean("sitemapService")); }
From source file:org.openmeetings.servlet.outputhandler.LangExport.java
public Usermanagement getUserManagement() { try {/* w w w. jav a 2 s . c o m*/ if (ScopeApplicationAdapter.initComplete) { ApplicationContext context = WebApplicationContextUtils .getWebApplicationContext(getServletContext()); return context.getBean("userManagement", Usermanagement.class); } } catch (Exception err) { log.error("[getUserManagement]", err); } return null; }
From source file:com.thoughtworks.go.spark.SparkPreFilter.java
@Override public void init(FilterConfig config) throws ServletException { servletHelper = ServletHelper.getInstance(); this.wac = WebApplicationContextUtils.getWebApplicationContext(config.getServletContext()); super.init(config); }
From source file:net.naijatek.myalumni.util.taglib.FrontPageLinksTag.java
/** * Includes the body of the tag if the page attribute equals the value set * in the 'match' attribute.// w w w . j a va2 s . co m * * @return SKIP_BODY if equalsAttribute body content does not equal the * value of the match attribute, EVAL_BODY_include if it does * @throws JspException */ @Override public final int doStartTag() throws JspException { request = (HttpServletRequest) pageContext.getRequest(); WebApplicationContext wac = WebApplicationContextUtils .getWebApplicationContext(pageContext.getServletContext()); frontPageService = (IFrontPageService) wac.getBean(BaseConstants.SERVICE_FRONT_PAGE); return EVAL_BODY_BUFFERED; }
From source file:org.openmeetings.servlet.outputhandler.ScreenRequestHandler.java
public Configurationmanagement getCfgManagement() { try {//from w ww .j a v a2 s . c om if (ScopeApplicationAdapter.initComplete) { ApplicationContext context = WebApplicationContextUtils .getWebApplicationContext(getServletContext()); return context.getBean(Configurationmanagement.class); } } catch (Exception err) { log.error("[getCfgManagement]", err); } return null; }
From source file:org.lamsfoundation.lams.admin.web.ScheduledJobListAction.java
/** * Get all waitting queue jobs scheduled in Quartz table and display job name, job start time and * description. The description will be in format "Lesson Name":"the lesson creator", or * "The gate name":"The relatived lesson name". * /*w w w .j ava2s . c o m*/ * @param mapping The ActionMapping used to select this instance * @param actionForm The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet exception occurs * */ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { WebApplicationContext ctx = WebApplicationContextUtils .getWebApplicationContext(this.getServlet().getServletContext()); Scheduler scheduler = (Scheduler) ctx.getBean("scheduler"); ArrayList<ScheduledJobDTO> jobList = new ArrayList<ScheduledJobDTO>(); try { String[] jobNames = scheduler.getJobNames(Scheduler.DEFAULT_GROUP); for (String name : jobNames) { ScheduledJobDTO jobDto = new ScheduledJobDTO(); JobDetail detail = scheduler.getJobDetail(name, Scheduler.DEFAULT_GROUP); jobDto.setName(name); jobDto.setDescription(detail.getDescription()); Trigger[] triggers = scheduler.getTriggersOfJob(name, Scheduler.DEFAULT_GROUP); for (Trigger trigger : triggers) { jobDto.setStartDate(trigger.getStartTime()); jobList.add(jobDto); } } } catch (SchedulerException e) { log.equals("Failed get job names:" + e.getMessage()); } request.setAttribute("jobList", jobList); return mapping.findForward("list"); }
From source file:gov.nih.nci.ccts.grid.service.LabConsumerServiceImpl.java
/** * Will try to locate a pre-existent {@link ApplicationContext}; if failed, * will create it explicitly./*from ww w.j a v a 2s . c om*/ * * @see http://jira.semanticbits.com/browse/CAAERS-4291 */ private synchronized void initialize() { if (this.consumer == null) { ApplicationContext ctx = null; String exp = ContainerConfig.getConfig().getOption(SPRING_CLASSPATH_EXPRESSION, DEFAULT_SPRING_CLASSPATH_EXPRESSION); String bean = ContainerConfig.getConfig().getOption(LAB_CONSUMER_BEAN_NAME, DEFAULT_LAB_CONSUMER_BEAN_NAME); // see http://jira.semanticbits.com/browse/CAAERS-4291 // let's see if ApplicationContext is already available as a // WebApplicationContext // if so, use it; otherwise, fall back to standard approach for // backward compatibility. SOAPMessageContext messageContext = MessageContext.getCurrentContext(); if (messageContext != null) { HttpServlet srv = (HttpServlet) messageContext.getProperty(HTTPConstants.MC_HTTP_SERVLET); if (srv != null) { ServletContext servletContext = srv.getServletContext(); ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext); } } if (ctx == null) { System.out.println( "LabConsumerServiceImpl: unable to find pre-existing spring context in servlet context; falling back to direct context creation."); System.out.println("LabConsumerServiceImpl: Creating spring context explicitly..."); ctx = new ClassPathXmlApplicationContext(exp); } if (ctx != null) this.consumer = (LabConsumerServiceI) ctx.getBean(bean); } }
From source file:com.openmeap.admin.web.servlet.AdminServlet.java
public void init() { context = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); ClusterNodeHealthCheckThread healthChecker = (ClusterNodeHealthCheckThread) context .getBean("clusterNodeHealthCheck"); new Thread(healthChecker).start(); }
From source file:com.vaadin.spring.server.SpringVaadinServlet.java
@Override protected void servletInitialized() throws ServletException { getService().addSessionInitListener(new SessionInitListener() { private static final long serialVersionUID = -6307820453486668084L; @Override//from w ww . j a v a 2 s. c om public void sessionInit(SessionInitEvent sessionInitEvent) throws ServiceException { WebApplicationContext webApplicationContext = WebApplicationContextUtils .getWebApplicationContext(getServletContext()); // remove DefaultUIProvider instances to avoid mapping // extraneous UIs if e.g. a servlet is declared as a nested // class in a UI class VaadinSession session = sessionInitEvent.getSession(); List<UIProvider> uiProviders = new ArrayList<UIProvider>(session.getUIProviders()); for (UIProvider provider : uiProviders) { // use canonical names as these may have been loaded with // different classloaders if (DefaultUIProvider.class.getCanonicalName().equals(provider.getClass().getCanonicalName())) { session.removeUIProvider(provider); } } // add Spring UI provider SpringUIProvider uiProvider = new SpringUIProvider(webApplicationContext); session.addUIProvider(uiProvider); } }); }
From source file:de.itsvs.cwtrpc.controller.CacheControlFilter.java
public void init(FilterConfig filterConfig) throws ServletException { final WebApplicationContext applicationContext; final CacheControlConfig config; final List<CacheControlUriConfig> uriConfigs; String configBeanName;//w w w . ja v a 2s .c om configBeanName = filterConfig.getInitParameter(CONFIG_BEAN_NAME_INIT_PARAM); if (configBeanName == null) { configBeanName = CacheControlConfig.DEFAULT_BEAN_ID; } applicationContext = WebApplicationContextUtils.getWebApplicationContext(filterConfig.getServletContext()); if (log.isDebugEnabled()) { log.debug("Resolving cache control config with bean name '" + configBeanName + "' from application context"); } config = applicationContext.getBean(configBeanName, CacheControlConfig.class); setLowerCaseMatch(config.isLowerCaseMatch()); uriConfigs = new ArrayList<CacheControlUriConfig>(); if (config.isDefaultsEnabled()) { log.debug("Adding default URI configurations"); uriConfigs.addAll(createDefaultUriConfigs(config)); } uriConfigs.addAll(config.getUriConfigs()); setUriConfigs(createCacheControlUriConfigBuilder().build(uriConfigs)); }