polishing

This commit is contained in:
Juergen Hoeller
2009-12-07 09:43:16 +00:00
parent f72769a621
commit f36e8252c8
6 changed files with 70 additions and 82 deletions

View File

@@ -22,7 +22,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -72,7 +71,8 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
private final Map<String, Object> handlerMap = new LinkedHashMap<String, Object>();
private MappedInterceptors mappedInterceptors;
/**
* Set if URL lookup should always use the full path within the current servlet
* context. Else, the path within the current servlet mapping is used if applicable
@@ -164,10 +164,11 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
@Override
protected void initInterceptors() {
super.initInterceptors();
Map<String, MappedInterceptor> mappedInterceptors = BeanFactoryUtils.beansOfTypeIncludingAncestors(getApplicationContext(), MappedInterceptor.class, true, false);
Map<String, MappedInterceptor> mappedInterceptors = BeanFactoryUtils.beansOfTypeIncludingAncestors(
getApplicationContext(), MappedInterceptor.class, true, false);
if (!mappedInterceptors.isEmpty()) {
this.mappedInterceptors = new MappedInterceptors(mappedInterceptors.values().toArray(new MappedInterceptor[mappedInterceptors.size()]));
this.mappedInterceptors = new MappedInterceptors(mappedInterceptors.values().toArray(
new MappedInterceptor[mappedInterceptors.size()]));
}
}
@@ -201,8 +202,9 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
handler = buildPathExposingHandler(rawHandler, lookupPath, lookupPath, null);
}
}
if (handler != null & this.mappedInterceptors != null) {
Set<HandlerInterceptor> mappedInterceptors = this.mappedInterceptors.getInterceptors(lookupPath, this.pathMatcher);
if (handler != null && this.mappedInterceptors != null) {
Set<HandlerInterceptor> mappedInterceptors =
this.mappedInterceptors.getInterceptors(lookupPath, this.pathMatcher);
if (!mappedInterceptors.isEmpty()) {
HandlerExecutionChain chain;
if (handler instanceof HandlerExecutionChain) {
@@ -435,6 +437,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
}
}
/**
* Special interceptor for exposing the
* {@link AbstractUrlHandlerMapping#URI_TEMPLATE_VARIABLES_ATTRIBUTE} attribute.

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.servlet.handler;
import org.springframework.web.context.request.WebRequestInterceptor;
@@ -20,6 +21,7 @@ import org.springframework.web.servlet.HandlerInterceptor;
/**
* Holds information about a HandlerInterceptor mapped to a path into the application.
*
* @author Keith Donald
* @since 3.0
*/
@@ -29,9 +31,10 @@ public final class MappedInterceptor {
private final HandlerInterceptor interceptor;
/**
* Creates a new mapped interceptor.
* @param pathPattern the path pattern
* Create a new mapped interceptor.
* @param pathPatterns the path patterns
* @param interceptor the interceptor
*/
public MappedInterceptor(String[] pathPatterns, HandlerInterceptor interceptor) {
@@ -40,8 +43,8 @@ public final class MappedInterceptor {
}
/**
* Creates a new mapped interceptor.
* @param pathPattern the path pattern
* Create a new mapped interceptor.
* @param pathPatterns the path patterns
* @param interceptor the interceptor
*/
public MappedInterceptor(String[] pathPatterns, WebRequestInterceptor interceptor) {
@@ -49,18 +52,19 @@ public final class MappedInterceptor {
this.interceptor = new WebRequestHandlerInterceptorAdapter(interceptor);
}
/**
* The path into the application the interceptor is mapped to.
*/
public String[] getPathPatterns() {
return pathPatterns;
return this.pathPatterns;
}
/**
* The actual Interceptor reference.
*/
public HandlerInterceptor getInterceptor() {
return interceptor;
return this.interceptor;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 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.
@@ -17,7 +17,6 @@
package org.springframework.web.servlet.tags.form;
import java.beans.PropertyEditor;
import javax.servlet.jsp.JspException;
/**
@@ -52,7 +51,7 @@ public abstract class AbstractCheckedElementTag extends AbstractHtmlInputElement
tagWriter.writeAttribute("checked", "checked");
}
}
/**
* Determines whether the supplied value matched the selected value
* through delegating to {@link SelectedValueComparator#isSelected}.
@@ -68,7 +67,7 @@ public abstract class AbstractCheckedElementTag extends AbstractHtmlInputElement
*/
protected void renderFromBoolean(Boolean boundValue, TagWriter tagWriter) throws JspException {
tagWriter.writeAttribute("value", "true");
if (boundValue.booleanValue()) {
if (boundValue) {
tagWriter.writeAttribute("checked", "checked");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 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.
@@ -19,7 +19,6 @@ package org.springframework.web.servlet.tags.form;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.jsp.JspException;
import org.springframework.beans.BeanWrapper;
@@ -103,13 +102,17 @@ public abstract class AbstractMultiCheckedElementTag extends AbstractCheckedElem
this.itemValue = itemValue;
}
/**
* Get the name of the property mapped to the '<code>value</code>' attribute
* of the '<code>input type="checkbox/radio"</code>' tag.
*/
protected String getItemValue() {
return this.itemValue;
}
/**
* Set the value to be displayed as part
* of the '<code>input type="checkbox/radio"</code>' tag.
* Set the value to be displayed as part of the
* '<code>input type="checkbox/radio"</code>' tag.
* <p>May be a runtime expression.
*/
public void setItemLabel(String itemLabel) {
@@ -118,8 +121,8 @@ public abstract class AbstractMultiCheckedElementTag extends AbstractCheckedElem
}
/**
* Get the value to be displayed as part
* of the '<code>input type="checkbox/radio"</code>' tag.
* Get the value to be displayed as part of the
* '<code>input type="checkbox/radio"</code>' tag.
*/
protected String getItemLabel() {
return this.itemLabel;
@@ -183,7 +186,7 @@ public abstract class AbstractMultiCheckedElementTag extends AbstractCheckedElem
@Override
protected int writeTagContent(TagWriter tagWriter) throws JspException {
Object items = getItems();
Object itemsObject = (items instanceof String ? evaluate("items", (String) items) : items);
Object itemsObject = (items instanceof String ? evaluate("items", items) : items);
String itemValue = getItemValue();
String itemLabel = getItemLabel();