[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.newcomer] Re: Accessing fragment from host plugin

Tony,

I'm not sure the answer.  You might have better luck on the RCP newsgroup because I see lots of detailed questions there about OSGi and all this kind of plugin and fragment stuff:
news://news.eclipse.org/eclipse.platform.rcp
Perhaps it's not even possible to do what you are doing.  E.g., I have to wonder how the host plugin can properly have a direct development time compile dependency on something that is only optionally available at runtime.  I would think that normally what you're trying to do would be accomplished by the host plugin defining an extension point and having some other plugin(s) contributing to that extension point.  That certainly seems like an easier and perhaps better way.  I've only seen fragments used to provide things like optional translations (though I'm not saying that's their only use).


Tony wrote:
I'm sure I'm missing something obvious here, but I just can't figure out what it is.  I'm trying to use a plugin fragment to provide optional functionality, which is one of the envisioned uses of plugin fragments according to everything I've read about them.  I have a package in my host plugin, and have the same package in my fragment.  I have defined an abstract class in my host plugin, and defined a concrete subclass in my fragment.  The subclass in the fragment resolves it's superclass just fine, without having to import or qualify the name or anything, since both the superclass and the subclass are in the same package.

My problem appears when I try to access the concrete subclass, defined in the fragment, from within my host plugin.  When I try to do so, compilation fails because the name of my subclass can't be resolved, with or without imports or qualification.

It seems obvious to me why this happens -- the host plugin knows nothing about it's fragment after all.  However, based on what I've read, it seems like code contained in a fragment ought to be accessible from within the host.  In particular, if a fragment is to provide optional functionality to a host plugin, then its code must somehow be accessible from the host plugin.

Anyway, if anyone can help me out with what I'm doing wrong, or correct me if I'm making bad assumptions, please respond.  In a sentence, my question would be "How do I make a class defined in a plugin fragment visible to a class in the fragment's host plugin"?  Thanks in advance.

Tony