6. Triggers
   6.1 TriggerManager
   6.2 MailTrigger
   6.3 FileTrigger
   6.4 FTPTrigger
   6.5 TimeTrigger
 6 Triggers
JawFlow has an internal mechanism to trigger process instances start when particula events occur. A bunch of triggers are predefined to cover the most common situations.
 6.1 TriggerManager
The TriggerManager is the component of the jawFlow architecture responsible for keeping track of all triggers installed in the system and for the effective process spawning,
The TriggerManager can be configured to "listen" on a directory for trigger configuration files. Basically you can install a trigger by copying a configuration file in a given directory and the TriggerManager watch over the directory for any modifications or removal of the file.
 6.2 MailTrigger
The MailTrigger monitors an email address and if a mail is received respecting defined rules it starts a given process instance.

<trigger> <name>MailTrigger</name> <version>1</version> <class>net.arsretia.jawflow.triggers.mail.MailTrigger</class> <processid> <rule regexp="Process1*" field="Subject">Process1</rule> <rule regexp="Process2*" field="Subject">Process2</rule> ... </processid> <period>5000</period> <domain name="domain"> <var name="var1" value="value1"/> <var name="var2" value="value2"/> ... </domain> <host>[mail host]</host> <user>[mail username]</user> <password>[mail password]</password> <protocol>[mail protocol]</protocol> <port>[mail host port]</port> <maxmessages>1</maxmessages> <attachmentdir>[mail attachments dir]</attachmentdir> <debug>false</debug> </trigger>

The processid section includes a list of rules to start different process id if defined rules are met. The "field" attribute can be one of the valid Mail Header file names (e.g.: Subject). The "regexp" attribute is a regexp which is evaluated on the content of the field's value. If the rule is met the processid in the related tag is started. In the above example if the subject starts with "Process1" than a new process instance of th Process1 definition is started.
The other configuration parameters are:

  Param DescriptionMandatory
 period Period of the check in ms  
 domain In this section you can add variables to the process instance which is started and you can configure the default domain  
 host Mail Server  
 user Mail User  
 password Mail Password  
 protocol Mail Protocol (supported by javamail)  
 port Mail Port  
 maxmessages Max number of messages to be retrieved each run  
 attachmentdir Directory in which attachment files will be stored  
 debug true to debug javamail  

The started process has the following attributes set:

  Param Description Type
 mail.messagecontents if message has no attachments it contains message contentjava.lang.String
 mail.contents a List of attachment file namesjava.util.List
 mail.recbcc a List of BCC addressesjava.util.List
 mail.reccc a List of CC addressesjava.util.List
 mail.from a List of FROM addressesjava.util.List
 mail.recto a List of TO addressesjava.util.List
 mail.replyto a List of REPLYTO addressesjava.util.List
 mail.received date of receivaljava.lang.String
 mail.sent date of sendingjava.lang.String
 mail.attachmentdir Attachment Dirjava.lang.String
 mail.header.headername Value of header headername java.lang.String

 6.3 FileTrigger
The FileTrigger monitors a directory tree on the filesystem and if a file is copied/modified it starts a given process instance.

<trigger> <name>nesteddir</name> <version>1</version> <class>net.arsretia.jawflow.triggers.file.FileTrigger</class> <processid>Test</processid> <period>1000</period> <rootdir>[rootdir]</rootdir> <domain>var1_$var1name1</domain> <dir path="dir1" filefilter="*.txt"> <var name="var1name1" value="var1value1"/> <var name="var1name2" value="var1value2"/> <var name="var1name3" value="var1value3"/> <dir path="dir1.1" filefilter="*.txt1"> <var name="var1.1name1" value="var1.1value1"/> <var name="var1.1name2" value="var1.1value2"/> </dir> <dir path="dir1.2" filefilter="*.zip"> <var name="var1.2name1" value="var1.2value1"/> <var name="var1.2name2" value="var1.2value2"/> <dir path="dir1.2.1" filefilter="*.doc"> <var name="var1.2.1name1" value="var1.2.1value1"/> <var name="var1.2.1name2" value="var1.2.1value2"/> </dir> </dir> </dir> </trigger>

In the above example we are monitoring a tree with the following structure:

[rootdir] | |----dir1 | |----dir1.1 | |----dir1.2 | |---dir1.2.1


The "filefilter" attribute ensures that only the filtered file are checked, so, for instance, in directory dir1, only .txt files are checked. The started process has the following attributes set:

  Param Description Type
 var The started process will have this variables as attributes if the file is modified in the corresponding directory java.lang.String
 FileNotificationTimeStamp Time of notification User java.lang.String
 InputFileDir directory of modified filejava.lang.String
 FileLength File Lenghtjava.lang.Long
 LastModified Last Modified Timejava.lang.String
 InputFile File name without extensionjava.lang.String
 InputFileSuffix File Suffixjava.lang.String

 6.4 FTPTrigger
The FTPTrigger monitors a file on a remote server and starts a given process instance.

<trigger> <name>FTPTrigger</name> <version>1</version> <class>net.arsretia.jawflow.triggers.ftp.FTPTrigger</class> <processid>Test</processid> <period>5000</period> <domain name="domain"> <var name="var1" value="value1"/> <var name="var2" value="value12"/> </domain> <host>[host]</host> <user>[username]</user> <password>[password]</password> <remotedir>[dir]</remotedir> <remotefile>[file]</remotefile> <localdir>[localdir]</localdir> <mode>[ftp mode]</mode> <downloadfile>true</downloadfile> <deleteremote>true</deleteremote> </trigger>

The other configuration parameters are:

  Param DescriptionMandatory
 period Period of the check in ms  
 domain In this section you can add variables to the process instance which is started and you can configure the default domain  
 host FTP Host  
 user Username  
 password Password  
 remotedir Dir on remote server  
 remotefile File on remote server  
 localdir Local dir where file will be written if downloadfile=true  
 mode FTP Mode  
 downloadfile true if file must be downloaded  
 deleteremote true if file must be deleted after downloading  

 6.5 Timerigger
The TimeTrigger acts as a unix crontab starting a process with a scheduler.

<trigger> <name>Time</name> <version>1</version> <class>net.arsretia.jawflow.triggers.time.TimeTrigger</class> <processid>Test</processid> <period>1000</period> <rootdir>[rootdir]</rootdir> <domain>var1_$var1name1</domain> <crontabentry>[min] [hour] [day of month] [month] [day of week]</crontabentry> <crontabentry>[min] [hour] [day of month] [month] [day of week]</crontabentry> ..... </trigger>

The crontab entry is in the standard unix crontab form (it supports only the wildcard "*")

Chapter 5 Contents