Sometimes you have to do some tasks in a scheduled way. Let’s say every 24 hours.
To make that happen in Ninja you need two things
The class and method then looks like:
@Singleton public class ScheduledAction { @Schedule(delay = 60, initialDelay = 5, timeUnit = TimeUnit.SECONDS) public void doStuffEach60Seconds() { // do stuff } }
Don’t forget to bind the class explicitly inside conf/Module.java
public class Module extends AbstractModule { protected void configure() { bind(ScheduledAction.class); } }
By that Ninja will execute method doStuffEach60Seconds each - well - 60 seconds.