Add delegating filter proxy Kotlin samples to docs

Issue gh-8172
This commit is contained in:
Eleftheria Stein 2020-03-26 15:35:51 -04:00
parent 5b4cb5b13d
commit 8e5e0c4a9e
1 changed files with 14 additions and 1 deletions

View File

@ -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 <<servlet-delegatingfilterproxy-figure>> `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.