I am trying to create a Spring application (NOT a web application) to perform some simple tasks. In the end, they will connect to some other Spring applications over the network, but for now, I keep them simple. I have a CheckForNewItems class (timer extension) that is configured to run every 10 seconds.
I can confirm that it works by calling it programmatic:
public class Tester { public static ApplicationContext context; private void loadContext() { String filename = "beans.xml"; context = new FileSystemXmlApplicationContext(filename); } public static void main(String[] args) { Tester test = new Tester(); test.loadContext(); CheckNewItemsTask task = (CheckNewItemsTask)context.getBean("checkNewItemsTask"); } }
Doing this works as expected, task.run () is called every 10 seconds. Now I need to figure out how to deploy this to a JBoss or Tomcat server so that it starts the task automatically.
Most of the tutorials I found only described how to get Spring MVC and servlets, not a standalone application. Does anyone know better?
Greetings Rob.
source share