Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Dynamically loading external files
Dynamically loading external files [message #485753] Mon, 14 September 2009 19:51 Go to next message
Ric Wright is currently offline Ric WrightFriend
Messages: 70
Registered: July 2009
Member
I have written a (physics) modeling system that manages datasets, dataflow
and visualization dynamically. Third parties can write their own
data-processing and visualization classes and have them included in the
workflows. The external classes are loaded via reflection (i.e.
ClassForName and then classe.getConstructor(types).newInstance(args).

This all works fine as long as the class is within the jars that make up the
modeling system. But if the class is in some third party jar that the
modeling system has never seen before, then of course the classloader can't
find the class.

Is there a way to update the classpaths the classloader searches WITHOUT
recompiling or otherwise change the host modeling system?

TIA, Ric
Re: Dynamically loading external files [message #485947 is a reply to message #485753] Tue, 15 September 2009 15:48 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Are you talking about a java app? Then adding the 3rd party jars to the classpath is enough to make them visible to Class.forName(*).

Is this an RCP application?

If you are talking about turning your modeling engine into a plugin and then having other plugins contribute to it, then that's done via extension points and extensions.

Otherwise you have to use Buddy classloading (that's still 2 plugins).

If you are talking about having your modeling engine in a plugin and then loading extra classes from jars on the system ... well, that's another story entirely Smile

PW


Re: Dynamically loading external files [message #485965 is a reply to message #485947] Tue, 15 September 2009 17:51 Go to previous messageGo to next message
Ric Wright is currently offline Ric WrightFriend
Messages: 70
Registered: July 2009
Member
Well, it is "another story entirely". The modeling engine is implemented as
a group of plugins that form a perspective. The engine needs to be able to
instantiate objects that are present in 3rd party jars that are not known to
the engine at compile time for the engine. The classes in the third party
jar implement interfaces or abstract classes that are defined in the engine.
All this works now as long as the "3rd party jar" is known to the engine
when the engine is compiled (so the classpaths are known). But that isn't a
palatable requirement down the road.

I have done a little spelunking and it looks like I can achieve what I want
either using URLLoader classloader or writing my own classloader. The
former may sandbox the class causing grief. I don't know a lot about
classloaders so I probably have some learning ahead. :-)

Thanks,
Ric



On 9/15/09 8:48 AM, in article h8od10$gnh$1@build.eclipse.org, "Paul
Webster" <pwebster@ca.ibm.com> wrote:

> Are you talking about a java app? Then adding the 3rd party jars to the
> classpath is enough to make them visible to Class.forName(*).
>
> Is this an RCP application?
>
> If you are talking about turning your modeling engine into a plugin and then
> having other plugins contribute to it, then that's done via extension points
> and extensions.
>
> Otherwise you have to use Buddy classloading (that's still 2 plugins).
>
> If you are talking about having your modeling engine in a plugin and then
> loading extra classes from jars on the system ... well, that's another story
> entirely :)
>
> PW
Re: Dynamically loading external files [message #485991 is a reply to message #485965] Tue, 15 September 2009 19:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Since your modeling engine was developed as a plugin, can you instead
require the "3rd party jars" to be plugins instead and they would use
extension points? That would simplify your whole problem. You would use
the extension points instead of looking up classes.

But if you require to also run outside of Eclipse plugins then you will
need to do classloader gunk.

--
Thanks,
Rich Kulp
Re: Dynamically loading external files [message #486025 is a reply to message #485991] Tue, 15 September 2009 23:15 Go to previous messageGo to next message
Ric Wright is currently offline Ric WrightFriend
Messages: 70
Registered: July 2009
Member
Ah, that is an interesting idea. I was thinking more in terms of generic
Java. Requiring the third party jars to be plugins is eminently doable. I
have little experience of defining extension points - only implementing
them. More learning ahead. But that sounds better than learning more about
the black art of classloaders - about which I know only a little but more
than I want.

Thanks,
Ric



On 9/15/09 12:53 PM, in article h8orce$449$1@build.eclipse.org, "Rich Kulp"
<richkulp@us.NO_SPAM.ibm.com> wrote:

> Since your modeling engine was developed as a plugin, can you instead
> require the "3rd party jars" to be plugins instead and they would use
> extension points? That would simplify your whole problem. You would use
> the extension points instead of looking up classes.
>
> But if you require to also run outside of Eclipse plugins then you will
> need to do classloader gunk.
Re: Dynamically loading external files [message #486133 is a reply to message #486025] Wed, 16 September 2009 13:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Hi,

Here's an article on the plugin architecture including extensions.

http://www.eclipse.org/articles/Article-Plug-in-architecture /plugin_architecture.html


Ric Wright wrote:
> Ah, that is an interesting idea. I was thinking more in terms of generic
....
> them. More learning ahead. But that sounds better than learning more about
> the black art of classloaders - about which I know only a little but more
> than I want.
>
> Thanks,
> Ric

--
Thanks,
Rich Kulp
Re: Dynamically loading external files [message #487043 is a reply to message #486133] Mon, 21 September 2009 16:06 Go to previous messageGo to next message
Ric Wright is currently offline Ric WrightFriend
Messages: 70
Registered: July 2009
Member
Thanks, Rich. That turned out to be good advice. It's all working smoothly
now.

Ric



On 9/16/09 6:34 AM, in article h8qph8$aif$1@build.eclipse.org, "Rich Kulp"
<richkulp@us.NO_SPAM.ibm.com> wrote:

> Hi,
>
> Here's an article on the plugin architecture including extensions.
>
> http://www.eclipse.org/articles/Article-Plug-in-architecture /plugin_architectu
> re.html
>
>
> Ric Wright wrote:
>> Ah, that is an interesting idea. I was thinking more in terms of generic
> ...
>
>> them. More learning ahead. But that sounds better than learning more about
>> the black art of classloaders - about which I know only a little but more
>> than I want.
>>
>> Thanks,
>> Ric
Re: Dynamically loading external files [message #487067 is a reply to message #487043] Mon, 21 September 2009 18:02 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Great!

Ric Wright wrote:
> Thanks, Rich. That turned out to be good advice. It's all working smoothly
> now.
>
> Ric
>

--
Thanks,
Rich Kulp
Previous Topic:Filter commands by parameter
Next Topic:Re: Column Resize Is Too Large To Display
Goto Forum:
  


Current Time: Tue Apr 23 15:50:01 GMT 2024

Powered by FUDForum. Page generated in 0.03614 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top