mardi 15 juin 2021

Spring kotlin - How to inject internal class to public class

I have some problem but also I don't know if my approach is right so I decided to ask you about it. I try to create public facade (for REST controllers or another modules) in application layer which should communicate with domain layer. The problem is that it seems to me that everything in domain should be internal and when I want to inject some service from domain to facade then intellij returns me error: 'public' function exposes its 'internal' parameter type SomeService. What is the best approach for this case? Should I make interface SomeService as public? But then any other modules also could inject it what is probably wrong :/

example code:

applicaion layer: 

class MyFacade(
    private val myInternalService: InternalService
){
   fun save(...){
       return myInternalService.save(...)
   }
}

domain layer:

internal interface InternalService {
    fun save(...)
}

and rest implementation of domain...

Aucun commentaire:

Enregistrer un commentaire