在Felix中,提供了Metatype Service,可以为每个Component提供图形化的属性配置界面,步骤如下
设置@Component中的
metatype
=true将类中某一个静态常量用@Property标注,并给出默认值value,还要通过属性
longValue
,doubleValue
,floatValue
,intValue
,byteValue
,charValue
,boolValue
,shortValue指定类型
定义一个类变量,用以保存Component属性的值
通过@Activate, @Modified定义对应的生命周期方法,在方法中获得该Component属性的指并设置到对应的类变量中