Polishing
This commit is contained in:
parent
19e5a34f9f
commit
102dc8a4dd
|
|
@ -31,9 +31,8 @@ package org.springframework.cache.interceptor;
|
|||
public interface CacheOperationInvoker {
|
||||
|
||||
/**
|
||||
* Invoke the cache operation defined by this instance. Wraps any
|
||||
* exception that is thrown during the invocation in a
|
||||
* {@link ThrowableWrapper}.
|
||||
* Invoke the cache operation defined by this instance. Wraps any exception
|
||||
* that is thrown during the invocation in a {@link ThrowableWrapper}.
|
||||
* @return the result of the operation
|
||||
* @throws ThrowableWrapper if an error occurred while invoking the operation
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream {
|
|||
* Update the message digest with the rest of the bytes in this stream.
|
||||
* <p>Using this method is more optimized since it avoids creating new
|
||||
* byte arrays for each call.
|
||||
* @param messageDigest The message digest to update
|
||||
* @param messageDigest the message digest to update
|
||||
* @throws IOException when propagated from {@link #read()}
|
||||
*/
|
||||
public void updateMessageDigest(MessageDigest messageDigest) throws IOException {
|
||||
|
|
@ -47,7 +47,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream {
|
|||
* Update the message digest with the next len bytes in this stream.
|
||||
* <p>Using this method is more optimized since it avoids creating new
|
||||
* byte arrays for each call.
|
||||
* @param messageDigest The message digest to update
|
||||
* @param messageDigest the message digest to update
|
||||
* @param len how many bytes to read from this stream and use to update the message digest
|
||||
* @throws IOException when propagated from {@link #read()}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
|
@ -24,10 +24,9 @@ import java.util.concurrent.TimeoutException;
|
|||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Abstract class that adapts a {@link Future} parameterized over S into a {@code
|
||||
* Future} parameterized over T. All methods are delegated to the adaptee, where {@link
|
||||
* #get()} and {@link #get(long, TimeUnit)} call {@link #adapt(Object)} on the adaptee's
|
||||
* result.
|
||||
* Abstract class that adapts a {@link Future} parameterized over S into a {@code Future}
|
||||
* parameterized over T. All methods are delegated to the adaptee, where {@link #get()}
|
||||
* and {@link #get(long, TimeUnit)} call {@link #adapt(Object)} on the adaptee's result.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
|
|
|
|||
|
|
@ -147,6 +147,67 @@ public class CodeFlow implements Opcodes {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the main expression evaluation method has been generated, this
|
||||
* method will callback any registered FieldAdders or ClinitAdders to add any
|
||||
* extra information to the class representing the compiled expression.
|
||||
*/
|
||||
public void finish() {
|
||||
if (this.fieldAdders != null) {
|
||||
for (FieldAdder fieldAdder : this.fieldAdders) {
|
||||
fieldAdder.generateField(cw,this);
|
||||
}
|
||||
}
|
||||
if (this.clinitAdders != null) {
|
||||
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "<clinit>", "()V", null, null);
|
||||
mv.visitCode();
|
||||
this.nextFreeVariableId = 0; // To 0 because there is no 'this' in a clinit
|
||||
for (ClinitAdder clinitAdder : this.clinitAdders) {
|
||||
clinitAdder.generateCode(mv, this);
|
||||
}
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(0,0); // not supplied due to COMPUTE_MAXS
|
||||
mv.visitEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a FieldAdder which will add a new field to the generated
|
||||
* class to support the code produced by an ast nodes primary
|
||||
* generateCode() method.
|
||||
*/
|
||||
public void registerNewField(FieldAdder fieldAdder) {
|
||||
if (this.fieldAdders == null) {
|
||||
this.fieldAdders = new ArrayList<>();
|
||||
}
|
||||
this.fieldAdders.add(fieldAdder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a ClinitAdder which will add code to the static
|
||||
* initializer in the generated class to support the code
|
||||
* produced by an ast nodes primary generateCode() method.
|
||||
*/
|
||||
public void registerNewClinit(ClinitAdder clinitAdder) {
|
||||
if (this.clinitAdders == null) {
|
||||
this.clinitAdders = new ArrayList<>();
|
||||
}
|
||||
this.clinitAdders.add(clinitAdder);
|
||||
}
|
||||
|
||||
public int nextFieldId() {
|
||||
return this.nextFieldId++;
|
||||
}
|
||||
|
||||
public int nextFreeVariableId() {
|
||||
return this.nextFreeVariableId++;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return this.clazzName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert any necessary cast and value call to convert from a boxed type to a
|
||||
* primitive value
|
||||
|
|
@ -778,76 +839,6 @@ public class CodeFlow implements Opcodes {
|
|||
return descriptors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the main expression evaluation method has been generated, this
|
||||
* method will callback any registered FieldAdders or ClinitAdders to add any
|
||||
* extra information to the class representing the compiled expression.
|
||||
*/
|
||||
public void finish() {
|
||||
if (fieldAdders != null) {
|
||||
for (FieldAdder fieldAdder: fieldAdders) {
|
||||
fieldAdder.generateField(cw,this);
|
||||
}
|
||||
}
|
||||
if (clinitAdders != null) {
|
||||
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "<clinit>", "()V", null, null);
|
||||
mv.visitCode();
|
||||
nextFreeVariableId = 0; // To 0 because there is no 'this' in a clinit
|
||||
for (ClinitAdder clinitAdder: clinitAdders) {
|
||||
clinitAdder.generateCode(mv, this);
|
||||
}
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(0,0); // not supplied due to COMPUTE_MAXS
|
||||
mv.visitEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a FieldAdder which will add a new field to the generated
|
||||
* class to support the code produced by an ast nodes primary
|
||||
* generateCode() method.
|
||||
*/
|
||||
public void registerNewField(FieldAdder fieldAdder) {
|
||||
if (fieldAdders == null) {
|
||||
fieldAdders = new ArrayList<>();
|
||||
}
|
||||
fieldAdders.add(fieldAdder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a ClinitAdder which will add code to the static
|
||||
* initializer in the generated class to support the code
|
||||
* produced by an ast nodes primary generateCode() method.
|
||||
*/
|
||||
public void registerNewClinit(ClinitAdder clinitAdder) {
|
||||
if (clinitAdders == null) {
|
||||
clinitAdders = new ArrayList<>();
|
||||
}
|
||||
clinitAdders.add(clinitAdder);
|
||||
}
|
||||
|
||||
public int nextFieldId() {
|
||||
return nextFieldId++;
|
||||
}
|
||||
|
||||
public int nextFreeVariableId() {
|
||||
return nextFreeVariableId++;
|
||||
}
|
||||
|
||||
public String getClassname() {
|
||||
return clazzName;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface FieldAdder {
|
||||
void generateField(ClassWriter cw, CodeFlow codeflow);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ClinitAdder {
|
||||
void generateCode(MethodVisitor mv, CodeFlow codeflow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the optimal instruction for loading a number on the stack.
|
||||
* @param mv where to insert the bytecode
|
||||
|
|
@ -979,4 +970,17 @@ public class CodeFlow implements Opcodes {
|
|||
}
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface FieldAdder {
|
||||
|
||||
void generateField(ClassWriter cw, CodeFlow codeflow);
|
||||
}
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ClinitAdder {
|
||||
|
||||
void generateCode(MethodVisitor mv, CodeFlow codeflow);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,8 +132,8 @@ public class InlineList extends SpelNodeImpl {
|
|||
|
||||
@Override
|
||||
public void generateCode(MethodVisitor mv, CodeFlow codeflow) {
|
||||
final String constantFieldName = "inlineList$"+codeflow.nextFieldId();
|
||||
final String clazzname = codeflow.getClassname();
|
||||
final String constantFieldName = "inlineList$" + codeflow.nextFieldId();
|
||||
final String className = codeflow.getClassName();
|
||||
|
||||
codeflow.registerNewField(new CodeFlow.FieldAdder() {
|
||||
public void generateField(ClassWriter cw, CodeFlow codeflow) {
|
||||
|
|
@ -143,11 +143,11 @@ public class InlineList extends SpelNodeImpl {
|
|||
|
||||
codeflow.registerNewClinit(new CodeFlow.ClinitAdder() {
|
||||
public void generateCode(MethodVisitor mv, CodeFlow codeflow) {
|
||||
generateClinitCode(clazzname,constantFieldName, mv,codeflow,false);
|
||||
generateClinitCode(className, constantFieldName, mv, codeflow, false);
|
||||
}
|
||||
});
|
||||
|
||||
mv.visitFieldInsn(GETSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
|
||||
mv.visitFieldInsn(GETSTATIC, className, constantFieldName, "Ljava/util/List;");
|
||||
codeflow.pushDescriptor("Ljava/util/List");
|
||||
}
|
||||
|
||||
|
|
@ -158,8 +158,8 @@ public class InlineList extends SpelNodeImpl {
|
|||
if (!nested) {
|
||||
mv.visitFieldInsn(PUTSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
|
||||
}
|
||||
int childcount = getChildCount();
|
||||
for (int c=0; c < childcount; c++) {
|
||||
int childCount = getChildCount();
|
||||
for (int c = 0; c < childCount; c++) {
|
||||
if (!nested) {
|
||||
mv.visitFieldInsn(GETSTATIC, clazzname, constantFieldName, "Ljava/util/List;");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,23 +23,24 @@ import org.springframework.http.HttpRequest;
|
|||
/**
|
||||
* Represents the context of a client-side HTTP request execution.
|
||||
*
|
||||
* <p>Used to invoke the next interceptor in the interceptor chain, or - if the calling interceptor is last - execute
|
||||
* the request itself.
|
||||
* <p>Used to invoke the next interceptor in the interceptor chain,
|
||||
* or - if the calling interceptor is last - execute the request itself.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @see ClientHttpRequestInterceptor
|
||||
* @since 3.1
|
||||
* @see ClientHttpRequestInterceptor
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ClientHttpRequestExecution {
|
||||
|
||||
/**
|
||||
* Execute the request with the given request attributes and body, and return the response.
|
||||
*
|
||||
* Execute the request with the given request attributes and body,
|
||||
* and return the response.
|
||||
* @param request the request, containing method, URI, and headers
|
||||
* @param body the body of the request to execute
|
||||
* @return the response
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
ClientHttpResponse execute(HttpRequest request, byte[] body) throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
|
@ -51,8 +51,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||
public interface LocaleResolver {
|
||||
|
||||
/**
|
||||
* Resolve the current locale via the given request. Can return a default locale as
|
||||
* fallback in any case.
|
||||
* Resolve the current locale via the given request.
|
||||
* Can return a default locale as fallback in any case.
|
||||
* @param request the request to resolve the locale for
|
||||
* @return the current locale (never {@code null})
|
||||
*/
|
||||
|
|
@ -63,8 +63,8 @@ public interface LocaleResolver {
|
|||
* @param request the request to be used for locale modification
|
||||
* @param response the response to be used for locale modification
|
||||
* @param locale the new locale, or {@code null} to clear the locale
|
||||
* @throws UnsupportedOperationException if the LocaleResolver implementation does not
|
||||
* support dynamic changing of the locale
|
||||
* @throws UnsupportedOperationException if the LocaleResolver
|
||||
* implementation does not support dynamic changing of the locale
|
||||
*/
|
||||
void setLocale(HttpServletRequest request, HttpServletResponse response, Locale locale);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
|
|
@ -23,7 +23,7 @@ import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
|||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* Abstract adapter class for the HandlerInterceptor interface,
|
||||
* Abstract adapter class for the {@link AsyncHandlerInterceptor} interface,
|
||||
* for simplified implementation of pre-only/post-only interceptors.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
|
|
@ -36,7 +36,8 @@ public abstract class HandlerInterceptorAdapter implements AsyncHandlerIntercept
|
|||
*/
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
throws Exception {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,8 +123,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||
|
||||
private boolean hasScheme(String link) {
|
||||
int schemeIndex = link.indexOf(":");
|
||||
return (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/"))
|
||||
|| link.indexOf("//") == 0;
|
||||
return (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/")) || link.indexOf("//") == 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -132,9 +131,9 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||
protected interface CssLinkParser {
|
||||
|
||||
void parseLink(String content, Set<CssLinkInfo> linkInfos);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected static abstract class AbstractCssLinkParser implements CssLinkParser {
|
||||
|
||||
/**
|
||||
|
|
@ -190,6 +189,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||
|
||||
}
|
||||
|
||||
|
||||
private static class ImportStatementCssLinkParser extends AbstractCssLinkParser {
|
||||
|
||||
@Override
|
||||
|
|
@ -209,6 +209,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private static class UrlFunctionCssLinkParser extends AbstractCssLinkParser {
|
||||
|
||||
@Override
|
||||
|
|
@ -230,8 +231,7 @@ public class CssLinkResourceTransformer extends ResourceTransformerSupport {
|
|||
|
||||
private final int end;
|
||||
|
||||
|
||||
private CssLinkInfo(int start, int end) {
|
||||
public CssLinkInfo(int start, int end) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@ public interface ResourceTransformer {
|
|||
* @param request the current request
|
||||
* @param resource the resource to transform
|
||||
* @param transformerChain the chain of remaining transformers to delegate to
|
||||
* @return the transformed resource, never {@code null}
|
||||
* @return the transformed resource (never {@code null})
|
||||
* @throws IOException if the transformation fails
|
||||
*/
|
||||
Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain)
|
||||
throws IOException;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue