You can also access this tutorial in German and French.

 

This video is about codelets in YAWL. A Codelet is a Java class that is invoked from a task. Everything you can do in Java you can do in a codelet. You can use it to do complex computations. In most cases it‘s used to communicate with the  outside world – IT systems outside of YAWL.
In this tutorial‘s example we create a random number. We focus on the deployment of codelets.

The zip file below contains all the files necessary to follow the tutorial.

 

Welcome to another YAWL tutorial. This is the first of the additional tutorials that originate from viewer requests. Joran has requested something on storing information from a YAWL workflow in a database. Before we get to that, we have to talk about codelets and about installing the database management system. A codelet is a Java class that is invoked from a task. Everything that you can do with Java, you can do in a codelet. You can use it to do complex computations. In most cases however it's used to communicate with the outside world - IT systems outside of YAWL. In this tutorial's example, we create a random number. We focus on the deployment of codelets. As usual, you can find the necessary files in the companion page below this video. I've based this whole tutorial on Oracle Java 8. If you manage to run this based on open JDK 11 or later, please let me know in the comments. So, let's go to the computer. Okay, so I have opened Netbeans here and what we'll do is we create a project. We have already done that in Netbeans and we go to "new" and we choose "Java with ANT" and "Java application" and then we created a project called "RandomCodelet" and you can see this random codelet project here and in this project we have a source package that is called org.yawlfoundation.yawl.resourcing.codelets. We can also choose another name but this one is the package name of the ordinary YAWL codelets and inside this, we put the "RandomNumberCodelet.java and here you can see the code of this codelet and the interesting part is the execute method. In the execute method, there is an exchange of the input and output parameters of the codelet and then there is a part that does the actual logic and in this case - it's the random generator that generates a random number between I think one and the maximum number. The maximum number is the input parameter to the codelet. So that's for the code. The file is in the supplementary material. You have to - in order to compile it, you have to go to the project properties under libraries and you can add in the class path. You can add the library YAWLLib and also jdom2. These two are needed for compiling our codelet. Then we compile the whole thing. And the resulting jar file, we put it here in a directory YAWL plugins directly under C. And here you can see RandomCodelet2.jar. This is the jar file of this project and there's also another Java file from another tutorial here. We have to tell the YAWL engine that it has to look in this directory and for this we edit the web.xml file. This is the web xml file in the resource service WEB-INF directory of the YAWL engine. This file is also in the supplementary material. You can use this or you can just edit your own file. There's just one line we have to edit we have to go down somewhere there is a parameter called External Plugins Path and there is a description here that explains well how all this has to be set up and we just took the example directory C:\yawlplugins. You can choose any other directory of course and that's all we have to change. So now we can compile the whole thing, put the jar file in this directory and then we can start the YAWL engine and also start the YAWL editor and in the YAWL editor, we load the specification CodeletInvocation.yawl. This is also found in the supplementary material and this is a very simple three-step workflow. We set the maximum number. This is a manual task. Then there is an automatic task you can recognize this by this green triangle here. As soon as it's automated it has this green triangle and then, in the third step, we check the random number. This is just a control if everything has worked well and you can if we select this invoke codelet task you can see that here we have said that this is automated. So, we have put the check mark here and if we go to this three dots here, we can see that the random number codelet is in the list. So, this is something you have to check when you try to do this. You may have to restart the YAWL editor before things become visible but your codelets should be in this list. There is a list of default codelets that come shipped with the YAWL engine like ExampleCodelet for example and then this is here and so this has to be connected and the next step is that we upload this to the YAWL engine. And we have a new case with case id 4. Here it is and in the admin queues, we just assign this directly to this admin user here. Go to the work queue and we see the first task "Set maximum" and I put in 56 here, complete and then the invoke codelet is running. We may just look at the log here. So, check out successful check random number. So, we can see that random number is now active. We go to the admin queues and see that this is in our work list in the started queue and the result is 46. That's all! I hope you could get this running on your computer. Next, we'll install the Postgres database management system.