简体   繁体   English

如何限制捆绑包在OSGi中使用服务?

[英]How to limit a bundle's use of services in OSGi?

I'm developing an OSGi platform, following the ideology of Pattern Extender. 我正在开发一个OSGi平台,遵循Pattern Extender的意识形态。 There is a module called Kernel, which verifies the installation of the other modules, verifying the metadata in the Manifest. 有一个名为Kernel的模块,用于验证其他模块的安装,验证Manifest中的元数据。 This module presents a series of interfaces to other modules and also registered web services and other things for each of the modules. 该模块为其他模块提供了一系列接口,并为每个模块提供了已注册的Web服务和其他内容。 What I want to know is whether it is possible to control the use of services such as HttpServices in dependent modules. 我想知道的是,是否可以在依赖模块中控制HttpServices等服务的使用。 The Kernel, records Servlets and services in a particular url. 内核,在特定网址中记录Servlet和服务。 I like, that none of the modules that are part of the platform to use for example, the HttpService . 我喜欢,没有一个模块是平台的一部分,例如HttpService Is this possible? 这可能吗?

Thanks 谢谢

If you want to restrict the ability of a bundle to find a particular service, you can implement some service hooks. 如果要限制捆绑包查找特定服务的能力,可以实现一些服务挂钩。 See http://www.osgi.org/javadoc/r5/core/index.html?org/osgi/framework/hooks/service/package-summary.html 请参阅http://www.osgi.org/javadoc/r5/core/index.html?org/osgi/framework/hooks/service/package-summary.html

You will probably want to implement a FindHook to prevent the bundle from being able to locate the service in the service registry and also an EventListenerHook to prevent the bundle from receiving service events about the service. 您可能希望实现FindHook以防止bundle在服务注册表中找到该服务,并且还希望实现EventListenerHook以防止bundle接收有关该服务的服务事件。 These two will prevent the bundle from normally obtaining the ServiceReference to the service which is necessary to bind to the service. 这两个将阻止bundle正常获取绑定到服务所必需的服务的ServiceReference。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM