在jboss啟動時載入class方法(定時操作) (轉)

amyz發表於2007-08-17
在jboss啟動時載入class方法(定時操作) (轉)[@more@]

一.在啟動時載入class方法

A. 編寫class,要import org.jboss.varia.scheduler.Schedulable包,此包在%JBOSS_DISC%serveralllib目錄下,同時要把編譯好的class(壓成包)放在%JBOSS_DISC%serveralllib目錄下,以便能載入。:namespace prefix = o ns = "urn:schemas--com::office" />

B.修改%JBOSS_DISC%/server/all/conf/jboss-service.xml

 

新增以下相似文字:

<!--============================================================ --&gt

<!-- Scheduler Initialization 定時操作             --&gt

<!--============================================================ --&gt

 

name="jboss. piosan.util:service=Scheduler">

true

com.piosan.util.PiosanTimer

TheName,123456789

.lang.String,long

NOW

1000

-1

 

 

C. 附上PiosanTimer.java例子

/*

 * Created on -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部落格 ” ,連結:http://blog.itpub.net/10752019/viewspace-962921/,如需轉載,請註明出處,否則將追究法律責任。

相關文章