Polishing
This commit is contained in:
@@ -73,7 +73,6 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Create a new MockHttpSession with a default {@link MockServletContext}.
|
||||
*
|
||||
* @see MockServletContext
|
||||
*/
|
||||
public MockHttpSession() {
|
||||
@@ -82,7 +81,6 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Create a new MockHttpSession.
|
||||
*
|
||||
* @param servletContext the ServletContext that the session runs in
|
||||
*/
|
||||
public MockHttpSession(ServletContext servletContext) {
|
||||
@@ -91,7 +89,6 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Create a new MockHttpSession.
|
||||
*
|
||||
* @param servletContext the ServletContext that the session runs in
|
||||
* @param id a unique identifier for this session
|
||||
*/
|
||||
@@ -100,6 +97,7 @@ public class MockHttpSession implements HttpSession {
|
||||
this.id = (id != null ? id : Integer.toString(nextId++));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getCreationTime() {
|
||||
assertIsValid();
|
||||
@@ -112,8 +110,8 @@ public class MockHttpSession implements HttpSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* As of Servlet 3.1 the id of a session can be changed.
|
||||
* @return the new session id.
|
||||
* As of Servlet 3.1, the id of a session can be changed.
|
||||
* @return the new session id
|
||||
* @since 4.0.3
|
||||
*/
|
||||
public String changeSessionId() {
|
||||
@@ -228,7 +226,6 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Invalidates this session then unbinds any objects bound to it.
|
||||
*
|
||||
* @throws IllegalStateException if this method is called on an already invalidated session
|
||||
*/
|
||||
@Override
|
||||
@@ -245,13 +242,10 @@ public class MockHttpSession implements HttpSession {
|
||||
/**
|
||||
* Convenience method for asserting that this session has not been
|
||||
* {@linkplain #invalidate() invalidated}.
|
||||
*
|
||||
* @throws IllegalStateException if this session has been invalidated
|
||||
*/
|
||||
private void assertIsValid() {
|
||||
if (isInvalid()) {
|
||||
throw new IllegalStateException("The session has already been invalidated");
|
||||
}
|
||||
Assert.state(!isInvalid(), "The session has already been invalidated");
|
||||
}
|
||||
|
||||
public void setNew(boolean value) {
|
||||
@@ -267,7 +261,6 @@ public class MockHttpSession implements HttpSession {
|
||||
/**
|
||||
* Serialize the attributes of this session into an object that can be
|
||||
* turned into a byte array with standard Java serialization.
|
||||
*
|
||||
* @return a representation of this session's serialized state
|
||||
*/
|
||||
public Serializable serializeState() {
|
||||
@@ -294,7 +287,6 @@ public class MockHttpSession implements HttpSession {
|
||||
/**
|
||||
* Deserialize the attributes of this session from a state object created by
|
||||
* {@link #serializeState()}.
|
||||
*
|
||||
* @param state a representation of this session's serialized state
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -73,7 +73,6 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Create a new MockHttpSession with a default {@link MockServletContext}.
|
||||
*
|
||||
* @see MockServletContext
|
||||
*/
|
||||
public MockHttpSession() {
|
||||
@@ -82,7 +81,6 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Create a new MockHttpSession.
|
||||
*
|
||||
* @param servletContext the ServletContext that the session runs in
|
||||
*/
|
||||
public MockHttpSession(ServletContext servletContext) {
|
||||
@@ -91,7 +89,6 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Create a new MockHttpSession.
|
||||
*
|
||||
* @param servletContext the ServletContext that the session runs in
|
||||
* @param id a unique identifier for this session
|
||||
*/
|
||||
@@ -100,6 +97,7 @@ public class MockHttpSession implements HttpSession {
|
||||
this.id = (id != null ? id : Integer.toString(nextId++));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getCreationTime() {
|
||||
assertIsValid();
|
||||
@@ -112,8 +110,8 @@ public class MockHttpSession implements HttpSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* As of Servlet 3.1 the id of a session can be changed.
|
||||
* @return the new session id.
|
||||
* As of Servlet 3.1, the id of a session can be changed.
|
||||
* @return the new session id
|
||||
* @since 4.0.3
|
||||
*/
|
||||
public String changeSessionId() {
|
||||
@@ -228,7 +226,6 @@ public class MockHttpSession implements HttpSession {
|
||||
|
||||
/**
|
||||
* Invalidates this session then unbinds any objects bound to it.
|
||||
*
|
||||
* @throws IllegalStateException if this method is called on an already invalidated session
|
||||
*/
|
||||
@Override
|
||||
@@ -245,13 +242,10 @@ public class MockHttpSession implements HttpSession {
|
||||
/**
|
||||
* Convenience method for asserting that this session has not been
|
||||
* {@linkplain #invalidate() invalidated}.
|
||||
*
|
||||
* @throws IllegalStateException if this session has been invalidated
|
||||
*/
|
||||
private void assertIsValid() {
|
||||
if (isInvalid()) {
|
||||
throw new IllegalStateException("The session has already been invalidated");
|
||||
}
|
||||
Assert.state(!isInvalid(), "The session has already been invalidated");
|
||||
}
|
||||
|
||||
public void setNew(boolean value) {
|
||||
@@ -267,7 +261,6 @@ public class MockHttpSession implements HttpSession {
|
||||
/**
|
||||
* Serialize the attributes of this session into an object that can be
|
||||
* turned into a byte array with standard Java serialization.
|
||||
*
|
||||
* @return a representation of this session's serialized state
|
||||
*/
|
||||
public Serializable serializeState() {
|
||||
@@ -294,7 +287,6 @@ public class MockHttpSession implements HttpSession {
|
||||
/**
|
||||
* Deserialize the attributes of this session from a state object created by
|
||||
* {@link #serializeState()}.
|
||||
*
|
||||
* @param state a representation of this session's serialized state
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -45,13 +45,14 @@ public class InterceptorRegistration {
|
||||
|
||||
|
||||
/**
|
||||
* Creates an {@link InterceptorRegistration} instance.
|
||||
* Create an {@link InterceptorRegistration} instance.
|
||||
*/
|
||||
public InterceptorRegistration(HandlerInterceptor interceptor) {
|
||||
Assert.notNull(interceptor, "Interceptor is required");
|
||||
this.interceptor = interceptor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add URL patterns to which the registered interceptor should apply to.
|
||||
*/
|
||||
@@ -80,8 +81,8 @@ public class InterceptorRegistration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying interceptor. If URL patterns are provided the returned type is
|
||||
* {@link MappedInterceptor}; otherwise {@link HandlerInterceptor}.
|
||||
* Build the underlying interceptor. If URL patterns are provided, the returned
|
||||
* type is {@link MappedInterceptor}; otherwise {@link HandlerInterceptor}.
|
||||
*/
|
||||
protected Object getInterceptor() {
|
||||
if (this.includePatterns.isEmpty() && this.excludePatterns.isEmpty()) {
|
||||
@@ -91,11 +92,9 @@ public class InterceptorRegistration {
|
||||
String[] include = StringUtils.toStringArray(this.includePatterns);
|
||||
String[] exclude = StringUtils.toStringArray(this.excludePatterns);
|
||||
MappedInterceptor mappedInterceptor = new MappedInterceptor(include, exclude, this.interceptor);
|
||||
|
||||
if (this.pathMatcher != null) {
|
||||
mappedInterceptor.setPathMatcher(this.pathMatcher);
|
||||
}
|
||||
|
||||
return mappedInterceptor;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public final class MappedInterceptor implements HandlerInterceptor {
|
||||
|
||||
/**
|
||||
* Create a new MappedInterceptor instance.
|
||||
* @param includePatterns the path patterns to map with a {@code null} value matching to all paths
|
||||
* @param includePatterns the path patterns to map (empty for matching to all paths)
|
||||
* @param interceptor the WebRequestInterceptor instance to map to the given patterns
|
||||
*/
|
||||
public MappedInterceptor(String[] includePatterns, WebRequestInterceptor interceptor) {
|
||||
@@ -85,7 +85,8 @@ public final class MappedInterceptor implements HandlerInterceptor {
|
||||
|
||||
/**
|
||||
* Create a new MappedInterceptor instance.
|
||||
* @param includePatterns the path patterns to map with a {@code null} value matching to all paths
|
||||
* @param includePatterns the path patterns to map (empty for matching to all paths)
|
||||
* @param excludePatterns the path patterns to exclude (empty for no specific excludes)
|
||||
* @param interceptor the WebRequestInterceptor instance to map to the given patterns
|
||||
*/
|
||||
public MappedInterceptor(String[] includePatterns, String[] excludePatterns, WebRequestInterceptor interceptor) {
|
||||
@@ -94,11 +95,11 @@ public final class MappedInterceptor implements HandlerInterceptor {
|
||||
|
||||
|
||||
/**
|
||||
* Configure a PathMatcher to use with this MappedInterceptor instead of the
|
||||
* one passed by default to the {@link #matches(String, org.springframework.util.PathMatcher)}
|
||||
* method. This is an advanced property that is only required when using custom
|
||||
* PathMatcher implementations that support mapping metadata other than the
|
||||
* Ant-style path patterns supported by default.
|
||||
* Configure a PathMatcher to use with this MappedInterceptor instead of the one passed
|
||||
* by default to the {@link #matches(String, org.springframework.util.PathMatcher)} method.
|
||||
* <p>This is an advanced property that is only required when using custom PathMatcher
|
||||
* implementations that support mapping metadata other than the Ant-style path patterns
|
||||
* supported by default.
|
||||
*/
|
||||
public void setPathMatcher(PathMatcher pathMatcher) {
|
||||
this.pathMatcher = pathMatcher;
|
||||
@@ -119,14 +120,15 @@ public final class MappedInterceptor implements HandlerInterceptor {
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual Interceptor reference.
|
||||
* The actual {@link HandlerInterceptor} reference.
|
||||
*/
|
||||
public HandlerInterceptor getInterceptor() {
|
||||
return this.interceptor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the interceptor applies to the given request path.
|
||||
* Determine a match for the given lookup path.
|
||||
* @param lookupPath the current request path
|
||||
* @param pathMatcher a path matcher for path pattern matching
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user