Custom codelets
Hi all,
As I was reading throught the User's Manual, it mentioned that a codelet was a custom Java class that could be run in an automated task. It also mentioned that adding a custom codelet was covered in the Technical Manual, which I found out doesn't exist yet. My question is, does anyone know how to add a custom codelet to the YAWL envrionment, and any of the possible interfaces that need to be inherited?
Thanks in advance for your help.
Jeremy
Hi Andreas,
The package for your class has to match the package you put it into (that is, org.yawlfoundation.yawl.resourcing.codelets). If it matches and you still have a problem, you can email me a copy of your class directly and i will figure out what's wrong.
Cheers, Michael.
Hi Michael, thanks a lot. That solved it. I will continue my work until I run into the next problem ;-) Regards, Andreas
Question...once I have a codelet written, how do I get the YAWL Editor to recognize the new codelet? My hunch at first was to take the .class file and update the exisiting .Jar, putting the new class in the correct spot. The problem I'm having is that there are too many dependancies to compile the class. I've got YAWL built as a NetBeans project, but I'm running into several missing .jars that are nowhere to be found (com.sun.rave.web.ui.component.*). Is there a better way to add a new codelet into the mix? Thanks for your help in advance.
Jeremy
Hi Jeremy,
Put your class file on the server side (not inside the editor jar) at "your_tomcat_dir/webapps/WEB-INF/classes/org/yawlfoundation/yawl/resourcing/codelets".
Once its there, the 'CodeletFactory' will automatically find it when the editor asks for a list of codelets across the resource service interface, and it will show up in the editor's list along with the standard codelets.
Cheers, Michael.
what if i already put the class file for my codelete in the location you specified..and still the yawl engine doesn't recognize it?and after a while,the list of the existing codelets(given as examples) disappears?
The problem may be the editor - please download the latest build of the editor and see if that makes a difference.
Hi Jeremy,
To create a custom codelet, you need to create a new class extending from AbstractCodelet (all codelets, and the AbstractCodelet class, reside in the package org.yawlfoundation.yawl.resourcing.codelets). There are two methods your codelet needs to implement - execute and cancel. The execute method receives the calling workitem's data (as xml), and lists of the workitem's input and output parameters, and returns the updated data. The cancel method will be called if a codelet is running when the calling workitem is cancelled, so should be written to handle any cleanup action required.
AbstractCodelet contains a number of helper methods to take care of the mundane stuff, so a codelet developer can just concentrate on what it wants to do with the workitem. There are a few codelets that ship with YAWL that you can look at to get the general idea. In particular, take a look at ExampleCodelet (first) - its a trivial example, but has lots of comments to explain what's going on and how to create your own.
Cheers, Michael.
Thanks for pointing the way, Michael. :)
regards,
Jeremy





hi,
I seem to have a similar problem... here is what I did:
I copied ExampleCodelet.java in a new project and included jdom.jar and YAWL_2.1_standalone.jar in the build path. I changed the name of the class to MyCodelet and put it into another package.
I compiled it and put the MyCodelet.class into the
YAWL4Study-2.1/engine/apache-tomcat-6.0.18/webapps/resourceService/WEB-INF/classes/org/yawlfoundation/yawl/resourcing/codelets
folder.
When I try to get the list of codelets (I'm using YAWL editor 2.1 build date 2010.07.27 13:10:32) it ist EMPTY!!
As soon as I delete the MyCodelet.class from the folder the list reappears.
What am I doing wrong?
Your help would be appreciated.
Regards, Andreas