Package org.quartz

Examples of org.quartz.JobListener


      return scheduler_.getGlobalJobListeners();
   }

   public JobListener getGlobalJobListener(String name) throws Exception
   {
      JobListener jlistener;
      List listener = scheduler_.getGlobalJobListeners();
      ListIterator iterator = listener.listIterator();
      while (iterator.hasNext())
      {
         jlistener = (JobListener)iterator.next();
         if (jlistener.getName().equals(name))
         {
            return jlistener;
         }
      }
      return null;
View Full Code Here


      return null;
   }

   public boolean removeGlobalJobListener(String name) throws Exception
   {
      JobListener jlistener = getGlobalJobListener(name);
      return scheduler_.removeGlobalJobListener(jlistener);
   }
View Full Code Here

      return scheduler_.getGlobalJobListeners();
   }

   public JobListener getGlobalJobListener(String name) throws Exception
   {
      JobListener jlistener;
      List listener = scheduler_.getGlobalJobListeners();
      ListIterator iterator = listener.listIterator();
      while (iterator.hasNext())
      {
         jlistener = (JobListener)iterator.next();
         if (jlistener.getName().equals(name))
         {
            return jlistener;
         }
      }
      return null;
View Full Code Here

      return jlist;
   }

   public void addGlobalJobListener(ComponentPlugin plugin) throws Exception
   {
      JobListener jl = (JobListener)plugin;
      try
      {
         scheduler_.getListenerManager().addJobListener(jl);
      }
      catch (Exception e)
      {
         LOG.warn("Could not add the global job listener (" + jl.getName() + ") defined in the plugin "
            + plugin.getName() + " : " + e.getMessage());
      }
   }
View Full Code Here

      return scheduler_.getListenerManager().removeJobListener(name);
   }

   public void addJobListener(AddJobListenerComponentPlugin plugin) throws Exception
   {
      JobListener jl = (JobListener)plugin;
      try
      {
         List<Matcher<JobKey>> matchers = null;
         if (plugin.getKeys() != null)
         {
            matchers = new ArrayList<Matcher<JobKey>>();
            for (org.exoplatform.services.scheduler.JobKey key : plugin.getKeys())
            {
               matchers.add(KeyMatcher.keyEquals(JobKey.jobKey(key.getName(), getGroupName(key.getGroup()))));
            }
         }
         scheduler_.getListenerManager().addJobListener(jl, matchers);
      }
      catch (Exception e)
      {
         LOG.warn("Could not add the job listener (" + jl.getName() + ") defined in the plugin " + plugin.getName()
            + " : " + e.getMessage());
      }
   }
View Full Code Here

   }

   public JobListener getGlobalJobListener(String name) throws Exception
   {
      List listener;
      JobListener jlistener;
      listener = scheduler_.getGlobalJobListeners();
      ListIterator iterator = listener.listIterator();
      while (iterator.hasNext())
      {
         jlistener = (JobListener)iterator.next();
         if (jlistener.getName().equals(name))
         {
            return jlistener;
         }
      }
      return null;
View Full Code Here

      return null;
   }

   public boolean removeGlobalJobListener(String name) throws Exception
   {
      JobListener jlistener = getGlobalJobListener(name);
      boolean b = scheduler_.removeGlobalJobListener(jlistener);
      return b;
   }
View Full Code Here

   {
      // ---------getAllGlobalJobListener
      List<JobListener> jobListenerCol = service_.getAllGlobalJobListener();
      assertEquals("expect 1 GlobalJobListener is found", 1, jobListenerCol.size());
      /* -----2 joblistener------------- */
      JobListener jcontext = service_.getGlobalJobListener("JobContextConfigListener");
      assertTrue("exepect found 'JobContextConfigListenner'", jcontext != null
         && jcontext.getName().equals("JobContextConfigListener"));
      hasObjectInCollection(jcontext, jobListenerCol, new JobListenerComparator());
      // --------------remove JobContextConfigListenner of SchedulerSerice-------
      boolean b = service_.removeGlobalJobListener(jcontext.getName());
      jcontext = service_.getGlobalJobListener("JobContextConfigListener");
      assertTrue("expect JobContextConfigListenner is removed", b && jcontext == null);
      jobListenerCol = service_.getAllGlobalJobListener();
      assertEquals("expect 1 job listenner is found", 0, jobListenerCol.size());

      // -----Test global trigger listener
      List<TriggerListener> triggerListenerCol = service_.getAllGlobalTriggerListener();
      assertEquals("expect no global trigger listener is found", 0, triggerListenerCol.size());
      /* ----------add TriggerListenner--- */
      service_.addGlobalTriggerListener(new GlobalTriggerListener());
      // ------getAllTriggerListener---
      TriggerListener globalTriggerListener = service_.getGlobalTriggerListener("GlobalTriggerListener");
      assertTrue("expect 'GlobalTriggerListener' is found", globalTriggerListener != null
         && globalTriggerListener.getName().equals("GlobalTriggerListener"));
      triggerListenerCol = service_.getAllGlobalTriggerListener();
      assertEquals("expect 1 trigger listenner is found", 1, triggerListenerCol.size());
      hasObjectInCollection(globalTriggerListener, triggerListenerCol, new TriggerListenerComparator());
      // ----------------remove GlobalTriggerListener
      b = service_.removeGlobaTriggerListener(globalTriggerListener.getName());
      assertTrue("expect GlobalTriggerListener is removed", b);
      triggerListenerCol = service_.getAllGlobalTriggerListener();
      assertEquals("expect no trigger listenner is found", 0, triggerListenerCol.size());

      // --------------Test non global Job Listener
      jobListenerCol = service_.getAllJobListener();
      assertEquals("expect no non global job listener is found", 0, jobListenerCol.size());
      // ----add 2 Non Global Job Listenner----
      service_.addGlobalJobListener(new GlobalJobListener());
      service_.addJobListener(new FirstJobListener());
      service_.addJobListener(new SecondJobListener());
      JobListener globalListener = service_.getGlobalJobListener("GlobalJobListener");
      JobListener joblistener1st = service_.getJobListener("FirstJobListener");
      JobListener joblistener2nd = service_.getJobListener("SecondJobListener");
      assertTrue("expect 'GlobalJobListener' is found", globalListener != null
               && globalListener.getName().equals("GlobalJobListener"));
      assertTrue("expect 'FirstJobListener' is found", joblistener1st != null
         && joblistener1st.getName().equals("FirstJobListener"));
      assertTrue("expect 'SecondJobListenner' is found", joblistener2nd != null
         && joblistener2nd.getName().equals("SecondJobListener"));
      jobListenerCol = service_.getAllJobListener();
      assertEquals("expect 1 global job listener is found", 1, service_.getAllGlobalJobListener().size());
      assertEquals("expect 2 non global job listener is found", 2, jobListenerCol.size());
      hasObjectInCollection(joblistener1st, jobListenerCol, new JobListenerComparator());
      hasObjectInCollection(joblistener2nd, jobListenerCol, new JobListenerComparator());
     
      GlobalJobListener.countCalled_ = 0;
      FirstJobListener.countCalled_ = 0;
      SecondJobListener.countCalled_ = 0;
      assertEquals(0, GlobalJobListener.countCalled_);
      assertEquals(0, FirstJobListener.countCalled_);
      assertEquals(0, SecondJobListener.countCalled_);
     
      service_.addJob(new JobInfo("GlobalJobListener", null/* default group */, AJob.class), new Date());
      service_.addJob(new JobInfo("FirstJobListener", null/* default group */, AJob.class), new Date());
      service_.addJob(new JobInfo("SecondJobListener", null/* default group */, AJob.class), new Date());
      Thread.sleep(100);
     
      //Scheduler can be faster and execute more than 3 tasks
      assertTrue(GlobalJobListener.countCalled_ >= 3);
      assertEquals(1, FirstJobListener.countCalled_);
      assertEquals(1, SecondJobListener.countCalled_);
      // ---remove FirstJobListenner---
      b = service_.removeJobListener(joblistener1st.getName());
      assertTrue("expect FirstJobListenner is removed", b);
      joblistener1st = service_.getJobListener("FirstJobListenner");
      assertTrue("expect FirstJobListenner is not found", joblistener1st == null);
      jobListenerCol = service_.getAllJobListener();
      assertEquals("now,expect 1 non global job is found", 1, jobListenerCol.size());
      // ---remove SecondJobListenner---
      b = service_.removeJobListener(joblistener2nd.getName());
      joblistener2nd = service_.getJobListener("SecondJobListener");
      assertTrue("expect SecondJobListenner is removed", b && joblistener2nd == null);
      jobListenerCol = service_.getAllJobListener();
      assertEquals("now,expect no non global job is found", 0, jobListenerCol.size());

View Full Code Here

      return jlist;
   }

   public void addGlobalJobListener(ComponentPlugin plugin) throws Exception
   {
      JobListener jl = (JobListener)plugin;
      try
      {
         scheduler_.getListenerManager().addJobListener(jl);
      }
      catch (Exception e)
      {
         LOG.warn("Could not add the global job listener (" + jl.getName() + ") defined in the plugin "
            + plugin.getName() + " : " + e.getMessage());
      }
   }
View Full Code Here

      return scheduler_.getListenerManager().removeJobListener(name);
   }

   public void addJobListener(AddJobListenerComponentPlugin plugin) throws Exception
   {
      JobListener jl = (JobListener)plugin;
      try
      {
         List<Matcher<JobKey>> matchers = null;
         if (plugin.getKeys() != null)
         {
            matchers = new ArrayList<Matcher<JobKey>>();
            for (org.exoplatform.services.scheduler.JobKey key : plugin.getKeys())
            {
               matchers.add(KeyMatcher.keyEquals(JobKey.jobKey(key.getName(), getGroupName(key.getGroup()))));
            }
         }
         scheduler_.getListenerManager().addJobListener(jl, matchers);
      }
      catch (Exception e)
      {
         LOG.warn("Could not add the job listener (" + jl.getName() + ") defined in the plugin " + plugin.getName()
            + " : " + e.getMessage());
      }
   }
View Full Code Here

TOP

Related Classes of org.quartz.JobListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.