Quick Start
Bean Interface
interface ActionHandler {
/**
* The action that this handler can handle, add the `@ComponentMapKey` annotation to the getter in order to register it
*/
@get:ComponentMapKey
val type: String
fun handle()
}public interface ActionHandler {
/**
* The action that this handler can handle, add the `@ComponentMapKey` annotation to the getter in order to register it
*/
@ComponentMapKey
String getType();
void handle();
}@Component
class ActionHandler1 : ActionHandler {
override val type = "type1"
override fun handle() {
println("ActionHandler1")
}
}
@Component
class ActionHandler2 : ActionHandler {
override val type = "type2"
override fun handle() {
println("ActionHandler2")
}
}@Component
public class ActionHandler1 implements ActionHandler {
@Override
public String getType() {
return "type1";
}
@Override
public void handle() {
System.out.println("ActionHandler1");
}
}
@Component
public class ActionHandler2 implements ActionHandler {
@Override
public String getType() {
return "type2";
}
@Override
public void handle() {
System.out.println("ActionHandler2");
}
}Injecting The Map
Code Examples
Last updated