https://kotlinlang.org logo
#feed
Title
s

sdeleuze

05/28/2020, 1:02 PM
FYI I have released Spring Fu 0.3.0 (with KoFu Kotlin experimental DSL for Spring Boot) and shared some insights about the roadmap https://spring.io/blog/2020/05/28/spring-fu-0-3-0-and-beyond
👍 18
🎉 7
t

Tristan

05/28/2020, 1:19 PM
I miss your messages so much, you always have good news 😄
s

sdeleuze

05/28/2020, 1:19 PM
🙂
n

nfrankel

05/28/2020, 1:27 PM
will read later thanks!
t

todd.ginsberg

05/28/2020, 1:50 PM
Very exciting!
s

sdeleuze

05/28/2020, 1:56 PM
Thanks 🙂
r

Robert Jaros

05/28/2020, 2:34 PM
Does Spring Fu target Spring MVC or Spring WebFlux? Does it support Kotlin coroutines?
n

nfrankel

05/28/2020, 2:47 PM
ok so as far as i understand in order to get the no-annotation experience you still need to go reactive? and it’s not going to change anytime soon did i get it right?
s

sdeleuze

05/28/2020, 2:51 PM
Did you read the blog post @nfrankel ?
Yes it supports both Spring MVC and WebFlux
I show an exemple in the blog post
And wrote « Since Spring MVC is now usable in a functional way »
n

nfrankel

05/28/2020, 2:53 PM
it’s been the case for ages 😉 since 0.2 sorry i was not specific enough my point was about db access does it handle spring data jpa repository
?
s

sdeleuze

05/28/2020, 2:54 PM
Ah ok
Not yet but with the work we do currently it could be added in 0.4 Probably
Via Spring Data JDBC/JPA support
I would accept such contribution 😉
👍 1
n

nfrankel

05/28/2020, 2:58 PM
i know you would 🙂 i’d love to contribute - really but i’ve come to realize i work even more now that i’m at home so i try to make long breaks away from computers and run in the countryside close to home
r

Robert Jaros

05/28/2020, 2:58 PM
If
webMvc
and
webFlux
function were having the same name, the functional configuration would be exactly the same for both mvc and webflux? You only need to change the starter to migrate the project ;-)
Would it be possible to introduce local / child application contexts to Spring with this functional approach? Or is this out of the question because of Spring architecture?
t

Tristan

05/28/2020, 3:34 PM
Also, I read a tweet where you talked about some FE stuff, is that related? 🤤
s

sdeleuze

05/28/2020, 4:38 PM
If 
webMvc
 and 
webFlux
 function were having the same name, the functional configuration would be exactly the same for both mvc and webflux? You only need to change the starter to migrate the project 😉
Yeah but require much more other changes so not sure this is a goal 😉
Would it be possible to introduce local / child application contexts to Spring with this functional approach? Or is this out of the question because of Spring architecture?
It is technically possible but I am not sure to want to add this level of complexity. Most modern Spring apps don't really take advantage of app context hierarchy.
Also, I read a tweet where you talked about some FE stuff, is that related? 🤤
@Tristan FE = Front End?
r

Robert Jaros

05/28/2020, 4:50 PM
Currently when using webflux and coroutines only the prototype and singleton scopes seems to be useful. Other scopes are based on ThreadLocal and are useless. But with the ability to create child contexts, we could autowire current
ServerRequest
. We would have request scope working again. Ktor with Guice (which supports child contexts) works in a similar way. With my KVision interfaces to Spring Webflux I'm using horrible hacks to make such simple thing working.
s

sdeleuze

05/28/2020, 5:09 PM
I am not sure to understand, could you share a code example ?
Or a repro project ?
t

Tristan

05/28/2020, 5:17 PM
Yes @sdeleuze
r

Robert Jaros

05/28/2020, 5:18 PM
When Ktor is integrated with Guice, it basically creates a child guice context for every request, and binds the request (a call instance) to this context. It allows to inject current request inside other components. Here is Ktor code sample https://ktor.io/samples/feature/guice.html. But I can't do the same with Spring Webflux, because there is only one, global context. So to be able to inject ServerRequest, I'm using such workaround hack:
Copy code
@Bean
    @Scope(BeanDefinition.SCOPE_PROTOTYPE)
    open fun serverRequest(): ServerRequest {
        return threadLocalRequest.get() ?: KVServerRequest()
    }
and then I'm using it this way when getting bean from context:
Copy code
tlReq.set(req)
val service = ctx.getBean(serviceClass.java)
tlReq.remove()
You can find the whole code in KVision spring-boot module: https://github.com/rjaros/kvision/tree/master/kvision-modules/kvision-server-spring-boot/src/jvmMain/kotlin/pl/treksoft/kvision/remote
s

sdeleuze

05/28/2020, 5:19 PM
@Tristan Yeah I am working on that, more news in the coming weeks
👍 1
@Robert Jaros Thanks I will have a look
2 Views