Implementing Listeners in the quartz_jobs.xml FileAll the examples in this chapter have shown how to set up listeners using a programmatic approach. This chapter wouldn't be complete if we didn't provide at least an example of configuring a listener using a declarative approach with the quartz_jobs.xml file. Starting with Quartz 1.5, you are able to specify listeners in the job-definition file, otherwise known as the quartz_jobs.xml file. Listing 7.14 shows an example of using a global listener. Listing 7.14. Quartz Listeners Can Be Implemented with the quartz_jobs.xml File
You see in Listing 7.14 the additional <job-listener> element with the two required attributes: <job-listener The class-name property identifies the fully qualified name of the listener class. The name attribute assigns a logical name to the listener used in the <job-detail> element. The next step is to define a <job-listener-ref> element in the <job-detail> element in the same file for each job that you want the listener on. The value of the element must match the name property of one of the defined <job-listener> elements in the file. After you have done that, make sure you've configured the Scheduler to use the JobInitializationPlugin by setting the properties in the quartz.properties file. Quartz plug-ins are discussed in detail in the next chapter. For now, just add the following lines to your quartz.properties file: org.quartz.plugin.jobInitializer.class = Then name your XML file quartz_jobs.xml and put the file in your classpath.
|
Wednesday, January 6, 2010
Implementing Listeners in the quartz_jobs.xml File
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment