Load the Class method when JBoss is started (Timed)

zhaozj2021-02-17  73

One. Load the Class method during JBoss startup

A. Write Class, you want to import org.jboss.varia.scheduler.schedulable package, this package is placed in% jboss_disc% / server / all / lib directory, at the same time / ALL / LIB directory in order to load.

B. Modify% jboss_disc% / server / all / conf / jboss-service.xml file

Add a following text:

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

True

com.piosan.util.piosantimer

Thename, 123456789

java.lang.string, long

1000

- 1

C. Attachment Piosantimer.java source code example

/ *

* 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);

}

/ **

This function will be performed automatically.

* /

Public Void Perform (Date now, long remainingrepetitions)

{

System.out.println ("Perform, now:" Now

", RemainingRepetitions:" RemainingRepetitions

", Name:" Name ", Value:" value);

}

}

转载请注明原文地址:https://www.9cbs.com/read-28816.html

New Post(0)