From 57f27fa42ffcd2d0bae78654da348b8c6800cb6c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 27 Dec 2023 23:22:30 +0100 Subject: [PATCH] Document autowiring of request/session proxies into Spring-managed beans Closes gh-26201 --- .../ROOT/pages/core/beans/factory-scopes.adoc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/framework-docs/modules/ROOT/pages/core/beans/factory-scopes.adoc b/framework-docs/modules/ROOT/pages/core/beans/factory-scopes.adoc index 8d8e3d0cea..6049003235 100644 --- a/framework-docs/modules/ROOT/pages/core/beans/factory-scopes.adoc +++ b/framework-docs/modules/ROOT/pages/core/beans/factory-scopes.adoc @@ -324,7 +324,6 @@ Kotlin:: - [[beans-factory-scopes-application]] === Application Scope @@ -374,7 +373,6 @@ Kotlin:: - [[beans-factory-scopes-websocket]] === WebSocket Scope @@ -384,7 +382,6 @@ xref:web/websocket/stomp/scope.adoc[WebSocket scope] for more details. - [[beans-factory-scopes-other-injection]] === Scoped Beans as Dependencies @@ -544,6 +541,19 @@ see xref:core/aop/proxying.adoc[Proxying Mechanisms]. +[[beans-factory-scopes-injection]] +=== Injecting Request/Session References Directly + +As an alternative to factory scopes, a Spring `WebApplicationContext` also supports +the injection of `HttpServletRequest`, `HttpServletResponse`, `HttpSession`, +`WebRequest` and (if JSF is present) `FacesContext` and `ExternalContext` into +Spring-managed beans, simply through type-based autowiring next to regular injection +points for other beans. Spring generally injects proxies for such request and session +objects which has the advantage of working in singleton beans and serializable beans +as well, similar to scoped proxies for factory-scoped beans. + + + [[beans-factory-scopes-custom]] == Custom Scopes