Created

Jul 08, 2013

Scheduling Jobs Using Sling

Posted by Ugo Cei

The Sling Commons Scheduler Service is a Sling-provided mechanism that is used to execute jobs at predefined times–either periodically or at a set time. Is is based on the Quartz scheduling library and can therefore make use of its syntax for defining the execution times of jobs, making it possible to precisely indicate times like "at 6:32pm on every Saturday and Sunday" or "at 2:30am on the first Friday of every month". At the other end of the spectrum, a simple numeric value can be used to specify the interval–in seconds–between each execution of the job.

More information about the cron-like expressions used by Quartz can be found at http://docjar.com/docs/api/org/quartz/CronExpression.html.

Inside CQ, an OSGi component that implements the java.lang.Runnable or the org.quartz.Job interface will be started if it has a configuration property called either scheduler.expression (whose value must be a cron expression) or scheduler.period (whose value must be a number of seconds).

Thanks to OSGi annotations, one can simply define a scheduled jobs using code like the following:

@Component(immediate=true)
@Service(interface="java.lang.Runnable")
@Property(name="scheduler.expression" value="0 0/10 * * * ?", type="String")
public class MyScheduledJob implements java.lang.Runnable {
  public void run() {
    // code to execute goes here
  }
}

Notice that we specified "immediate=true" in the @Component declaration. This makes sure that the component is activated immediately when the bundle is registered, a thing which is necessary for it to be properly invoked by the scheduler.

The method run() of the above component will be executed every hour at 0, 10, 20, 30, 40, and 50 minutes, zero seconds. If we had simply wanted an execution every 10 minutes, we could have used the following annotation instead:

@Property(name="scheduler.period" value="600", type="Long")

Concurrent execution of the job, which might happen if the previous execution has not yet finished when a new one is scheduled, can be prevented by setting the scheduler.concurrent property to false:

@Property(name="scheduler.concurrent", propertyPrivate=true, boolValue=false)

In a real-world scenario, we might want to be able to specify the execution time using the CQ5 Web Console. To do this, we need to modify the declaration of the property as follows:

@Component(immediate=true, metatype=true)

COMMENTS

  • By APK - 10:23 AM on May 31, 2014   Reply
    Many Thanks.
  • By visit the website - 8:33 AM on Jun 01, 2014   Reply
    Sling-provided mechanism that is used to execute jobs at predefined times–either periodically or at a set time. Is is based on the Quartz scheduling library and can therefore make use of its syntax for defining the execution times of jobs, making it possible to precisely indicate times like "at 6:32pm on every Saturday and Sunday" or "at 2:30am
    • By unlock her legs reviews - 12:34 PM on Jun 01, 2014   Reply
      we might want to be able to specify the execution time using the CQ5 Web Console. To do this, we need to modify the declaration of the property as follows:
      • By http://www.grandcityproperties.com/ - 5:59 PM on Jun 01, 2014   Reply


        This is exactly what I was looking for. Thanks for sharing this great article! That is very interesting Smile I love reading and I am always searching for informative information like this!
        • By tidung.net - 4:59 AM on Jun 02, 2014   Reply
          Thanks.
          • By www: rebelmouse.com - 5:42 AM on Jun 03, 2014   Reply
            Concurrent execution of the job, which might happen if the previous execution has not yet finished when a new one is scheduled,
            • By best garcinia cambogia brand - 5:34 AM on Jun 15, 2014   Reply
              Concurrent execution of the job, which might happen if the previous execution has not yet finished when a new one is scheduled, can be prevented by setting the scheduler.concurrent property to false:
            • By High Pr Backlinks service - 7:48 AM on Jun 03, 2014   Reply
              After the standards are first proposed, they undergo a 45-day public review period before an official review and final consideration. These standards also reflect EPA's updated production projections, which are informed by an assessment of the biofuels market, the agency said.
              • By hargaandroid.com - 8:54 AM on Jun 03, 2014   Reply
                Many Thanks.
                • By visit website - 6:34 PM on Jun 03, 2014   Reply


                  Thanks for sharing this interesting blog with us.My pleasure to being here on your blog..I wanna come beck here for new post from your site.
                  • By apk - 11:16 AM on Jun 06, 2014   Reply
                    Thanks.
                    • By http://topicalvitamincserum.com/ - 10:19 AM on Jun 07, 2014   Reply
                      In a real-world scenario, we might want to be able to specify the execution time using the CQ5 Web Console. To do this,
                      • By http://newdehumidifierreviews.com/ - 11:44 AM on Jun 07, 2014   Reply
                        To be honest. I haven't seen a good post like this in a year now. And seeing this post now, ahh, it really pleasures me. Thanks a lot for this post.
                        • By link building service - 7:34 AM on Jun 28, 2014   Reply


                          I also benefit from learning the assessments, but learn that alot of people ought to stay on essay to try and add worth in the direction of the authentic weblog release.
                          • By link building service - 7:35 AM on Jun 28, 2014   Reply


                            I also benefit from learning the assessments, but learn that alot of people ought to stay on essay to try and add worth in the direction of the authentic weblog release.
                          • By Jasa SEO - 11:29 AM on Jun 08, 2014   Reply
                            Many Thanks.
                            • By free minecraft premium account - 11:44 AM on Jun 08, 2014   Reply


                              Thanks for sharing this interesting blog with us.My pleasure to being here on your blog..I wanna come beck here for new post from your site.
                              • By Tattoos - 4:36 PM on Jun 08, 2014   Reply
                                Many Thanks.
                                • By step up height - 5:14 AM on Jun 09, 2014   Reply
                                  i am very happy with step up height because it can return my confidence and personality.Thanku step up
                                  • By check it out - 9:02 AM on Jun 09, 2014   Reply
                                    Actual product packaging and materials may contain more and different information than what is shown on our website. We recommend that you do not rely solely on the information presented and that you always read labels, warnings, and directions before using or consuming a product. Please see our full disclaimer below.
                                    • By Commentmaster - 8:20 PM on Jun 09, 2014   Reply
                                      Actually get pleasure from this fantastic submit that you've got provided for people like us. Fantastic web page along with a wonderful topic also i really find amazed to learn to read this. Its fantastic.
                                      • By marqueelightshop - 5:58 AM on Jun 10, 2014   Reply
                                        Sling-provided mechanism that is used to execute jobs at predefined times–either periodically or at a set time. Is is based on the Quartz scheduling library and can therefore make use of its syntax for defining the execution times of jobs, making it possible to precisely indicate times like "at 6:32pm on every Saturday and Sunday
                                        • By c serum amazon - 8:12 AM on Jun 10, 2014   Reply
                                          Sling-provided mechanism that is used to execute jobs at predefined times–either periodically or at a set time. Is is based on the Quartz scheduling library and can therefore make use of its syntax for defining the execution times of jobs, making it possible to precisely indicate times like "at 6:32pm on every Saturday and
                                          • By anti aging fitness workout - 11:17 AM on Jun 10, 2014   Reply
                                            In a real-world scenario, we might want to be able to specify the execution time using the CQ5 Web Console. To do this, we need to modify the declaration of the property as follows:
                                            • By step up height increaser - 12:17 PM on Jun 11, 2014   Reply
                                              Really i am impressed from this post. The person who created this post is a genius and knows how to keep the readers connected.
                                              • By male enlargement pills - 2:43 PM on Jun 11, 2014   Reply
                                                Male Enhancement Pills 100% SAFE & NATURAL, Would you like Bigger, Harder Erections & More Intense Orgasms? Try Male Extra Risk Free Today .....
                                                When it comes to the junk in your (swimming) trunks, size does matter - or at least it does to male athletes.
                                                A recent study has revealed that the bigger your package, the more highly regarded you will be in the locker room.
                                                Not only are men with larger penises 'idolised' by their teammates, but they are often central to team camaraderie and the focus of 'banter'.
                                                • By learn more about this video - 6:00 AM on Jun 14, 2014   Reply
                                                  When it comes to the junk in your (swimming) trunks, size does matter - or at least it does to male athletes.
                                                  A recent study has revealed that the bigger your package, the more highly regarded you will be in the locker room.
                                                  Not only are men wit
                                                • By male enlargement pills - 2:55 PM on Jun 11, 2014   Reply
                                                  Male Enhancement Pills 100% SAFE & NATURAL, Would you like Bigger, Harder Erections & More Intense Orgasms? Try Male Extra Risk Free Today .....The analyze, which explored masculinity in sport and how sportsmen interact with their bodies, was carried available by Dr Christopher Morriss-Roberts, in his PhD research at the actual University of Brighton.
                                                  The size of other men's penis when in the homosocial (same-sex) environment "helped specific sporting males climb up a new social hierarchy of importance", notices Dr. Morriss-Roberts.

                                                  • By penis enlargement pills - 3:03 PM on Jun 11, 2014   Reply
                                                    Male Enhancement Pills 100% SAFE & NATURAL, Would you like Bigger, Harder Erections & More Intense Orgasms? Try Male Extra Risk Free Today .....He studied the actual behaviour of eight athletes, as well as four self-identified gay men and also four self-identified straight men.
                                                    The experience of sizing each other up occurs in spite of sexuality and type of hobby, he notes. "All participants noted that they can looked at each other’s cocks inside locker room. "Although bigger isn't always better. Doctor. Morriss-Roberts noted that if a man's penis was very large, teammates often doubted the power to use it properly - something that will need to be proven.
                                                    "There was an understanding of which as an athlete you would have to be sexually active; it added substantially to masculine capital, and the qualities associated with a sporting hegemonic mate, " they says.
                                                    • By step up height increaser - 4:30 AM on Jun 12, 2014   Reply
                                                      Just like others, I am also happy and excited after using Stepup Height Growth. I don't have words to Thank you for the change I have got in my personality after using your product.
                                                      • By col3neg Italy - 4:50 AM on Jun 12, 2014   Reply
                                                        you have good chances to find even the latest episodes as they are uploaded regularly.There are a few official websites that sell each episode download at a particular fee
                                                        • By GO here! - 7:28 AM on Jun 15, 2014   Reply
                                                          I am also happy and excited after using Stepup Height Growth. I don't have words to Thank you for the change I have got in my personality after using your product.
                                                          • By venus factor - 11:05 AM on Jun 15, 2014   Reply
                                                            Your good knowledge and kindness in playing with all the pieces was very useful. I don’t know what I would have done if I had not encountered such a step like this.
                                                            • By This Site - 8:26 PM on Jun 16, 2014   Reply
                                                              Your post is quite informative for me!
                                                              • By manichiura - 5:24 AM on Jun 17, 2014   Reply
                                                                Toate datele transmise de catre producatorii sau distribuitorii autorizati pot fi modificate fara instiintare prealabila si nu constituie obligativitate contractuala, aceleasi conditii se aplica si pretului produsului .
                                                                • By Obat Keputihan - 9:28 AM on Jun 22, 2014   Reply
                                                                  Many Thanks.
                                                                  • By the bv miracle - 1:49 PM on Jun 23, 2014   Reply
                                                                    The Sling Commons Scheduler Service is a Sling-provided mechanism that is used to execute jobs at predefined times–either periodically or at a set time. Is is based on the Quartz scheduling library and can therefore make use of its syntax for
                                                                    • By progettareilbagno.it - 12:23 PM on Jun 25, 2014   Reply
                                                                      The Sling Commons Scheduler Service is a Sling-provided mechanism that is used to execute jobs at predefined times–either periodically or at a set time. Is is based on the Quartz scheduling library and can therefore make use of its syntax for defining the execution times of jobs, making it possible to precisely indicate times like "at 6:32pm on every Saturday and Sunday
                                                                      • By Buy high pagerank Backlinks - 3:56 PM on Jun 29, 2014   Reply
                                                                        which is wholeness, incredibility, strength, love, joy fun and all that's worthwhile.
                                                                        • By sportdog sdf-100a - 5:53 AM on Jun 30, 2014   Reply
                                                                          OK had refused the assistance of FEMA, total so that they could rebuild their acknowledge houses minus the bureaucracy or inefficiency of the federal governm...
                                                                          • By Top Weight Loss Pills - 8:30 AM on Jul 02, 2014   Reply
                                                                            Melissa says that she gets “lost not only pounds, yet guilt. ” With the confidence of Heidi, Chris, and the girl entire community, shhe completed the run, saying “I had to complete it, to heal. ”
                                                                          • By Best Weight Loss Pills - 8:43 AM on Jul 02, 2014   Reply
                                                                            After an additional commercial break, when Extreme Weight loss returns, we get to see Melissa and learn how much weight she has lost as a whole. She is dressed in an elegant black pantsuit with a violet shirt.
                                                                          • By cara daftar di bisnis libertagia - 1:34 PM on Jul 02, 2014   Reply
                                                                            Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.
                                                                            • By airul - 10:50 AM on Jul 06, 2014   Reply
                                                                              Thanks.
                                                                              • By restore my vision today review - 6:39 AM on Jul 08, 2014   Reply
                                                                                Written for consumers by a consumer, this fan site includes a fun and informative Restore My Vision Today review, ebook FAQ, and PDF download guide that provides an insider's look at the program and answers frequently asked questions about Dr. Sen and Samantha Pearson's unique and highly popular vision training guide.
                                                                                • By the venus factor diet reviews - 7:19 AM on Jul 12, 2014   Reply
                                                                                  Of Conversational Hypnosis PDF book and hypnotic training system that teaches you effective techniques for influencing and persuading people to give you exactly what you want during everyday conversations.
                                                                                  • By menu buka puasa - 8:31 AM on Jul 15, 2014   Reply
                                                                                    i really to say nice tools from adobe. i like it.
                                                                                    • By Fast url opener - 5:41 PM on Jul 15, 2014   Reply
                                                                                      Really appreciate this wonderful post that you have provided for us.Great site and a great topic as well i really get amazed to read this. Its really good.
                                                                                      • By Crystal X Asli - 2:32 AM on Jul 17, 2014   Reply
                                                                                        i really to say nice tools from adobe. i like it.
                                                                                        • By duplichecker - 6:59 PM on Jul 18, 2014   Reply
                                                                                          pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon.
                                                                                          • By mansion88 - 4:00 AM on Jul 19, 2014   Reply
                                                                                            Initially there were fears the move will not be made after M88 Conte decided to leave Juventus, but in fact this was the deal BLD M88 Turin club decided earlier (also part caused disagreement this coach). Shortly after Massimiliano Allegri was appointed to the empty seat instead of Conte, Juve BLD M88 quick decisions as a case moves to reassure public opinion.
                                                                                            • By Online free movies - 9:53 AM on Jul 22, 2014   Reply
                                                                                              I was very impressed by this post, this site has always been pleasant news Thank you very much for such an interesting post, and I meet them more often then I visited this site.
                                                                                              • By http://chordgitarakustik.blogspot.com - 1:38 PM on Jul 22, 2014   Reply
                                                                                                Really appreciate this wonderful post that you have provided for us.Great site and a great topic as well i really get amazed to read this. Its really good.
                                                                                                • By Crystal X Asli - 6:46 PM on Jul 22, 2014   Reply
                                                                                                  i really to say nice tools from adobe. i like it.
                                                                                                  • By get rid of herpes review - 6:22 AM on Jul 24, 2014   Reply
                                                                                                    Below you will find the important facts and figures I feel every consumer should know surrounding Sarah Wilcox's Get Rid Of Herpes book and complete guide to treating herpes naturally, safely, and effectively from home.
                                                                                                    • By asadailkhatri - 9:07 AM on Aug 03, 2014   Reply
                                                                                                      At the end of the project we hope to produce resources that will be meaningful and useful to the sector and inform the building of collaborations around the principals of fairness and equality.<a href="https://www.facebook.com/Lunatik.promo.code">Lunatik promo code</a>
                                                                                                      • By Cheap Price blog comments - 6:05 AM on Aug 19, 2014   Reply
                                                                                                        Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
                                                                                                      • By Lunatik promo code - 11:46 AM on Aug 03, 2014   Reply
                                                                                                        At the end of the project we hope to produce resources that will be meaningful and useful to the sector and inform the building of collaborations around the principals of fairness and equality.
                                                                                                        • By High Pr Backlinks service - 12:07 PM on Aug 07, 2014   Reply
                                                                                                          I have great quality High PR do-follow manually blog comments service increase your rank within few days guarantee All low OBL links i will give you all links just in 5$
                                                                                                          • By High Pr Blog comments service - 12:08 PM on Aug 07, 2014   Reply
                                                                                                            I have great quality High PR do-follow manually blog comments service increase your rank within few days guarantee All low OBL links i will give you all links just in 5$
                                                                                                            • By ps3 code gta 5 - 1:57 PM on Aug 10, 2014   Reply
                                                                                                              Excellent and very exciting site. Love to watch. Keep Rocking.
                                                                                                              • By emulateur telechargement - 9:41 PM on Aug 10, 2014   Reply
                                                                                                                This content is written very well. Your use of formatting when making your points makes your observations very clear and easy to understand. Thank you.
                                                                                                                • By instant car insurance quotes - 9:56 AM on Aug 12, 2014   Reply
                                                                                                                  Our website works hard to meet your requirements and provide you with instant rates for comparison, obtaining an affordable quote on protection for your auto. Each tip could save you extra money, take few minutes, check out our saving tips.
                                                                                                                  • By compare auto insurance - 12:13 PM on Aug 14, 2014   Reply
                                                                                                                    The important thing is how to get quotes online on cheap car insurance. In most cases, it's free to get a quote by zip code. Finding auto insurance quotes from top insurers become more easy because comparison by ZIP Code allows drivers to seek auto coverage policies and compare them.
                                                                                                                    • By website design - 9:00 AM on Aug 17, 2014   Reply
                                                                                                                      My spouse and I absolutely love your blog and find almost all of your post’s to be just what I’m looking for. can you offer guest writers to write content for you? I wouldn’t mind producing a post or elaborating on a number of the subjects you write concerning here. Again, awesome weblog!
                                                                                                                      • By Bulk SMS in Nigeria - 2:25 PM on Aug 18, 2014   Reply
                                                                                                                        This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value. Im glad to have found this post as its such an interesting one! I am always on the lookout for quality posts and articles so i suppose im lucky to have found this! I hope you will be adding more in the future...
                                                                                                                        • By samsung galaxy s5 case - 12:39 AM on Aug 19, 2014   Reply
                                                                                                                          Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
                                                                                                                          • By venue finder - 2:00 PM on Aug 19, 2014   Reply
                                                                                                                            I simply wanted to thank you so much again. I am not sure the things that I might have gone through without the type of hints revealed by you regarding that situation.
                                                                                                                            • By Agen Bola Terpercaya - 3:19 PM on Aug 19, 2014   Reply
                                                                                                                              I’ve been searching for some decent stuff on the subject and haven't had any luck up until this point, You just got a new biggest fan!..
                                                                                                                              • By Nootropics - 4:29 PM on Aug 20, 2014   Reply
                                                                                                                                It’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read!
                                                                                                                                • By rancangan desain rumah - 8:27 AM on Aug 21, 2014   Reply
                                                                                                                                  You truly did more than visitors’ expectations. Thank you for rendering these helpful, trusted, edifying and in addition cool thoughts on the topic.
                                                                                                                                  • By homeowner insurance quotes - 12:36 PM on Aug 22, 2014   Reply
                                                                                                                                    The cheapest way to save on policy getting such coverage for home loan pre-approval, if it needs for financial company or if you are buying a new house. If you're just looking for a cheap quote on house protection, as a homeowner, for your current home, check quotes from leading homeowners insurance companies that fits your needs and budget. Maximize your savings, choose the cheapest coverage, compare quotes through over 2000 agents and trusted companies of the United States.
                                                                                                                                    • By homeowner insurance quotes - 12:36 PM on Aug 22, 2014   Reply
                                                                                                                                      The cheapest way to save on policy getting such coverage for home loan pre-approval, if it needs for financial company or if you are buying a new house. If you're just looking for a cheap quote on house protection, as a homeowner, for your current home, check quotes from leading homeowners insurance companies that fits your needs and budget. Maximize your savings, choose the cheapest coverage, compare quotes through over 2000 agents and trusted companies of the United States.
                                                                                                                                      • By compare auto quotes - 4:50 PM on Aug 22, 2014   Reply
                                                                                                                                        Compare and get free quotes on auto insurance online by ZIP code. If you are interested in comparison of auto insurance, and have not yet decided on choice of company and insurance program, we will help you to compare and buy auto insurance on the best terms.
                                                                                                                                        • cate times like "at 6:32pm on every Saturday and Sunday" or "at 2:30am on the first Friday of every month". At the
                                                                                                                                          • Service is a Sling-provided mechanism that is used to execute jobs at predefined times–either periodically or at a

                                                                                                                                            ADD A COMMENT