I know "normal" Java, but I'm new to the world of servlets, containers, etc. Because of this, I am not sure which approach is most reasonable.
Situation: I created a servlet that receives information and stores it in a database. This database is read by other applications.
Now I need an application that receives exactly the same information and stores it in the same database. However, this new application should pull this information from another server (I will use httpClient for this) instead of being clicked. Both applications will coexist.
For these new applications, I see the following two options:
Make a standalone application. To do this, I can copy the paste of a large amount of existing internal code, but I will need to make some changes (the servlet container offers a context, a simple database connection pool, etc.). Also, I may need to use some kind of shell so that it can work as the right daemon that I can start, but also gracefully stop / restart, etc.
Make the new application part of the servlet. That is: just run a new thread in the init () of the servlet that will launch the new application. This would allow me to reuse all the code that I already have, without having to rewrite it. I only need to write code that executes HTTP-GET requests to another server. With this approach, it will also be easier to start and stop the service, because for this I can use the Servlet container.
Some information about the project: the internal code that analyzes and writes data to the database has several streams, but not very complicated. Writing the code for the source servlet took about one week to complete. With the existing code base, I believe that this new application should probably be a maximum of 1, 2 days of work.
, , 2 . , "" .
: , , , ? - , ? ?
tl; dr: , ?