Platform.getBundle()... symbolic name of class in PDE project? [message #247108] |
Wed, 29 August 2007 23:19  |
Eclipse User |
|
|
|
I have built an RCP app that allows users to run a series of financial
models. These models (which are updated frequently) include (1) data
stored as xml and (2) a unique java code snippet written to my API. The
xml and java code reside on a web server.
To be of any use, the RCP app has to load these models through corporate
firewalls (meaning: HTTP only). That is easy for the xml files and java
source, using an HttpUrlConnection and related authentication.
....but then...
I need the app to compile the code snippet and instantiate the class
that it represents (not as dangerous as it sounds... the code is tested
before it is put on the web server).
Compilation is easy enough: the RCP app makes a local java project, adds
the PDE nature and streams the code into /project/src. The auto build
takes over and drops related class file into /bin. I have a resource
change listener that wakes up when the class file appears...
....but then...
I don't know how to instantiate the class. Does it have a symbolic name
so I can call Platform.getBundle(String)?
** I realize that this seems silly if you are accustomed to production
environments that allow normal connections between clients and servers,
but my customers all have similar (strict) firewall policies **
(thanks)
|
|
|
Re: Platform.getBundle()... symbolic name of class in PDE project? [message #247116 is a reply to message #247108] |
Thu, 30 August 2007 02:19   |
Eclipse User |
|
|
|
Originally posted by: wharley.bea.com
"Michael Megliola" <michael.megliola@gmail.com> wrote in message
news:fb5d0s$llq$1@build.eclipse.org...
>
> I have built an RCP app that allows users to run a series of financial
> models. These models (which are updated frequently) include (1) data
> stored as xml and (2) a unique java code snippet written to my API. The
> xml and java code reside on a web server.
>
> To be of any use, the RCP app has to load these models through corporate
> firewalls (meaning: HTTP only). That is easy for the xml files and java
> source, using an HttpUrlConnection and related authentication.
>
> ...but then...
>
> I need the app to compile the code snippet and instantiate the class that
> it represents (not as dangerous as it sounds... the code is tested before
> it is put on the web server).
Why can't the compilation happen on the server side, and a .class file be
transmitted to the client, rather than transmitting .java and compiling on
the client side? In other words, can this not be done with an applet?
> Compilation is easy enough: the RCP app makes a local java project, adds
> the PDE nature and streams the code into /project/src. The auto build
> takes over and drops related class file into /bin. I have a resource
> change listener that wakes up when the class file appears...
Seems like overkill... could you just call the Eclipse Java compiler
directly to compile the .java, rather than setting up a whole Java project?
Then you wouldn't need PDE and JDT UI in the picture, and in fact you'd only
need a fraction of JDT core.
> ...but then...
>
> I don't know how to instantiate the class. Does it have a symbolic name so
> I can call Platform.getBundle(String)?
It's not in a Bundle, so that wouldn't help. What you want is to create an
URLClassLoader aimed at the directory that you're compiling (or downloading)
the .class file into. Then use the ClassLoader to instantiate the class.
As an aside, obviously you know more about this than I :-) but I can't say I
share your confidence in the safety of this method. What you're saying is
that you are allowing your client app to load and execute arbitrary Java
code, albeit obtained over a connection that you hopefully have some control
over. If I were the guy running that client on my machine, I'd want that
code to be precompiled and digitally signed by a trusted server; and I'd
want it to be running in a safe "sandbox", the way Java applets do.
|
|
|
Re: Platform.getBundle()... symbolic name of class in PDE project? [message #247128 is a reply to message #247116] |
Thu, 30 August 2007 07:36  |
Eclipse User |
|
|
|
I agree with your comments completely... it is an unintended (sad?
funny?) side effect of our client's security policies that we can't use
class files or applets on the server side -- they have those blocked --
so we have to send arbitrary source code and compile it locally (how
much less safe is that?)
Otherwise --
-- I should call the java compiler directly; I made the local side an
Eclipse project in mis-placed hope of using the Eclipse infrastructure
to load the resulting class
-- I did not use a URLClassLoader out of ignorance, I will try that.
Thanks for the help --
Michael
Walter Harley wrote:
> "Michael Megliola" <michael.megliola@gmail.com> wrote in message
> news:fb5d0s$llq$1@build.eclipse.org...
>> I have built an RCP app that allows users to run a series of financial
>> models. These models (which are updated frequently) include (1) data
>> stored as xml and (2) a unique java code snippet written to my API. The
>> xml and java code reside on a web server.
>>
>> To be of any use, the RCP app has to load these models through corporate
>> firewalls (meaning: HTTP only). That is easy for the xml files and java
>> source, using an HttpUrlConnection and related authentication.
>>
>> ...but then...
>>
>> I need the app to compile the code snippet and instantiate the class that
>> it represents (not as dangerous as it sounds... the code is tested before
>> it is put on the web server).
>
> Why can't the compilation happen on the server side, and a .class file be
> transmitted to the client, rather than transmitting .java and compiling on
> the client side? In other words, can this not be done with an applet?
>
>
>> Compilation is easy enough: the RCP app makes a local java project, adds
>> the PDE nature and streams the code into /project/src. The auto build
>> takes over and drops related class file into /bin. I have a resource
>> change listener that wakes up when the class file appears...
>
> Seems like overkill... could you just call the Eclipse Java compiler
> directly to compile the .java, rather than setting up a whole Java project?
> Then you wouldn't need PDE and JDT UI in the picture, and in fact you'd only
> need a fraction of JDT core.
>
>
>> ...but then...
>>
>> I don't know how to instantiate the class. Does it have a symbolic name so
>> I can call Platform.getBundle(String)?
>
> It's not in a Bundle, so that wouldn't help. What you want is to create an
> URLClassLoader aimed at the directory that you're compiling (or downloading)
> the .class file into. Then use the ClassLoader to instantiate the class.
>
> As an aside, obviously you know more about this than I :-) but I can't say I
> share your confidence in the safety of this method. What you're saying is
> that you are allowing your client app to load and execute arbitrary Java
> code, albeit obtained over a connection that you hopefully have some control
> over. If I were the guy running that client on my machine, I'd want that
> code to be precompiled and digitally signed by a trusted server; and I'd
> want it to be running in a safe "sandbox", the way Java applets do.
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.10482 seconds