Spring Boot Web application with Swing Local GUI - java

I have developed a Spring Boot Web applications. I have provided REST API's for users to interact with the server.
Now i want to write application for admin to interact with server, in the sense change the data in database. I know i can do REST api with admin role and do a authentication and authorization. But currently i have made front end application with python and this i will like to change later on to angular.
So, as of now i don't want to create extra REST api's and the logic around it. Is it possible to create a Swing GUI with the spring boot web application ? So, admin can directly interact with the database.
I can create a separate GUI application for admin, to interact with database, but i have already defined entity and mongorespository in web application. I would like to use the same and not maintain two copies of same.

Yes, you can call REST APIs from a Swing application using JAX-RS.
There are some resources here. In particular, note the section on RESTful Java clients
https://mkyong.com/tutorials/jax-rs-tutorials/

Related

In a Spring Web MVC application - how do we break up the architecture into Front-end & Back-end?

Looking at the sample Spring Web MVC application PetClinic https://github.com/spring-projects/spring-petclinic as an example.
Application typically broken up into 3 different physical tiers and within the server side it is broken into different layers:
Client side: (JavaScript/CSS etc...)
Server side:
- Web
- Service
- Repository
Database:
Using above application as an example what constitutes front-end and back-end?
I always believe everything within the server side (web controllers/service/repositories) + database makes up the backend. But one of my colleague argue that only the database is what 'back-end' is.
Another of my colleague says only the 'Service & Repository' layers constitutes backend and he argue that stuff inside the web layer (consisting of JSP/Thymeleaf templates, form-backing objects, Controllers) is considered 'front-end'
In a SpringMVC app the front-end is the views. jsp files in the petclinic app are used to generate html files that are served from the server to the client. These files allow the user to view the model's data.
In a web application the backend is certainly not just the database. The controllers are also part of the backend. In a SpringMVC app these are classes annotated with #Controller.
Regarding files the petclinic app you may consider everything in src/main/webapp as the front-end and everything else the backend. Other people may disagree.
Mind you that a server app built with SpringMVC may be also used to expose a REST api receiving and transmitting JSON documents to a mobile app for instance. This app may implement the MVC pattern itself with its own frontend and backend.
In simple words
I would say whatever you want display to user irrespective of technology will go in View (Like HTML forms or any informative HTML page).
Regarding backend i would say you want some data to display on Frontend (View in SpringMVC) so you will do any preprocessing which includes getting data from another systems through web services and all , it will go in the backend part.In the same case if you are getting data from DB you can say its backend as well.

Application architecture - how to connect Swing app to backend?

We are developing a java application which provide web services through SSL. This application is running in Tomcat server.
The purpose of web services is insert, update and select data. So under web service tier is implemented backend tier, which provide access to database.
Suddenly we were asked to build swing application which will also access the data in database. We want to use the same backend (exactly the same runtime) which is used for web service application. How to reach this goal?
I see following possibilities:
use web app instead swing application, which will be part of the same project like web service application and then it will be able to connect backend
Provide some extra web services for swing application only.
Use JMX. It is possible run JMX on Tomcat. Backend could provide functionality through JMX and Swing application could connect it.
Each of these possibilities have advantages and disadvantages. We followed solution 3 and I think it wasn't a clever selection. JMX has problem with generics, you can run only one JMX on tomcat etc.
Java world is rich and there should be some optimal solution for this situation. Could you help?
Add a web service client to the Swing app and let it make exactly the same calls to web services that a browser based UI would.
You're certainly free to add extra, Swing-only web services if you choose.
I didn't think JMX was anything other than a way to allow you to monitor MBeans using a JConsole. What does that have to do with Swing?

How to integreate Java FX and Spring MVC

I want to use JavaFx as a front-end in my web-application. My question is that is it possible to bind Model object with the form which is developed with Java Fx.
I kindly request you to put some light on this issue.
Please let me know If you need more clarification regarding this
The main differences between Web front-ends (like Spring MVC) and rich clients (and RIAs like JavaFX) is that for web front-ends the server-side logic runs in the same JVM as the web framework while for rich clients the server-side logic and the client are running on 2 separate JVMs, one on the server machine and one on the client machine.
Rich clients are usually downloaded/ installed completely before the user can run it, while for web front-ends each HTML page is possibly first dynamically created and then send to the user as needed.
Since the user usually already has the complete rich client from start, only the actual data (DTOs) get sent back and forth using some kind of remote service e.g Web Services.
So this means that the JavaFX client cannot access the objects of the server (e.g. attached JPA entities). You need to wrap the data up and send it to the JavaFX client using some kind of service (see the Service Facade and DTO design patterns).
The main difference between JAVAFX and any Java EE framework is same as the difference between the swing applications and Java EE apps.
You can design applications using JAVAFX to be directly used on desktop or deployed as browser applets with the help of the Java browser plugin. But, using it as a framework for designing the front end of a Java EE application is not possible.
Read this post :
https://www.java.net//node/674176

Client architecture for calling Spring based web service

I have written a SOAP based web service which runs fine on a Tomcat server. The Web Service service itself is a Spring MVC based web service that runs on the Tomcat application server.
Now i need to write a Thick client which will be a standalone Java app that will use the services of the web service. I think i am correct in that the client only needs to know about the service details (i.e. operations) and nothing else.
What i am not sure of is the architecture and environment i should use for the client. The client application will be based on Swing but is it possible to use Spring with Swing together?
On the web service i have the following setup
view --> Service --> Model
The client application is basically a configuration tool. It uses the web service to configure user accounts. This means that the client application does not actually write anything to any database. It just uses the services of the web service to make changes to 'user account' and probably view list of accounts.
My question really is
- Is an MVC design suitable for such a use case
- Usually Spring is used for web based applications. Is there any benefit in using Spring with the Swing based client?
- Are there any alternative or better solutions/design/architecture that would achieve the same?
An example showing Spring used in conjunction with a Swing application would be very usefull.
Thanks in advance.
Spring MVC is not appropriate for a Swing-based client. Use the core Spring framework and a JAX-RS implementation like Jersey to provide simple REST web services in tomcat. Jersey also provides a corresponding client API that you can use within your Swing application to invoke the REST services.
If you have decided upon Swing as your platform, there are two options you can look at:
(1) Net Beans Rich Client Platform
http://netbeans.org/kb/trails/platform.html
(2) You can roll up your sleeves and write your own app using a low level yet extremely flexible framework called Swixml
http://www.swixml.org/
Give Swixml a good try before you try others, it may surprise you.
You can implement Swing-based thin client application with Spring Integration backend serving as a integration tier. It can expose gateways accepting simple Java types or DTOs. Your Swing presenters / controllers interacts with these components in order to call remote webservices.

asp.net with java backend

I currently have a full java web application stack (J2EE web app using Spring and Hibernate with a RIA client using dojo).
I have to move technology stacks for the UI to be asp.net but am allowed to keep the server components in java.
Any ideas on best practice here - and yes, I have to adopt this hybrid tech stack.
Initial thoughts are:
asp.net ajax (possibly using asp.net MVC) to provide the UI and a thin control layer in IIS.
expose current java web app (residing on a remote machine) as RESTful web services (the web app would remain in a J2EE serlet container such as Tomcat or Jetty). The new control layer would provide security (authentication and authorisation), comet server push abilities and then basic request passthrough to the web app.
Basically, I am unsure 'how much' C# I should write in the control layer and how best to expose and communicate with the existing java web app. Also, currently, I use JSON as the data interchange format.
I would suggest you start moving to asp.net feature by feature, don't try to implement everything at once.

Categories

Resources