简体   繁体   中英

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*. I know restful services are stateless and wicket is stateful framework.

Does somebody have a simple example what would be a good way to call rest service from wicket page. Currently I'm using 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.

Making the calls under the rest layer breaks the architechture. I'd rather be able to change the UI layer.

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.

I would simply write a service layer that does all the interesting business logic - could be Spring, could be EJB, whatever you want really.

Then you can have the frontend (in this case, Wicket - or anything else should you decide to use something else) call that service layer. Classical tiered approach.

Why would you want to add another layer between Wicket and 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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