Specifying the componentid
Typically the component ID that a builder maps to is declared using the @ComponentBuilder annotation in your builder class declaration.
@ComponentBuilder(value = "{<componetId1>, <componetId2>}")
public class MyBuilder extends … {}
If you wish to implement your config and data builders in separate classes, then you must supply an additional ComponentBuilderType parameter to the @ComponentBuilder annotation.
For config builders, this looks like:
@ComponentBuilder(value="<componetId>", type=ComponentBuilderType.CONFIG_ONLY)
public class MyConfigBuilder implements ComponentConfigBuilder …. {}
For data builders, this looks like:
@ComponentBuilder(value="<componetId>", type=ComponentBuilderType.DATA_ONLY)
public class MyDataBuilder implements ComponentDataBuilder… {}
Note that framework will throw an error if two builders will have the same component id. Spring initialization will fail in the MethodServer start up phase. If you need to override an OOTB builder, please use OverrideComponentBuilder annotation.
@ComponentBuilder(value="{compId1, compId2, compId3}")
public class OOTBBuilder1 extends …… {
}
@OverrideComponentBuilder
public class MyCustomBuilder1 extends …… {
}
MyCustomBuilder1 will be mapped to compId1, compId2, compId3
@ComponentBuilder(value="{compIdA, compIdB, compIdC}")
public class OOTBBuilder2 extends ……{
}
@ComponentBuilder(value="{compIdA, compIdC}")
@OverrideComponentBuilder
public class MyCustomBuilder2 extends ……{
}
@ComponentBuilder(value="{compIdB}")
@OverrideComponentBuilder
public class MyCustomBuilder3 extends ……{
}
MyCustomBuilder2 will be mapped to compIdA, compIdC
MyCustomBuilder3 will be mapped to compIdB
這是否有幫助?