假设我有这样的课程:
@References(
value={
@Reference(name="dataSources",cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE,policy=ReferencePolicy.DYNAMIC,strategy=ReferenceStrategy.EVENT,bind="bind",unbind="unbind",referenceInterface=DataSourceProvider.class)
})
public class DataSourceStoreServiceImpl implements DataSourceStoreService {
List<DataSourceProvider> dataSourceProviders = new CopyOnWriteArrayList<DataSourceProvider>();
public void bind(DataSourceProvider dataSourceProvider) {
dataSourceProviders.add(dataSourceProvider);
}
public void unbind(DataSourceProvider dataSourceProvider) {
dataSourceProviders.remove(dataSourceProvider);
}
}
这就是我处理具有MULTIPLE
基数的裁判的方式。
我的问题是是否可以在没有样板的情况下做到这一点?我的想法是这样的:
public class DataSourceStoreServiceImpl implements DataSourceStoreService {
@CollectionType(CopyOnWriteArrayList.class)
@Reference(name="dataSources",cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE,policy=ReferencePolicy.DYNAMIC,strategy=ReferenceStrategy.EVENT,bind="bind",unbind="unbind",referenceInterface=DataSourceProvider.class)
List<DataSourceProvider> dataSourceProviders
}