Java中的hessian,如何控制实例化?
我有一个对象缓存(不是 HTTP 会话属性),并且希望当 Hessian 请求传入时能够从该缓存中获取一个对象,并让 Hessian 对该对象而不是 servlet 执行调用。
我可以通过在 HessianServlet 上设置 service-class 和 api-class init 参数来控制执行请求的类。 然而,它正在执行对象本身的实例化,看起来我无法控制它。
我尝试重写HessianServlet的execute()方法并调用setService()或setObject(),但它不使用我传入的对象。相反,它似乎实例化了自己的对象。
I have a cache of objects (not the HTTP session attributes) and I want to be able to get an object from this cache when a Hessian request comes in and have Hessian execute the call on this object instead of the servlet.
I can control the class that the request is executed on by setting the service-class and api-class init parameters on the HessianServlet. However, it is performing the instantiation of objects itself and it does not look like I can control this.
I've tried to override the execute() method of HessianServlet and calling setService() or setObject() but it does not use the object I've passed in. Instead it seems to instantiate its own.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个简单的技巧是创建一个在您的对象上具有相同接口的服务类,该服务类委托给它提取到池中的对象实例,通过 Hessian 公开此服务。
A simple hack is create a service class that has the same interface on your object, which delegates to an instance of your object it fetches to the pool, expose this service through Hessian.