2 Replies Latest reply on May 25, 2009 1:05 AM by swd847

    Reinitialising @startup class

    sunsear

      We're running a site that is loaded with new data once every day. A part of this data is a property bundle that comes from the database. It is currently loaded using @startup combined with a Property domain class annotated with @entity.


      After the new data is available, I'd like to re-initialize the property collection. Is there some way of telling Seam that it should do this?


      Love to hear from you,


      Martin

        • 1. Re: Reinitialising @startup class
          walterjwhite
          Hi Martin,

          It depends on exactly what you want to do.  It seems to me that this would best work with the Quartz schedule.  Run a daily cron job that loads this data.

          There are good examples on the Seam website for Quartz Cron jobs:
          [Seam&Quartz=>http://docs.jboss.com/seam/2.1.2.CR2/reference/en-US/html/jms.html#d0e21218]


          That shows you how to use Quartz with Seam.  When the component is started, you could create the cron job.  You will need to make that bean dependent on quartzDispatcher in order for it to work then:



          `@Startup(depends = "quartzDispatcher")

          public DataLoader()
          {
            loadData(null, "* * * * *", null);// read what expression runs daily, you can configure the time of day and whatnot too
          }

          @Asynchronous

              public QuartzTriggerHandle loadData(@Expiration Date when,

                                           @IntervalCron String cronl,

                                           @FinalExpiration Date endDate)
          {
            doStuff();
            return(null);// Seam intercepts this method call and returns a QuartzTriggerHandle ...
          }`




          Walter
          • 2. Re: Reinitialising @startup class
            swd847

            try


            Contexts.removeFromAllContexts("componentName");
            Component.getInstance("componentName");