2016-02-09 16 views
5

私は次のサービスがあります。OSGiで複数値(配列)プロパティを使用するには?

@Component(
     immediate = true, 
     metatype = true) 
@Service 
@Property(name = EventConstants.EVENT_TOPIC, value = {ReplicationAction.EVENT_TOPIC}) 
public class MyService implements EventHandler { 

    @Property 
    private static final String MULTI_PROPERTY = "config.multiproperty"; 

    ........ 
    //another implementation 
    ........ 
} 

は、私が画像上のような値のセットを使用する可能性を持っているために、配列の値のようにMULTI_PROPERTYをしたいの:

enter image description here

それを実装する方法?

答えて

5

unbounded属性を使用して多値プロパティを指定し、cardinality属性を使用してエントリ数を制限します。あなたはPropertiesUtil

PropertiesUtil.toStringArray(properties.get(MULTI_PROPERTY)); 
#toStringArray()方法を使用することができますプロパティの配列を読み取るために

@Property(unbounded = PropertyUnbounded.ARRAY, cardinality=10, label = "Some Label") 
private static final String MULTI_PROPERTY = "config.multiproperty"; 

関連する問題