Hello Leo.
OK, sounds reasonable. Attached is a new patch, which makes it possible to override
the default implementation of "runEntry", without changing the current rescheduling
behaviour.
I'm not altogether happy with this patch because now some seemingly random methods and
fields are protected, some are private. And because of dependencies of the non-public
class TimeScheduleEntry the overriding class has to be placed in the package
org.apache.avalon.cornerstone.blocks.scheduler as well.
Do you want to apply this patch in this way, or should i/we
1) try to make a consistent "contract interface" for overiding selected implementation
details of the DefaultTimeScheduler class, but perhaps some refactoring is needed to
achieve that.
or 2) just make the rescheduling behavior in some way configurable, so it is not
needed to override at all?
Stefan
> -----Original Message-----
> From: Leo Simons [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 21, 2003 2:58 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [Components: TimeScheduler] TimeScheduler behaviour with
> periodic triggers
>
>
> Hi Stefan,
>
> sorry for taking so long getting back to you on this. I think
> it depends
> entirely on the context of your application on whether
> execution overlap
> is desireable. I would guess there are applications that your patch
> would break since they depend on the overlap behaviour (the
> idea behind
> a time scheduler is that it guarantees something happens at a
> particular
> time, innit). Do you agree?
>
> Hence I think it's not a wise idea to apply it. However, if you could
> generate a patch against the defaultscheduler that makes the
> methods you
> need to override protected, rather than private, that is something we
> can do. Sounds like a plan?
>
> cheers,
>
> - Leo
Index: DefaultTimeScheduler.java
===================================================================
RCS file:
/home/cvspublic/avalon-components/scheduler-impl/src/java/org/apache/avalon/cornerstone/blocks/scheduler/DefaultTimeScheduler.java,v
retrieving revision 1.2
diff -u -r1.2 DefaultTimeScheduler.java
--- DefaultTimeScheduler.java 19 Jun 2003 20:31:29 -0000 1.2
+++ DefaultTimeScheduler.java 21 Aug 2003 14:50:53 -0000
@@ -80,7 +80,7 @@
private final Hashtable m_entries = new Hashtable();
private final PriorityQueue m_priorityQueue =
new SynchronizedPriorityQueue( new BinaryHeap() );
- private ThreadManager m_threadManager;
+ protected ThreadManager m_threadManager;
private boolean m_running;
private ArrayList m_triggerFailureListeners = new ArrayList();
@@ -180,7 +180,7 @@
* @param clone true if new entry is to be created
* @return true if added to queue, false if not added
*/
- private synchronized boolean rescheduleEntry( final TimeScheduledEntry timeEntry,
+ protected synchronized boolean rescheduleEntry( final TimeScheduledEntry
timeEntry,
final boolean clone )
{
TimeScheduledEntry entry = timeEntry;
@@ -242,11 +242,11 @@
}
/**
- * Rune entry in a separate thread.
+ * Run entry in a separate thread and reschedule the entry.
*
* @param entry the entry to run
*/
- private void runEntry( final TimeScheduledEntry entry )
+ protected void runEntry( final TimeScheduledEntry entry )
{
final Runnable runnable = new Runnable()
{
@@ -266,6 +266,9 @@
final String message = "Error executing trigger " + entry.getName();
getLogger().warn( message, e );
}
+
+ // reschedule the entry
+ rescheduleEntry( entry, false );
}
/**
@@ -273,7 +276,7 @@
*
* @param entry the entry to run
*/
- private void doRunEntry( final TimeScheduledEntry entry )
+ protected void doRunEntry( final TimeScheduledEntry entry )
{
try
{
@@ -348,8 +351,8 @@
if( duration < 0 )
{
+ // runs and reschedules the entry
runEntry( entry );
- rescheduleEntry( entry, false );
continue;
}
else if( 0 == duration )
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]