Running a Java background application on an application server

My experience with application servers is limited by some basic coding for a servlet, so I'm not even sure how to ask this question correctly.

I need to write a java program that runs on the application server (java) and constantly executes a specific method (it checks files in a specific directory).

I found a way to schedule applications to start, but you need to know where to put the code, which I would usually put in the main () method in a regular java program.

+3
source share
4 answers

You can use the Quartz , or EJB timer services (if you can learn EJB) for this task.

-, Tomcat, Quartz. , Quartz - .

, EJB EJB, EJB 2.1 .

+1

, Spring , .

+2
+1

One way to do this is to write a Listener that implements the ServletContextListener, and you write that you plan your timer in the context of the Initialized method

0
source

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


All Articles