diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Lookup.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Lookup.java index 495354aa20..0fca4f3316 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Lookup.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/Lookup.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2020 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. @@ -41,12 +41,11 @@ import java.lang.annotation.Target; * regular constructors: i.e. lookup methods cannot get replaced on beans returned * from factory methods where we cannot dynamically provide a subclass for them. * - *

Concrete limitations in typical Spring configuration scenarios: - * When used with component scanning or any other mechanism that filters out abstract - * beans, provide stub implementations of your lookup methods to be able to declare - * them as concrete classes. And please remember that lookup methods won't work on - * beans returned from {@code @Bean} methods in configuration classes; you'll have - * to resort to {@code @Inject Provider} or the like instead. + *

Recommendations for typical Spring configuration scenarios: + * When a concrete class may be needed in certain scenarios, consider providing stub + * implementations of your lookup methods. And please remember that lookup methods + * won't work on beans returned from {@code @Bean} methods in configuration classes; + * you'll have to resort to {@code @Inject Provider} or the like instead. * * @author Juergen Hoeller * @since 4.1 diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index 3c5059a4f1..06d9b37230 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java @@ -887,7 +887,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp /** * Return whether this factory holds a InstantiationAwareBeanPostProcessor - * that will get applied to singleton beans on shutdown. + * that will get applied to singleton beans on creation. * @see #addBeanPostProcessor * @see org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor */ diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java index 4b4d5e506a..4cfe5439f6 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java +++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.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"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ import org.springframework.validation.annotation.Validated; * at the type level of the containing target class, applying to all public service methods * of that class. By default, JSR-303 will validate against its default group only. * - *

As of Spring 5.0, this functionality requires a Bean Validation 1.1 provider. + *

As of Spring 5.0, this functionality requires a Bean Validation 1.1+ provider. * * @author Juergen Hoeller * @since 3.1 @@ -87,7 +87,6 @@ public class MethodValidationInterceptor implements MethodInterceptor { @Override - @SuppressWarnings("unchecked") public Object invoke(MethodInvocation invocation) throws Throwable { // Avoid Validator invocation on FactoryBean.getObjectType/isSingleton if (isFactoryBeanMetadataMethod(invocation.getMethod())) { diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java index b5907bf6fe..45e5d13a5f 100644 --- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java @@ -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"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ import org.springframework.validation.annotation.Validated; * inline constraint annotations. Validation groups can be specified through {@code @Validated} * as well. By default, JSR-303 will validate against its default group only. * - *

As of Spring 5.0, this functionality requires a Bean Validation 1.1 provider. + *

As of Spring 5.0, this functionality requires a Bean Validation 1.1+ provider. * * @author Juergen Hoeller * @since 3.1 diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java index d66f59c601..9135b96231 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -46,12 +46,12 @@ import org.springframework.lang.Nullable; */ public class ServerSentEventHttpMessageReader implements HttpMessageReader { + private static final ResolvableType STRING_TYPE = ResolvableType.forClass(String.class); + private static final DataBufferFactory bufferFactory = new DefaultDataBufferFactory(); private static final StringDecoder stringDecoder = StringDecoder.textPlainOnly(); - private static final ResolvableType STRING_TYPE = ResolvableType.forClass(String.class); - @Nullable private final Decoder decoder; @@ -129,7 +129,7 @@ public class ServerSentEventHttpMessageReader implements HttpMessageReader { sseBuilder.data(o); diff --git a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java index fec0ed09ec..04dc30b3cc 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java +++ b/spring-web/src/main/java/org/springframework/http/codec/ServerSentEventHttpMessageWriter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -184,7 +184,7 @@ public class ServerSentEventHttpMessageWriter implements HttpMessageWriter encodeText(CharSequence text, MediaType mediaType, DataBufferFactory bufferFactory) { Assert.notNull(mediaType.getCharset(), "Expected MediaType with charset"); byte[] bytes = text.toString().getBytes(mediaType.getCharset()); - return Mono.just(bufferFactory.wrap(bytes)); // wrapping, not allocating + return Mono.just(bufferFactory.wrap(bytes)); // wrapping, not allocating } @Override diff --git a/src/docs/asciidoc/core/core-expressions.adoc b/src/docs/asciidoc/core/core-expressions.adoc index 22b3c4e78d..22c01b2dc7 100644 --- a/src/docs/asciidoc/core/core-expressions.adoc +++ b/src/docs/asciidoc/core/core-expressions.adoc @@ -436,8 +436,12 @@ example shows: ---- ==== -The `systemProperties` variable is predefined, so you can use it in your expressions, as -the following example shows: +All beans in the application context are available as predefined variables with their +common bean name. This includes standard context beans such as `environment` (of type +`org.springframework.core.env.Environment`) as well as `systemProperties` and +`systemEnvironment` (of type `Map`) for access to the runtime environment. + +The following example shows access to the `systemProperties` bean as a SpEL variable: ==== [source,xml,indent=0] @@ -451,8 +455,7 @@ the following example shows: ---- ==== -Note that you do not have to prefix the predefined variable with the `#` -symbol in this context. +Note that you do not have to prefix the predefined variable with the `#` symbol here. You can also refer to other bean properties by name, as the following example shows: @@ -479,8 +482,8 @@ You can also refer to other bean properties by name, as the following example sh [[expressions-beandef-annotation-based]] === Annotation Configuration -To specify a default value, you can place the `@Value` annotation on fields, methods, and method or constructor -parameters. +To specify a default value, you can place the `@Value` annotation on fields, methods, +and method or constructor parameters. The following example sets the default value of a field variable: @@ -1265,7 +1268,7 @@ The following example shows how to use the Elvis operator: ---- ExpressionParser parser = new SpelExpressionParser(); - String name = parser.parseExpression("name?:'Unknown'").getValue(String.class); + String name = parser.parseExpression("name?:'Unknown'").getValue(new Inventor(), String.class); System.out.println(name); // 'Unknown' ---- ====