Browse Source

Polishing

pull/1837/head
Juergen Hoeller 8 years ago
parent
commit
b4f83dbdc3
  1. 31
      spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java
  2. 8
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java

31
spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 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.
@ -33,17 +33,15 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
* Implementation of AspectJ ProceedingJoinPoint interface * An implementation of the AspectJ {@link ProceedingJoinPoint} interface
* wrapping an AOP Alliance MethodInvocation. * wrapping an AOP Alliance {@link org.aopalliance.intercept.MethodInvocation}.
* *
* <p><b>Note</b>: the {@code getThis()} method returns the current Spring AOP proxy. * <p><b>Note</b>: The {@code getThis()} method returns the current Spring AOP proxy.
* The {@code getTarget()} method returns the current Spring AOP target (which may be * The {@code getTarget()} method returns the current Spring AOP target (which may be
* {@code null} if there is no target), and is a plain POJO without any advice. * {@code null} if there is no target instance) as a plain POJO without any advice.
* <b>If you want to call the object and have the advice take effect, use * <b>If you want to call the object and have the advice take effect, use {@code getThis()}.</b>
* {@code getThis()}.</b> A common example is casting the object to an * A common example is casting the object to an introduced interface in the implementation of
* introduced interface in the implementation of an introduction. * an introduction. There is no such distinction between target and proxy in AspectJ itself.
*
* <p>Of course there is no such distinction between target and proxy in AspectJ.
* *
* @author Rod Johnson * @author Rod Johnson
* @author Juergen Hoeller * @author Juergen Hoeller
@ -58,7 +56,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
private final ProxyMethodInvocation methodInvocation; private final ProxyMethodInvocation methodInvocation;
@Nullable @Nullable
private Object[] defensiveCopyOfArgs; private Object[] args;
/** Lazily initialized signature object */ /** Lazily initialized signature object */
@Nullable @Nullable
@ -79,6 +77,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
this.methodInvocation = methodInvocation; this.methodInvocation = methodInvocation;
} }
@Override @Override
public void set$AroundClosure(AroundClosure aroundClosure) { public void set$AroundClosure(AroundClosure aroundClosure) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -120,12 +119,10 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
@Override @Override
public Object[] getArgs() { public Object[] getArgs() {
if (this.defensiveCopyOfArgs == null) { if (this.args == null) {
Object[] argsSource = this.methodInvocation.getArguments(); this.args = this.methodInvocation.getArguments().clone();
this.defensiveCopyOfArgs = new Object[argsSource.length];
System.arraycopy(argsSource, 0, this.defensiveCopyOfArgs, 0, argsSource.length);
} }
return this.defensiveCopyOfArgs; return this.args;
} }
@Override @Override
@ -133,7 +130,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
if (this.signature == null) { if (this.signature == null) {
this.signature = new MethodSignatureImpl(); this.signature = new MethodSignatureImpl();
} }
return signature; return this.signature;
} }
@Override @Override

8
spring-webmvc/src/main/java/org/springframework/web/servlet/config/ResourcesBeanDefinitionParser.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 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.
@ -201,7 +201,7 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
private CacheControl parseCacheControl(Element element) { private CacheControl parseCacheControl(Element element) {
CacheControl cacheControl = CacheControl.empty(); CacheControl cacheControl;
if ("true".equals(element.getAttribute("no-cache"))) { if ("true".equals(element.getAttribute("no-cache"))) {
cacheControl = CacheControl.noCache(); cacheControl = CacheControl.noCache();
} }
@ -211,6 +211,10 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
else if (element.hasAttribute("max-age")) { else if (element.hasAttribute("max-age")) {
cacheControl = CacheControl.maxAge(Long.parseLong(element.getAttribute("max-age")), TimeUnit.SECONDS); cacheControl = CacheControl.maxAge(Long.parseLong(element.getAttribute("max-age")), TimeUnit.SECONDS);
} }
else {
cacheControl = CacheControl.empty();
}
if ("true".equals(element.getAttribute("must-revalidate"))) { if ("true".equals(element.getAttribute("must-revalidate"))) {
cacheControl = cacheControl.mustRevalidate(); cacheControl = cacheControl.mustRevalidate();
} }

Loading…
Cancel
Save