3

I have a huge read-only RESTFUL application built in Spring MVC and Hibernate-Search that marshals some data to json and xml to be consumed for a mobile app and a monitoring application.

Our urls are pretty simple, we have this:

server:port/entity/id/?marshalling=json

or

server:port/entity/id/?marshalling=xml

and sometimes

server:port/entity/id/?marshalling=something&filterProp=entity.prop&ordering=desc

Now I have a requirement to make a presentation layer for this using JSF 2.1 and adding some user admin capabilities and I was thinking in something like this:

server:port/entity/id/?marshall=html

Or omitting entirely the marshall request parameter.

Now. As far as I know, you can only couple JSF 2.1 and Spring Web Flow, not Spring MVC directly. Anyone know how can I accomplish this requirement?

ElderMael
  • 7,000
  • 5
  • 34
  • 53

1 Answers1

2

Both Spring MVC and JSF work on seperate servlets that can only be mapped to a context that doesn't conflict with another servlet, so this cannot be done easily and if you succeed then it is basically an enormous hack.

If I absolutely had to do it this way (which I wouldn't), then I would probably use the marshall servlet to clone my JSF requests, send that request to my FacesServlet using a WebClient, and then copying the returning WebClient response into my marshall servlet response and return that. This would be transparent to the user but highly messy and potentially insecure.

The best way to implement a seperate web based presentation layer would be for requests to your presentation layer to be mapped to the FacesServlet so that your RESTFUL web services do not get called directly.

Actor - > /admin/page.jsf -> FacesServlet -> JSF View - > JSF Controller -> Business Logic Layer -> RESTFUL Web Services

In this way your RESTFUL web services can return XML or JSON data and act as your DAO, your Business Logic layer can perform additional logic on that.

maple_shaft
  • 10,435
  • 6
  • 46
  • 74
  • I am a bit preoccupied about performance in this topic... any useful tip about it? – ElderMael Sep 12 '12 at 14:16
  • @mael If you are concerned about the performance of this approach then the other option is to run the RESTFUL web services as well as the JSF front end on the same instance, which will allow you to bypass the service layer and go directly to the Business Logic layer of the RESTFUL web services. This would reduce the overhead of making those additional web requests on the JSF server side. – maple_shaft Sep 12 '12 at 16:42