Add a Startup Class in Jetty
Add a Startup Class in Jetty
Jetty provides an approach, known as module, to start a Class while Jetty server is started. Add following line in start.ini:
--module=tasks
The new module name is tasks. We should have a simple module modules/tasks.mod with content:
[xml]
etc/tasks.xml
And etc/tasks.xml with content:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure id="tasks" class="com.mycom.task.Schedular">
</Configure>
The Class com.mycom.task.Schedular should have a constructor with no argument.
Start Jetty server with command start -jar start.jar, an instance of com.mycom.task.Schedular will be initialized.
