我正在使用Equinox与DS,我有一些服务,我想注册自定义属性。我正在使用:
Hashtable<String, Object> properties = new Hashtable<String,Object>();
properties.put("service.market","ch");
context.registerService(Workflow.class.getName(), new WorkflowAlternate(), properties);
这不是诀窍。当我getAllServiceReferences(WorkFlow,null)并询问密钥时,它们都只显示objectclass,service.id,service.bundleid和service.scope。
使用自定义属性注册服务(以编程方式)需要做什么?
根据下面的注释,我正在编辑添加我用来查询密钥的代码。找到正确的捆绑包并正常工作,但当我以这种方式询问密钥时,我只得到上面的四个密钥。
public void dumpReferences() throws Exception
{
ServiceReference<?>[] references = context.getAllServiceReferences(Workflow.class.getName(), null);
for(ServiceReference<?> reference : references)
{
String[] keys = reference.getPropertyKeys();
System.out.println("Bundle: "+reference.getBundle().getSymbolicName());
for(String key:keys)
{
System.out.println("\tKey: "+key+ " ["+reference.getProperty(key)+"]");
}
}
}