-
Notifications
You must be signed in to change notification settings - Fork 3
AutoWiring
kordx-commands
comes with a annotation processor, kordx-commands-processor
, which will find autowired elements and group them in a single configure
function during compilation.
The following types can be autowired, provided they're annotated with @Autowired
:
- org.koin.core.module.Module
- com.gitlab.kordlib.kordx.commands.model.module.ModuleModifier
- com.gitlab.kordlib.kordx.commands.model.processor.EventSource
- com.gitlab.kordlib.kordx.commands.model.processor.EventHandler
- com.gitlab.kordlib.kordx.commands.model.eventFilter.EventFilter
- com.gitlab.kordlib.kordx.commands.model.precondition.Precondition
- com.gitlab.kordlib.kordx.commands.model.module.CommandSet
- com.gitlab.kordlib.kordx.commands.model.prefix.PrefixConfiguration
- com.gitlab.kordlib.kordx.commands.model.plug.Plug
CommandSet
s are required to be annotated with@ModuleName
Koin modules will always be configured first, allowing you to set up Dependency Injection for your commands/modules etc.
Files can also be autowired by annotating them with @file:Autowired
, this will automatically autowire all top level functions or properties returning the above listed types.
Having an autowired file with elements annotated with
@Autowired
is undefined behaviour. Ensure you're using either a file annotation or a function/property annotation, not both, in the same file.
The generated configure
function will be present in kapt.kotlin.generated
as an extension function to the ProcessorBuilder
and needs to be manually called for your code to set be up.