Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2007

Tip: Looking for answers? Try searching our database.

[Runtime Code Changes] ideas...

Thread view: 
Bogus Exception - 15 Oct 2007 21:26 GMT
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?

TIA for any experiences and/or insights!
Daniel Pitts - 16 Oct 2007 05:10 GMT
> I'm curious as to which approaches exist for defining and running Java
> code at run time in EJB3. For example, programmatically defining an
[quoted text clipped - 11 lines]
>
> TIA for any experiences and/or insights!

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.
Lew - 16 Oct 2007 06:21 GMT
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
[quoted text clipped - 9 lines]
>> every time it is run, then it may well be a lot slower than writing
>> source, compiling it, and running in the container, right?

> 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.

Signature

Lew

B☼gus Excepti☼n - 30 Nov 2007 04:58 GMT
Great answers Lew & Daniel,

I don't want the user to do any compiling at all.I want them to enter
code in a window/form and have that code run in a bean at runtime. You
know... they enter their own business logic. I'm just curious what the
best way to do so might be.

Thanks!

> Bogus Exception wrote:
> >> I'm curious as to which approaches exist for defining and running Java
[quoted text clipped - 36 lines]
> --
> Lew
Roedy Green - 30 Nov 2007 07:28 GMT
On Thu, 29 Nov 2007 20:58:46 -0800 (PST), "B?gus Excepti?n"
<bogusexception@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>I don't want the user to do any compiling at all.I want them to enter
>code in a window/form and have that code run in a bean at runtime. You
>know... they enter their own business logic. I'm just curious what the
>best way to do so might be.

Obviously SOMETHING has to parse the source and convert it into
something executable.  The usual thing to do that is javac or the
on-the-fly equivalents.

Perhaps what you mean is you don't want the user to be involved in any
way with the compilation process.  It should happen transparently.

see http://mindprod.com/jgloss/onthefly.html
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

B☼gus Excepti☼n - 02 Dec 2007 17:25 GMT
Roedy,

Thanks for writing. See below inline...

On Nov 30, 2:28 am, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
[...]
> Obviously SOMETHING has to parse the source and convert it into
> something executable.  The usual thing to do that is javac or the
> on-the-fly equivalents.

Exactly. And this is why I have posted the inquiry. There seem to be 2
choices, and I can't determine the differences between them. I see the
choices as:

1. An actual compile into a class, and create/copy that class into a
jar, then copying that jar file into the ./deploy dir (my prototype is
JBoss 4).
2. Have the user fill in BeanShell, and run that.

I am very concerned about the speed of BeanShell in comparison to
compiled classes. Unfortunately, I need performance centered around
creating objects based on the user code at a very high rate. If I need
to parse BeanShell every time an object is instantiated, then it will
probably be exponentially slower than a compiled class, no?

> Perhaps what you mean is you don't want the user to be involved in any
> way with the compilation process.  It should happen transparently.

Exactly. I just want them to configure any business logic, save their
session/work, and it just works.

I just don't know anything about the performance risks associated with
BeanShell, or whether there is another, oblique option I am not even
aware of.

Thanks again for writing!
Daniel Pitts - 02 Dec 2007 17:55 GMT
Apologies to Bogus, I've had to sanitize the encoding of your name.
Bogus Exception wrote:
> Roedy,
>
[quoted text clipped - 33 lines]
>
> Thanks again for writing!
Or you could have them submit a Java source file and compile on the
remote end, and automatically handle the deployments there.

You might even make it into a HTML form where they can type the Java
source text in there.  Although in reality, if the client needs this
kind of customizable software, then they probably should be savvy enough
to use a full fledged compiler/ide/etc...

Signature

Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.