在jboss启动时加载class方法
2010-08-30 22:30
381 查看
在jboss启动时加载class方法
在jboss启动时加载class的方法A.编写class,要import org.jboss.varia.scheduler.Schedulable包,此包在
%JBOSS_DISC%/server/all/lib目录下,同时要把编译好的class(压成包)放在
%JBOSS_DISC%/server/all/lib目录下,以便能加载。
B.修改%JBOSS_DISC%/server/all/conf/jboss-service.xml文件
添加以下相似文字:
<!--======================================================= -->
<!-- Scheduler Initialization 定时操作 -->
<!--======================================================= -->
<mbean code="org.jboss.varia.scheduler.Scheduler"
name="jboss. piosan.util:service=Scheduler">
<attribute name="StartAtStartup">true</attribute>
<attribute name="SchedulableClass">com.piosan.util.PiosanTimer</attribute>
<attribute name="SchedulableArguments">TheName,123456789</attribute>
<attribute name="SchedulableArgumentTypes">java.lang.String,long</attribute>
<attribute name="InitialStartDate">NOW</attribute>
<attribute name="SchedulePeriod">1000</attribute>
<attribute name="InitialRepetitions">-1</attribute>
</mbean>
<!—name为任意但唯一,com.piosan.util.PiosanTimer为class名 -->
<!—SchedulableArguments的值为传递参数,这里为两个参数,theName为String型,123456789为long型,在SchedulableArgumentTypes中体现了参数的类型 -->
<!—SchedulePeriod 的值为每隔1秒操作一次 -->
<!—InitialRepetitions的值为一共执行多少次,如果为-1,则不停的循环执行—>
C.附上PiosanTimer.java源代码例子
packagecom.piosan.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);
}
/**
*JBoss 启动时会自动执行此函数,所以可以在此函数中可以执行一些初始化的方法,
* 例如Load Cache
*/
public void perform(Date now,long remainingRepetitions) {
System.out.println("perform,now:"+now+
",remainingRepetitions: "+remainingRepetitions+
",name: "+name+ ",value: "+value);
}
}
相关文章推荐
- 在jboss启动时加载class方法(定时操作)
- 在jboss启动时加载class方法(定时操作)
- 在jboss启动时加载class方法(定时操作)
- spring启动加载程序的几种方法
- 在eclipse下用java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource定义data-source Tomcat无法启动的解决方法
- Tomcat启动web项目报Bad version number in .class file (unable to load class ...)错误的解决方法
- 图学PowerBuilder----去除启动后加载上次项目的方法
- jboss之启动加载过程详解(-)
- Android 启动加载jar包 init.rc BOOTCLASSPATH
- spring 容器启动后加载某个方法
- 在liunx下面启动jboss 7.0 报 UnknownHostException的解决方法
- Weblogic启动时classloader加载顺序
- JBOSS 启动 加载 过程
- 加载RT3070驱动出现 Unknown symbol led_classdev_suspend的解决方法
- 实现自己的类加载时,重写方法loadClass与findClass的区别
- vue.js默认路由不加载linkActiveClass问题的解决方法
- jboss之启动加载过程详解(二)
- php面向对象中的单例与静态方法的对比,以及关于class自动加载的分析
- 开机自动启动jboss配置方法
- 解决Jboss打开run.bat时闪退不能启动的方法