If you load test-JavaScript.xpdl (or test-BeanShell.xpdl) by using Admin application, you can find out how Tool agents work.
This XPDL have defined extended attributes for application definitions, and these attributes contain data needed to call appropriate tool agents without need for mapping information (these tool agents are called through default tool agent by reading extended attribute parameters). The only thing you should do before starting shark engine is to configure your "Shark.conf" file to define proper settings for DefaultMailMessageHandler, but even if you don't do that, the example will work, because on MailToolAgent failure, it will proceed with DEFAULT_EXCEPTION transition.
If you want to do your own mappings, it will override default configuration in application's XPDL extended attributes because shark first looks at mapping information, and only if it can't find it, it calls Default tool agent, which reads ext. attributes. You can do the following to see how the mappings work:
Start SharkAdmin application and go to the application mapping section
Map the following:
addition -> org.enhydra.shark.JavaClassToolAgent (enter AdditionProc for application name)
arbitrarymathop -> org.enhydra.shark.SOAPToolAgent (enter http://samples.gotdotnet.com/quickstart/aspplus/samples/services/MathService/VB/MathService.asmx?WSDL for application name)
division -> org.enhydra.shark.JavaScriptToolAgent (enter c=a/b for application name, and 1 for application mode)
multiplication -> org.enhydra.shark.BshToolAgent (enter c=new Long(a.longValue()*b.longValue()); for application name, and 1 for application mode)
notepad -> org.enhydra.shark.RuntimeApplicationToolAgent (enter notepad for application name, and 1 for application mode) - this application is executed if shark is running on Windows
send_mail -> org.enhydra.shark.JavaClassToolAgent (enter email.MailProc for application name)
send_mail2 -> org.enhydra.shark.MailToolAgent (enter org.enhydra.shark.toolagent.DefaultMailMessageHandler for application name, and 0 for application mode)
substraction -> org.enhydra.shark.JavaScriptToolAgent (enter SubstractionProc.js for application name and 0 for application mode)
vi -> org.enhydra.shark.RuntimeApplicationToolAgent (enter xterm - e vi for application name, and 1 for application mode) - this application is executed if shark is running on *nix
waiting -> org.enhydra.shark.JavaClassToolAgent (enter WaitProc for application name)
Instantiate the "Do math" process
execute the given workitems (below is the explanation of the process)
The process is consisted of two loops:
The first loop performs math operations using sub-process referenced from subflow activity "Calculate". When you perform "Enter math parameters" activity, enter some parameters, i.e. "addition", "44" and "33", and when the subflow activity "Calculate" finishes, you should see the result of the addition ("77") when performing next activity. Here you can decide if you're going to repeat the calculation. If you are not, the process goes to the last activity, but it can't finish until the second loop is exited (you can also enter "substraction", "multiplication" and "division" for a operation parameter).
The second loop is more interesting - it performs two operations:
it executes arbitrary mathematical operation
it executes waiting procedure
Both operations have to be finished to continue the loop. Arbitrary mathematical operation is executed by calling WEB service, and waiting procedure uses java's sleep method.
I.e., if you enter parameters "Add", "100.3","10.2","10000", the result of the arbitrary math operation that you will see when all operations are finished (if mapped as above) will be "110.5". You will be able to perform the activity that shows you the result of math operation, and asks you if you want to proceed with this loop, only when 10 second has past (you can also enter "Subtract", "Multiply" and "Divide" for a arbitraryOperation parameter - be careful, there is a typo in WSDL definition, so you should really enter "Subtract" if you want substraction to be performed).
When you decide to exit both loops, the process goes to "Notepad" or "Vi editor" activity, depending on OS that engine runs on, and appropriate text editor will be started on shark machine using RuntimeApplication tool agent, but process will continue to "Enter Mail Params" activity, because mode of RuntimeApplication tool agent is previously (in mappings) set to 1, which means asynchronous execution of editor application.
Now, you should enter some parameters to send e-mail notification to someone. I.e., enter something like this:
txt_msg -> Do math process is finished
subject -> Do math process status
destination_address -> shark@enhydra.org
After that, the mail should be sent using MailToolAgent, and process will finish. If this is not the case, it means that you didn't setup appropriate parameters in Shark.conf file, so exception in tool agent will happen, but since XPDL has defined DEFAULT_EXCEPTION transition, the process will proceed to exception handling path -> to activity "Enter Aditional Mail Params". Now, you should enter additional parameters that are needed by email.MailProc class used to send mails through JavaClass tool agent. I.e., enter something like this:
source_address -> admin@together.at
user_auth -> admin
pwd_auth -> mypassword
server -> myserver
port -> 25
After that, process will be finished no matter if you've entered proper parameters or not.
Now, you can play around with the mappings. I.e., you can enter different java script text for executing math operations, enter different parameter values, ...