Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Handle to project's classloader
Handle to project's classloader [message #303612] Thu, 18 May 2006 00:19 Go to next message
Eclipse UserFriend
Originally posted by: kautulm.bea.com

Does anybody know how can I can get a handle to a project's classloader? My
plugin needs access to the project's classloader and I am not able to find a
way to get a handle to it.

Thanks in advance for your reply.

-Kautul
Re: Handle to project's classloader [message #303641 is a reply to message #303612] Thu, 18 May 2006 11:33 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Kautul Mehta wrote:
> Does anybody know how can I can get a handle to a project's classloader? My
> plugin needs access to the project's classloader and I am not able to find a
> way to get a handle to it.

What's a project classloader? When eclipse is running you have the
application classpath (which is startup.jar) and the bundle classpaths.

Within your plugin, you can see your own plugin classloader.
MyPlugin.class.getClassLoader().

You can get eclipse to load classes from any plugin using that plugin's
Bundle#loadClass(*) method. You can find bundles using
Platform#getBundle(*).

Through OSGi, you can also get find the bundle that loaded a particular
class.

Later,
PW


Re: Handle to project's classloader [message #303667 is a reply to message #303641] Thu, 18 May 2006 18:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kautulm.bea.com

Let's say that I have a project foo of type 'Web project' in my workspace.
Now, it has dependencies defined on other projects and so on. So, at runtime
when this web project is deployed, it will have a classloader of it's own
which will define what all this web project can access. My plugin needs the
design time equivalent of this classloader to find classes/resources that
this web project can access. So, my question is how do I get a handle to a
project's classloader/classpath. There is a way of doing this for java
projects through IJavaProject.getResolvedClasspath(), but what about other
types of projects.


"Paul Webster" <pwebster@ca.ibm.com> wrote in message
news:e4hm31$b3e$1@utils.eclipse.org...
> Kautul Mehta wrote:
>> Does anybody know how can I can get a handle to a project's classloader?
>> My plugin needs access to the project's classloader and I am not able to
>> find a way to get a handle to it.
>
> What's a project classloader? When eclipse is running you have the
> application classpath (which is startup.jar) and the bundle classpaths.
>
> Within your plugin, you can see your own plugin classloader.
> MyPlugin.class.getClassLoader().
>
> You can get eclipse to load classes from any plugin using that plugin's
> Bundle#loadClass(*) method. You can find bundles using
> Platform#getBundle(*).
>
> Through OSGi, you can also get find the bundle that loaded a particular
> class.
>
> Later,
> PW
Re: Handle to project's classloader [message #303699 is a reply to message #303667] Fri, 19 May 2006 11:12 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Kautul Mehta wrote:
> Let's say that I have a project foo of type 'Web project' in my workspace.
> Now, it has dependencies defined on other projects and so on. So, at runtime
> when this web project is deployed, it will have a classloader of it's own
> which will define what all this web project can access. My plugin needs the
> design time equivalent of this classloader to find classes/resources that
> this web project can access. So, my question is how do I get a handle to a
> project's classloader/classpath. There is a way of doing this for java
> projects through IJavaProject.getResolvedClasspath(), but what about other
> types of projects.
>

That is probably per-feature dependent. The WTP people can probably
help answer that.

Later,
PW


Previous Topic:Stepping into JDK
Next Topic:Setting up Eclipse for a new programming language
Goto Forum:
  


Current Time: Sat Apr 20 00:04:31 GMT 2024

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

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

Back to the top