List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getWebApplicationContext
@Nullable public static WebApplicationContext getWebApplicationContext(ServletContext sc)
From source file:com.telefonica.euro_iaas.paasmanager.bootstrap.PropertiesMBeanRegisterBootstrap.java
/** * Stores every system properties in BD and show them by JMX */// w ww. ja v a2 s. c om public void contextInitialized(ServletContextEvent event) { WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext()); PropertiesProvider propertiesUtil = new PropertiesProviderFactoryImpl() .createPropertiesProvider((EntityManagerFactory) ctx.getBean("entityManagerFactory")); try { for (String namespace : propertiesUtil.getNamespaces()) { PropertiesProviderMBean mbean = new PropertiesProviderMBean(namespace, propertiesUtil); log.info("Registering mbean " + namespace); MBeanUtils.register(mbean, event.getServletContext().getContextPath() + ":service=SystemConfiguration-" + namespace); } } catch (Exception e) { throw new PaasManagerServerRuntimeException(e); } }
From source file:org.openmeetings.servlet.outputhandler.Install.java
private ImportInitvalues getImportInitvalues() { try {/*from w w w . ja v a2 s .c om*/ if (!ScopeApplicationAdapter.initComplete) { return null; } ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); return (ImportInitvalues) context.getBean("importInitvalues"); } catch (Exception err) { log.error("[getImportInitvalues]", err); } return null; }
From source file:org.LexGrid.LexBIG.caCore.web.util.LexEVSHTTPQuery.java
/** * Initialize the servlet/* w w w.j ava 2 s . c o m*/ */ public void init(ServletConfig config) throws ServletException { super.init(config); context = config.getServletContext(); WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context); Properties systemProperties = (Properties) ctx.getBean("WebSystemProperties"); cacoreStyleSheet = systemProperties.getProperty("resultOutputFormatter"); jsonStyleSheet = systemProperties.getProperty("jsonOutputFormatter"); log.debug("cacoreStylesheet: " + cacoreStyleSheet); try { String pageCount = systemProperties.getProperty("rowCounter"); log.debug("rowCounter: " + pageCount); if (pageCount != null) { pageSize = Integer.parseInt(pageCount); } } catch (Exception ex) { log.error("Exception: ", ex); } }
From source file:org.brixcms.rmiserver.web.dav.WebDavServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); final ServletContext sc = config.getServletContext(); ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(sc); if (context == null) { throw new IllegalStateException("Could not find application context"); }//from w w w. j a v a 2s . c om repository = (Repository) BeanFactoryUtils.beanOfTypeIncludingAncestors(context, Repository.class); if (repository == null) { throw new IllegalStateException("Could not find JackRabbit repository in spring context"); } UserService users = (UserService) BeanFactoryUtils.beanOfTypeIncludingAncestors(context, UserService.class); if (repository == null) { throw new IllegalStateException("Could not find UserService implementation in spring context"); } authorizer = new Authorizer(users); credentialsProvider = getCredentialsProvider(); }
From source file:eu.earthobservatory.org.StrabonEndpoint.DescribeBean.java
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); // get StrabonWrapper ServletContext context = getServletContext(); WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context); strabonWrapper = (StrabonBeanWrapper) applicationContext.getBean("strabonBean"); }
From source file:ee.pri.rl.blog.web.BlogApplication.java
@Override protected void init() { // Set the blog service for the service holder. BlogServiceHolder.set((BlogService) WebApplicationContextUtils.getWebApplicationContext(getServletContext()) .getBean("blogService")); // See method comments. mountBookmarkablePages();// ww w .j ava 2 s . co m configureSecurity(); setupErrorHandling(); setupDatabaseWhenNecessary(); // Strip wicket:* tags from the HTML output. getMarkupSettings().setStripWicketTags(true); // Strip comments from HTML output. getMarkupSettings().setStripComments(true); }
From source file:fr.putnami.pwt.plugin.spring.web.filter.DelegatingChainFilter.java
protected WebApplicationContext findWebApplicationContext() { if (this.webApplicationContext == null) { webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); }/*from www. j ava 2s .c o m*/ return webApplicationContext; }
From source file:ch.frankel.vaadin.spring.SpringApplicationServlet.java
/** * Get the application bean in Spring's context. * /*w ww . ja v a2 s . c o m*/ * @see AbstractApplicationServlet#getNewApplication(HttpServletRequest) */ @Override protected Application getNewApplication(HttpServletRequest request) throws ServletException { WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); if (wac == null) { throw new ServletException("Cannot get an handle on Spring's context. Is Spring running?" + "Check there's an org.springframework.web.context.ContextLoaderListener configured."); } Object bean = wac.getBean(name); if (!(bean instanceof Application)) { throw new ServletException("Bean " + name + " is not of expected class Application"); } return (Application) bean; }
From source file:nc.noumea.mairie.organigramme.core.authentification.AuthentificationFilter.java
public void init(FilterConfig config) throws ServletException { ServletContext servletContext = config.getServletContext(); WebApplicationContext webApplicationContext = WebApplicationContextUtils .getWebApplicationContext(servletContext); AutowireCapableBeanFactory autowireCapableBeanFactory = webApplicationContext .getAutowireCapableBeanFactory(); radiWSConsumer = (IRadiWSConsumer) autowireCapableBeanFactory.getBean("radiWSConsumer"); sirhWSConsumer = (ISirhWSConsumer) autowireCapableBeanFactory.getBean("sirhWSConsumer"); }
From source file:org.seamless_if.services.servlets.SchedulerServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); WebApplicationContext springContext = WebApplicationContextUtils .getWebApplicationContext(getServletContext()); schedulerDao = (SchedulerService) springContext.getBean("schedulerDao"); // TODO remove test code // create some sample model chains ModelChainInfoTO chainA = new ModelChainInfoTO(); chainA.setName("APES->FSSIM"); chainA.setVersion("1.0"); ModelChainInfoTO chainB = new ModelChainInfoTO(); chainB.setName("FSSIM<->CAPRI"); chainB.setVersion("1.1"); // create some sample workers WorkerTO workerA = new WorkerTO(); workerA.setName("WorkerA"); workerA.addAvailableModelChain(chainA); schedulerDao.registerWorker(workerA); WorkerTO workerB = new WorkerTO(); workerB.setName("WorkerB"); workerB.addAvailableModelChain(chainA); workerB.addAvailableModelChain(chainB); schedulerDao.registerWorker(workerB); // create some sample jobs JobTO jobA = new JobTO(); jobA.setExperimentId(1L);//from ww w .j a v a 2 s .c o m jobA.setModelChain(chainA); schedulerDao.addJob(jobA); JobTO jobB = new JobTO(); jobB.setExperimentId(2L); jobB.setModelChain(chainB); schedulerDao.addJob(jobB); }