-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scaffold kotlin code Add EntryPoints Missing (#190)
* Add kotlin files driver-adapters * Update License MIT To Apache 2.0 * Add entryPoints Kotlin Co-authored-by: ElvertMora
- Loading branch information
Showing
17 changed files
with
132 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 12 additions & 23 deletions
35
src/main/resources/entry-point/async-event-handler/commands-handler.kt.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
package {{package}}.events.handlers; | ||
|
||
{{#lombok}} | ||
import lombok.AllArgsConstructor; | ||
{{/lombok}} | ||
import org.reactivecommons.api.domain.Command; | ||
import org.reactivecommons.async.impl.config.annotations.EnableCommandListeners; | ||
import reactor.core.publisher.Mono; | ||
package {{package}}.events.handlers | ||
|
||
{{#lombok}} | ||
@AllArgsConstructor | ||
{{/lombok}} | ||
@EnableCommandListeners | ||
class CommandsHandler constructor(sampleUseCase: SampleUseCase) { | ||
// val sampleUseCase: SampleUseCase; | ||
import org.reactivecommons.api.domain.Command | ||
import org.reactivecommons.async.impl.config.annotations.EnableCommandListeners | ||
import reactor.core.publisher.Mono | ||
|
||
{{^lombok}} | ||
fun CommandsHandler(/*SampleUseCase sampleUseCase*/) { | ||
//this.sampleUseCase = sampleUseCase; | ||
@EnableCommandListeners | ||
open class CommandsHandler //(private val sampleUseCase: SampleUseCase) | ||
{ | ||
open fun handleCommandA(command: Command<Any>): Mono<Void> { | ||
println("command received: " + command.name + " ->" + command.data) // TODO: Remove this line | ||
//return sampleUseCase.doSomething(command.getData()) | ||
return Mono.empty() | ||
} | ||
{{/lombok}} | ||
} | ||
|
||
fun handleCommandA(command :Command<Any/*change for proper model*/>) : Mono<Unit> { | ||
System.out.println("command received: " + command.getName() + " ->" + command.getData()); // TODO: Remove this line | ||
// return sampleUseCase.doSomething(command.getData()); | ||
return Mono.empty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 10 additions & 23 deletions
33
src/main/resources/entry-point/async-event-handler/events-handler.kt.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,15 @@ | ||
package {{package}}.events.handlers; | ||
package {{package}}.events.handlers | ||
|
||
{{#lombok}} | ||
import lombok.AllArgsConstructor; | ||
{{/lombok}} | ||
import org.reactivecommons.api.domain.DomainEvent; | ||
import org.reactivecommons.async.impl.config.annotations.EnableEventListeners; | ||
import reactor.core.publisher.Mono; | ||
import org.reactivecommons.api.domain.DomainEvent | ||
import org.reactivecommons.async.impl.config.annotations.EnableEventListeners | ||
import reactor.core.publisher.Mono | ||
|
||
{{#lombok}} | ||
@AllArgsConstructor | ||
{{/lombok}} | ||
@EnableEventListeners | ||
class EventsHandler constructor(sampleUseCase: SampleUseCase) { | ||
// final SampleUseCase sampleUseCase; | ||
{{^lombok}} | ||
fun EventsHandler(/*SampleUseCase sampleUseCase*/) { | ||
//this.sampleUseCase = sampleUseCase; | ||
} | ||
{{/lombok}} | ||
|
||
fun handleEventA(event :DomainEvent<Any/*change for proper model*/>):Mono<Unit> { | ||
fun println("event received: " + event.getName() + " ->" + event.getData()); // TODO: Remove this line | ||
// return sampleUseCase.doSomething(event.getData()); | ||
return Mono.empty(); | ||
open class EventsHandler //(private val sampleUseCase: SampleUseCase) | ||
{ | ||
open fun handleEventA(event: DomainEvent<Any>): Mono<Void> { | ||
println("event received: " + event.name + " ->" + event.data) // TODO: Remove this line | ||
// return sampleUseCase.doSomething(event.getData()) | ||
return Mono.empty() | ||
} | ||
} |
59 changes: 45 additions & 14 deletions
59
...main/resources/entry-point/async-event-handler/handler-registry-configuration.kt.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,53 @@ | ||
package {{package}}.events; | ||
|
||
import {{package}}.events.handlers.CommandsHandler; | ||
import {{package}}.events.handlers.EventsHandler; | ||
import {{package}}.events.handlers.QueriesHandler; | ||
import org.reactivecommons.async.api.HandlerRegistry; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
package {{package}}.events | ||
|
||
import {{package}}.events.handlers.CommandsHandler | ||
import {{package}}.events.handlers.EventsHandler | ||
import {{package}}.events.handlers.QueriesHandler | ||
import org.reactivecommons.api.domain.Command | ||
import org.reactivecommons.api.domain.DomainEvent | ||
import org.reactivecommons.async.api.HandlerRegistry | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
class HandlerRegistryConfiguration { | ||
|
||
@Configuration | ||
open class HandlerRegistryConfiguration { | ||
// see more at: https://reactivecommons.org/reactive-commons-java/#_handlerregistry_2 | ||
@Bean | ||
fun handlerRegistry(commands :CommandsHandler, events :EventsHandler, queries QueriesHandler):HandlerRegistry { | ||
open fun handlerRegistry(commands: CommandsHandler, events: EventsHandler, queries: QueriesHandler): HandlerRegistry { | ||
return HandlerRegistry.register() | ||
.listenNotificationEvent("some.broadcast.event.name", events::handleEventA, Object.class/*change for proper model*/) | ||
.listenEvent("some.event.name", events::handleEventA, Object.class/*change for proper model*/) | ||
.handleCommand("some.command.name", commands::handleCommandA, Object.class/*change for proper model*/) | ||
.serveQuery("some.query.name", queries::handleQueryA, Object.class/*change for proper model*/); | ||
.listenNotificationEvent( | ||
"some.broadcast.event.name", | ||
{ event: DomainEvent<Any> -> | ||
events.handleEventA( | ||
event | ||
) | ||
}, | ||
Any::class.java /*change for proper model*/ | ||
) | ||
.listenEvent( | ||
"some.event.name", | ||
{ event: DomainEvent<Any> -> | ||
events.handleEventA( | ||
event | ||
) | ||
}, | ||
Any::class.java /*change for proper model*/ | ||
) | ||
.handleCommand( | ||
"some.command.name", | ||
{ command: Command<Any> -> | ||
commands.handleCommandA( | ||
command | ||
) | ||
}, | ||
Any::class.java /*change for proper model*/ | ||
) | ||
.serveQuery( | ||
"some.query.name", | ||
{ query: Any -> queries.handleQueryA(query) }, | ||
Any::class.java /*change for proper model*/ | ||
) | ||
} | ||
} |
31 changes: 10 additions & 21 deletions
31
src/main/resources/entry-point/async-event-handler/queries-handler.kt.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,16 @@ | ||
package {{package}}.events.handlers; | ||
|
||
{{#lombok}} | ||
import lombok.AllArgsConstructor; | ||
{{/lombok}} | ||
import org.reactivecommons.async.impl.config.annotations.EnableQueryListeners; | ||
import reactor.core.publisher.Mono; | ||
package {{package}}.events.handlers | ||
|
||
{{#lombok}} | ||
@AllArgsConstructor | ||
{{/lombok}} | ||
@EnableQueryListeners | ||
class QueriesHandler constructor (sampleUseCase: SampleUseCase) { | ||
// private final SampleUseCase sampleUseCase; | ||
import org.reactivecommons.async.impl.config.annotations.EnableQueryListeners | ||
import reactor.core.publisher.Mono | ||
|
||
{{^lombok}} | ||
fun QueriesHandler(/*SampleUseCase sampleUseCase*/) { | ||
//this.sampleUseCase = sampleUseCase; | ||
} | ||
{{/lombok}} | ||
@EnableQueryListeners | ||
open class QueriesHandler //(private val sampleUseCase: SampleUseCase) | ||
{ | ||
open fun handleQueryA(query: Any /*change for proper model*/): Mono<Any> { | ||
println("query received->$query") // TODO: Remove this line | ||
// return sampleUseCase.doSomethingReturningNoMonoVoid(query) | ||
return Mono.just("Response Data") | ||
fun handleQueryA(query/*change for proper model*/ :Any) :Mono<Any/*change for proper model*/> { | ||
System.out.println("query received->" + query); // TODO: Remove this line | ||
// return sampleUseCase.doSomethingReturningNoMonoVoid(query); | ||
return Mono.just("Response Data"); | ||
} | ||
} |
29 changes: 8 additions & 21 deletions
29
src/main/resources/entry-point/graphql-api/api-mutations.kt.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,18 @@ | ||
package {{package}}.graphqlapi; | ||
|
||
import graphql.kickstart.tools.GraphQLMutationResolver; | ||
{{#lombok}} | ||
import lombok.RequiredArgsConstructor; | ||
{{/lombok}} | ||
import org.springframework.stereotype.Controller; | ||
package {{package}}.graphqlapi | ||
|
||
import graphql.kickstart.tools.GraphQLMutationResolver | ||
import org.springframework.stereotype.Controller | ||
|
||
{{#lombok}} | ||
@RequiredArgsConstructor | ||
{{/lombok}} | ||
@Controller | ||
/** | ||
* To interact with the API make use of Playground in the "/playground" path, but remember, | ||
* Playground ONLY must be used in dev or qa environments, not in production. | ||
*/ | ||
class ApiMutations : GraphQLMutationResolver { | ||
// private val useCase: MyUseCase; | ||
{{^lombok}} | ||
fun ApiMutations(useCase: MyUseCase ){ | ||
this.useCase = useCase; | ||
} | ||
{{/lombok}} | ||
class ApiMutations(/*private val useCase: MyUseCase*/) : GraphQLMutationResolver { | ||
fun addSomething(String objRequest/* change for object request */) : String { | ||
// return useCase.doAction(objRequest); | ||
return "Hello world from graphql-api mutations " + objRequest; | ||
fun addSomething(objRequest :String/* change for object request */) : String { | ||
// return useCase.doAction(objRequest) | ||
return "Hello world from graphql-api mutations " + objRequest | ||
} | ||
} |
28 changes: 8 additions & 20 deletions
28
src/main/resources/entry-point/graphql-api/api-queries.kt.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,19 @@ | ||
package {{package}}.graphqlapi; | ||
|
||
import graphql.kickstart.tools.GraphQLQueryResolver; | ||
{{#lombok}} | ||
import lombok.RequiredArgsConstructor; | ||
{{/lombok}} | ||
import org.springframework.stereotype.Controller; | ||
package {{package}}.graphqlapi | ||
|
||
import graphql.kickstart.tools.GraphQLQueryResolver | ||
import org.springframework.stereotype.Controller | ||
|
||
{{#lombok}} | ||
@RequiredArgsConstructor | ||
{{/lombok}} | ||
@Controller | ||
/** | ||
* To interact with the API make use of Playground in the "/playground" path, but remember, | ||
* Playground ONLY must be used in dev or qa environments, not in production. | ||
*/ | ||
class ApiQueries : GraphQLQueryResolver { | ||
// private val useCase: MyUseCase ; | ||
class ApiQueries(/*private val useCase :MyUseCase*/) : GraphQLQueryResolver { | ||
{{^lombok}} | ||
fun ApiQueries(useCase: MyUseCase){ | ||
this.useCase = useCase; | ||
} | ||
{{/lombok}} | ||
fun getSomething(objRequest : String/* change for object request */) : String { | ||
// return useCase.doAction(objRequest) | ||
return "Hello world from graphql-api queries " + objRequest | ||
fun getSomething(String objRequest/* change for object request */) : String { | ||
// return useCase.doAction(objRequest); | ||
return "Hello world from graphql-api queries " + objRequest; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/resources/entry-point/graphql-api/build.gradle.kts.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dependencies { | ||
implementation(project(":model")) | ||
implementation(project(":usecase")) | ||
implementation("org.springframework:spring-context") | ||
implementation("com.graphql-java-kickstart:graphql-spring-boot-starter:11.0.0") | ||
implementation("com.graphql-java-kickstart:playground-spring-boot-starter:11.0.0") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.