[seam-commits] Seam SVN: r11902 - in sandbox/trunk/modules/scheduling: src/main/java/org/jboss/seam/scheduling/events and 2 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sun Jan 3 08:52:56 EST 2010


Author: peteroyle
Date: 2010-01-03 08:52:56 -0500 (Sun, 03 Jan 2010)
New Revision: 11902

Modified:
   sandbox/trunk/modules/scheduling/pom.xml
   sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/AbstractTimeEvent.java
   sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/Hour.java
   sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/Minute.java
   sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/Second.java
   sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/QuartzStarter.java
   sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/AbstractTimeEventJob.java
   sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/HourJob.java
   sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/MinuteJob.java
   sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/SecondJob.java
Log:
Second, Minute and Hour events record which second, minute or hour they were fired on as the 'value' property. Also included some new dependencies of the weld-core-test project for use during testing only.

Modified: sandbox/trunk/modules/scheduling/pom.xml
===================================================================
--- sandbox/trunk/modules/scheduling/pom.xml	2010-01-03 12:03:45 UTC (rev 11901)
+++ sandbox/trunk/modules/scheduling/pom.xml	2010-01-03 13:52:56 UTC (rev 11902)
@@ -112,6 +112,20 @@
             <version>1.0.1-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
+        <!-- required by weld-core-test ... -->
+        <dependency>
+           <groupId>javax.servlet</groupId>
+           <artifactId>servlet-api</artifactId>
+           <version>2.5</version>
+           <scope>test</scope>
+        </dependency>
+        <dependency>
+           <groupId>org.jboss.test-harness</groupId>
+           <artifactId>jboss-test-harness</artifactId>
+           <version>1.1.0-SNAPSHOT</version>
+           <scope>test</scope>
+        </dependency>
+        <!-- ... required by weld-core-test -->
     </dependencies>
 </project>
 

Modified: sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/AbstractTimeEvent.java
===================================================================
--- sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/AbstractTimeEvent.java	2010-01-03 12:03:45 UTC (rev 11901)
+++ sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/AbstractTimeEvent.java	2010-01-03 13:52:56 UTC (rev 11902)
@@ -31,6 +31,8 @@
 {
 
     private long timeFired;
+    // the value of the second, miute or hour, as the case may be
+    protected int value;
 
     /**
      * Create an instance of some subclass of AbstractTimeEvent using the given timeFired.
@@ -51,6 +53,14 @@
     }
 
     /**
+     * @return The value of the second, minute or hour fired.
+     */
+    public int getValue()
+    {
+       return value;
+    }
+
+    /**
      *
      * @return a String representation of this instance, showing the event type and the
      * time at which the event was fired (epoch).

Modified: sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/Hour.java
===================================================================
--- sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/Hour.java	2010-01-03 12:03:45 UTC (rev 11901)
+++ sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/Hour.java	2010-01-03 13:52:56 UTC (rev 11902)
@@ -27,9 +27,10 @@
      * Creates an instance of Hour using the given value of timeFired.
      * @param timeFired The time at which the event was fired.
      */
-    public Hour(long timeFired)
+    public Hour(long timeFired, int second)
     {
         super(timeFired);
+        this.value = second;
     }
     
 }

Modified: sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/Minute.java
===================================================================
--- sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/Minute.java	2010-01-03 12:03:45 UTC (rev 11901)
+++ sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/Minute.java	2010-01-03 13:52:56 UTC (rev 11902)
@@ -27,8 +27,9 @@
      * Creates an instance of Minute using the given value of timeFired.
      * @param timeFired The time at which the event was fired.
      */
-    public Minute(long timeFired)
+    public Minute(long timeFired, int second)
     {
         super(timeFired);
+        this.value = second;
     }
 }

Modified: sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/Second.java
===================================================================
--- sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/Second.java	2010-01-03 12:03:45 UTC (rev 11901)
+++ sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/events/Second.java	2010-01-03 13:52:56 UTC (rev 11902)
@@ -27,9 +27,10 @@
      * Creates an instance of Second using the given value of timeFired.
      * @param timeFired The time at which the event was fired.
      */
-    public Second(long timeFired)
+    public Second(long timeFired, int second)
     {
         super(timeFired);
+        this.value = second;
     }
-    
+
 }

Modified: sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/QuartzStarter.java
===================================================================
--- sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/QuartzStarter.java	2010-01-03 12:03:45 UTC (rev 11901)
+++ sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/QuartzStarter.java	2010-01-03 13:52:56 UTC (rev 11902)
@@ -131,17 +131,17 @@
 
             // Start scheduler for Second every second
             final Trigger secondTrigger = new SimpleTrigger("jcdiTickerTrigger", TICKER_JOB_GROUP, startTime, null, SimpleTrigger.REPEAT_INDEFINITELY, 1000);
-            Set tickObservers = manager.resolveObserverMethods(new Second(0), new EveryBinding());
+            Set tickObservers = manager.resolveObserverMethods(new Second(0, 0), new EveryBinding());
             scheduleTicks(tickObservers, "second-trigger", manager, secondTrigger, SecondJob.class);
 
             // Start scheduler for Minute every minute
-            Set minTickObservers = manager.resolveObserverMethods(new Minute(0), new EveryBinding());
+            Set minTickObservers = manager.resolveObserverMethods(new Minute(0, 0), new EveryBinding());
             final CronTrigger minTrigger = new CronTrigger("jcdiMinutelyTickerTrigger", TICKER_JOB_GROUP, "0 * * ? * *");
             minTrigger.setStartTime(startTime);
             scheduleTicks(minTickObservers, "minute-trigger", manager, minTrigger, MinuteJob.class);
 
             // Start scheduler for Hour every hour
-            Set hrlyTickObservers = manager.resolveObserverMethods(new Hour(0), new EveryBinding());
+            Set hrlyTickObservers = manager.resolveObserverMethods(new Hour(0, 0), new EveryBinding());
             final CronTrigger hrTrigger = new CronTrigger("jcdiHourlyTickerTrigger", TICKER_JOB_GROUP, "0 0 * ? * *");
             hrTrigger.setStartTime(startTime);
             scheduleTicks(hrlyTickObservers, "hour-trigger", manager, hrTrigger, HourJob.class);

Modified: sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/AbstractTimeEventJob.java
===================================================================
--- sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/AbstractTimeEventJob.java	2010-01-03 12:03:45 UTC (rev 11901)
+++ sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/AbstractTimeEventJob.java	2010-01-03 13:52:56 UTC (rev 11902)
@@ -17,6 +17,8 @@
 package org.jboss.seam.scheduling.quartz.jobs;
 
 import java.lang.annotation.Annotation;
+import java.util.Date;
+import java.util.GregorianCalendar;
 import java.util.Set;
 import javax.enterprise.inject.spi.BeanManager;
 import org.jboss.seam.scheduling.quartz.*;
@@ -37,6 +39,8 @@
 public abstract class AbstractTimeEventJob implements Job
 {
 
+    protected int value = 0;
+    protected final GregorianCalendar gc = new GregorianCalendar();
     private Log log = LogFactory.getLog(SecondJob.class);
 
     /**
@@ -56,6 +60,7 @@
     public void execute(JobExecutionContext context) throws JobExecutionException
     {
         BeanManager manager = (BeanManager) context.getJobDetail().getJobDataMap().get(QuartzStarter.MANAGER_NAME);
+        gc.setTime(new Date());
         final AbstractTimeEvent eventPayload = createEventPayload();
         for (Annotation binding : (Set<Annotation>)context.getJobDetail().getJobDataMap().get(QuartzStarter.BINDINGS)) {
             log.trace("Firing time event for " + eventPayload + " with binding " + binding);

Modified: sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/HourJob.java
===================================================================
--- sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/HourJob.java	2010-01-03 12:03:45 UTC (rev 11901)
+++ sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/HourJob.java	2010-01-03 13:52:56 UTC (rev 11902)
@@ -16,6 +16,7 @@
  */
 package org.jboss.seam.scheduling.quartz.jobs;
 
+import java.util.GregorianCalendar;
 import org.jboss.seam.scheduling.events.AbstractTimeEvent;
 import org.jboss.seam.scheduling.events.Hour;
 
@@ -33,6 +34,6 @@
      */
     protected AbstractTimeEvent createEventPayload()
     {
-        return new Hour(System.currentTimeMillis());
+        return new Hour(System.currentTimeMillis(), gc.get(GregorianCalendar.MINUTE));
     }
 }

Modified: sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/MinuteJob.java
===================================================================
--- sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/MinuteJob.java	2010-01-03 12:03:45 UTC (rev 11901)
+++ sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/MinuteJob.java	2010-01-03 13:52:56 UTC (rev 11902)
@@ -16,6 +16,7 @@
  */
 package org.jboss.seam.scheduling.quartz.jobs;
 
+import java.util.GregorianCalendar;
 import org.jboss.seam.scheduling.events.AbstractTimeEvent;
 import org.jboss.seam.scheduling.events.Minute;
 
@@ -32,6 +33,6 @@
      */
     protected AbstractTimeEvent createEventPayload()
     {
-        return new Minute(System.currentTimeMillis());
+        return new Minute(System.currentTimeMillis(), gc.get(GregorianCalendar.MINUTE));
     }
 }

Modified: sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/SecondJob.java
===================================================================
--- sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/SecondJob.java	2010-01-03 12:03:45 UTC (rev 11901)
+++ sandbox/trunk/modules/scheduling/src/main/java/org/jboss/seam/scheduling/quartz/jobs/SecondJob.java	2010-01-03 13:52:56 UTC (rev 11902)
@@ -16,6 +16,7 @@
  */
 package org.jboss.seam.scheduling.quartz.jobs;
 
+import java.util.GregorianCalendar;
 import org.jboss.seam.scheduling.events.AbstractTimeEvent;
 import org.jboss.seam.scheduling.events.Second;
 
@@ -32,6 +33,6 @@
      */
     protected AbstractTimeEvent createEventPayload()
     {
-        return new Second(System.currentTimeMillis());
+        return new Second(System.currentTimeMillis(), gc.get(GregorianCalendar.SECOND));
     }
 }



More information about the seam-commits mailing list