List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getRequiredWebApplicationContext
public static WebApplicationContext getRequiredWebApplicationContext(ServletContext sc) throws IllegalStateException
From source file:org.alfresco.web.app.servlet.HTTPRequestAuthenticationFilter.java
public void init(FilterConfig config) throws ServletException { // Save the context this.context = config.getServletContext(); // Setup the authentication context WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(context); authComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); authenticationService = (AuthenticationService) ctx.getBean("AuthenticationService"); httpServletRequestAuthHeaderName = config.getInitParameter("httpServletRequestAuthHeaderName"); if (httpServletRequestAuthHeaderName == null) { httpServletRequestAuthHeaderName = "x-user"; }//from w w w . ja v a 2 s. c om this.authPatternString = config.getInitParameter("authPatternString"); if (this.authPatternString != null) { try { authPattern = Pattern.compile(this.authPatternString); } catch (PatternSyntaxException e) { logger.warn("Invalid pattern: " + this.authPatternString, e); authPattern = null; } } }
From source file:org.alfresco.web.app.servlet.JBPMDeployProcessServlet.java
@Override public void init() throws ServletException { // Render this servlet permanently unavailable if its enablement property is not set WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); Properties globalProperties = (Properties) wc.getBean(BEAN_GLOBAL_PROPERTIES); String enabled = globalProperties.getProperty(PROP_ENABLED); if (!PropertyCheck.isValidPropertyString(enabled) || !Boolean.parseBoolean(enabled)) { throw new UnavailableException("system.workflow.deployservlet.enabled=false"); }/*from w ww.j av a 2 s. c om*/ }
From source file:org.alfresco.web.app.servlet.JBPMDeployProcessServlet.java
/** * Deploy the jBPM process archive to the Alfresco Repository * /* www . j a v a2 s . co m*/ * @param deploymentArchive the archive to deploy * @return the deployed workflow definition */ private WorkflowDefinition deployArchive(InputStream deploymentArchive) { WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); WorkflowService workflowService = (WorkflowService) wc .getBean(ServiceRegistry.WORKFLOW_SERVICE.getLocalName()); WorkflowDeployment deployment = workflowService.deployDefinition(JBPMEngine.ENGINE_ID, deploymentArchive, MimetypeMap.MIMETYPE_ZIP); return deployment.definition; }
From source file:org.alfresco.web.app.servlet.UploadFileServlet.java
/** * @see javax.servlet.GenericServlet#init() *//* w ww . ja va 2 s . c om*/ @Override public void init(ServletConfig sc) throws ServletException { super.init(sc); WebApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(sc.getServletContext()); this.configService = (ConfigService) ctx.getBean("webClientConfigService"); }
From source file:org.alfresco.web.bean.repository.Repository.java
/** * Return the Repository Service Registry * /*from w w w.j a v a 2 s . co m*/ * @param context Servlet Context * @return the Service Registry */ public static ServiceRegistry getServiceRegistry(ServletContext context) { if (serviceRegistry == null) { serviceRegistry = (ServiceRegistry) WebApplicationContextUtils.getRequiredWebApplicationContext(context) .getBean(ServiceRegistry.SERVICE_REGISTRY); } return serviceRegistry; }
From source file:org.anyframe.iam.core.taglibs.ViewResourceTag.java
/** * find context of Spring// w w w .j av a2 s .co m * * @return */ protected ApplicationContext getContext() { return WebApplicationContextUtils.getRequiredWebApplicationContext(pageContext.getServletContext()); }
From source file:org.apache.archiva.web.rss.RssFeedServlet.java
@Override public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletConfig.getServletContext()); userRepositories = wac.getBean(UserRepositories.class); servletAuth = wac.getBean(ServletAuthenticator.class); httpAuth = wac.getBean("httpAuthenticator#basic", HttpAuthenticator.class); // TODO: what if there are other types? repositorySessionFactory = wac.getBean("repositorySessionFactory", RepositorySessionFactory.class); newArtifactsprocessor = wac.getBean("rssFeedProcessor#new-artifacts", RssFeedProcessor.class); newVersionsprocessor = wac.getBean("rssFeedProcessor#new-versions", RssFeedProcessor.class); }
From source file:org.apache.cocoon.servlet.RequestProcessor.java
public RequestProcessor(ServletContext servletContext) { this.servletContext = servletContext; this.cocoonBeanFactory = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); this.settings = (Settings) this.cocoonBeanFactory.getBean(Settings.ROLE); this.servletSettings = new ServletSettings(this.settings); final String encoding = this.settings.getContainerEncoding(); if (encoding == null) { this.containerEncoding = "ISO-8859-1"; } else {/*w w w . ja v a2s . c o m*/ this.containerEncoding = encoding; } // Obtain access logger String category = servletContext.getInitParameter("org.apache.cocoon.servlet.logger.access"); if (category == null || category.length() == 0) { category = "access"; } setLogger(LoggerUtils.getChildLogger(this.cocoonBeanFactory, category)); this.processor = getProcessor(); this.environmentContext = new HttpContext(this.servletContext); // get the optional request listener if (this.cocoonBeanFactory.containsBean(RequestListener.ROLE)) { this.requestListener = (RequestListener) this.cocoonBeanFactory.getBean(RequestListener.ROLE); } }
From source file:org.apache.cocoon.servletservice.DispatcherServlet.java
public Map getBlockServletMap() { ApplicationContext applicationContext = WebApplicationContextUtils .getRequiredWebApplicationContext(getServletContext()); if (this.blockServletCollector == null || applicationContext.getStartupDate() != this.applicationContextStartDate) { this.applicationContextStartDate = applicationContext.getStartupDate(); this.blockServletCollector = (Map) applicationContext .getBean("org.apache.cocoon.servletservice.spring.BlockServletMap"); }/* w w w . j ava2 s . c om*/ return blockServletCollector; }
From source file:org.apache.nifi.integration.util.NiFiTestServer.java
/** * Convenience method to provide access to Spring beans accessible from the * web application context./* w ww .ja va 2 s .c o m*/ * * @param <T> target cast * @param beanName name of the spring bean * @param clazz class of the spring bean * @return Spring bean with given name and class type * * @throws ClassCastException if the bean found cannot be cast to the given * class type */ public <T> T getSpringBean(String beanName, Class<T> clazz) { ServletContext servletContext = webappContext.getServletHandler().getServletContext(); WebApplicationContext webApplicationContext = WebApplicationContextUtils .getRequiredWebApplicationContext(servletContext); return clazz.cast(webApplicationContext.getBean(beanName)); }