替换 Jersey 2.26 中的 AbstractContainerRequestValueFactory

Replace AbstractContainerRequestValueFactory in Jersey 2.26

大家好,我一直在努力从 Jersey 2.25 迁移到 2.26,因为它在库 class 的内部 class 中有一个中断更改 AbstractContainerRequestValueFactory

他们在问题部分声称,由于该包是内部包,因此不应使用。但他们不提供解决方案或解决方法。

知道如何将 class 的使用替换为其他东西以继续使用 provide 实现吗?

class MyOwnFactory extends AbstractContainerRequestValueFactory[Future[Object]] {
  override def provide: Future[Object] = getContainerRequest.getProperty(Constants.individual).asInstanceOf[Future[Object]]
}

等同于使用 Supplier and inject the ContainerRequest, as the Supplier replaces the HK2 Factory and all AbstractContainerRequestValueFactory is is an HK2 Factory that injects the Provider<ContainerRequest>. Just look at the source

另请参阅:

  • Registering a custom ValueParamProvider in Jersey 2.27