From b995f4b927c230e0ae15d51920390dc6afff6caa Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Thu, 20 Dec 2018 10:19:55 +0100 Subject: Refactor server side modules. --- .../treksoft/kvision/remote/JoobyServiceManager.kt | 107 ------------------- .../pl/treksoft/kvision/remote/KVServiceManager.kt | 115 +++++++++++++++++++++ .../kvision/remote/SpringServiceManager.kt | 110 -------------------- 3 files changed, 115 insertions(+), 217 deletions(-) delete mode 100644 kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/JoobyServiceManager.kt create mode 100644 kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt delete mode 100644 kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/SpringServiceManager.kt (limited to 'kvision-modules/kvision-common-remote/src/main/kotlin/pl') diff --git a/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/JoobyServiceManager.kt b/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/JoobyServiceManager.kt deleted file mode 100644 index cb1b44d0..00000000 --- a/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/JoobyServiceManager.kt +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2017-present Robert Jaros - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package pl.treksoft.kvision.remote - -/** - * Multiplatform service manager for Jooby. - */ -expect open class JoobyServiceManager(service: T) : ServiceManager { - - /** - * Binds a given route with a function of the receiver. - * @param function a function of the receiver - * @param route a route - * @param method a HTTP method - */ - protected inline fun bind( - noinline function: suspend T.(Request?) -> RET, - route: String? = null, - method: RpcHttpMethod = RpcHttpMethod.POST - ) - - /** - * Binds a given route with a function of the receiver. - * @param function a function of the receiver - * @param route a route - * @param method a HTTP method - */ - protected inline fun bind( - noinline function: suspend T.(PAR, Request?) -> RET, - route: String? = null, - method: RpcHttpMethod = RpcHttpMethod.POST - ) - - /** - * Binds a given route with a function of the receiver. - * @param function a function of the receiver - * @param route a route - * @param method a HTTP method - */ - protected inline fun bind( - noinline function: suspend T.(PAR1, PAR2, Request?) -> RET, - route: String? = null, - method: RpcHttpMethod = RpcHttpMethod.POST - ) - - /** - * Binds a given route with a function of the receiver. - * @param function a function of the receiver - * @param route a route - * @param method a HTTP method - */ - protected inline fun bind( - noinline function: suspend T.(PAR1, PAR2, PAR3, Request?) -> RET, - route: String? = null, - method: RpcHttpMethod = RpcHttpMethod.POST - ) - - /** - * Binds a given route with a function of the receiver. - * @param function a function of the receiver - * @param route a route - * @param method a HTTP method - */ - protected inline fun bind( - noinline function: suspend T.(PAR1, PAR2, PAR3, PAR4, Request?) -> RET, - route: String? = null, - method: RpcHttpMethod = RpcHttpMethod.POST - ) - - /** - * Binds a given route with a function of the receiver. - * @param function a function of the receiver - * @param route a route - * @param method a HTTP method - */ - protected inline fun bind( - noinline function: suspend T.(PAR1, PAR2, PAR3, PAR4, PAR5, Request?) -> RET, - route: String? = null, - method: RpcHttpMethod = RpcHttpMethod.POST - ) - - /** - * Applies all defined routes to the given server. - * @param k a server - */ - fun applyRoutes(k: KVServer) - -} diff --git a/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt b/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt new file mode 100644 index 00000000..4b4fcfd2 --- /dev/null +++ b/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVServiceManager.kt @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2017-present Robert Jaros + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pl.treksoft.kvision.remote + +import kotlin.reflect.KClass + +/** + * Multiplatform service manager. + */ +expect open class KVServiceManager(serviceClass: KClass) : ServiceManager { + + /** + * Binds a given route with a function of the receiver. + * @param function a function of the receiver + * @param route a route + * @param method a HTTP method + */ + protected inline fun bind( + noinline function: suspend T.() -> RET, + route: String? = null, + method: RpcHttpMethod = RpcHttpMethod.POST + ) + + /** + * Binds a given route with a function of the receiver. + * @param function a function of the receiver + * @param route a route + * @param method a HTTP method + */ + protected inline fun bind( + noinline function: suspend T.(PAR) -> RET, + route: String? = null, + method: RpcHttpMethod = RpcHttpMethod.POST + ) + + /** + * Binds a given route with a function of the receiver. + * @param function a function of the receiver + * @param route a route + * @param method a HTTP method + */ + protected inline fun bind( + noinline function: suspend T.(PAR1, PAR2) -> RET, + route: String? = null, + method: RpcHttpMethod = RpcHttpMethod.POST + ) + + /** + * Binds a given route with a function of the receiver. + * @param function a function of the receiver + * @param route a route + * @param method a HTTP method + */ + protected inline fun bind( + noinline function: suspend T.(PAR1, PAR2, PAR3) -> RET, + route: String? = null, + method: RpcHttpMethod = RpcHttpMethod.POST + ) + + /** + * Binds a given route with a function of the receiver. + * @param function a function of the receiver + * @param route a route + * @param method a HTTP method + */ + protected inline fun bind( + noinline function: suspend T.(PAR1, PAR2, PAR3, PAR4) -> RET, + route: String? = null, + method: RpcHttpMethod = RpcHttpMethod.POST + ) + + /** + * Binds a given route with a function of the receiver. + * @param function a function of the receiver + * @param route a route + * @param method a HTTP method + */ + protected inline fun bind( + noinline function: suspend T.(PAR1, PAR2, PAR3, PAR4, PAR5) -> RET, + route: String? = null, + method: RpcHttpMethod = RpcHttpMethod.POST + ) + + /** + * Binds a given function of the receiver as a select options source + * @param function a function of the receiver + */ + protected fun bind( + function: T.(String?, String?) -> List + ) + + /** + * Applies all defined routes to the given server. + */ + fun applyRoutes(k: KVServer) +} diff --git a/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/SpringServiceManager.kt b/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/SpringServiceManager.kt deleted file mode 100644 index bc45d72b..00000000 --- a/kvision-modules/kvision-common-remote/src/main/kotlin/pl/treksoft/kvision/remote/SpringServiceManager.kt +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2017-present Robert Jaros - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package pl.treksoft.kvision.remote - -import kotlin.reflect.KClass - -/** - * Multiplatform service manager for Spring Boot. - */ -expect open class SpringServiceManager(serviceClass: KClass) : ServiceManager { - - /** - * Binds a given route with a function of the receiver. - * @param function a function of the receiver - * @param route a route - * @param method a HTTP method - */ - protected inline fun bind( - noinline function: suspend T.() -> RET, - route: String? = null, - method: RpcHttpMethod = RpcHttpMethod.POST - ) - - /** - * Binds a given route with a function of the receiver. - * @param function a function of the receiver - * @param route a route - * @param method a HTTP method - */ - protected inline fun bind( - noinline function: suspend T.(PAR) -> RET, - route: String? = null, - method: RpcHttpMethod = RpcHttpMethod.POST - ) - - /** - * Binds a given route with a function of the receiver. - * @param function a function of the receiver - * @param route a route - * @param method a HTTP method - */ - protected inline fun bind( - noinline function: suspend T.(PAR1, PAR2) -> RET, - route: String? = null, - method: RpcHttpMethod = RpcHttpMethod.POST - ) - - /** - * Binds a given route with a function of the receiver. - * @param function a function of the receiver - * @param route a route - * @param method a HTTP method - */ - protected inline fun bind( - noinline function: suspend T.(PAR1, PAR2, PAR3) -> RET, - route: String? = null, - method: RpcHttpMethod = RpcHttpMethod.POST - ) - - /** - * Binds a given route with a function of the receiver. - * @param function a function of the receiver - * @param route a route - * @param method a HTTP method - */ - protected inline fun bind( - noinline function: suspend T.(PAR1, PAR2, PAR3, PAR4) -> RET, - route: String? = null, - method: RpcHttpMethod = RpcHttpMethod.POST - ) - - /** - * Binds a given route with a function of the receiver. - * @param function a function of the receiver - * @param route a route - * @param method a HTTP method - */ - protected inline fun bind( - noinline function: suspend T.(PAR1, PAR2, PAR3, PAR4, PAR5) -> RET, - route: String? = null, - method: RpcHttpMethod = RpcHttpMethod.POST - ) - - /** - * Binds a given function of the receiver as a select options source - * @param function a function of the receiver - */ - protected fun bind( - function: T.(String) -> List - ) -} -- cgit