List of usage examples for org.springframework.web.context.support WebApplicationContextUtils getRequiredWebApplicationContext
public static WebApplicationContext getRequiredWebApplicationContext(ServletContext sc) throws IllegalStateException
From source file:org.agnitas.web.MailingBaseAction.java
protected WebApplicationContext getApplicationContext(HttpServletRequest req) { return WebApplicationContextUtils.getRequiredWebApplicationContext(req.getSession().getServletContext()); }
From source file:org.alfresco.repo.webdav.auth.HTTPRequestAuthenticationFilter.java
/** * Initialize the filter//from w w w.j a v a2 s. c o m * * @param config * FitlerConfig * @exception ServletException */ public void init(FilterConfig config) throws ServletException { // Save the context m_context = config.getServletContext(); // Setup the authentication context WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(m_context); ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); setNodeService(serviceRegistry.getNodeService()); setAuthenticationService(serviceRegistry.getAuthenticationService()); setTransactionService(serviceRegistry.getTransactionService()); setPersonService((PersonService) ctx.getBean("PersonService")); // transactional and permission-checked m_authComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); httpServletRequestAuthHeaderName = config.getInitParameter("httpServletRequestAuthHeaderName"); if (httpServletRequestAuthHeaderName == null) { httpServletRequestAuthHeaderName = "x-user"; } this.m_authPatternString = config.getInitParameter("authPatternString"); if (this.m_authPatternString != null) { try { m_authPattern = Pattern.compile(this.m_authPatternString); } catch (PatternSyntaxException e) { logger.warn("Invalid pattern: " + this.m_authPatternString, e); m_authPattern = null; } } }
From source file:org.alfresco.repo.webdav.WebDAVServlet.java
/** * Initialize the servlet// ww w . j a v a2s . co m * * @param config ServletConfig * @exception ServletException */ @SuppressWarnings("unchecked") public void init(ServletConfig config) throws ServletException { super.init(config); // Get service registry WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); // If no context has been initialised, exit silently so config changes can be made if (context == null) { return; } // Get global configuration properties WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); initParams = (WebDAVInitParameters) wc.getBean(BEAN_INIT_PARAMS); // Render this servlet permanently unavailable if its enablement property is not set if (!initParams.getEnabled()) { logger.info("Marking servlet WebDAV as unavailable!"); return; } // Get root paths String storeValue = initParams.getStoreName(); rootPath = initParams.getRootPath(); // Get beans serviceRegistry = (ServiceRegistry) context.getBean(ServiceRegistry.SERVICE_REGISTRY); transactionService = serviceRegistry.getTransactionService(); tenantService = (TenantService) context.getBean("tenantService"); nodeService = (NodeService) context.getBean("NodeService"); searchService = (SearchService) context.getBean("SearchService"); namespaceService = (NamespaceService) context.getBean("NamespaceService"); ActivityPoster poster = (ActivityPoster) context.getBean("activitiesPoster"); singletonCache = (SimpleCache<String, NodeRef>) context.getBean("immutableSingletonCache"); // Collaborator used by WebDAV methods to create activity posts. activityPoster = new ActivityPosterImpl("WebDAV", poster); // Create the WebDAV helper m_davHelper = (WebDAVHelper) context.getBean("webDAVHelper"); // Initialize the root node initializeRootNode(storeValue, rootPath, context, nodeService, searchService, namespaceService, tenantService, transactionService); // Create the WebDAV methods table m_davMethods = new Hashtable<String, Class<? extends WebDAVMethod>>(); m_davMethods.put(WebDAV.METHOD_PROPFIND, PropFindMethod.class); m_davMethods.put(WebDAV.METHOD_PROPPATCH, PropPatchMethod.class); m_davMethods.put(WebDAV.METHOD_COPY, CopyMethod.class); m_davMethods.put(WebDAV.METHOD_DELETE, DeleteMethod.class); m_davMethods.put(WebDAV.METHOD_GET, GetMethod.class); m_davMethods.put(WebDAV.METHOD_HEAD, HeadMethod.class); m_davMethods.put(WebDAV.METHOD_LOCK, LockMethod.class); m_davMethods.put(WebDAV.METHOD_MKCOL, MkcolMethod.class); m_davMethods.put(WebDAV.METHOD_MOVE, MoveMethod.class); m_davMethods.put(WebDAV.METHOD_OPTIONS, OptionsMethod.class); m_davMethods.put(WebDAV.METHOD_POST, PostMethod.class); m_davMethods.put(WebDAV.METHOD_PUT, PutMethod.class); m_davMethods.put(WebDAV.METHOD_UNLOCK, UnlockMethod.class); }
From source file:org.alfresco.repo.webdav.WebDAVSessionListener.java
@Override public void contextInitialized(ServletContextEvent sce) { ApplicationContext context = WebApplicationContextUtils .getRequiredWebApplicationContext(sce.getServletContext()); this.webDAVLockService = (WebDAVLockService) context.getBean(WebDAVLockService.BEAN_NAME); }
From source file:org.alfresco.web.app.Application.java
/** * Retrieves the configured error page for the application * /* w w w. j a v a 2 s. c o m*/ * @param servletContext The servlet context * @return The configured error page or null if the configuration is missing */ public static String getErrorPage(ServletContext servletContext) { return getErrorPage(WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext)); }
From source file:org.alfresco.web.app.Application.java
/** * Retrieves the configured login page for the application * /*from w w w.j av a 2s . co m*/ * @param servletContext The servlet context * @return The configured login page or null if the configuration is missing */ public static String getLoginPage(ServletContext servletContext) { return getLoginPage(WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext)); }
From source file:org.alfresco.web.app.Application.java
/** * @return Returns the repository store URL (retrieved from config service) *//*from w w w.j a v a 2 s .c om*/ public static StoreRef getRepositoryStoreRef(ServletContext context) { return getRepositoryStoreRef(WebApplicationContextUtils.getRequiredWebApplicationContext(context)); }
From source file:org.alfresco.web.app.Application.java
/** * @return Returns the root path for the application *///from www . j av a2 s . co m public static String getRootPath(ServletContext context) { return getRootPath(WebApplicationContextUtils.getRequiredWebApplicationContext(context)); }
From source file:org.alfresco.web.app.Application.java
/** * @return Returns the glossary folder name *//*from w ww. jav a 2 s.co m*/ public static String getGlossaryFolderName(ServletContext context) { return getGlossaryFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context)); }
From source file:org.alfresco.web.app.Application.java
/** * @return Returns the Space templates folder name *//* ww w. j a va 2 s. co m*/ public static String getSpaceTemplatesFolderName(ServletContext context) { return getSpaceTemplatesFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context)); }