From the course: Java EE: Concurrency and Multithreading

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Add a REST method to call the URLProcessor

Add a REST method to call the URLProcessor

From the course: Java EE: Concurrency and Multithreading

Add a REST method to call the URLProcessor

- [Instructor] So now let's go ahead and do the last step. You have to add a method to the REST class, get that scheduled executer service object that we've already injected. And submit the task for scheduling of the URL health check. Let's go ahead on the IDE and we've already added that REST class. We just need to go ahead and add a REST method to it. So let's get hold of the resource first. Yes. And here we will just add a @GET API. And what is it going to do? It is going to say public String checkHealthOf the app. Okay, so what is this going to do? Let's have a string message. Okay, and let's go ahead and take the scheduledExecutorService object now, grab that, and go ahead and call the schedule API. Okay, so this will take in three arguments: One is the instance of the URLHealthProcessor. So let's feed the instance to it. The initial delay, let's say is three seconds only. TimeUnit is seconds, of course, and as I said, you may want to actually schedule this health check maybe…

Contents