2

I have scheduled task in JBoss:

<?xml version="1.0" encoding="UTF-8"?>  
 <server>  
  <mbean code="org.jboss.varia.scheduler.Scheduler" name="acme:service=Scheduler">  
   <attribute name="...">...</attribute>  
   .....
  </mbean>  
 </server>  

How to write this task, that will execute at 1:00 AM on the first day of every month? Thank You!

WhoAre
  • 144
  • 2
  • 13

1 Answers1

0

You'll need to create a scheduling class. org.jboss.varia.scheduler.Scheduler

Since you want to perform monthly and cannot state this as a attribute. You'll need to have another Class which handles setting the next interval. Java Monthly Timer

Have the scheduler class call the monthly timer to get the next interval and set it. Maybe pass some values at initial start.

<mbean code="org.jboss.varia.scheduler.Scheduler"
       name="jboss.docs:service=Scheduler">
    <attribute name="StartAtStartup">true</attribute>
    <attribute name="SchedulableClass">org.jboss.book.misc.ex2.ExSchedulable</attribute>
    <attribute name="SchedulableArguments">01:00</attribute> <!-- 24hr time hh:mm -->
    <attribute name="SchedulableArgumentTypes">java.lang.String</attribute>

</mbean>

ExSchedulable (this is just pseudo-code)

public ExSchedulable(String time)  {
    Date tDate = new Date();
    tDate.setTime(time);

    Monthly monthyObj = Monthly(1); //Day of the month
    //Gets the next interval date specified from the day of the month 
    Date nextInterval = monthyObj .getNextInterval(tDate); 

}
Community
  • 1
  • 1
GeekyDaddy
  • 384
  • 2
  • 12