Creating a Flavor instance:
Code (Text):
val flavor = Flavor.create<FlavorTest>()
Binding a class to an instance:
Code (Text):
flavor.bind<SomeObject>()
.scoped(InjectScope.SINGLETON)
.annotated<Named> {
it.value == "horsie"
}
.to(someObjectInstance)
An example of a Flavor service:
Code (Text):
@Service
// @IgnoreAutoScan - if you do not want Flavor to
// automatically register this service
object SomeService
{
@Inject @Named("SomethingString")
lateinit var something: String
@Configure
fun configure()
{
// this method is invoked once all
// fields have been injected!
}
}
Your Flavor instance can be started using:
Code (Text):
flavor.startup()
and stopped using:
Code (Text):
flavor.close()
- NOTE: Flavor automatically iterates through each class in the base package of the registration class, registers any available service, and injects all fields which need injection.
Code (Text):
gg.scala.flavor.FlavorTest - registration class
gg.scala.flavor - package which flavor will scan
⚠️
There is currently no way to disable automatic scanning.