Skip to content
Snippets Groups Projects
Commit 1228e69c authored by tonschnoer's avatar tonschnoer
Browse files

add comments, reformat source

parent 6f71228d
No related branches found
No related tags found
No related merge requests found
package de.kmt.ndr;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.annotation.Resource;
......@@ -12,58 +11,62 @@ import jakarta.ejb.Timer;
import jakarta.ejb.TimerConfig;
import jakarta.ejb.TimerService;
@Singleton
@Startup
public class Main {
@Resource
private TimerService timerService;
private void _setUP() {
}
@Timeout
public void scheduler(Timer timer) {
try {
_setUP();
System.out.println("Timer fired.");
}
catch(Exception _ex) {
}
}
@PostConstruct
public void initialize() {
try {
_setUP();
ScheduleExpression se = new ScheduleExpression();
se.hour("*").minute("0/1").second("0/1");
timerService.createCalendarTimer(se, new TimerConfig("Cleanup Service scheduled at ", false));
}
catch(Exception _ex) {
}
}
@PreDestroy
public void stop() {
try {
_setUP();
for (Timer timer : timerService.getTimers()) {
timer.cancel();
}
}
catch(Exception _ex) {
}
}
}
@Resource
private TimerService timerService;
private void _setUP() {
}
// ***********************************************************************************
// triggers every time when timer fires
// ***********************************************************************************
@Timeout
public void scheduler(Timer timer) {
try {
_setUP();
System.out.println("Timer fired.");
} catch (Exception _ex) {
}
}
// ***********************************************************************************
// OnStart; configures timer
// ***********************************************************************************
@PostConstruct
public void initialize() {
try {
_setUP();
ScheduleExpression se = new ScheduleExpression();
se.hour("*").minute("0/1").second("0/1");
timerService.createCalendarTimer(se, new TimerConfig("Cleanup Service scheduled at ", false));
} catch (Exception _ex) {
}
}
// ***********************************************************************************
// OnStop; destroys timer
// ***********************************************************************************
@PreDestroy
public void stop() {
try {
_setUP();
for (Timer timer : timerService.getTimers()) {
timer.cancel();
}
} catch (Exception _ex) {
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment