简体   繁体   English

如何使用wicket的休息服务

[英]how to use rest service from wicket

I am making restful services for a Java *client* and I would like to use the same services making web page using Wicket *Framework*. 我正在为Java *客户端*提供宁静的服务,我想使用相同的服务使用Wicket * Framework *制作网页。 I know restful services are stateless and wicket is stateful framework. 我知道宁静的服务是无国籍的,而wicket是有状态的框架。

Does somebody have a simple example what would be a good way to call rest service from wicket page. 有人有一个简单的例子,从wicket页面调用休息服务是一个好方法。 Currently I'm using resteasy . 目前我正在使用resteasy

Simplest way for me is to make a EJB layer, and just have the rest call these services, but I would like to hear different options. 对我来说最简单的方法是创建一个EJB层,然后让其他人调用这些服务,但我想听听不同的选择。

Making the calls under the rest layer breaks the architechture. 在休息层下进行调用会破坏架构。 I'd rather be able to change the UI layer. 我宁愿能够改变UI层。

You've basically stated the answer yourself. 你自己基本上已经说明了答案。 Wicket doesn't care what you call and how you do it when it comes to your own business logic, and the stateful vs stateless nature is not important here. Wicket并不关心你所谓的你自己的业务逻辑,以及你如何做到这一点,而状态与无状态本质在这里并不重要。

I would simply write a service layer that does all the interesting business logic - could be Spring, could be EJB, whatever you want really. 我只想写一个服务层来完成所有有趣的业务逻辑 - 可能是Spring,可能是EJB,无论你想要什么。

Then you can have the frontend (in this case, Wicket - or anything else should you decide to use something else) call that service layer. 然后你可以拥有前端(在这种情况下,Wicket - 或者你应该决定使用别的东西)调用该服务层。 Classical tiered approach. 经典的分层方法。

Why would you want to add another layer between Wicket and RESTEasy? 为什么要在Wicket和RESTEasy之间添加另一层? Is there a proper reason why you don't want to use a RESTEasy client directly from Wicket components without having it wrapped in another service layer? 您是否有正当理由不直接从Wicket组件使用RESTEasy客户端而不将其包装在另一个服务层中?

Please don't get me wrong, I think it is perfectly OK to create a reusable client that does proper exception handling etc., and then inject it into pages/components/whatever. 请不要误解我的意思,我认为创建一个可重用的客户端可以完成正确的异常处理等,然后将其注入页面/组件/其他内容。 But this can be done with simple DI tools, so in my opinion you should just get rid of any additional layer and simply call the REST interface directly. 但这可以通过简单的DI工具完成,所以在我看来你应该摆脱任何额外的层,只需直接调用REST接口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM