instantiating a class from another plugin [message #307756] |
Wed, 30 August 2006 17:51 |
Eclipse User |
|
|
|
Originally posted by: vik_ram.hotmail.com
Hi,
Is it possible to instantiate a class from another plugin without
defining a dependency on that plugin.
The way our product is bundled is that we may ship plugin A alone OR
plugin A and plugin B. plugin B depends on plugin A but plugin A can run
independently. We want to define a documentProvider common to both
plugins - so we define it in plugin A. The problem is that the
documentProvider class should be able to invoke classes in both A and B
depending on certain criteria ( strategy pattern ) . But as it is
defined in plugin A , it cannot instantiate classes in plugin B.
Thanks,
Vikram
|
|
|
|
Re: instantiating a class from another plugin [message #307759 is a reply to message #307756] |
Wed, 30 August 2006 18:08 |
|
vikram wrote:
> Hi,
>
> Is it possible to instantiate a class from another plugin without
> defining a dependency on that plugin.
>
> The way our product is bundled is that we may ship plugin A alone OR
> plugin A and plugin B. plugin B depends on plugin A but plugin A can run
> independently. We want to define a documentProvider common to both
> plugins - so we define it in plugin A. The problem is that the
> documentProvider class should be able to invoke classes in both A and B
> depending on certain criteria ( strategy pattern ) . But as it is
> defined in plugin A , it cannot instantiate classes in plugin B.
That is the most common use for the extension points/extensions.
ex: plugin A creates a "document provider" extension point and the
interface class, com.example.text.IDocumentProvider. If it also comes
with a document provider, plugin A implements the extension as well:
<documentProvider name="MyDocs"
class="com.example.a.text.MyDocsProvider"/>
Then plugin B creates the extension for its document provider:
<documentProvider name="RedDocs"
class="com.example.b.text.RedDocsProvider"/>
In plugin A, your extension point processing code walks through
IConfigurationElements ... you can use
createExecutableExtension("class") to instantiate a document provider,
and never have to depend on its plugin.
Later,
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
Re: instantiating a class from another plugin [message #307760 is a reply to message #307756] |
Wed, 30 August 2006 18:30 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Vikram,
I agree with Rich's good advice.
But here's a way you could load classes without using an extension point.
Bundle xsdPlugin = Platform.getBundle("org.eclipse.xsd");
if (xsdPlugin != null)
{
try
{
Class theGeneratorClass =
xsdPlugin.loadClass
("org.eclipse.xsd.ecore.Ecore" + type + "SchemaBuilder");
vikram wrote:
> Hi,
>
> Is it possible to instantiate a class from another plugin without
> defining a dependency on that plugin.
>
> The way our product is bundled is that we may ship plugin A alone OR
> plugin A and plugin B. plugin B depends on plugin A but plugin A can
> run independently. We want to define a documentProvider common to
> both plugins - so we define it in plugin A. The problem is that the
> documentProvider class should be able to invoke classes in both A and
> B depending on certain criteria ( strategy pattern ) . But as it is
> defined in plugin A , it cannot instantiate classes in plugin B.
>
> Thanks,
> Vikram
|
|
|
Re: instantiating a class from another plugin [message #307761 is a reply to message #307760] |
Wed, 30 August 2006 19:05 |
Eclipse User |
|
|
|
Originally posted by: vik_ram.hotmail.com
Rich, Paul and Ed,
Thanks for the responses.
Ed Merks wrote:
> Vikram,
>
> I agree with Rich's good advice.
> But here's a way you could load classes without using an extension point.
>
> Bundle xsdPlugin = Platform.getBundle("org.eclipse.xsd");
> if (xsdPlugin != null)
> {
> try
> {
> Class theGeneratorClass =
> xsdPlugin.loadClass
> ("org.eclipse.xsd.ecore.Ecore" + type + "SchemaBuilder");
>
>
> vikram wrote:
>
>> Hi,
>>
>> Is it possible to instantiate a class from another plugin without
>> defining a dependency on that plugin.
>>
>> The way our product is bundled is that we may ship plugin A alone OR
>> plugin A and plugin B. plugin B depends on plugin A but plugin A can
>> run independently. We want to define a documentProvider common to
>> both plugins - so we define it in plugin A. The problem is that the
>> documentProvider class should be able to invoke classes in both A and
>> B depending on certain criteria ( strategy pattern ) . But as it is
>> defined in plugin A , it cannot instantiate classes in plugin B.
>>
>> Thanks,
>> Vikram
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03234 seconds