Page 1 of 1
compile method via code
Posted: Fri Aug 24, 2012 2:08 am
by thaban
Do anyone know how to compile a Method through coding after modifying it (via vMethod.setPropertyValue('source',vSrc) ). The system does not recongize changes to method source code until it has been compiled. Is there a way to force code compile through code?
Re: compile method via code
Posted: Fri Aug 24, 2012 3:00 am
by ghosttie
As far as I know this is not possible
Re: compile method via code
Posted: Fri Aug 24, 2012 8:28 am
by suzuki1100
Have a look at Process :: createTransientMethod to see if that will suit your needs.
You can essentially provide the modified source code to the method for it to execute.
I dont think you can override an existing method i.e. The transient method cant have the same schema and method name as the existing compiled method
Re: compile method via code
Posted: Fri Aug 24, 2012 9:09 am
by torrie
If the transient method doesn't meet your needs, you could load a new method from a schema file. The schema file is just a text file containing the method source. Right click a method and choose Extract to create a file. You should be able to copy the format. It can be loaded using the Jadloadb utility (see Jadload.pdf). This can be run as an external process (see Node::createExternalProcess) (Note you will need to be running Jade in MultiUser mode for this to work.)
We use Jadloadb to deploy updated schemas to our client sites. I would be a little concerned if the systems were updating their own code as it would create a number of deployment issues!
Re: compile method via code
Posted: Fri Aug 24, 2012 10:52 pm
by alanvl
I found the following works
beginTransaction;
lJadeMethod.setPropertyValue('source', lValidatedSource);
lJadeMethod._compile;
commitTransaction;
I made sure that the source is validated as a transient method first (must use a different name if the method already exists). BUT this does not update patch versioning and as Torrie points out you need to carefully consider deployment issues. I have used Torries method with JadLoadb as well - you can work this in to an online solution
Re: compile method via code
Posted: Wed Sep 05, 2012 3:26 am
by thaban
thanks guys. i will try it out.