We have a desktop java application (image-processing) that is working great, now we have to add a client/server architecture using Java EE plateform.
We must use also MVC, and interacting with many other libraries like JDOM, JMatlink(MATLAB), and calling some exe files.
Based on your experience what is the best choice to do that (framworks, ... )
Correct, you must use an MVC framework to design a flexible and reusable web application on the Java EE platform.
I suggest the following design:
Use JSF (Java Server Faces) to design the front end. As you are migrating your desktop application then it will better suit you becuase it's Component and Event driven framework.
Middlware: EJB 3(or EJB3.1) This will provide best available flexibility, performance and security to call your Business components directy from JSF Beans or any other remote application.
Over here you can use various design pattern to encapsulate Library and database access i.e. DAO (Data Access Object).
Use DTO (Data Transfer Objects) to transfer your request/response.
Hope it will give base to start your research.
If you can abstract the layers that talk to the backends such that your frontend (Swing?) doesn't need to know where those service are located, you are half-way there.
The key should be a good module concept. Frameworks like the NetBeans platform help you with that, and they can easily integrate non-visual modules that handle the backend code.
I'm not sure what you mean with "We must use also MVC"
MVC is a design pattern not a library or framework.
But if you use something like the NetBeans platform, you'll be applying that pattern anyway, because it forces you to think in modules. Each module will have a defined responsibility and during startup it registers itself with the application.
Take an application that allows you to manage people (e.g. for a human resource department). One module is responsible for displaying a form where the user can look at a single employee. That module in turn looks for a provider that can load or list all employees. How that provider gets the data is invisible to the front end. It could use a flat file, a relational database or a call to a remote EJB server (this is were you could plug your JavaEE stuff in)
The application could even download the modules from the server if correctly configured.
The key is to make the modules independent from each other. This is true for any large scale application regardless of the technology used (web application, a server side daemon or a desktop application)
Related
The eclipse-maven-tomcat project(containing html/css, jquery, javascript) will make ajax-jquery calls, using exposed web service url's(using json/xml) and interact with database. The database persistence layer and web framework (spring), etc, modules are part of another project which exposes web services.
Will using the above mentioned technologies will follow the headless websites/decoupled architecture?
Quoting this answer:
A "Headless Architecture" is a buzz phrase in the software development community pertaining generally to web applications describing an approach which splits the code base cleanly between server side (e.g. REST webs services) code which defines data and business logic from client side (e.g. JavaScript) code which invokes the logic and renders the data and typically as part of an MVC pattern.
So of course you can implement this using HTML/CSS/JS for the front-end and Spring for backend in separate projects.
Eclipse, Tomcat or Maven are quite orthogonal to the question.
I need to build a desktop application for internal users for certain business. It also needs web based GUI for external users. I know, with web GUI both internal and external users can access it, but there are certain factors which are outside our control - due to which, desktop application is really unavoidable. For the purpose of this question, I would like to focus on the way to support both Desktop client (Swing) and Browser client.
Are there any best practices to be followed? I could think of below:
Expose service classes as web services and use these from both Swing client and web client
Expose service classes as EJB (business is into Java EE techs) and use Swing client as EJB client. Web client can use controller classes to interact with EJB
Are there any known benefits of using either approach, apart from technology agnosticism offered by web services?
Also, for swing client, I am thinking of using Java Web Start for easy distribution. I have never used it before, but from what I understood, it can support automatic version check at startup and update the client when required - is this correct?
If you need to avoid dependency to Java/JVM on the browser (which you most likely at least want to), you should definitely go with mixed Swing-Vaadin approach. Build the internal application with Swing or JavaFX and web part with Vaadin. The programming model in Vaadin is so close to typical desktop UI library that it is really easy for the same developers to work with both code base, and naturally you'll use exactly the same backend.
See the example application I recently built to demonstrate a setup like this.
After one year i have finished the development of my application.
Now when searching the internet i got a new knowledge about the 3tiers applications.
My Application running on 2tier Architecture (Standalone application connecting directly to database server).
My Application Developed using:
- Java SE (Swing).
- MySQL Server as database server.
I want to reconstruct my application to be 3tier application. (Client-Server)
- What technology i have to use?
- What I have to change within my current code?
- The application will run on network, there will be Many concurrent users who will use the application accessing the database (Insert,Update,Delete ... etc).
There are two main approaches. The first involves rewriting the client in HTML/JavaScript with help from one of the many available frameworks (Struts, Spring, Java Server Faces, etc.) Unless you specifically prefer a web application to a Swing application, or your user interface is a very thin layer on top of your business logic, then this is a costly approach.
The second approach involves inserting a server between your user interface and your database. Open source Java-based servers include Jetty, Tomcat, Spring, JBoss/WildFly and GlassFish.
If your code is structured in layers so that the user interface, the business logic and the data access code belong to separate layers, then converting from a two-tier system to a three-tier system should be straightforward once you understand the capabilities of your chosen mid-tier server and how to use them.
The basic technique is:
All user interface/Swing code remains on the client.
All business logic moves to the middle-tier server. The client talks to the business logic using a remote protocol.
All data access code is moved to the server.
Dependency Injection is useful to perform this refactoring step-by-step and also allow you to choose between working in two-tier or three-tier mode if that is needed.
The three main differences between a two-tier and three-tier application are:
Security - there is a new access point into your system. You need to be careful about the access rights it has to the database - do you have one server user that can do everything, or does each user need to use their own connection credentials. You also need to secure the server correctly and be careful not to add security holes in your mid-tier API.
Remote access - some method calls that were previously made within the same process are now made across the network. Server APIs generally need to support less fine-grained operations than local APIs, and the amount of data shipped as arguments and return values may also need to be managed.
The structure of your application becomes more important. The code isn't necessarily very different, but it will need to be organised into different layers.
Java EE is your answer.You could choose a framework like Hibernate/Spring/Struts to build a 3 tier architecture (MVC).You would also need to make a choice for a servlet container.Apache Tomcat should be a good choice.
It would be nice if you could post little more details like complexity , purpose etc. of your application.
I search for an architecture to implement an egovernment solution with java. I would like the possible solution present the following features:
Based on Java (JSF, Spring, JPA)
Modular architecture
Strongly designed around BPM
processes
Isolate workflow engine from user
task forms (in order to provide fault
tolerance)
I have found several bpm alternatives such as jBPM, Activiti, Intalio or Enhydra. By now, I like Activiti approach but I don't find a suitable solution for a modular architecture and user task forms isolation. Perhaps, a multimodule maven project (ie, one jar module per procees) or a OSGi option would fit but I don't know how to wire up all these pieces.
What would you recommend me in my quest?
Thanks very much in advance
Intalio runs the user tasks in a separate web application. It can be deployed to a different server from the runtime engine.
I think that you might be interested by the upcoming version 7 of Bonita BPM.
Engine conception is services oriented and all implementations are injected using Spring. Persistence is handle directly by Hibernate (no JPA) but make use of JTA.
Architecture is separated into three main components:
Studio: the development environment for BPMN process modeling
UI Designer: to define forms and pages that will be used for process execution as well as for applications creation. it's a custom AngularJS solution that is used here but you can as well use any alternative solution you want thanks to Engine API.
Portal: web interface for administration and end users operation.
Engine: component that actually execute the process definition build using the Studio. Engine provides a set of API available using REST or a Java client library.
The Engine is the core of the Solution and Portal is built on top of it using Engine API.
Process definition actually declare a set of contract at process and step level to define what data must be provided by the forms in order to start a new process instance or execute a task. So we have a loosely coupled design here.
Does anyone know of any tool that can facilitate/ease porting of an app to both Java Swing and GWT?
I've got a few "screens" that makes complete sense to have both in a desktop app and in a browser and I was wondering if there was some kind of common API that could be targeted that would facilitate creating these two different "views" (see my comment)?
I think it's entirely possible, but it would mean a different take on the server side of things.
If you do interface-based POJO development of the server-side components that the UI communicates with to do the work, you leave yourself the option of either an in-memory implementation or one that acts as a proxy to a remote component. The Swing desktop UI might use the in-memory version of the server-side, while the GWT version talks to the distributed version.
If you use Spring, it's easy to inject the appropriate implementation for each UI. Both only know about the interface and are oblivious to the implementation details.
I imagine a single code base that might be packaged in different ways. The Swing desktop app would be packaged and delivered as a JAR file. It wouldn't include the GWT or web tier controller classes. The GWT code base would include web configuration and controllers, because controllers are really part of the web tier.
The service interface and everything behind it would remain the same for both. The only difference would be that the Swing desktop configuration would inject the in-memory service layer implementations of the service interface. The web configuration would inject the web-based implementations of the service interface.
Whether my attempt to read your mind for requirements is correct or not, this approach has value regardless of how you decide to implement the service and client tiers.
I'm a Spring fan, so I'd recommend the use of Spring.