Browse Source

Polishing

pull/27093/head
Juergen Hoeller 6 years ago
parent
commit
9e12a20324
  1. 3
      spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractInterfaceDrivenDependencyInjectionAspect.aj
  2. 8
      spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AnnotationBeanConfigurerAspect.aj
  3. 14
      spring-core/src/main/java/org/springframework/util/FileCopyUtils.java
  4. 10
      spring-core/src/main/java/org/springframework/util/StreamUtils.java
  5. 8
      spring-web/src/main/java/org/springframework/web/context/request/WebRequest.java
  6. 4
      src/docs/asciidoc/web/webmvc.adoc

3
spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AbstractInterfaceDrivenDependencyInjectionAspect.aj

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2020 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.
@ -67,6 +67,7 @@ import java.io.Serializable;
* @since 2.5.2 * @since 2.5.2
*/ */
public abstract aspect AbstractInterfaceDrivenDependencyInjectionAspect extends AbstractDependencyInjectionAspect { public abstract aspect AbstractInterfaceDrivenDependencyInjectionAspect extends AbstractDependencyInjectionAspect {
/** /**
* Select initialization join point as object construction * Select initialization join point as object construction
*/ */

8
spring-aspects/src/main/java/org/springframework/beans/factory/aspectj/AnnotationBeanConfigurerAspect.aj

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2020 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.
@ -47,22 +47,26 @@ import org.springframework.beans.factory.wiring.BeanConfigurerSupport;
public aspect AnnotationBeanConfigurerAspect extends AbstractInterfaceDrivenDependencyInjectionAspect public aspect AnnotationBeanConfigurerAspect extends AbstractInterfaceDrivenDependencyInjectionAspect
implements BeanFactoryAware, InitializingBean, DisposableBean { implements BeanFactoryAware, InitializingBean, DisposableBean {
private BeanConfigurerSupport beanConfigurerSupport = new BeanConfigurerSupport(); private final BeanConfigurerSupport beanConfigurerSupport = new BeanConfigurerSupport();
@Override
public void setBeanFactory(BeanFactory beanFactory) { public void setBeanFactory(BeanFactory beanFactory) {
this.beanConfigurerSupport.setBeanWiringInfoResolver(new AnnotationBeanWiringInfoResolver()); this.beanConfigurerSupport.setBeanWiringInfoResolver(new AnnotationBeanWiringInfoResolver());
this.beanConfigurerSupport.setBeanFactory(beanFactory); this.beanConfigurerSupport.setBeanFactory(beanFactory);
} }
@Override
public void afterPropertiesSet() { public void afterPropertiesSet() {
this.beanConfigurerSupport.afterPropertiesSet(); this.beanConfigurerSupport.afterPropertiesSet();
} }
@Override
public void configureBean(Object bean) { public void configureBean(Object bean) {
this.beanConfigurerSupport.configureBean(bean); this.beanConfigurerSupport.configureBean(bean);
} }
@Override
public void destroy() { public void destroy() {
this.beanConfigurerSupport.destroy(); this.beanConfigurerSupport.destroy();
} }

14
spring-core/src/main/java/org/springframework/util/FileCopyUtils.java

@ -171,15 +171,15 @@ public abstract class FileCopyUtils {
Assert.notNull(out, "No Writer specified"); Assert.notNull(out, "No Writer specified");
try { try {
int byteCount = 0; int charCount = 0;
char[] buffer = new char[BUFFER_SIZE]; char[] buffer = new char[BUFFER_SIZE];
int bytesRead = -1; int charsRead;
while ((bytesRead = in.read(buffer)) != -1) { while ((charsRead = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead); out.write(buffer, 0, charsRead);
byteCount += bytesRead; charCount += charsRead;
} }
out.flush(); out.flush();
return byteCount; return charCount;
} }
finally { finally {
close(in); close(in);
@ -188,7 +188,7 @@ public abstract class FileCopyUtils {
} }
/** /**
* Copy the contents of the given String to the given output Writer. * Copy the contents of the given String to the given Writer.
* Closes the writer when done. * Closes the writer when done.
* @param in the String to copy from * @param in the String to copy from
* @param out the Writer to copy to * @param out the Writer to copy to

10
spring-core/src/main/java/org/springframework/util/StreamUtils.java

@ -87,9 +87,9 @@ public abstract class StreamUtils {
StringBuilder out = new StringBuilder(); StringBuilder out = new StringBuilder();
InputStreamReader reader = new InputStreamReader(in, charset); InputStreamReader reader = new InputStreamReader(in, charset);
char[] buffer = new char[BUFFER_SIZE]; char[] buffer = new char[BUFFER_SIZE];
int bytesRead = -1; int charsRead;
while ((bytesRead = reader.read(buffer)) != -1) { while ((charsRead = reader.read(buffer)) != -1) {
out.append(buffer, 0, bytesRead); out.append(buffer, 0, charsRead);
} }
return out.toString(); return out.toString();
} }
@ -130,7 +130,7 @@ public abstract class StreamUtils {
} }
/** /**
* Copy the contents of the given String to the given output OutputStream. * Copy the contents of the given String to the given OutputStream.
* <p>Leaves the stream open when done. * <p>Leaves the stream open when done.
* @param in the String to copy from * @param in the String to copy from
* @param charset the Charset * @param charset the Charset
@ -161,7 +161,7 @@ public abstract class StreamUtils {
int byteCount = 0; int byteCount = 0;
byte[] buffer = new byte[BUFFER_SIZE]; byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead = -1; int bytesRead;
while ((bytesRead = in.read(buffer)) != -1) { while ((bytesRead = in.read(buffer)) != -1) {
out.write(buffer, 0, bytesRead); out.write(buffer, 0, bytesRead);
byteCount += bytesRead; byteCount += bytesRead;

8
spring-web/src/main/java/org/springframework/web/context/request/WebRequest.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2020 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.
@ -140,7 +140,7 @@ public interface WebRequest extends RequestAttributes {
* and HTTP status when applicable. * and HTTP status when applicable.
* <p>Typical usage: * <p>Typical usage:
* <pre class="code"> * <pre class="code">
* public String myHandleMethod(WebRequest webRequest, Model model) { * public String myHandleMethod(WebRequest request, Model model) {
* long lastModified = // application-specific calculation * long lastModified = // application-specific calculation
* if (request.checkNotModified(lastModified)) { * if (request.checkNotModified(lastModified)) {
* // shortcut exit - no further processing necessary * // shortcut exit - no further processing necessary
@ -177,7 +177,7 @@ public interface WebRequest extends RequestAttributes {
* and HTTP status when applicable. * and HTTP status when applicable.
* <p>Typical usage: * <p>Typical usage:
* <pre class="code"> * <pre class="code">
* public String myHandleMethod(WebRequest webRequest, Model model) { * public String myHandleMethod(WebRequest request, Model model) {
* String eTag = // application-specific calculation * String eTag = // application-specific calculation
* if (request.checkNotModified(eTag)) { * if (request.checkNotModified(eTag)) {
* // shortcut exit - no further processing necessary * // shortcut exit - no further processing necessary
@ -208,7 +208,7 @@ public interface WebRequest extends RequestAttributes {
* response headers, and HTTP status when applicable. * response headers, and HTTP status when applicable.
* <p>Typical usage: * <p>Typical usage:
* <pre class="code"> * <pre class="code">
* public String myHandleMethod(WebRequest webRequest, Model model) { * public String myHandleMethod(WebRequest request, Model model) {
* String eTag = // application-specific calculation * String eTag = // application-specific calculation
* long lastModified = // application-specific calculation * long lastModified = // application-specific calculation
* if (request.checkNotModified(eTag, lastModified)) { * if (request.checkNotModified(eTag, lastModified)) {

4
src/docs/asciidoc/web/webmvc.adoc

@ -4835,7 +4835,7 @@ as the following example shows:
.Java .Java
---- ----
@RequestMapping @RequestMapping
public String myHandleMethod(WebRequest webRequest, Model model) { public String myHandleMethod(WebRequest request, Model model) {
long eTag = ... // <1> long eTag = ... // <1>
@ -4855,7 +4855,7 @@ as the following example shows:
.Kotlin .Kotlin
---- ----
@RequestMapping @RequestMapping
fun myHandleMethod(webRequest: WebRequest, model: Model): String? { fun myHandleMethod(request: WebRequest, model: Model): String? {
val eTag: Long = ... // <1> val eTag: Long = ... // <1>

Loading…
Cancel
Save