在jboss启动时加载class方法(定时操作)
2003-12-11 11:40
435 查看
一.在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秒操作一次 -->
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);
}
}
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秒操作一次 -->
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);
}
}
相关文章推荐
- 在jboss启动时加载class方法(定时操作)
- 在jboss启动时加载class方法(定时操作)
- 在jboss启动时加载class方法
- jQuery 属性操作 - hasClass() 方法
- 项目启动时就执行某些操作、@Scheduled定时项目启动时执行一次
- 项目启动后开启定时任务方法-->InitializingBean和ServletContextListener比较
- C#操作Word导致 “Microsoft.Office.Interop.Word.ApplicationClass”的 COM 组件错误的解决方法
- 自定义类加载器:从网上加载class到内存、实例化调用其中的方法
- Spring的web应用启动加载数据字典方法
- 01、配置tomcat的web.xml文件,使得方法在tomcat启动时被加载
- 写服务,删除服务的方法,定时启动程序,关闭程序
- jQuery 属性操作 - removeClass() 方法
- 【Hadoop datanode重新加载失败无法启动现象解决方法介绍】
- 基于PHP的加载类操作以及其他两种魔术方法的应用实例
- Weblogic启动时classloader加载顺序
- 实现自己的类加载时,重写方法loadClass与findClass的区别
- 通过web.xml启动spring容器遇到classnotfound解决方法
- Android应用程序启动时发生AndroidRuntime : ClassNotFoundException for Activity class的解决方法
- 如何用Class_forName方法动态加载构造方法带参数的类
- spark1.4加载mysql数据 创建Dataframe及join操作连接方法问题