提交 97ea4368 编写于 作者: J Juergen Hoeller

Polishing

上级 e2518e0b
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -20,21 +20,23 @@ import org.springframework.beans.BeansException; ...@@ -20,21 +20,23 @@ import org.springframework.beans.BeansException;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
* Exception thrown when a {@code BeanFactory} is asked for a bean instance * Exception thrown when a {@code BeanFactory} is asked for a bean instance for which it
* for which it cannot find a definition. * cannot find a definition. This may point to a non-existing bean, a non-unique bean,
* or a manually registered singleton instance without an associated bean definition.
* *
* @author Rod Johnson * @author Rod Johnson
* @author Juergen Hoeller * @author Juergen Hoeller
* @see BeanFactory#getBean(String) * @see BeanFactory#getBean(String)
* @see BeanFactory#getBean(Class) * @see BeanFactory#getBean(Class)
* @see NoUniqueBeanDefinitionException
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class NoSuchBeanDefinitionException extends BeansException { public class NoSuchBeanDefinitionException extends BeansException {
/** Name of the missing bean. */ /** Name of the missing bean */
private String beanName; private String beanName;
/** Required type of the missing bean. */ /** Required type of the missing bean */
private Class<?> beanType; private Class<?> beanType;
......
...@@ -62,13 +62,14 @@ public class TilesView extends AbstractUrlBasedView { ...@@ -62,13 +62,14 @@ public class TilesView extends AbstractUrlBasedView {
* Specify whether to always include the view rather than forward to it. * Specify whether to always include the view rather than forward to it.
* <p>Default is "false". Switch this flag on to enforce the use of a * <p>Default is "false". Switch this flag on to enforce the use of a
* Servlet include, even if a forward would be possible. * Servlet include, even if a forward would be possible.
* @see TilesViewResolver#setAlwaysInclude(Boolean)
* @since 4.1.2 * @since 4.1.2
* @see TilesViewResolver#setAlwaysInclude
*/ */
public void setAlwaysInclude(boolean alwaysInclude) { public void setAlwaysInclude(boolean alwaysInclude) {
this.alwaysInclude = alwaysInclude; this.alwaysInclude = alwaysInclude;
} }
@Override @Override
public boolean checkResource(final Locale locale) throws Exception { public boolean checkResource(final Locale locale) throws Exception {
TilesContainer container = ServletUtil.getContainer(getServletContext()); TilesContainer container = ServletUtil.getContainer(getServletContext());
......
...@@ -48,24 +48,26 @@ public class TilesViewResolver extends UrlBasedViewResolver { ...@@ -48,24 +48,26 @@ public class TilesViewResolver extends UrlBasedViewResolver {
setViewClass(requiredViewClass()); setViewClass(requiredViewClass());
} }
/**
* This resolver requires {@link TilesView}.
*/
@Override
protected Class<?> requiredViewClass() {
return TilesView.class;
}
/** /**
* Specify whether to always include the view rather than forward to it. * Specify whether to always include the view rather than forward to it.
* <p>Default is "false". Switch this flag on to enforce the use of a * <p>Default is "false". Switch this flag on to enforce the use of a
* Servlet include, even if a forward would be possible. * Servlet include, even if a forward would be possible.
* @see TilesView#setAlwaysInclude
* @since 4.1.2 * @since 4.1.2
* @see TilesView#setAlwaysInclude
*/ */
public void setAlwaysInclude(Boolean alwaysInclude) { public void setAlwaysInclude(Boolean alwaysInclude) {
this.alwaysInclude = alwaysInclude; this.alwaysInclude = alwaysInclude;
} }
/**
* Requires {@link TilesView}.
*/
@Override
protected Class<?> requiredViewClass() {
return TilesView.class;
}
@Override @Override
protected AbstractUrlBasedView buildView(String viewName) throws Exception { protected AbstractUrlBasedView buildView(String viewName) throws Exception {
......
...@@ -70,7 +70,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed ...@@ -70,7 +70,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
} }
/** /**
* @return the configured {@code UrlPathHelper}. * Return the configured {@code UrlPathHelper}.
*/ */
public UrlPathHelper getPathHelper() { public UrlPathHelper getPathHelper() {
return this.pathHelper; return this.pathHelper;
...@@ -85,7 +85,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed ...@@ -85,7 +85,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
} }
/** /**
* @return the configured {@code PathMatcher}. * Return the configured {@code PathMatcher}.
*/ */
public PathMatcher getPathMatcher() { public PathMatcher getPathMatcher() {
return this.pathMatcher; return this.pathMatcher;
...@@ -93,7 +93,6 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed ...@@ -93,7 +93,6 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
/** /**
* Manually configure the resource mappings. * Manually configure the resource mappings.
*
* <p><strong>Note:</strong> by default resource mappings are auto-detected * <p><strong>Note:</strong> by default resource mappings are auto-detected
* from the Spring {@code ApplicationContext}. However if this property is * from the Spring {@code ApplicationContext}. However if this property is
* used, the auto-detection is turned off. * used, the auto-detection is turned off.
...@@ -107,7 +106,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed ...@@ -107,7 +106,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
} }
/** /**
* @return the resource mappings, either manually configured or auto-detected * Return the resource mappings, either manually configured or auto-detected
* when the Spring {@code ApplicationContext} is refreshed. * when the Spring {@code ApplicationContext} is refreshed.
*/ */
public Map<String, ResourceHttpRequestHandler> getHandlerMap() { public Map<String, ResourceHttpRequestHandler> getHandlerMap() {
...@@ -115,7 +114,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed ...@@ -115,7 +114,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
} }
/** /**
* @return {@code false} if resource mappings were manually configured, * Return {@code false} if resource mappings were manually configured,
* {@code true} otherwise. * {@code true} otherwise.
*/ */
public boolean isAutodetect() { public boolean isAutodetect() {
...@@ -134,7 +133,6 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed ...@@ -134,7 +133,6 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
} }
protected void detectResourceHandlers(ApplicationContext appContext) { protected void detectResourceHandlers(ApplicationContext appContext) {
logger.debug("Looking for resource handler mappings"); logger.debug("Looking for resource handler mappings");
Map<String, SimpleUrlHandlerMapping> map = appContext.getBeansOfType(SimpleUrlHandlerMapping.class); Map<String, SimpleUrlHandlerMapping> map = appContext.getBeansOfType(SimpleUrlHandlerMapping.class);
...@@ -162,7 +160,6 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed ...@@ -162,7 +160,6 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
* A variation on {@link #getForLookupPath(String)} that accepts a full request * A variation on {@link #getForLookupPath(String)} that accepts a full request
* URL path (i.e. including context and servlet path) and returns the full request * URL path (i.e. including context and servlet path) and returns the full request
* URL path to expose for public use. * URL path to expose for public use.
*
* @param request the current request * @param request the current request
* @param requestUrl the request URL path to resolve * @param requestUrl the request URL path to resolve
* @return the resolved public URL path or {@code null} if unresolved * @return the resolved public URL path or {@code null} if unresolved
...@@ -189,12 +186,10 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed ...@@ -189,12 +186,10 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
* if a match is found use the {@code ResourceResolver} chain of the matched * if a match is found use the {@code ResourceResolver} chain of the matched
* {@code ResourceHttpRequestHandler} to resolve the URL path to expose for * {@code ResourceHttpRequestHandler} to resolve the URL path to expose for
* public use. * public use.
* * <p>It is expected that the given path is what Spring MVC would use for
* <p>It is expected the given path is what Spring MVC would use for request * request mapping purposes, i.e. excluding context and servlet path portions.
* mapping purposes, i.e. excluding context and servlet path portions.
*
* @param lookupPath the lookup path to check * @param lookupPath the lookup path to check
* @return the resolved public URL path or {@code null} if unresolved * @return the resolved public URL path, or {@code null} if unresolved
*/ */
public final String getForLookupPath(String lookupPath) { public final String getForLookupPath(String lookupPath) {
if (logger.isTraceEnabled()) { if (logger.isTraceEnabled()) {
......
...@@ -81,8 +81,8 @@ public class TilesView extends AbstractUrlBasedView { ...@@ -81,8 +81,8 @@ public class TilesView extends AbstractUrlBasedView {
* Specify whether to always include the view rather than forward to it. * Specify whether to always include the view rather than forward to it.
* <p>Default is "false". Switch this flag on to enforce the use of a * <p>Default is "false". Switch this flag on to enforce the use of a
* Servlet include, even if a forward would be possible. * Servlet include, even if a forward would be possible.
* @see TilesViewResolver#setAlwaysInclude(Boolean)
* @since 4.1.2 * @since 4.1.2
* @see TilesViewResolver#setAlwaysInclude
*/ */
public void setAlwaysInclude(boolean alwaysInclude) { public void setAlwaysInclude(boolean alwaysInclude) {
this.alwaysInclude = alwaysInclude; this.alwaysInclude = alwaysInclude;
...@@ -99,6 +99,7 @@ public class TilesView extends AbstractUrlBasedView { ...@@ -99,6 +99,7 @@ public class TilesView extends AbstractUrlBasedView {
} }
} }
@Override @Override
public boolean checkResource(final Locale locale) throws Exception { public boolean checkResource(final Locale locale) throws Exception {
HttpServletRequest servletRequest = null; HttpServletRequest servletRequest = null;
......
...@@ -41,6 +41,15 @@ public class TilesViewResolver extends UrlBasedViewResolver { ...@@ -41,6 +41,15 @@ public class TilesViewResolver extends UrlBasedViewResolver {
setViewClass(requiredViewClass()); setViewClass(requiredViewClass());
} }
/**
* This resolver requires {@link TilesView}.
*/
@Override
protected Class<?> requiredViewClass() {
return TilesView.class;
}
/** /**
* Set the {@link Renderer} to use. If not specified, a default * Set the {@link Renderer} to use. If not specified, a default
* {@link org.apache.tiles.renderer.DefinitionRenderer} will be used. * {@link org.apache.tiles.renderer.DefinitionRenderer} will be used.
...@@ -54,20 +63,13 @@ public class TilesViewResolver extends UrlBasedViewResolver { ...@@ -54,20 +63,13 @@ public class TilesViewResolver extends UrlBasedViewResolver {
* Specify whether to always include the view rather than forward to it. * Specify whether to always include the view rather than forward to it.
* <p>Default is "false". Switch this flag on to enforce the use of a * <p>Default is "false". Switch this flag on to enforce the use of a
* Servlet include, even if a forward would be possible. * Servlet include, even if a forward would be possible.
* @see TilesView#setAlwaysInclude
* @since 4.1.2 * @since 4.1.2
* @see TilesView#setAlwaysInclude
*/ */
public void setAlwaysInclude(Boolean alwaysInclude) { public void setAlwaysInclude(Boolean alwaysInclude) {
this.alwaysInclude = alwaysInclude; this.alwaysInclude = alwaysInclude;
} }
/**
* Requires {@link TilesView}.
*/
@Override
protected Class<?> requiredViewClass() {
return TilesView.class;
}
@Override @Override
protected TilesView buildView(String viewName) throws Exception { protected TilesView buildView(String viewName) throws Exception {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册