Commit Graph

46 Commits

Author SHA1 Message Date
Stephane Nicoll
7231f22c23 Update copyright of changed file
See gh-27115
2023-08-26 16:39:25 +02:00
Gergely Nagy
3470240ef0 Allow null attribute value in Model.set()
See gh-27115
2023-08-26 16:38:19 +02:00
Sam Brannen
2161e865d7 Update copyright header 2023-07-03 15:53:43 +02:00
Vladyslav Baidak
0b2c2d04b2 Fix typo in Javadoc for BeanDefinitionDsl.kt
Closes gh-30798
2023-07-03 15:49:28 +02:00
Sébastien Deleuze
7a2110d8a5 Refine Kotlin bean DSL for AOT use case
Before this commit, beans registered with the Kotlin bean DSL
typically added via SpringApplication#addInitializers
were registered 2 times: by the code generated AOT and by
the listener executed at runtime.

After this commit, such beans are only registered 1 time when
AOT generation is involved, and does not require specific
reflection hints on native execution anymore.

Closes gh-29211
2022-09-30 12:25:43 +02:00
Brian Clozel
bb53a99def Upgrade to Kotlin 1.6.10
Closes gh-27413
2021-12-14 15:25:50 +01:00
Stephane Nicoll
65dc2afe9d Polish "Add Kotlin extensions for Cache and CacheManager"
See gh-23927
2021-12-02 14:51:29 +01:00
sokomishalov
5ec1e20242 Add Kotlin extensions for Cache and CacheManager
See gh-23927
2021-12-02 14:51:29 +01:00
Stephane Nicoll
b0f724a597 Update copyright year of changed file
See gh-27105
2021-06-29 19:27:57 +02:00
takumi34
9add04f800 Fix typo in BeanDefinitionDsl.kt
See gh-27105
2021-06-29 19:27:29 +02:00
Sébastien Deleuze
3f1882c4eb Support noarg callable references in Kotlin beans DSL
Closes gh-23395
2020-01-13 10:53:23 +01:00
Sébastien Deleuze
6c7250b0ae Make Kotlin DSL class constructors internal
Closes gh-24059
2019-11-22 16:10:42 +01:00
Sebastien Deleuze
23cd261b6b Deprecate AnnotationConfigApplicationContext { } Kotlin extension
Closes gh-23420
2019-08-06 11:28:32 +02:00
Thomas Girard
87c15ba9ad Use the accepted profiles in BeanDefinitionDsl
Closes gh-22393
2019-06-29 17:25:45 +02:00
Sebastien Deleuze
8003aa4f26 Deprecate GenericApplicationContext { } Kotlin extension
Closes gh-22692
2019-03-27 15:12:16 +01:00
Sebastien Deleuze
fb1da01410 Support creating beans from Kotlin callable references
This commit updates Kotlin beans DSL in order to support
creating beans using callable references with autowired
parameters. Type resolution is implemented using Kotlin
reified type parameters without requiring reflection.

Closes gh-21845
2019-03-27 14:47:42 +01:00
Spring Operator
dc6f63f610 URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://www.apache.org/licenses/ with 1 occurrences migrated to:
  https://www.apache.org/licenses/ ([https](https://www.apache.org/licenses/) result 200).
* [ ] http://www.apache.org/licenses/LICENSE-2.0 with 6625 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).
2019-03-21 23:49:28 -05:00
Sebastien Deleuze
0ad9349d84 Limit ref() and provider() visibility in Kotlin DSL
This commit makes ref() and provider() only available from
inside the bean lambda and not from the root level of the beans DSL.

Closes gh-22177
2019-02-05 16:59:56 +01:00
Sebastien Deleuze
af6a5566a3 Replace context by provider<T>() in Kotlin bean DSL
Spring Framework 5.1.0 exposed by mistake context in the Kotlin bean DSL
API in order to fix SPR-16269. Now that BeanFactory#getBeanprovider is
available, it should be exposed via a provider<Foo>() function in order
to provide a more clean API instead.

Issue: SPR-17352
2018-10-08 14:00:12 +02:00
Sebastien Deleuze
f7839675f6 Don't set role in Kotlin bean DSL unless specified
Issue: SPR-17275
2018-09-20 00:21:38 +02:00
Sebastien Deleuze
47d6e91227 Leverage non-default ctor support in Kotlin bean DSL
Since non-default constructors are now evaluated for autowiring,
there is no need anymore for setting autowiring mode or exposing
it in Kotlin bean DSL.

Issue: SPR-17292
2018-09-20 00:21:38 +02:00
Sebastien Deleuze
c4aea626fe Update Kotlin bean DSL with new BeanDefinition methods
Issue: SPR-17275
2018-09-17 12:01:33 +02:00
Juergen Hoeller
b6d32ef55f Bean definition DSL generates unique bean names for bean classes
Issue: SPR-17242
2018-09-12 14:59:10 +02:00
Sebastien Deleuze
b71d0eeec9 Fix Kotlin bean DSL conditional handling
Issue: SPR-16412
2018-06-01 14:40:27 +02:00
Sebastien Deleuze
be416ef9c4 Polish BeanDefinitionDsl
Issue: SPR-16412
2018-05-29 09:34:35 +02:00
sdeleuze
97ee94f4ca Expose env and context in Kotlin beans DSL
This commit introduces a deferred initialization of the declared beans
in order to make it possible to access to the environment (and even
to the context for advanced use-cases) in the beans { } Kotlin DSL.

Issues: SPR-16269, SPR-16412
2018-04-12 11:31:37 +02:00
sdeleuze
9f1d8517ba Polish Kotlin source code style 2017-11-21 15:59:23 +01:00
Sebastien Deleuze
23497a7ece Support autowiring by constructor in Kotlin bean DSL
Issue: SPR-16014
2017-09-27 01:25:22 +02:00
Sebastien Deleuze
14cba15296 Open router and bean Kotlin DSL to allow building custom ones 2017-09-26 16:31:16 +02:00
Sebastien Deleuze
8b8a6766de Change BeanDefinitionDsl to implement ApplicationContextInitializer 2017-09-04 10:46:20 +02:00
Sebastien Deleuze
d2c1b284f3 Polish Kotlin API contracts and documentation
Issue: SPR-15659
2017-08-29 00:56:39 +02:00
Sebastien Deleuze
29c112c010 Avoid requiring it parameter in Kotlin bean DSL
By using function literals with receiver, we can avoid requiring
lambda parameters for a shorter and nicer syntax. Based on a
proposal from Joseph Taylor.

Issue: SPR-15815
2017-07-25 11:21:08 +02:00
Sebastien Deleuze
f72e0daa54 Add an env accessor to BeanDefinitionContext
Issue: SPR-15755
2017-07-19 07:57:19 +02:00
Sebastien Deleuze
1f011467b8 Introduce Kotlin functional bean definition DSL
As a follow-up of the ApplicationContext Kotlin extensions, close to
the Kotlin functional WebFlux DSL and partially inspired of the
Groovy/Scala bean configuration DSL, this commit introduces a
lightweight Kotlin DSL for functional bean declaration.

It allows declaring beans as following:

beans {
	bean<Foo>()
	profile("bar") {
		bean<Bar>("bar", scope = Scope.PROTOTYPE)
	}
	environment({ it.activeProfiles.contains("baz") }) {
		bean { Baz(it.ref()) }
		bean { Baz(it.ref("bar")) }
	}
}

Advantages compared to Regular ApplicationContext API are:
 - No exposure of low-level ApplicationContext API
 - Focused DSL easier to read, but also easier to write with a fewer
   entries in the auto-complete
 - Declarative syntax instead of functions with verbs like registerBeans
   while still allowing programmatic registration of beans if needed
 - Such DSL is idiomatic in Kotlin
 - No need to have an ApplicationContext instance to write how you
   register your beans since beans { } DSL is conceptually a
   Consumer<GenericApplicationContext>

This DSL effectively replaces ApplicationContext Kotlin extensions as
the recommended way to register beans in a functional way with Kotlin.

Issue: SPR-15755
2017-07-12 16:38:41 +02:00
Sebastien Deleuze
d728d597f2 Add missing license headers in Kotlin files 2017-06-27 14:39:26 +02:00
Sebastien Deleuze
04d5a2951c Remove KClass based Kotlin extensions
Issue: SPR-15660
2017-06-13 18:43:59 +02:00
Sebastien Deleuze
e2fd398bad Specify explicitly Kotlin extensions return type
The main purpose is to specify nullability.
2017-03-30 14:25:13 +02:00
Sebastien Deleuze
0a988fd2b1 Remove object wrappers in Kotlin extensions
This commit also improve significantly Kotlin extensions
documentation.

Issue: SPR-15127
2017-01-11 08:52:01 +01:00
Sebastien Deleuze
8f14e29067 Support AnnotationConfigApplicationContext{} in Kotlin
Issue: SPR-15126
2017-01-10 22:47:33 +01:00
Sebastien Deleuze
f8461d856a Support Gradle-style Kotlin bean API
val context = GenericApplicationContext {
    registerBean<Foo>()
    registerBean { Bar(it.getBean<Foo>()) }
}

Issue: SPR-15126
2017-01-10 21:43:27 +01:00
Mario Arias
1af905ca0a Add Model and ModelMap Kotlin extensions
Issue: SPR-15119
2017-01-10 14:22:54 +01:00
Sebastien Deleuze
6ee5e2a817 Polishing
Issue: SPR-15118
2017-01-10 10:54:24 +01:00
Sebastien Deleuze
c5cfd8c8fc Make the Kotlin bean registration API even more idiomatic
Put the lambda parameter at the end and use a function
instead of a supplier to be able to register beans like this:

val context = GenericApplicationContext()
context.registerBean(Foo::class)
context.registerBean{ Bar(it.getBean(Foo::class)) }

Issue: SPR-15118
2017-01-10 10:38:24 +01:00
Sebastien Deleuze
715274e327 Avoid the need to specify Supplier in Kotlin bean registration API
Based on an idea from Mario Arias, we can avoid requiring specifying
explicitly Supplier lambda type in Kotlin API by declaring the supplier
parameter as "crossinline supplier: () -> T" instead of
"supplier: Supplier<T>".

Issue: SPR-15118
2017-01-09 20:22:30 +01:00
Sebastien Deleuze
6a850ee688 Polishing 2016-12-27 10:08:12 +01:00
Sebastien Deleuze
ff675f5226 Add Kotlin extensions for bean registration and retrieval
Issue: SPR-15048
2016-12-26 14:21:10 +01:00