public SpringMessageResolver(HttpServletRequest request) { super(request); // Retrieve the Spring messageSource bean messageSource = RequestContextUtils.getWebApplicationContext(request); }
public SpringMessageResolver(HttpServletRequest request) { super(request); // Retrieve the Spring messageSource bean messageSource = RequestContextUtils.getWebApplicationContext(request); }
public static ApplicationContext getApplicationContext () { HttpServletRequest servletRequest = getServletRequest(); if (servletRequest == null) return null; return RequestContextUtils.getWebApplicationContext(servletRequest); }
private static WebApplicationContext getWebApplicationContext() { return RequestContextUtils.getWebApplicationContext(HttpUtils.getCurrentRequest()); } }
public static HandlerUrlResolver getUrlResolver(HttpServletRequest request) { return getUrlResolver(RequestContextUtils.getWebApplicationContext(request)); }
@Override public String getLocalizedKey( String key ) { String localizedKey = super.getLocalizedKey( key ); if ( localizedKey != null ) { return localizedKey; } // Use Spring MessageResources (if any) // // Note: we are unclear how, in Spring, to differentiate 'there is no key // in the bundle' from 'there are no bundles'. So for now we always assume // the latter (eg. we'll never return ???key???) HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); MessageSource context = RequestContextUtils.getWebApplicationContext( request ); return context.getMessage( key, null, null, RequestContextUtils.getLocale( request ) ); }
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (handler instanceof Postback) { handler = ((Postback) handler).getHandler(); } WebApplicationContext webApplicationContext = RequestContextUtils.getWebApplicationContext(request, this.servletContext); initializeSpringFacesContext(this.lifecycleAccessor, webApplicationContext, request, response, handler); return true; }
MessageSource messageSource = RequestContextUtils.getWebApplicationContext(pageContext.getRequest(), pageContext.getServletContext()); if (messageSource == null)
@Override public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception { if (handlerUrlResolver == null) { WebApplicationContext context = RequestContextUtils.getWebApplicationContext(request); handlerUrlResolver = (HandlerUrlResolver) context.getBean("handlerUrlResolver"); } String handlerUrl = handlerUrlResolver.getUrlForHandler(handlerName, model, null); Assert.notNull(handlerUrl, "Can't resolve URL for handler " + handlerName); setUrl(handlerUrl); setContextRelative(true); super.render(model, request, response); }
/** * This implementation delegates to <code>doPerform</code>, * lazy-initializing the application context reference if necessary. * <p>This is the preferred execution method in Struts 1.2. * When running with Struts 1.1, it will be called by <code>perform</code>. * @see #perform * @see #doPerform */ @Override public final void execute( ComponentContext componentContext, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) throws Exception { synchronized (this) { if (this.webApplicationContext == null) { this.webApplicationContext = RequestContextUtils.getWebApplicationContext(request, servletContext); this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext); } } doPerform(componentContext, request, response); }
/** * This implementation delegates to {@code doPerform}, * lazy-initializing the application context reference if necessary. * <p>This is the preferred execution method in Struts 1.2. * When running with Struts 1.1, it will be called by {@code perform}. * @see #perform * @see #doPerform */ @Override public final void execute( ComponentContext componentContext, HttpServletRequest request, HttpServletResponse response, ServletContext servletContext) throws Exception { synchronized (this) { if (this.webApplicationContext == null) { this.webApplicationContext = RequestContextUtils.getWebApplicationContext(request, servletContext); this.messageSourceAccessor = new MessageSourceAccessor(this.webApplicationContext); } } doPerform(componentContext, request, response); }
/** * @return A found BeanFactory configuration */ private BeanFactory getBeanFactory() { // If someone has set a resource name then we need to load that. if (configLocation != null && configLocation.length > 0) { log.info("Spring BeanFactory via ClassPathXmlApplicationContext using " + configLocation.length + "configLocations."); return new ClassPathXmlApplicationContext(configLocation); } ServletContext srvCtx = ServerContextFactory.get().getServletContext(); HttpServletRequest request = null; try { request = WebContextFactory.get().getHttpServletRequest(); } catch (Exception ex) { // Probably on boot time } return request != null ? RequestContextUtils.getWebApplicationContext(request, srvCtx) : WebApplicationContextUtils.getWebApplicationContext(srvCtx); }
/** * @return A found BeanFactory configuration */ private BeanFactory getBeanFactory() { // If someone has set a resource name then we need to load that. if (configLocation != null && configLocation.length > 0) { log.info("Spring BeanFactory via ClassPathXmlApplicationContext using " + configLocation.length + "configLocations."); //$NON-NLS-1$ //$NON-NLS-2$ return new ClassPathXmlApplicationContext(configLocation); } ServletContext srvCtx = WebContextFactory.get().getServletContext(); HttpServletRequest request = WebContextFactory.get().getHttpServletRequest(); if (request != null) { return RequestContextUtils.getWebApplicationContext(request, srvCtx); } else { return WebApplicationContextUtils.getWebApplicationContext(srvCtx); } }