Hardware support from web application

I have a web application that works with support for some specific hardware. This is achieved in the following steps:

  • The user launches a small installer that places java files (and a couple of others) on the client machine. The main part is a bank called "hardwareManager".
  • A user visits a web application. The web application launches a Java applet, which, due to the .java.policy file placed during installation, has permission to interact with the client machine outside the stand-alone browser program.
  • The applet checks if the hardwareManager is working, and if a command is not running to run it.
  • The user interacts with a web application that sends commands to the applet via JavaScript. The applet then writes the commands to a text file on the client machine. The text file is constantly monitored by the hardwareManager, which runs any commands it reads.

It works, but it seems awkward. I have a couple of ideas on how to improve it, but I donโ€™t know which ones are even worth a try.

Would it be better to configure the hardwareManager as socketServer and connect the applet directly to it, rather than go through text files? Is it possible?

Is there a way to completely remove the applet and talk to javascript directly with the hardware manager? Maybe by writing hardwareManager as a local HTTP server? What port should it work in? Javascript xss limitations fit around here somewhere?

+6
source share
1 answer

It would be inconvenient to run a Java application using Java Web Start. This would eliminate the need to uninstall or install the Java hardware manager.

Another alternative is to use the built-in browser inside Java. I suppose this is not an option since you are very dependent on Javascript (I suppose to provide a rich customer experience).

If you already need to install something on the client machine, why did you decide to do this using a web application?

Speaking from experience: We had a Java EE application that needed to be printed to PoS printers on a client site. We installed a small synchronizer application that connects via SSH and synchronizes all client files. Subsequently, it loads the JAR and executes the program. This program connects via RMI to the server and subscribes to the JMS queue to receive print assignments. A.

Applicable to your case:. Why not let your Java application connect directly to the server? You can use HTTP, SOAP, or even JMS on top of RMI. Then you can run the hardware command from the server (and not from a limited JavaScript browser environment). Thus, you get many functions: authentication, command buffering, as well as the ability to share equipment between multiple clients.

Scheme:

<----AJAX------> Web browser ApplicationServer <---HTTP/SOAP--> Java hardware manager application 

You can launch a Java application using Java Web Start, which allows you to automatically update the application (instead of passing a new installer to each client).

+2
source

Source: https://habr.com/ru/post/906194/


All Articles