Re: ideas...
Bogus Exception wrote:
I'm curious as to which approaches exist for defining and running Java
code at run time in EJB3. For example, programmatically defining an
entity, or other, bean.
My program wants to take code written by a user and incorporate it
into the running system. For speed (and other?) considerations,
BeanShell appears to be an unwise choice, right? This leaves me with
crafting a complete Java class in a string, then compiling and copying
to ./deploy, right?
If BeanShell is parsed (like any other interpreted language) each and
every time it is run, then it may well be a lot slower than writing
source, compiling it, and running in the container, right?
Daniel Pitts wrote:
Why not have the end-user compile and upload the code? Or better yet,
use RMI's capability in that regard. BTW, it sounds like a bad idea.
Unless you have really strict and secure access. As soon as someone
can run arbitrary code on your end, then someone can run malicious
code on your end.
Actually, Java is a good environment for doing exactly that, with great
caution and not without risk. You can bring foreign classes in via a custom
ClassLoader that isolates the suspect code from doing undo damage.
I'm no expert in that, and I sure wouldn't tread there lightly, but I've heard
tell of such schemes.
This is not the same as to "incorporate it into the running system", perhaps,
if by that the OP means without such walls of protection.
Jini is another approach for runtime discovery and connection to components.
The workable approaches provide mechanisms for "really strict and secure access".
I don't know how one can make /a priori/ judgments about the speed of
BeanShell vs. other approaches. What is it that would make BeanShell slow,
and for what meaning of slow.
--
Lew