简体   繁体   English

OSGI服务版本控制实践?

[英]OSGI service versioning practices?

I'm familiar with OSGI Semantic Versioning - technical whitepaper. 我熟悉OSGI语义版本 - 技术白皮书。 However, I don't see any versioning concept proposed for OSGI services. 但是,我没有看到为OSGI服务提出的任何版本控制概念。

Simple situation: I'm providing service registerd as com.services.payments.PaymentService, which impelemnts method void makePayment(Integer amount, String accountNo), I'm packing as a bundle version 1.0. 简单的情况:我提供的服务注册为com.services.payments.PaymentService,其中inslemnts方法void makePayment(Integer amount,String accountNo),我打包为1.0版本。 Then, I update service with modified interface. 然后,我用修改后的界面更新服务。 I remove this method and add new method: makePaymentInDifferentWay (Integer amount, String accountNo) and package new service as a bundle version 2.0. 我删除此方法并添加新方法:makePaymentInDifferentWay(整数金额,字符串accountNo)并将新服务打包为捆绑版本2.0。 after first bundle is stopped, client will have second service wired, and CRASH on service invocation, because method signature is not binary compatible. 在第一个bundle停止后,客户端将连接第二个服务,并在服务调用时使用CRASH ,因为方法签名不是二进制兼容的。 Such situations are perfectly solved while you deal with java packages, however I do not see any versioning capabilities out of the box with OSGI services. 在处理java包时,这种情况是完全解决的,但我没有看到OSGI服务开箱即用的任何版本控制功能。 Am I missing something? 我错过了什么吗? (I know I could design versioning scheme upfront by setting service property like 'service.version' and filter provided services by this property on client side, or simply rename a API package or class name, but why no versioning is provided of the box? Maybe there is some other more stadard way solution? Maybe there is some concept related to services that I simply didn't grasp?) (我知道我可以通过设置像'service.version'这样的服务属性来预先设计版本控制方案,并在客户端通过此属性过滤提供的服务,或者只是重命名API包或类名,但为什么没有为该框提供版本控制?也许还有其他一些更为标准的解决方案?也许有一些与服务相关的概念我根本没有掌握?)

The client should have versions on its Import-Package statements (or Require-Bundle) statements, like: 客户端应该在其Import-Package语句(或Require-Bundle)语句中具有版本,例如:

Import-Package: com.services.payments;version="[1.0,2.0)"

And the service will export package as: 该服务将导出包:

Export-Package:  com.services.payments;version="1.0.0"

After you stop the first bundle and install second one, the client will not be resolved resolve (since the required constraint, com.services.payments;version="[1.0,2.0)" will not be satisfied. 停止第一个捆绑并安装第二个捆绑后,客户端将无法解析(因为所需的约束, com.services.payments;version="[1.0,2.0)"将不会得到满足。

Furthermore, if you have two API packages, one with package versioned as "1.0.0" and second one with version "2.0.0", and client importing "1.0.0" API, the client will not "see" service implementing API version "2.0.0" at all. 此外,如果您有两个API包,一个包版本为“1.0.0”,第二个版本为“2.0.0”,客户端导入“1.0.0”API,客户端将不会“看到”服务实现API版本“2.0.0”。

Services are types and types are in packages. 服务的类型和类型都在包中。 So the version of a service is the version of the package containing the service type. 因此,服务的版本是包含服务类型的包的版本。 The OSGi framework makes sure only to expose services to clients when the client is using the same package for the service type as the provider of the service. 当客户端使用与服务提供者相同的服务类型包时,OSGi框架确保仅向客户端公开服务。

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

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