I have tried this technique and I get errors stating the "the descriptor is in an unproxiable scope." This technique only works if the "RequestScoped" annotation is itself annotated with the @Proxiable annotation as described on the HK2 website, yes?
https://hk2.java.net/hk2-api/extensibility.html
If so, what RequestScoped annotation are you using that works with Jersey? The org.glassfish.jersey.process.internal.RequestScoped annotation, which is what I'm using, does not have this annotation, and you cannot extend annotations in Java.
It's a complete runnable test that shows that it is doable. If you still have problems, maybe you can provide your own gist that I can check out. Or ask a question on Stack Overflow. I am a lot more active there than I am on this blog.
Thanks for responding. After more experimenting I was making a flawed assumption. If you have a service that depends on a RequestScoped dependency, you do not need to specify that the service is RequestScoped. HK2 just figures it out. However, once you make that service a proxy that inference goes out the window, and you need to explicitly state that the service with a RequestScoped dependency is also RequestScoped.
So what you have in your blog here is correct because you always list the scope explicitly on your dependencies. You do not expect HK2 to infer the scope based upon the scope of the dependencies injected into the proxied service.
I have tried this technique and I get errors stating the "the descriptor is in an unproxiable scope." This technique only works if the "RequestScoped" annotation is itself annotated with the @Proxiable annotation as described on the HK2 website, yes?
ReplyDeletehttps://hk2.java.net/hk2-api/extensibility.html
If so, what RequestScoped annotation are you using that works with Jersey? The org.glassfish.jersey.process.internal.RequestScoped annotation, which is what I'm using, does not have this annotation, and you cannot extend annotations in Java.
Technetium, apologies for the late reply. I haven't been maintaining this blog like I should be.
DeleteAs far as your comment, I have never run into this problem. Please have a look at the following gist
https://gist.github.com/psamsotha/fd77d9bf9f5362453ac0f8bad9fdd751
It's a complete runnable test that shows that it is doable. If you still have problems, maybe you can provide your own gist that I can check out. Or ask a question on Stack Overflow. I am a lot more active there than I am on this blog.
Thanks for responding. After more experimenting I was making a flawed assumption. If you have a service that depends on a RequestScoped dependency, you do not need to specify that the service is RequestScoped. HK2 just figures it out. However, once you make that service a proxy that inference goes out the window, and you need to explicitly state that the service with a RequestScoped dependency is also RequestScoped.
DeleteSo what you have in your blog here is correct because you always list the scope explicitly on your dependencies. You do not expect HK2 to infer the scope based upon the scope of the dependencies injected into the proxied service.
Cheers.
Dịch vụ chuyển phát nhanh ở việt nam đi lào chi phí thấp
ReplyDeleteĐơn vị chuyên ship hàng từ trung quốc về việt nam giá rẻ nhất
Vận chuyển hàng hóa từ trung quốc về việt nam