OSGi控制台“;ls-c";:虽然没有提供程序,但引用是绑定的
调试服务绑定问题时,我调用了命令OSGi控制台“;ls-c";:虽然没有提供程序,但引用是绑定的,osgi,declarative-services,Osgi,Declarative Services,调试服务绑定问题时,我调用了命令ls-c(或等效的list-c),并为我的组件获得了以下输出: 21 Component[ name = org.example.myproject.repo activate = activate deactivate = deactivate modified = configuration-policy = optional factory = null
ls-c
(或等效的list-c
),并为我的组件获得了以下输出:
21 Component[
name = org.example.myproject.repo
activate = activate
deactivate = deactivate
modified =
configuration-policy = optional
factory = null
autoenable = true
immediate = true
implementation = org.example.myproject.RepositoryServiceHandler
state = Unsatisfied
properties =
serviceFactory = false
serviceInterface = null
references = {
Reference[name = Repository, interface = org.example.core.repository.api.Repository, policy = static, cardinality = 1..1, target = null, bind = bindRepository, unbind = unbindRepository]
Reference[name = IRepositoryClient, interface = org.example.core.repository.client.RepositoryClient, policy = static, cardinality = 1..1, target = null, bind = bindRepositoryClient, unbind = unbindRepositoryClient]
}
located in bundle = org.example.myproject_0.20.1348.3 [30]
]
Dynamic information :
The component is satisfied
All component references are satisfied
Component configurations :
Configuration properties:
component.name = org.example.myproject.repo
component.id = 34
Instances:
org.eclipse.equinox.internal.ds.impl.ComponentInstanceImpl@75b98b5a
Bound References:
String[org.example.core.repository.client.RepositoryClient]
-> org.example.core.repository.client.impl.RepositoryClientImpl@67680c91
String[org.example.core.repository.api.Repository]
-> org.example.core.repository.api.impl.RepositoryImpl@1c27ecd6
我想找到提供接口org.example.core.repository.client.RepositoryClient
的包,因此搜索了ls-c
的完整输出。令我惊讶的是,没有其他事件(即,只有我的组件中的两个引用)
怎么可能没有提供者,但服务仍然是绑定的?难道不应该有一个具有
serviceInterface=org.example.core.repository.client.RepositoryClient
的提供者组件吗?过了一段时间,我自己想出了解决方案,但我想我还是可以在这里分享它,以防其他人有同样的问题
我没有找到服务提供者的原因是ls-c
只列出通过声明性服务注册的服务。相反,该服务是以编程方式注册的,因此没有被ls-c
列出
要搜索所有服务提供商,需要使用service
命令:
osgi> services (objectClass=org.example.core.repository.client.RepositoryClient)
{org.example.core.repository.client.RepositoryClient}={service.id=83}
Registered by bundle: org.example.core.repository.client_1.2.102 [45]
Bundles using service:
org.example.myproject_0.20.1348.3 [30]