Polishing
This commit is contained in:
@@ -621,7 +621,7 @@ public class TypeDescriptor implements Serializable {
|
||||
}
|
||||
|
||||
private String wildcard(TypeDescriptor typeDescriptor) {
|
||||
return typeDescriptor != null ? typeDescriptor.toString() : "?";
|
||||
return (typeDescriptor != null ? typeDescriptor.toString() : "?");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -67,6 +67,7 @@ public interface AsyncTaskExecutor extends TaskExecutor {
|
||||
* @param task the {@code Runnable} to execute (never {@code null})
|
||||
* @return a Future representing pending completion of the task
|
||||
* @throws TaskRejectedException if the given task was not accepted
|
||||
* @since 3.0
|
||||
*/
|
||||
Future<?> submit(Runnable task);
|
||||
|
||||
@@ -76,6 +77,7 @@ public interface AsyncTaskExecutor extends TaskExecutor {
|
||||
* @param task the {@code Callable} to execute (never {@code null})
|
||||
* @return a Future representing pending completion of the task
|
||||
* @throws TaskRejectedException if the given task was not accepted
|
||||
* @since 3.0
|
||||
*/
|
||||
<T> Future<T> submit(Callable<T> task);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -28,7 +28,7 @@ import org.springframework.core.task.TaskRejectedException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Adapter that takes a JDK 1.5 {@code java.util.concurrent.Executor} and
|
||||
* Adapter that takes a JDK {@code java.util.concurrent.Executor} and
|
||||
* exposes a Spring {@link org.springframework.core.task.TaskExecutor} for it.
|
||||
* Also detects an extended {@code java.util.concurrent.ExecutorService}, adapting
|
||||
* the {@link org.springframework.core.task.AsyncTaskExecutor} interface accordingly.
|
||||
@@ -41,13 +41,13 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class TaskExecutorAdapter implements AsyncTaskExecutor {
|
||||
|
||||
private Executor concurrentExecutor;
|
||||
private final Executor concurrentExecutor;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new TaskExecutorAdapter,
|
||||
* using the given JDK 1.5 concurrent executor.
|
||||
* @param concurrentExecutor the JDK 1.5 concurrent executor to delegate to
|
||||
* using the given JDK concurrent executor.
|
||||
* @param concurrentExecutor the JDK concurrent executor to delegate to
|
||||
*/
|
||||
public TaskExecutorAdapter(Executor concurrentExecutor) {
|
||||
Assert.notNull(concurrentExecutor, "Executor must not be null");
|
||||
@@ -56,7 +56,7 @@ public class TaskExecutorAdapter implements AsyncTaskExecutor {
|
||||
|
||||
|
||||
/**
|
||||
* Delegates to the specified JDK 1.5 concurrent executor.
|
||||
* Delegates to the specified JDK concurrent executor.
|
||||
* @see java.util.concurrent.Executor#execute(Runnable)
|
||||
*/
|
||||
public void execute(Runnable task) {
|
||||
|
||||
@@ -50,29 +50,37 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class AntPathMatcher implements PathMatcher {
|
||||
|
||||
private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\{[^/]+?\\}");
|
||||
|
||||
/** Default path separator: "/" */
|
||||
public static final String DEFAULT_PATH_SEPARATOR = "/";
|
||||
|
||||
private static final Pattern VARIABLE_PATTERN = Pattern.compile("\\{[^/]+?\\}");
|
||||
|
||||
|
||||
private String pathSeparator = DEFAULT_PATH_SEPARATOR;
|
||||
|
||||
private boolean trimTokens = true;
|
||||
|
||||
private final Map<String, AntPathStringMatcher> stringMatcherCache =
|
||||
new ConcurrentHashMap<String, AntPathStringMatcher>(256);
|
||||
|
||||
private boolean trimTokens = true;
|
||||
|
||||
|
||||
/** Set the path separator to use for pattern parsing. Default is "/", as in Ant. */
|
||||
/**
|
||||
* Set the path separator to use for pattern parsing.
|
||||
* Default is "/", as in Ant.
|
||||
*/
|
||||
public void setPathSeparator(String pathSeparator) {
|
||||
this.pathSeparator = (pathSeparator != null ? pathSeparator : DEFAULT_PATH_SEPARATOR);
|
||||
}
|
||||
|
||||
/** Whether to trim tokenized paths and patterns. */
|
||||
/**
|
||||
* Specify whether to trim tokenized paths and patterns.
|
||||
* Default is {@code true}.
|
||||
*/
|
||||
public void setTrimTokens(boolean trimTokens) {
|
||||
this.trimTokens = trimTokens;
|
||||
this.trimTokens = trimTokens;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPattern(String path) {
|
||||
return (path.indexOf('*') != -1 || path.indexOf('?') != -1);
|
||||
}
|
||||
@@ -94,15 +102,13 @@ public class AntPathMatcher implements PathMatcher {
|
||||
* as far as the given base path goes is sufficient)
|
||||
* @return {@code true} if the supplied {@code path} matched, {@code false} if it didn't
|
||||
*/
|
||||
protected boolean doMatch(String pattern, String path, boolean fullMatch,
|
||||
Map<String, String> uriTemplateVariables) {
|
||||
|
||||
protected boolean doMatch(String pattern, String path, boolean fullMatch, Map<String, String> uriTemplateVariables) {
|
||||
if (path.startsWith(this.pathSeparator) != pattern.startsWith(this.pathSeparator)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String[] pattDirs = StringUtils.tokenizeToStringArray(pattern, this.pathSeparator, this.trimTokens, true);
|
||||
String[] pathDirs = StringUtils.tokenizeToStringArray(path, this.pathSeparator, this.trimTokens, true);
|
||||
String[] pattDirs = tokenizePath(pattern);
|
||||
String[] pathDirs = tokenizePath(path);
|
||||
|
||||
int pattIdxStart = 0;
|
||||
int pattIdxEnd = pattDirs.length - 1;
|
||||
@@ -111,11 +117,11 @@ public class AntPathMatcher implements PathMatcher {
|
||||
|
||||
// Match all elements up to the first **
|
||||
while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {
|
||||
String patDir = pattDirs[pattIdxStart];
|
||||
if ("**".equals(patDir)) {
|
||||
String pattDir = pattDirs[pattIdxStart];
|
||||
if ("**".equals(pattDir)) {
|
||||
break;
|
||||
}
|
||||
if (!matchStrings(patDir, pathDirs[pathIdxStart], uriTemplateVariables)) {
|
||||
if (!matchStrings(pattDir, pathDirs[pathIdxStart], uriTemplateVariables)) {
|
||||
return false;
|
||||
}
|
||||
pattIdxStart++;
|
||||
@@ -152,11 +158,11 @@ public class AntPathMatcher implements PathMatcher {
|
||||
|
||||
// up to last '**'
|
||||
while (pattIdxStart <= pattIdxEnd && pathIdxStart <= pathIdxEnd) {
|
||||
String patDir = pattDirs[pattIdxEnd];
|
||||
if (patDir.equals("**")) {
|
||||
String pattDir = pattDirs[pattIdxEnd];
|
||||
if (pattDir.equals("**")) {
|
||||
break;
|
||||
}
|
||||
if (!matchStrings(patDir, pathDirs[pathIdxEnd], uriTemplateVariables)) {
|
||||
if (!matchStrings(pattDir, pathDirs[pathIdxEnd], uriTemplateVariables)) {
|
||||
return false;
|
||||
}
|
||||
pattIdxEnd--;
|
||||
@@ -221,6 +227,15 @@ public class AntPathMatcher implements PathMatcher {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tokenize the given path String into parts, based on this matcher's settings.
|
||||
* @param path the path to tokenize
|
||||
* @return the tokenized path parts
|
||||
*/
|
||||
protected String[] tokenizePath(String path) {
|
||||
return StringUtils.tokenizeToStringArray(path, this.pathSeparator, this.trimTokens, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not a string matches against a pattern. The pattern may contain two special characters:
|
||||
* <br>'*' means zero or more characters
|
||||
|
||||
Reference in New Issue
Block a user