Thanks for the link to the articles.
I was able to test a code very similar to the ones in the articles, but this is not acceptable for my solution.
I can only access the rules engine by a set of APIs and one of the objects that I have to create is an Action. The rules engine API provides me and Abstract class that I use to create JtyhonAction class, where I implement the two methods exec and configure.
I cannot create an interface and I cannot create a factory, because this would require to create java modules and I'd like a solution where the user can write exclusively Jython code to interact with the rules engine.
I could produce the interface and factory automatically ( or use a template for that), but my problem is the Jython code that has to pass the JythonClass name to another API in my rules engine that will load that class at the apropriate time. I don't control when the class is going to be executed.
I tried generating the java class file using jythonc (which would be acceptable for our solution), but now I cannot import the Jython module into another Jython module.
I need two Jython Modules: JythonAction.py and testProgram.py
# JythonAction.py - contains only the code for the new action that I'm creating for the rules engine
def configure(self, properties):
def exec(self, executionContext, action):
from JythonAction import JythonAction
# on this test Program I'll eventually call
The handle.LoadAction expects a string with the name of the action and a string with the name of the Java class that will be loaded by the event engine.
The original Java code equivalent to the test program would call:
When I compile JythonAction.py and put it in the my classpath, my testProgram.py cannot import JythonAction anymore.
It might be a problem with my classpath being all mixed up, but I tried several things and I couldn't get it to run.
Teresa Vandusen schrieb:
> Hi Diez,
> I wanto to avoid writing anything in Java for this p-o-c. The point is
> to evaluate if we can extend our Rules engine purely using Jython, even
> if I have to break in several modules and run some "magic" in between,
> as long I can automate this steps transparently for the user.
You don't have to write anything in java, beside the basic glueing of
the interpreter together with your framework somehow. The easiest way to
do so is to start from jython and instantiate the rules engine from
there, passing potential jython-implemented objects into the engine.
Here is one of the articles I mentioned, sorry for saying that it was
earlier this year where in fact it appeared in october: