From bb1fdac9cb09fb30649e76d5d5fbade9462244e0 Mon Sep 17 00:00:00 2001 From: Oleg Yukhnevich Date: Wed, 14 Aug 2024 22:10:51 +0300 Subject: [PATCH] WIP --- .../src/commonMain/kotlin/ServiceLoader.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sweetspi-runtime/src/commonMain/kotlin/ServiceLoader.kt b/sweetspi-runtime/src/commonMain/kotlin/ServiceLoader.kt index 78a3eb5..2f0130c 100644 --- a/sweetspi-runtime/src/commonMain/kotlin/ServiceLoader.kt +++ b/sweetspi-runtime/src/commonMain/kotlin/ServiceLoader.kt @@ -54,6 +54,25 @@ public annotation class ServiceProvider( public vararg val services: KClass<*>, ) +// to be interoperable with the jvm service loader +// doesn't require to have `Service` annotation +@Repeatable +@MustBeDocumented +@Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION) +@Retention(AnnotationRetention.BINARY) +public annotation class JvmServiceProvider( + public val service: KClass<*>, +) + +public interface S {} + +public class SImpl : S by SImpl() + +public sealed class ServiceList : List { + public abstract fun asSequence(): Sequence + public abstract fun reloadServices() +} + /** * Provides functionality for dynamically loading service implementations using the Service Provider Interface (SPI) mechanism. *