I have Spring+Java Server Faces (Facelets) application for which I would like to create Single Page Application (SPA) version, e.g. using AngularJS (which is the best and most popular GUI framework). But after some investigation of technologies I have come to conclusion that REST (which is necessarity for AngularJS) ir bad choice for complex business applications, because there is requirement to divide business logic accross software layers.
Let me explain this. In Spring+JSF application all the business logic was encoded in special layer - Spring entities and services. In Spring+REST+AngluarJS this should be different. I don't want to rewrite (move) business logic from Spring/Java to AngularJS/JavasScript but obviously I am required to to. There are one issue and 3 types of business logic in my application that requires consideration.
- Business logic type 2. Change monitoring and propagation. E.g. if user adds invoice line with article to the invoice inside application form, then program can retrieve all the discounts that are relevant for this customer, this article and this moment of time. Discounts can be applied to the invoice line and changes can be propagated to update invoice sales tax and totals. It is almost impossible to do this type of change propagation in the REST, if part of the business object in session are stored in the server side.
- Business logic type 3. Processing of business objects. E.g. if invoice is marked as ordered then Spring application can make extensive changes in other database objects - e.g. update inventory levels, plan shipping activities, create accounting entriess and so on. Spring could do this and Spring will still be able to do this in REST application. This is the only type of business logic that I can retaing from my initial application.
So - it seems to me that migration from Spring+JSF to Spring+AngluarJS requires rewrite of almost three fourths (3/4) of application. Does adding new type of GUI (and new type of communication - REST) to existing application should be so involved?
I am thinking about two problemts
So - the main question is - is there alternative to REST for SPA business application (AngularJS) communication with the stateful business logic that is implemented in the server side application (Spring/Java/Enterprise Java)?