From 8e5e0c4a9e498221fe2702a204b9bab3a115737c Mon Sep 17 00:00:00 2001 From: Eleftheria Stein Date: Thu, 26 Mar 2020 15:35:51 -0400 Subject: [PATCH] Add delegating filter proxy Kotlin samples to docs Issue gh-8172 --- .../architecture/delegating-filter-proxy.adoc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/manual/src/docs/asciidoc/_includes/servlet/architecture/delegating-filter-proxy.adoc b/docs/manual/src/docs/asciidoc/_includes/servlet/architecture/delegating-filter-proxy.adoc index d75a5c677d..d7c3d45ed3 100644 --- a/docs/manual/src/docs/asciidoc/_includes/servlet/architecture/delegating-filter-proxy.adoc +++ b/docs/manual/src/docs/asciidoc/_includes/servlet/architecture/delegating-filter-proxy.adoc @@ -16,7 +16,8 @@ The pseudo code of `DelegatingFilterProxy` can be seen below. .`DelegatingFilterProxy` Pseudo Code ==== -[source,java,subs="+quotes,+macros"] +.Java +[source,java,role="primary",subs="+quotes,+macros"] ---- public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) { // Lazily get Filter that was registered as a Spring Bean @@ -26,6 +27,18 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha delegate.doFilter(request, response); } ---- + +.Kotlin +[source,kotlin,role="secondary",subs="+quotes,+macros"] +---- +fun doFilter(request: ServletRequest, response: ServletResponse, chain: FilterChain) { + // Lazily get Filter that was registered as a Spring Bean + // For the example in <> `delegate` is an instance of __Bean Filter~0~__ + val delegate: Filter = getFilterBean(someBeanName) + // delegate work to the Spring Bean + delegate.doFilter(request, response) +} +---- ==== Another benefit of `DelegatingFilterProxy` is that it allows delaying looking `Filter` bean instances.