"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/docs/asciidoc/languages/kotlin.adoc" between
spring-framework-5.3.7.tar.gz and spring-framework-5.3.8.tar.gz

About: Spring Framework is an application framework for the Java platform and .NET Framework. Community edition.

kotlin.adoc  (spring-framework-5.3.7):kotlin.adoc  (spring-framework-5.3.8)
[[kotlin]] [[kotlin]]
= Kotlin = Kotlin
https://kotlinlang.org[Kotlin] is a statically typed language that targets the J VM https://kotlinlang.org[Kotlin] is a statically typed language that targets the J VM
(and other platforms) which allows writing concise and elegant code while provid ing (and other platforms) which allows writing concise and elegant code while provid ing
very good https://kotlinlang.org/docs/reference/java-interop.html[interoperabili ty] very good https://kotlinlang.org/docs/reference/java-interop.html[interoperabili ty]
with existing libraries written in Java. with existing libraries written in Java.
The Spring Framework provides first-class support for Kotlin and lets developers write The Spring Framework provides first-class support for Kotlin and lets developers write
Kotlin applications almost as if the Spring Framework was a native Kotlin framew ork. Kotlin applications almost as if the Spring Framework was a native Kotlin framew ork.
Most of the code samples of the reference documentation are
provided in Kotlin in addition to Java.
The easiest way to build a Spring application with Kotlin is to leverage Spring Boot and The easiest way to build a Spring application with Kotlin is to leverage Spring Boot and
its https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features -kotlin.html[dedicated Kotlin support]. its https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features -kotlin.html[dedicated Kotlin support].
https://spring.io/guides/tutorials/spring-boot-kotlin/[This comprehensive tutori al] https://spring.io/guides/tutorials/spring-boot-kotlin/[This comprehensive tutori al]
will teach you how to build Spring Boot applications with Kotlin using https://s tart.spring.io/#!language=kotlin&type=gradle-project[start.spring.io]. will teach you how to build Spring Boot applications with Kotlin using https://s tart.spring.io/#!language=kotlin&type=gradle-project[start.spring.io].
As of Spring Framework 5.2, most of the code samples of the reference documentat
ion are
provided in Kotlin in addition to Java.
Feel free to join the #spring channel of https://slack.kotlinlang.org/[Kotlin Sl ack] Feel free to join the #spring channel of https://slack.kotlinlang.org/[Kotlin Sl ack]
or ask a question with `spring` and `kotlin` as tags on or ask a question with `spring` and `kotlin` as tags on
https://stackoverflow.com/questions/tagged/spring+kotlin[Stackoverflow] if you n eed support. https://stackoverflow.com/questions/tagged/spring+kotlin[Stackoverflow] if you n eed support.
[[kotlin-requirements]] [[kotlin-requirements]]
== Requirements == Requirements
Spring Framework supports Kotlin 1.3 and requires Spring Framework supports Kotlin 1.3+ and requires
https://bintray.com/bintray/jcenter/org.jetbrains.kotlin%3Akotlin-stdlib[`kotlin https://search.maven.org/artifact/org.jetbrains.kotlin/kotlin-stdlib[`kotlin-std
-stdlib`] lib`]
(or one of its variants, such as https://bintray.com/bintray/jcenter/org.jetbrai (or one of its variants, such as https://search.maven.org/artifact/org.jetbrains
ns.kotlin%3Akotlin-stdlib-jdk8[`kotlin-stdlib-jdk8`]) .kotlin/kotlin-stdlib-jdk8[`kotlin-stdlib-jdk8`])
and https://bintray.com/bintray/jcenter/org.jetbrains.kotlin%3Akotlin-reflect[`k and https://search.maven.org/artifact/org.jetbrains.kotlin/kotlin-reflect[`kotli
otlin-reflect`] n-reflect`]
to be present on the classpath. They are provided by default if you bootstrap a Kotlin project on to be present on the classpath. They are provided by default if you bootstrap a Kotlin project on
https://start.spring.io/#!language=kotlin&type=gradle-project[start.spring.io]. https://start.spring.io/#!language=kotlin&type=gradle-project[start.spring.io].
NOTE: The https://github.com/FasterXML/jackson-module-kotlin[Jackson Kotlin modu
le] is required
for serializing or deserializing JSON data for Kotlin classes with Jackson, so m
ake sure to add the
`com.fasterxml.jackson.module:jackson-module-kotlin` dependency to your project
if you have such need.
It is automatically registered when found in the classpath.
[[kotlin-extensions]] [[kotlin-extensions]]
== Extensions == Extensions
Kotlin https://kotlinlang.org/docs/reference/extensions.html[extensions] provide the ability Kotlin https://kotlinlang.org/docs/reference/extensions.html[extensions] provide the ability
to extend existing classes with additional functionality. The Spring Framework K otlin APIs to extend existing classes with additional functionality. The Spring Framework K otlin APIs
use these extensions to add new Kotlin-specific conveniences to existing Spring APIs. use these extensions to add new Kotlin-specific conveniences to existing Spring APIs.
The {doc-root}/spring-framework/docs/{spring-version}/kdoc-api/spring-framework/ [Spring Framework KDoc API] lists The {doc-root}/spring-framework/docs/{spring-version}/kdoc-api/spring-framework/ [Spring Framework KDoc API] lists
and documents all available the Kotlin extensions and DSLs. and documents all available the Kotlin extensions and DSLs.
skipping to change at line 123 skipping to change at line 127
== Classes and Interfaces == Classes and Interfaces
The Spring Framework supports various Kotlin constructs, such as instantiating K otlin classes The Spring Framework supports various Kotlin constructs, such as instantiating K otlin classes
through primary constructors, immutable classes data binding, and function optio nal parameters through primary constructors, immutable classes data binding, and function optio nal parameters
with default values. with default values.
Kotlin parameter names are recognized through a dedicated `KotlinReflectionParam eterNameDiscoverer`, Kotlin parameter names are recognized through a dedicated `KotlinReflectionParam eterNameDiscoverer`,
which allows finding interface method parameter names without requiring the Java 8 `-parameters` which allows finding interface method parameter names without requiring the Java 8 `-parameters`
compiler flag to be enabled during compilation. compiler flag to be enabled during compilation.
The https://github.com/FasterXML/jackson-module-kotlin[Jackson Kotlin module], w
hich is required
for serializing or deserializing JSON data, is automatically registered when
found in the classpath, and a warning message is logged if Jackson and Kotlin ar
e
detected without the Jackson Kotlin module being present.
You can declare configuration classes as You can declare configuration classes as
https://kotlinlang.org/docs/reference/nested-classes.html[top level or nested bu t not inner], https://kotlinlang.org/docs/reference/nested-classes.html[top level or nested bu t not inner],
since the later requires a reference to the outer class. since the later requires a reference to the outer class.
[[kotlin-annotations]] [[kotlin-annotations]]
== Annotations == Annotations
The Spring Framework also takes advantage of https://kotlinlang.org/docs/referen ce/null-safety.html[Kotlin null-safety] The Spring Framework also takes advantage of https://kotlinlang.org/docs/referen ce/null-safety.html[Kotlin null-safety]
to determine if an HTTP parameter is required without having to explicitly to determine if an HTTP parameter is required without having to explicitly
define the `required` attribute. That means `@RequestParam name: String?` is tre ated define the `required` attribute. That means `@RequestParam name: String?` is tre ated
skipping to change at line 346 skipping to change at line 345
print() print()
} }
---- ----
=== Kotlin Script Templates === Kotlin Script Templates
Spring Framework provides a Spring Framework provides a
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframe work/web/servlet/view/script/ScriptTemplateView.html[`ScriptTemplateView`] https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframe work/web/servlet/view/script/ScriptTemplateView.html[`ScriptTemplateView`]
which supports https://www.jcp.org/en/jsr/detail?id=223[JSR-223] to render templ ates by using script engines. which supports https://www.jcp.org/en/jsr/detail?id=223[JSR-223] to render templ ates by using script engines.
By leveraging `kotlin-script-runtime` and `scripting-jsr223-embeddable` dependen cies, it By leveraging `scripting-jsr223` dependencies, it
is possible to use such feature to render Kotlin-based templates with is possible to use such feature to render Kotlin-based templates with
https://github.com/Kotlin/kotlinx.html[kotlinx.html] DSL or Kotlin multiline int erpolated `String`. https://github.com/Kotlin/kotlinx.html[kotlinx.html] DSL or Kotlin multiline int erpolated `String`.
`build.gradle.kts` `build.gradle.kts`
[source,kotlin,indent=0] [source,kotlin,indent=0]
---- ----
dependencies { dependencies {
compile("org.jetbrains.kotlin:kotlin-script-runtime:${kotlinVersion}") runtime("org.jetbrains.kotlin:kotlin-scripting-jsr223:${kotlinVersion}")
runtime("org.jetbrains.kotlin:kotlin-scripting-jsr223-embeddable:${kotlin
Version}")
} }
---- ----
Configuration is usually done with `ScriptTemplateConfigurer` and `ScriptTemplat eViewResolver` Configuration is usually done with `ScriptTemplateConfigurer` and `ScriptTemplat eViewResolver`
beans. beans.
`KotlinScriptConfiguration.kt` `KotlinScriptConfiguration.kt`
[source,kotlin,indent=0] [source,kotlin,indent=0]
---- ----
@Configuration @Configuration
 End of changes. 7 change blocks. 
22 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)