You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

vpr

Beginner

  • "vpr" is male
  • "vpr" started this thread

Posts: 30

Date of registration: May 21st 2014

  • Send private message

1

Saturday, December 20th 2014, 4:39am

Object creation syntax question

Hi, I'm having trouble converting this Java code (an example of using the Quartz scheduler library) to Jabaco code.

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;
 
public class SimpleTriggerExample {
	public static void main(String[] args) throws Exception {
 
		// Quartz 1.6.3
		// JobDetail job = new JobDetail();
		// job.setName("dummyJobName");
		// job.setJobClass(HelloJob.class);
 
		JobDetail job = JobBuilder.newJob(HelloJob.class)
			.withIdentity("dummyJobName", "group1").build();
 
                //Quartz 1.6.3
		// SimpleTrigger trigger = new SimpleTrigger();
		// trigger.setStartTime(new Date(System.currentTimeMillis() + 1000));
		// trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
		// trigger.setRepeatInterval(30000);
 
		// Trigger the job to run on the next round minute
		Trigger trigger = TriggerBuilder
			.newTrigger()
			.withIdentity("dummyTriggerName", "group1")
			.withSchedule(
				SimpleScheduleBuilder.simpleSchedule()
					.withIntervalInSeconds(5).repeatForever())
			.build();
 
		// schedule it
		Scheduler scheduler = new StdSchedulerFactory().getScheduler();
		scheduler.start();
		scheduler.scheduleJob(job, trigger);
 
	} }



The code comes from this website: http://www.mkyong.com/java/quartz-2-scheduler-tutorial/

The particular problem I'm having is expressing this in Jabaco code:


Trigger trigger = TriggerBuilder
.newTrigger()
.withIdentity("dummyTriggerName", "group1")
.withSchedule(
SimpleScheduleBuilder.simpleSchedule()
.withIntervalInSeconds(5).repeatForever())
.build();

Any ideas about how to create this trigger object properly would be appreciated :)

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

2

Sunday, December 21st 2014, 12:18pm

For me it works fine:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Public Sub main(ByJava args() As String)
  Dim job As JobDetail
  Dim jb As JobBuilder
  jb = JobBuilder.newJob(HelloJob.class)
  jb = jb.withIdentity("dummyJobName", "group1")
  job = Cast(jb.build, JobDetail)
  
  
  Dim trg As Trigger
  Dim trgb As TriggerBuilder
  trgb = TriggerBuilder.newTrigger
  trgb = trgb.withIdentity("dummyTriggerName", "group1")
  trgb = trgb.withSchedule(SimpleScheduleBuilder.simpleSchedule.withIntervalInSeconds(5).repeatForever)
  trg = Cast(trgb.build, Trigger)
  
  Dim sched As Scheduler
  Dim schedf As New StdSchedulerFactory
  sched = schedf.getScheduler
  sched.start
  sched.scheduleJob(job, trg)
End Sub


Be sure, that you have created the HelloJob.class file before. If you don't have a Java-compiler, then I have created it for you in HelloJob.zip for that case.

Also be sure, that you adding the jars
quartz-2.2.1.jar
quartz-jobs-2.2.1.jar
c3p0-0.9.1.1.jar
log4j-1.2.16.jar
slf4j-log4j12-1.6.6.jar
slf4j-api-1.6.6.jar
in your classpath.

And selecting in quartz-2.2.1.jar the files
org/quartz/JobBuilder
org/quartz/JobDetail
org/quartz/Scheduler
org/quartz/SimpleScheduleBuilder
org/quartz/Trigger
org/quartz/TriggerBuilder
org/quartz/impl/StdSchedulerFactory

Greatings
theuserbl
theuserbl has attached the following file:
  • HelloJob.zip (745 Byte - 338 times downloaded - latest: Mar 17th 2024, 5:00am)

vpr

Beginner

  • "vpr" is male
  • "vpr" started this thread

Posts: 30

Date of registration: May 21st 2014

  • Send private message

3

Sunday, December 21st 2014, 5:24pm

This is great theuserbl, thank's so much for your quick reply. I've just created a HelloJob class module and handled things in there instead of compiling a class with javac, but thanks for taking the time to do this and test it out.

I'm trying out some ideas for computer music software in Jabaco and trying to look at different timing methods for programming a step sequencer. I'm having trouble keeping things in time with the swing timer so I thought I'd look into Quartz. Interaction with the GUI seems to interrupt the Quartz scheduler though, it seems. I'll keep experimenting.

As you're active on the board at the moment I would really appreciate any help with a problem I posted a while back but haven't been able to get any assistance with and have had no luck myself in resolving. I actually have two problems I'd really like to be able to resolve, both of which are pretty essential to what I'm doing. The first of which though is here:

Beads Audio Library Question

I'll probably add the other as a reply in that thread in a while.

I really like working with Jabaco and it has taught me quite a bit about Java (having no real experience in it prior to Jabaco, save for some work in Processing). I just wish the community and the project was more active and that it was documented. Anyway, I don't want to diminish the great efforts of it creator and the kind help of those who help educate about its usage, so thanks again :)

Rate this thread
WoltLab Burning Board