Building a 'Job Monitoring' View

Hello,

I am currently trying to build a ‘Job Monitoring’ View using Quartz.
But I am experiencing some problems.

My first approach was simple: Just let the JobsView implement JobListener and add it to the scheduler.
(scheduler.getListenerManager().addJobListener(this):wink:
This is not possible, since the newly added instance overwrites the old one.

Now I tried it with a GlobalListener, defined in the quartz.properties and Broadcast the event to all listeners and then push the changes to the view using the EventBus.

This wont work either, because the BroadcastListener can’t get the CurrentUI.

public static DashboardEventBus getDashboardEventbus() { return ((DashboardUI) getCurrent()).dashboardEventbus; } returns Null and causes a NullPointerException.

To clarify it a bit:

class DashboardUI extends UI implements Broadcaster.BroadcastListener {

init() ....

@Override
public void broadcastTest(String msg) {
    DashboardEventBus.post(new DashboardEvent.Test(msg)); --- NullPointer happens here
}

@Subscribe
public void receiveTest(Final DashboardEvent.Test event) {
   ....
}

}
public class SchedulerGlobalListener implements JobListener {
//Gets initialized by Quartz.properties (org.quartz.jobListener.SchedulerGlobalListener.class = ... )
@Overwrite
public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {
    Broadcaster.broadcastTest("Job was executed ");
}
}

I hope my post isn’t gibberish to you guys.
Thanks for any tips and pointers.

Would it be possible to have the EventBus in it’s own Singleton from which the EventBus is gotten for both the UI and scheduler?

[code]
public class DashboardEventBus {
private EventBus eventBus = new EventBus();
private static DashboardEventBus instance;

protected DashboardEventBus() {}

public static DasboardEventBus getInstance() {
if(instance == null) {
instance = new DashboardEventBus();
}
return instance;
}
public static EventBus getDashboardEventbus() {
return getInstance().eventBus;
}
}
[/code]Then the work of the UI would be to register itself on init and unregister on close.

[code]
class DashbboardUI extends UI {
…init…{
DashboardEventBus.getDashboardEventBus().register(this);
}
…close() {
DashboardEventBus.getDashboardEventBus().unregister(this);
}

@Subscribe
public void recieve(…) {…}
}
[/code]The scheduler would then just need to post and all UI’s listening would get the event:

DashboardEventBus.getDashboardEventBus().post(new DashboardEvent.Test(msg));