Sounds like a good one:)
Will definately look into both..
The reason why i was asking for this is that i have been given the assignment to implement a "rule system" into a security system. The rule system should allow the user to dynamically define the functionality (interaction between security sensors and actuators).
Thus far i've found two possibiltys. The first is an interpreted script (either by my own definition->interpreted or translated to java and then interpreted, or perhaps plain java), the second are simple "expert systems" or "rule based systems".
Now, i'm still looking for alternatives or examples/knowledge of simple rule based systems as it is part of the research i have to do for school:)
Any tips on this are welcome!
: Have you looked into Java's reflection package? It is
: java.lang.reflect
:
: With Java reflection, you can load Class definitions by class name
: at runtime. You can also access Method arrays. It lets you invoke
: methods on particular Objects and so on. You can learn more about
: it from Java's tutorials.
:
: Java reflection works with compiled java code, though.
:
: To keep a degree of simplicity, my advice is to assume the user has
: an Java SDK version installed and maybe even that the environment
: variables are properly set so the javac command works. This way,
: you can use the RunTime class to delegate compiling to the javac
: command. After compilation, you can then use the reflection package
: classes to manipulate those new classes and objects at runtime.
:
: It is generally good to reuse things that have been thoroughly
: developed, and tested because they are more stable. If you want to
: encourage people to use your software, it is best to work with
: software that is well established and well known because it tends to
: be more familiar to those people. Either way prefers the use of
: Sun's Java compiler and the standard reflection API instead of a
: java interpreter.
:
:
: : : Hello everyone!
: : :
: : : Perhaps a strange question, but my subject says it all.. Im looking
: : : for a way to interprete runtime-generated javacode within java.
: : :
: : : That is, the generated code should be able to access "hard-coded"
: : : functions from the application itself.
: : :
: : : Is there a way to do this?
: :
: : In Java SE 6 there is: the JavaCompiler interface. JavaDoc:
: :
http://java.sun.com/javase/6/docs/api/javax/tools/JavaCompiler.html
: : If you want to run a script from within your program, you can also
: : use a descendant of the AbstractScriptEngine. JavaDoc:
: :
http://java.sun.com/javase/6/docs/api/javax/script/AbstractScriptEngi
: : ne.html
: : In Java 5 or earlier, you need to run javac with the correct
: : commandline options from your program.
:
: