From: Juergen H. <jho...@us...> - 2006-04-21 00:13:57
|
Update of /cvsroot/springframework/spring/src/org/springframework/web/servlet/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19629/src/org/springframework/web/servlet/view Modified Files: Tag: mbranch-1-2 AbstractCachingViewResolver.java BeanNameViewResolver.java InternalResourceView.java Log Message: backported fixes and enhancements from 2.0 M4 (HEAD) Index: BeanNameViewResolver.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/servlet/view/BeanNameViewResolver.java,v retrieving revision 1.6 retrieving revision 1.6.4.1 diff -C2 -d -r1.6 -r1.6.4.1 *** BeanNameViewResolver.java 25 Mar 2005 09:28:14 -0000 1.6 --- BeanNameViewResolver.java 21 Apr 2006 00:13:50 -0000 1.6.4.1 *************** *** 1,11 **** /* ! * Copyright 2002-2005 the original author or authors. ! * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at ! * * http://www.apache.org/licenses/LICENSE-2.0 ! * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, --- 1,11 ---- /* ! * Copyright 2002-2006 the original author or authors. ! * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at ! * * http://www.apache.org/licenses/LICENSE-2.0 ! * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, *************** *** 20,24 **** import org.springframework.beans.BeansException; ! import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.core.Ordered; import org.springframework.web.context.support.WebApplicationObjectSupport; --- 20,24 ---- import org.springframework.beans.BeansException; ! import org.springframework.context.ApplicationContext; import org.springframework.core.Ordered; import org.springframework.web.context.support.WebApplicationObjectSupport; *************** *** 57,60 **** --- 57,61 ---- private int order = Integer.MAX_VALUE; // default: same as non-Ordered + public void setOrder(int order) { this.order = order; *************** *** 65,76 **** } public View resolveViewName(String viewName, Locale locale) throws BeansException { ! try { ! return (View) getApplicationContext().getBean(viewName, View.class); ! } ! catch (NoSuchBeanDefinitionException ex) { ! // to allow for ViewResolver chaining return null; } } --- 66,77 ---- } + public View resolveViewName(String viewName, Locale locale) throws BeansException { ! ApplicationContext context = getApplicationContext(); ! if (!context.containsBean(viewName)) { ! // Allow for ViewResolver chaining. return null; } + return (View) context.getBean(viewName, View.class); } Index: InternalResourceView.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/servlet/view/InternalResourceView.java,v retrieving revision 1.19.4.1 retrieving revision 1.19.4.2 diff -C2 -d -r1.19.4.1 -r1.19.4.2 *** InternalResourceView.java 17 Jan 2006 21:29:36 -0000 1.19.4.1 --- InternalResourceView.java 21 Apr 2006 00:13:50 -0000 1.19.4.2 *************** *** 1,11 **** /* * Copyright 2002-2006 the original author or authors. ! * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at ! * * http://www.apache.org/licenses/LICENSE-2.0 ! * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, --- 1,11 ---- /* * Copyright 2002-2006 the original author or authors. ! * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at ! * * http://www.apache.org/licenses/LICENSE-2.0 ! * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, *************** *** 25,29 **** import javax.servlet.http.HttpServletResponse; ! import org.springframework.web.util.UrlPathHelper; /** --- 25,29 ---- import javax.servlet.http.HttpServletResponse; ! import org.springframework.web.util.WebUtils; /** *************** *** 182,185 **** --- 182,186 ---- protected String prepareForRendering(HttpServletRequest request, HttpServletResponse response) throws Exception { + return getUrl(); } *************** *** 197,205 **** * @see javax.servlet.RequestDispatcher#include * @see javax.servlet.ServletResponse#isCommitted ! * @see org.springframework.web.util.UrlPathHelper#INCLUDE_URI_REQUEST_ATTRIBUTE */ protected boolean useInclude(HttpServletRequest request, HttpServletResponse response) { ! return request.getAttribute(UrlPathHelper.INCLUDE_URI_REQUEST_ATTRIBUTE) != null || ! response.isCommitted(); } --- 198,205 ---- * @see javax.servlet.RequestDispatcher#include * @see javax.servlet.ServletResponse#isCommitted ! * @see org.springframework.web.util.WebUtils#isIncludeRequest */ protected boolean useInclude(HttpServletRequest request, HttpServletResponse response) { ! return (WebUtils.isIncludeRequest(request) || response.isCommitted()); } Index: AbstractCachingViewResolver.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/web/servlet/view/AbstractCachingViewResolver.java,v retrieving revision 1.24.4.1 retrieving revision 1.24.4.2 diff -C2 -d -r1.24.4.1 -r1.24.4.2 *** AbstractCachingViewResolver.java 2 Jan 2006 23:41:03 -0000 1.24.4.1 --- AbstractCachingViewResolver.java 21 Apr 2006 00:13:50 -0000 1.24.4.2 *************** *** 1,11 **** /* ! * Copyright 2002-2005 the original author or authors. ! * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at ! * * http://www.apache.org/licenses/LICENSE-2.0 ! * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, --- 1,11 ---- /* ! * Copyright 2002-2006 the original author or authors. ! * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at ! * * http://www.apache.org/licenses/LICENSE-2.0 ! * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, *************** *** 88,91 **** --- 88,100 ---- /** + * Return the cache key for the given viewName and the given locale. + * Needs to regard the locale in general, as a different locale can lead to a + * different view! Can be overridden in subclasses. + */ + protected String getCacheKey(String viewName, Locale locale) { + return viewName + "_" + locale; + } + + /** * Provides functionality to clear the cache for a certain view. * This can be handy in case developer are able to modify views *************** *** 102,107 **** else { String cacheKey = getCacheKey(viewName, locale); ! if (viewCache.remove(cacheKey) == null) { ! // some debug output might be useful if (logger.isDebugEnabled()) { logger.debug("No cached instance for view '" + cacheKey + "' was found"); --- 111,116 ---- else { String cacheKey = getCacheKey(viewName, locale); ! if (this.viewCache.remove(cacheKey) == null) { ! // Some debug output might be useful... if (logger.isDebugEnabled()) { logger.debug("No cached instance for view '" + cacheKey + "' was found"); *************** *** 110,114 **** else { if (logger.isDebugEnabled()) { ! logger.debug("Cach for view " + cacheKey + " has been cleared"); } } --- 119,123 ---- else { if (logger.isDebugEnabled()) { ! logger.debug("Cache for view " + cacheKey + " has been cleared"); } } *************** *** 117,128 **** /** ! * Return the cache key for the given viewName and the given locale. ! * Needs to regard the locale in general, as a different locale can lead to a ! * different view! Can be overridden in subclasses. */ ! protected String getCacheKey(String viewName, Locale locale) { ! return viewName + "_" + locale; } /** * Create the actual View object. --- 126,140 ---- /** ! * Clear the entire view cache, removing all cached view objects. ! * Subsequent resolve calls will lead to recreation of demanded view objects. */ ! public void clearCache() { ! logger.debug("Clearing entire view cache"); ! synchronized (this.viewCache) { ! this.viewCache.clear(); ! } } + /** * Create the actual View object. |