如何将 Hessian 与 Guice 集成?
我们正在为一个即将到来的项目寻找技术,我真的想使用 Guice 作为我们的依赖注入框架,我也想使用 Hessian 进行客户端/服务器通信,但它似乎与 Guice 不兼容。
public class WebMobule extends ServletModule {
@Override
protected void configureServlets() {
serve("/fileupload").with(FileUploadServlet.class);
// this doesn't work! AuthenticationServlet extends HessianServlet
// HessianServlet extends GenericServlet - Guice wants something that extends
// HttpServlet
serve("/authentication").with(AuthenticationServlet.class);
}
有没有人设法解决这个问题 - 如果是的话你是怎么做到的?
欢呼
菲尔
We're looking at technologies for an up and coming project here and I really want to use Guice as our dependency injection framework, I also want to use Hessian for client/server comms, but it doesn't seem to be compatible with Guice.
public class WebMobule extends ServletModule {
@Override
protected void configureServlets() {
serve("/fileupload").with(FileUploadServlet.class);
// this doesn't work! AuthenticationServlet extends HessianServlet
// HessianServlet extends GenericServlet - Guice wants something that extends
// HttpServlet
serve("/authentication").with(AuthenticationServlet.class);
}
Has anyone managed to solve this problem - if so how did you do it?
cheers
Phil
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我将编写一个自定义 HessianHttpServlet,它扩展 HttpServlet 并将方法调用委托给封装的 HessianServlet。通过这种方式,Guice 服务调用将得到满足,并且您将使用 HessianServlet 行为。
I would write a custom HessianHttpServlet which extends HttpServlet and delegates method calls to a encapsulated HessianServlet. In this way the Guice serve call will be satiated and you will be using HessianServlet behavior.
它需要一些工作,但从根本上我解决了这个问题(感谢语法!):
It needs some work, but fundamentally I solved the problem with this (thanks Syntax!):
我创建了一个小型开源项目,可以轻松集成 hessian 和 guice。您可以使用基于注释的配置,如下所示:
WebService:
Guice 配置:
或使用 EDSL 的手动方式:
此处提供更多信息、配置选项和完整示例:https://bitbucket.org/richard_hauswald/hessian-guice/
I created a little open source project which enables easy integration of hessian and guice. You can use annotation based configuration like this:
WebService:
Guice configuration:
or the manual way using the EDSL:
More information, configuration options and complete examples are available here: https://bitbucket.org/richard_hauswald/hessian-guice/