Extend the Replicator
One elegant way to improve perceived performance is to run computing task outside of user time. In Notes that is done using (scheduled) agents and scheduled replication (On mobile devices it is called PushMail ). When you have longer running tasks that only make sense when new data might have arrived, a scheduled agent doesn't make much sense.
Triggering a process "On Replication" is much preferable. Classic Notes agents don't have this ability, but the Notes full client can do that. Already today the replicator hosts not only classic Notes NSF replication, but also address sync and Activities sync. This type of extensions can easily be created using an Eclipse extension point:
There are a few caveats (besides designing an 32x32 icon) when building the class, but once you know them it is straight forward:
Triggering a process "On Replication" is much preferable. Classic Notes agents don't have this ability, but the Notes full client can do that. Already today the replicator hosts not only classic Notes NSF replication, but also address sync and Activities sync. This type of extensions can easily be created using an Eclipse extension point:
-
<extension point="com.ibm.notes.client.notesSync">
-
<unit class="com.notessensei.demo.RunOnReplication"
-
id="com.notessensei.demo.runonreplication"
-
image="icons/replicate.gif"
-
label="NotesSensei's Demo Replication">
-
</unit>
-
</extension>
- You either extend
org.eclipse.core.runtime.jobs.Job
orcom.ibm.notes.java.api.util.NotesSessionJob
- For both approached you must have a default constructor without parameter. Neither of classes you extend has one, but your implementation needs one
- When subclassing
Job
you extendrun()
forNotesSessionJob
you extendrunInNotesThread()
. The later has the advantage to have all the session handling completed, but you end with a dependency on Notes client code - While both methods provide an IProgressMonitor as parameter, your code needs to try to obtain the Notes specific one (see sample)
- Keeping track of units of work is a pain, expecially when your tasks calls various modules with unknown number of steps. Luckily there is SubMonitor that allows to specify a set amount of "ticks" for a subtask that can then adjust them as needed (see example)
- You should check
IProgressMonitor.isCanceled()
inside your code and terminate processing at the first possible point (without sacrificing data integrity) when encountered
Read more
Posted by Stephan H Wissel on 20 August 2013 | Comments (2) | categories: IBM Notes XPages