activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r521801 - in /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/pojo: PollingPojoComponent.java PollingSchedule.java
Date Fri, 23 Mar 2007 16:46:31 GMT
Author: rajdavies
Date: Fri Mar 23 09:46:30 2007
New Revision: 521801

URL: http://svn.apache.org/viewvc?view=rev&rev=521801
Log:
turn PollingSchedule into a bean

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/pojo/PollingPojoComponent.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/pojo/PollingSchedule.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/pojo/PollingPojoComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/pojo/PollingPojoComponent.java?view=diff&rev=521801&r1=521800&r2=521801
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/pojo/PollingPojoComponent.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/pojo/PollingPojoComponent.java
Fri Mar 23 09:46:30 2007
@@ -17,16 +17,30 @@
 import java.util.HashMap;
 
 /**
-* Represents the polling component that manages {@link PojoEndpoint}.  It holds the 
-* list of named pojos that queue endpoints reference.
-*
-* @version $Revision: 519973 $
-*/
+ * Represents the polling component that manages {@link PojoEndpoint}. It holds the list
of named pojos that queue
+ * endpoints reference.
+ * 
+ * @version $Revision: 519973 $
+ */
 public class PollingPojoComponent extends PojoComponent{
 
-    
-       
-       protected final HashMap<String,PollingSchedule> schedules=new HashMap<String,PollingSchedule>();
+    protected final HashMap<String,PollingSchedule> schedules=new HashMap<String,PollingSchedule>();
+
+    /**
+     * Registers a pojo and schedules the pojo for execution at the specified time. If the
time is in the past, the task
+     * is scheduled for immediate execution.
+     * 
+     * @param uri
+     * @param pojo
+     * @param schedule
+     * @throws IllegalArgumentException if <tt>time.getTime()</tt> is negative.
+     * @throws IllegalStateException if task was already scheduled or cancelled, timer was
cancelled, or timer thread
+     *             terminated.
+     */
+    public void registerAndSchedulePojo(String uri,Object pojo,PollingSchedule schedule){
+        super.registerPojo(uri,pojo);
+        schedules.put(uri,schedule);
+    }
 
     /**
      * Registers a pojo and schedules the pojo for execution at the specified time. If the
time is in the past, the task
@@ -41,161 +55,145 @@
      */
     public void registerAndSchedulePojo(String uri,Object pojo,Date time){
         super.registerPojo(uri,pojo);
-        
-        PollingSchedule schedule = new PollingSchedule(uri,time);
+        PollingSchedule schedule=new PollingSchedule(uri,time);
         schedules.put(uri,schedule);
     }
-    
+
     /**
      * Registers a pojo and cchedules the pojo for execution at the specified time. If the
time is in the past, the task
      * is scheduled for immediate execution.
      * 
      * @param uri
      * @param pojo
-     * @param firstTime 
-     * @param period 
+     * @param firstTime
+     * @param period
      * @throws IllegalArgumentException if <tt>time.getTime()</tt> is negative.
      * @throws IllegalStateException if task was already scheduled or cancelled, timer was
cancelled, or timer thread
      *             terminated.
      */
-    
     public void registerAndScheulePojo(String uri,Object pojo,Date firstTime,long period){
         super.registerPojo(uri,pojo);
         PollingSchedule schedule=new PollingSchedule(uri,firstTime,period);
         schedules.put(uri,schedule);
     }
-    
+
     /**
-     * Registers a pojo and schedules the specified task for repeated <i>fixed-delay
execution</i>,
-     * beginning after the specified delay.  Subsequent executions take place
-     * at approximately regular intervals separated by the specified period.
-     *
-     * <p>In fixed-delay execution, each execution is scheduled relative to
-     * the actual execution time of the previous execution.  If an execution
-     * is delayed for any reason (such as garbage collection or other
-     * background activity), subsequent executions will be delayed as well.
-     * In the long run, the frequency of execution will generally be slightly
-     * lower than the reciprocal of the specified period (assuming the system
-     * clock underlying <tt>Object.wait(long)</tt> is accurate).
-     *
-     * <p>Fixed-delay execution is appropriate for recurring activities
-     * that require "smoothness."  In other words, it is appropriate for
-     * activities where it is more important to keep the frequency accurate
-     * in the short run than in the long run.  This includes most animation
-     * tasks, such as blinking a cursor at regular intervals.  It also includes
-     * tasks wherein regular activity is performed in response to human
-     * input, such as automatically repeating a character as long as a key
-     * is held down.
-     * 
-     * @param uri 
-     * @param pojo 
-     * @param delay  delay in milliseconds before task is to be executed.
+     * Registers a pojo and schedules the specified task for repeated <i>fixed-delay
execution</i>, beginning after the
+     * specified delay. Subsequent executions take place at approximately regular intervals
separated by the specified
+     * period.
+     * 
+     * <p>
+     * In fixed-delay execution, each execution is scheduled relative to the actual execution
time of the previous
+     * execution. If an execution is delayed for any reason (such as garbage collection or
other background activity),
+     * subsequent executions will be delayed as well. In the long run, the frequency of execution
will generally be
+     * slightly lower than the reciprocal of the specified period (assuming the system clock
underlying
+     * <tt>Object.wait(long)</tt> is accurate).
+     * 
+     * <p>
+     * Fixed-delay execution is appropriate for recurring activities that require "smoothness."
In other words, it is
+     * appropriate for activities where it is more important to keep the frequency accurate
in the short run than in the
+     * long run. This includes most animation tasks, such as blinking a cursor at regular
intervals. It also includes
+     * tasks wherein regular activity is performed in response to human input, such as automatically
repeating a
+     * character as long as a key is held down.
+     * 
+     * @param uri
+     * @param pojo
+     * @param delay delay in milliseconds before task is to be executed.
      * @param period time in milliseconds between successive task executions.
-     * @throws IllegalArgumentException if <tt>delay</tt> is negative, or
-     *         <tt>delay + System.currentTimeMillis()</tt> is negative.
-     * @throws IllegalStateException if task was already scheduled or
-     *         cancelled, timer was cancelled, or timer thread terminated.
+     * @throws IllegalArgumentException if <tt>delay</tt> is negative, or <tt>delay
+ System.currentTimeMillis()</tt>
+     *             is negative.
+     * @throws IllegalStateException if task was already scheduled or cancelled, timer was
cancelled, or timer thread
+     *             terminated.
      */
-    
     public void registerAndScheulePojo(String uri,Object pojo,long delay,long period){
         super.registerPojo(uri,pojo);
         PollingSchedule schedule=new PollingSchedule(uri,delay,period);
         schedules.put(uri,schedule);
     }
-    
-    
+
     /**
-     * Register pojo and schedules the specified task for repeated <i>fixed-rate execution</i>,
-     * beginning at the specified time. Subsequent executions take place at
-     * approximately regular intervals, separated by the specified period.
-     *
-     * <p>In fixed-rate execution, each execution is scheduled relative to the
-     * scheduled execution time of the initial execution.  If an execution is
-     * delayed for any reason (such as garbage collection or other background
-     * activity), two or more executions will occur in rapid succession to
-     * "catch up."  In the long run, the frequency of execution will be
-     * exactly the reciprocal of the specified period (assuming the system
-     * clock underlying <tt>Object.wait(long)</tt> is accurate).
-     *
-     * <p>Fixed-rate execution is appropriate for recurring activities that
-     * are sensitive to <i>absolute</i> time, such as ringing a chime every
-     * hour on the hour, or running scheduled maintenance every day at a
-     * particular time.  It is also appropriate for recurring activities
-     * where the total time to perform a fixed number of executions is
-     * important, such as a countdown timer that ticks once every second for
-     * ten seconds.  Finally, fixed-rate execution is appropriate for
-     * scheduling multiple repeating timer tasks that must remain synchronized
-     * with respect to one another.
+     * Register pojo and schedules the specified task for repeated <i>fixed-rate execution</i>,
beginning at the
+     * specified time. Subsequent executions take place at approximately regular intervals,
separated by the specified
+     * period.
+     * 
+     * <p>
+     * In fixed-rate execution, each execution is scheduled relative to the scheduled execution
time of the initial
+     * execution. If an execution is delayed for any reason (such as garbage collection or
other background activity),
+     * two or more executions will occur in rapid succession to "catch up." In the long run,
the frequency of execution
+     * will be exactly the reciprocal of the specified period (assuming the system clock
underlying
+     * <tt>Object.wait(long)</tt> is accurate).
      * 
-     * @param uri 
-     * @param pojo 
+     * <p>
+     * Fixed-rate execution is appropriate for recurring activities that are sensitive to
<i>absolute</i> time, such as
+     * ringing a chime every hour on the hour, or running scheduled maintenance every day
at a particular time. It is
+     * also appropriate for recurring activities where the total time to perform a fixed
number of executions is
+     * important, such as a countdown timer that ticks once every second for ten seconds.
Finally, fixed-rate execution
+     * is appropriate for scheduling multiple repeating timer tasks that must remain synchronized
with respect to one
+     * another.
+     * 
+     * @param uri
+     * @param pojo
      * @param firstTime First time at which task is to be executed.
      * @param period time in milliseconds between successive task executions.
      * @throws IllegalArgumentException if <tt>time.getTime()</tt> is negative.
-     * @throws IllegalStateException if task was already scheduled or
-     *         cancelled, timer was cancelled, or timer thread terminated.
+     * @throws IllegalStateException if task was already scheduled or cancelled, timer was
cancelled, or timer thread
+     *             terminated.
      */
-    
-    public void registerAndScheulePojoAtFixedRate(String uri,Object pojo,Date firstTime,
long period){
+    public void registerAndScheulePojoAtFixedRate(String uri,Object pojo,Date firstTime,long
period){
         super.registerPojo(uri,pojo);
         PollingSchedule schedule=new PollingSchedule(uri,firstTime,-1,period,true);
         schedules.put(uri,schedule);
     }
-    
+
     /**
-     * Register pojo and schedules the specified task for repeated <i>fixed-rate execution</i>,
-     * beginning after the specified delay.  Subsequent executions take place
-     * at approximately regular intervals, separated by the specified period.
-     *
-     * <p>In fixed-rate execution, each execution is scheduled relative to the
-     * scheduled execution time of the initial execution.  If an execution is
-     * delayed for any reason (such as garbage collection or other background
-     * activity), two or more executions will occur in rapid succession to
-     * "catch up."  In the long run, the frequency of execution will be
-     * exactly the reciprocal of the specified period (assuming the system
-     * clock underlying <tt>Object.wait(long)</tt> is accurate).
-     *
-     * <p>Fixed-rate execution is appropriate for recurring activities that
-     * are sensitive to <i>absolute</i> time, such as ringing a chime every
-     * hour on the hour, or running scheduled maintenance every day at a
-     * particular time.  It is also appropriate for recurring activities
-     * where the total time to perform a fixed number of executions is
-     * important, such as a countdown timer that ticks once every second for
-     * ten seconds.  Finally, fixed-rate execution is appropriate for
-     * scheduling multiple repeating timer tasks that must remain synchronized
-     * with respect to one another.
-     * 
-     * @param uri 
-     * @param pojo 
-     * @param delay  delay in milliseconds before task is to be executed.
+     * Register pojo and schedules the specified task for repeated <i>fixed-rate execution</i>,
beginning after the
+     * specified delay. Subsequent executions take place at approximately regular intervals,
separated by the specified
+     * period.
+     * 
+     * <p>
+     * In fixed-rate execution, each execution is scheduled relative to the scheduled execution
time of the initial
+     * execution. If an execution is delayed for any reason (such as garbage collection or
other background activity),
+     * two or more executions will occur in rapid succession to "catch up." In the long run,
the frequency of execution
+     * will be exactly the reciprocal of the specified period (assuming the system clock
underlying
+     * <tt>Object.wait(long)</tt> is accurate).
+     * 
+     * <p>
+     * Fixed-rate execution is appropriate for recurring activities that are sensitive to
<i>absolute</i> time, such as
+     * ringing a chime every hour on the hour, or running scheduled maintenance every day
at a particular time. It is
+     * also appropriate for recurring activities where the total time to perform a fixed
number of executions is
+     * important, such as a countdown timer that ticks once every second for ten seconds.
Finally, fixed-rate execution
+     * is appropriate for scheduling multiple repeating timer tasks that must remain synchronized
with respect to one
+     * another.
+     * 
+     * @param uri
+     * @param pojo
+     * @param delay delay in milliseconds before task is to be executed.
      * @param period time in milliseconds between successive task executions.
-     * @throws IllegalArgumentException if <tt>delay</tt> is negative, or
-     *         <tt>delay + System.currentTimeMillis()</tt> is negative.
-     * @throws IllegalStateException if task was already scheduled or
-     *         cancelled, timer was cancelled, or timer thread terminated.
+     * @throws IllegalArgumentException if <tt>delay</tt> is negative, or <tt>delay
+ System.currentTimeMillis()</tt>
+     *             is negative.
+     * @throws IllegalStateException if task was already scheduled or cancelled, timer was
cancelled, or timer thread
+     *             terminated.
      */
-    
-    public void registerAndScheulePojoAtFixedRate(String uri,Object pojo,long delay, long
period){
+    public void registerAndScheulePojoAtFixedRate(String uri,Object pojo,long delay,long
period){
         super.registerPojo(uri,pojo);
         PollingSchedule schedule=new PollingSchedule(uri,null,delay,period,true);
         schedules.put(uri,schedule);
     }
-    
-    
-    public void registerActivation(String uri, PojoEndpoint endpoint) {
+
+    public void registerActivation(String uri,PojoEndpoint endpoint){
         super.registerActivation(uri,endpoint);
-        if (endpoint instanceof PollingPojoEndpoint) {
-            PollingSchedule schedule = schedules.get(uri);
-            if(schedule != null) {
+        if(endpoint instanceof PollingPojoEndpoint){
+            PollingSchedule schedule=schedules.get(uri);
+            if(schedule!=null){
                 schedule.activate((Runnable)endpoint);
             }
         }
     }
-    
-    public void unregisterActivation(String uri) {
+
+    public void unregisterActivation(String uri){
         super.unregisterActivation(uri);
-        PollingSchedule schedule = schedules.remove(uri);
-        if(schedule != null) {
+        PollingSchedule schedule=schedules.remove(uri);
+        if(schedule!=null){
             schedule.deactivate();
         }
     }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/pojo/PollingSchedule.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/pojo/PollingSchedule.java?view=diff&rev=521801&r1=521800&r2=521801
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/pojo/PollingSchedule.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/pojo/PollingSchedule.java
Fri Mar 23 09:46:30 2007
@@ -25,7 +25,7 @@
  * Schedule used for polling an endpoint
  *
  */
-class PollingSchedule{
+public class PollingSchedule{
 
     private String name;
     private Timer timer;
@@ -35,21 +35,24 @@
     private boolean fixedRate;
     private boolean daemon=true;
 
-    PollingSchedule(String name,Date time){
+    public PollingSchedule(String name,Date time){
         this(name,time,-1,-1,false);
     }
 
-    PollingSchedule(String name,Date time,long period){
+    public PollingSchedule(String name,Date time,long period){
         this(name,time,-1,period,false);
     }
 
-    PollingSchedule(String name,long delay){
+    public PollingSchedule(String name,long delay){
         this(name,null,delay,-1,false);
     }
     
-    PollingSchedule(String name,long delay,long period){
+    public PollingSchedule(String name,long delay,long period){
         this(name,null,delay,period,false);
     }
+    
+    public PollingSchedule(){
+    }
 
     PollingSchedule(String name,Date time,long delay,long period,boolean fixedRate){
         this.name=name;
@@ -99,5 +102,117 @@
             }
         }
         return result;
+    }
+
+    
+    /**
+     * @return the daemon
+     */
+    public boolean isDaemon(){
+        return this.daemon;
+    }
+
+    
+    /**
+     * @param daemon the daemon to set
+     */
+    public void setDaemon(boolean daemon){
+        this.daemon=daemon;
+    }
+
+    
+    /**
+     * @return the delay
+     */
+    public long getDelay(){
+        return this.delay;
+    }
+
+    
+    /**
+     * @param delay the delay to set
+     */
+    public void setDelay(long delay){
+        this.delay=delay;
+    }
+
+    
+    /**
+     * @return the fixedRate
+     */
+    public boolean isFixedRate(){
+        return this.fixedRate;
+    }
+
+    
+    /**
+     * @param fixedRate the fixedRate to set
+     */
+    public void setFixedRate(boolean fixedRate){
+        this.fixedRate=fixedRate;
+    }
+
+    
+    /**
+     * @return the name
+     */
+    public String getName(){
+        return this.name;
+    }
+
+    
+    /**
+     * @param name the name to set
+     */
+    public void setName(String name){
+        this.name=name;
+    }
+
+    
+    /**
+     * @return the period
+     */
+    public long getPeriod(){
+        return this.period;
+    }
+
+    
+    /**
+     * @param period the period to set
+     */
+    public void setPeriod(long period){
+        this.period=period;
+    }
+
+    
+    /**
+     * @return the time
+     */
+    public Date getTime(){
+        return this.time;
+    }
+
+    
+    /**
+     * @param time the time to set
+     */
+    public void setTime(Date time){
+        this.time=time;
+    }
+
+    
+    /**
+     * @return the timer
+     */
+    public Timer getTimer(){
+        return this.timer;
+    }
+
+    
+    /**
+     * @param timer the timer to set
+     */
+    public void setTimer(Timer timer){
+        this.timer=timer;
     }
 }



Mime
View raw message