如何在JBossAS5中设置调度器?

如何在JBossAS5中设置调度器?,jboss,schedule,Jboss,Schedule,我在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>

我在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>

…
…
如何编写此任务,它将在每个月的第一天凌晨1:00执行? 谢谢大家!

如何使用

否则,请检查:

这个怎么样

在jboss-service.xml中

<!-- Put a real date here -->
<attribute name="InitialStartDate">01-01-01 01:00</attribute>
<attribute name="SchedulePeriod">86400000</attribute>

我知道这个问题很老了,但你怎么看?

请用相关标题命名你的问题。谢谢!但是如何编写将在每个月的第一天凌晨1:00执行的任务?如果可能的话。。在“SchedulePeriod”中,我们只能指定两次运行之间的时间…
package test;
import java.util.Date;
import org.jboss.varia.scheduler.Schedulable;
import org.apache.log4j.Logger;
public class MySchedulable implements Schedulable
{
    private static final Logger log = Logger.getLogger(MySchedulable.class);

    private String name;
    private long value;

    public MySchedulable(String name, long value)
    {
        this.name = name;
        this.value = value;
        log.info("nt name: " + name + ", value: " + value);
    }

    public void perform(Date now, long repetitions)
    {
        log.info("perform(), time: " + now +", repetitions: " + repetitions +", name: " + name + ", value: " + value);
    }
}
<!-- Put a real date here -->
<attribute name="InitialStartDate">01-01-01 01:00</attribute>
<attribute name="SchedulePeriod">86400000</attribute>
package com.example.scheduler.job;

import java.util.Date;
import org.jboss.varia.scheduler.Schedulable;
import org.apache.log4j.Logger;

public class MyJobScheduler implements Schedulable {

    public MyJobScheduler() {}

    public void perform(Date now, long repetitions) {

         Calendar calendar = Calendar.getInstance();
         calendar.setTime(now);
         int day = calendar.get(Calendar.DAY_OF_MONTH);            
         if(day == 1) {
            // Do stuff
         }
    }
}