一.在jboss启动时加载class方法
A. 编写class,要import org.jboss.varia.scheduler.Schedulable包,此包在%JBOSS_DISC%serveralllib目录下,同时要把编译好的class(压成包)放在%JBOSS_DISC%serveralllib目录下,以便能加载。XML:namespace prefix = o ns = "urn:schemas-microsoft-com:Office:office" />
B.修改%JBOSS_DISC%/server/all/conf/jboss-service.xml文件
添加以下相似文字:
<!--============================================================ -->
<!-- Scheduler Initialization 定时操作 -->
<!--============================================================ -->
name="jboss. piosan.util:service=Scheduler">
C. 附上PiosanTimer.java源代码例子
/*
* Created on 2003-11-6
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package com.util;
import java.util.Date;
import org.jboss.varia.scheduler.*;
public class PiosanTimer implements Schedulable {
private String name;
private long value;
public PiosanTimer(String name,long value)
{
this.name = name;
this.value = value;
System.out.println("name="+name+" value="+value);
}
/**
*/
public void perform(Date now,long remainingRepetitions)
{
System.out.println("perform,now:"+now+
",remainingRepetitions: "+remainingRepetitions+
",name: "+name+ ",value: "+value);
}
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10752019/viewspace-962921/ ,如需转载,请注明出处,否则将追究法律责任。