English 中文(简体)
• 如何在JBOSS4.3内建立一个与EJB 3.0的JOB
原标题:How create a JOB with EJB 3.0 inside JBOSS 4.3

我怎么能够创造出一份每秒6秒的工作,而这项工作在提出申请时就自动开始?

目前,我有这一类人使用时间,但这一进程在开始部署时不会自动启动。

所有这一切,只有EJBs, 在JBos4.3和没有WAR的欧洲复兴开发银行,只有EJBs

@Stateless
public class MyJobBean implements MyJob {
private static final long EJECUTION_INTERVAL=6000;
@Resource
private TimerService ts;
@PostConstruct // This not work in deploy, only when somebody calls the EJB
public void init() { 
    System.out.println("Post Constructor Method init() Invoked"); 
    ts.createTimer(EJECUTION_INTERVAL, null);
}
@Timeout // Fired by the timer 
public void myJOBProcess(Timer timer) {
    System.out.println("the job was invoked");

    ts.createTimer(EJECUTION_INTERVAL, null); //create another future ejecution
}
@PreDestroy
public void tidyUp() {
    System.out.println("Canceling scheduled Timers");
    for (Object obj : ts.getTimers()) {
        Timer timer = (Timer)obj;
        timer.cancel();
        System.out.println("Timer Canceled");
    }   
}
}

预支

问题回答

在JBoss,你可以使用以@service为定义的甲基溴。 如果有<代码>的开端()方法,在申请启动时将采用这一方法。

Servlet listeners or load-on-startup servlets were the only javaee-portable way to autorun some code on deploy until EJB 3.1 with @Schedule annotation.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签