This tutorial is an advanced guide to Quartz plugin. It includes a quick presentation on Quartz plugin, the task artefact, Quartz Grails plugin Meta data, plugin events and application reloading. The tutorial begins with a section of introduction to Quartz plugin. It presents how to use a Quartz plugin and what all is inside the Quartz plugin. Following is a Task section. It includes the Grails artefact, the task artefact and talks about how it was created by the quartz plugin to model the idea of a job.
The next section is on Quartz Grails plugin Meta data. It involves the Quartz plugin Meta data and what it does with spring, dynamic methods and application context. The last section of the tutorial talks about the plugin events and application reloading. It includes the plugin events and application reloading, a plugin can listen to events on change, configchange and shutdown.
3. 1.Quick presentation on how to use
2. TaskArtifact
3.Bootstrap of Plugin
4.QuartzGrailsPlugin MetaData
5.Plugin Events and Application Reloading
Agenda
5. ● Artefact isused to refer to a Groovy file that fulfils a certain concept.
–Controller, Bootstrap, Codec, Service, Domain,TagLib
● For each artefact type, the GrailsApplication class provides dynamic
methods to access the artefacts of that
–grailsApplication.getControllerClasses()
–Dynamic finders onDomain
What is Grails Artefact?
6. ● Created by Quartz-plugin to model the idea of a job
● Created TaskArtefactHandler class byextending
ArtefactHandlerAdapter class
● Provided implementation for boolean isArtefactClass()method
● Made Grails aware of the new Artifact as
–def artefacts =[newTaskArtefactHandler()]
Task Artefact
7. Now the statements like this can be used
application.taskClasses.each{
GrailsTaskClass tc ->
//------------------
}
Task Artefact Cond...
8. ● Do WithSpring
● Do With DynamicMethods
● Do WithApplication
Context
QuartzGrailsPlugin MetaData
9. ● participation in the runtime configuration of
Grails’ underlying SpringApplicationContext
–creating beans, binding hibernate session
etc
Do With Spring
10. ● Merges DefaultQuartzConfig and QuartzConfiginto
appications main config file
● Bind Hibernate Sessionto each Job's thread using
SessionBinderJobListenerclass
● Create bean quartzScheduler which isan instance of
SchedulerFactoryBean
Do With Spring Cond...
11. ● Executed after the construction of the
ApplicationContext.
– Usage example - provide new behavior to Grails
classes
Do With Dynamic Methods
12. ● Injects the following static methods to TaskArtefact classes -
–Schedule
–TriggerNow
–RemoveJob
● e.g. FileUsageMonitorJob.triggerNow()
● calling theInstead of injecting qartzScheduler bean and
triggerNow with jobdetails
Do With Dynamic Methods cond...
13. ● Executed after Grails’ ApplicationContext has been
constructed
● Thisclosure ispassed applicationContext asfirst arg
–Add all jobs to quartzScheduler
–Schedules job for each trigger
Do With Application Context
14. ● A plugin can essentially listen for three core events:
● onChange
● onConfigChange
● onShutdown
Plugin Events and Application Reloading
15. ● Changes to resources being watched by the plugin
● def watchedResources =[”...**/*Job.groovy”]
● Quartz plugin creates new bean(after removing if it
is already there) and register all the triggers for
each changed jobclass.
On Change
17. Contact us
Our Office
Client
Location
Click Here To Know More!
Have more queries on Grails?
Talk to our GRAILS experts
Now!
Talk To Our Experts
Here's how the world's
biggest Grails team is
building enterprise
applications on Grails!