JAX-WS 和 Guice 3
是否有某种方法可以获取使用 JAX-WS 创建的 SOAP Web 服务类,并使用 Guice 3.0(guice-persist)事务或什至只是简单的依赖注入来注入它们? guiceyfruit 包提供了一个 @GuiceManaged 注释,使 Guice 2.0 成为可能,但 guiceyfruit(根据我的测试)似乎与 Guice 3 不兼容,我认为该项目不再活跃。
也许是因为还有另一种方法可以做到这一点?也许是 JSR 标准方式?
Is there some way to take SOAP web service classes creates with JAX-WS and inject them with, say, Guice 3.0 (guice-persist) transactions or even just plain ol' dependency injection? The guiceyfruit package provided a @GuiceManaged annotation that made this possible with Guice 2.0, but guiceyfruit (from my testing) appears to be incompatible with Guice 3, and I don't think the project is active any longer.
Perhaps because there is another way of doing this? Maybe a JSR standard way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不久前我遇到了同样的问题,我查看了 Guicyfruit 代码并决定提取我需要的内容。这导致了三个班级。
首先,我们需要一个注释,可以用来注释我们的 Web 服务端点。
GuiceManaged.java
其次,我们需要上面注释中提到的 GuiceManagedFeature。
GuiceManagedFeature.java
第三,我们创建实际的解析器。
GuiceManagedInstanceResolver.java
上面的示例使用 SLF4J 进行日志记录,但当然您可以随意使用。
I came across this same issue a while back and I had a look at the Guicyfruit code and decided to extract what I needed. This resulted in three classes.
First we need an annotation that we can use to annotate our web service endpoint with.
GuiceManaged.java
Second we need the GuiceManagedFeature mentioned in the annotation above.
GuiceManagedFeature.java
And third we create the actual resolver.
GuiceManagedInstanceResolver.java
The above example uses SLF4J for logging but it's of course up to you to use whatever you wish.
我的日志中出现一些与 guicyfruit 调用 2.0 内部结构相关的错误,这些错误在 3.0 中不再存在。从 GuiceManaged 代码来看,它实际上只是进行了一次 guicyfruit 调用,因此我决定放弃依赖项并寻找替代方案。
http://code.google.com/p/guice-recipes/< 有一个分叉/a> 如果使用它代替 guicyfruit,可能会也可能不会解决问题。
我选择了 http://code.google.com /p/google-guice/issues/detail?id=288#c69 代码并将其用作 GuiceManagedInstanceResolver 中的新 dispose() 方法。
我现在在代码中进行了 Guice 注入和方面,并且没有与缺失方法和/或内存泄漏相关的日志输出。
Got some errors in my logs related to guicyfruit calling 2.0 internals that no longer exist in 3.0. From the GuiceManaged code, it is actually just one guicyfruit call that is made so I decided to rip out the dependency and look around for alternatives.
There is a fork at http://code.google.com/p/guice-recipes/ which may or may not solve the issue if used instead of guicyfruit.
I went with the http://code.google.com/p/google-guice/issues/detail?id=288#c69 code and used it as my new dispose() method in GuiceManagedInstanceResolver.
I have working Guice injections and aspects within my code now, and no log output related to missing methods and/or memory leaks.