[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.platform] Re: how to read the extensions registry outside eclipse
|
Hi Paul,
I had found a similar code you mentioned in eclipsezone website. But it did
not work for me. Then I tried what you mentioned below, still I have an
issue.
Here is what I did -
I have a plugin called "com.mycompany.base.ui". This contains the below
plugin.xml file-
<plugin>
<extension-point id="testcontributor" name="%ExtPoint.testcontributor"
schema="schema/testcontributor.exsd"/>
<extension
id="MyDataProjectNature"
name="%MyDataProjectNature.name"
point="org.eclipse.core.resources.natures">
<runtime>
<run
class="com.mycompany.base.ui.project.MyDataProjectNature">
</run>
</runtime>
</extension>
</plugin>
Here is the code I had to load the above xml file to the registry-
RegistryStrategy stratergy = new RegistryStrategy(null, null);
IExtensionRegistry registry = new ExtensionRegistry(stratergy, masterToken,
null);
IContributor contrib =
ContributorFactorySimple.createContributor("com.mycompany.base.ui");
String path = "D:\com.mycompany.base.ui\plugin.xml";
InputStream is = new FileInputStream(path);
registry.addContribution( is, contrib, false, null, null, null );
I get the error -
Error: Could not parse XML contribution for "com.mycompany.base.ui/". Any
contributed extensions and extension points will be ignored.
But when I tried the below test case it worked. I think it is because the
plugin ID "RegistryTest" is in the XML file while the 3.2 plugin.xml that I
have does not have the plugin ID. This is now in the MANIFEST.MF file.
String xmlContribution = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
//$NON-NLS-1$
"<plugin id=\"RegistryTest\" version=\"1.0.0\">" + //$NON-NLS-1$
"<extension-point id=\"point1\" name=\"Test extension point\"
schema=\"schema/schema.exsd\"/>" + //$NON-NLS-1$
"<extension point=\"point1\" id=\"extension1\">" + //$NON-NLS-1$
"</extension></plugin>";
IContributor contrib =
ContributorFactorySimple.createContributor("RegistryTest");
RegistryStrategy stratergy = new RegistryStrategy(null, null);
IExtensionRegistry registry = new ExtensionRegistry(stratergy,masterToken,
null);
InputStream is = new ByteArrayInputStream(xmlContribution.getBytes());
registry.addContribution( is, contrib, false, null, null, null );
Is there anything else I have to do to get my plugin.xml file working?
Thanks.
"Paul Webster" <pwebster@xxxxxxxxxx> wrote in message
news:faf166$555$1@xxxxxxxxxxxxxxxxxxxx
> Rashmy wrote:
>> I found examples in the below two plugins for the creation of my own
>> ExtensionsRegsitry outside of the Eclipse IDE
>> org.eclipse.equinox.test.internal.standalone
>> org.eclipse.core.tests.internal.registry.simple
>>
>> But both these require me to pass an IContributor that is defined in
>> core.runtime.
>
> No, it's in the org.eclipse.core.runtime package but it is actually
> defined in the equinox.registry bundle. ContributorFactorySimple is also
> in the equinox.registry bundle.
>
> Also, check in the thread titled "Using Extension Registry without OSGi"
> in eclipse.technology.equinox. It looks like you don't even need the
> org.eclipse.osgi bundle, but can reduce the size needed by using the
> supplemental one.
>
> It can be done completely with the 3 jars mentioned in this thread and a
> java app:
>
> masterToken = new Object();
> registry = RegistryFactory.createRegistry(new RegistryStrategy(null,
> null), masterToken, null);
>
> Then for each plugin.xml you need to check:
>
> InputStream pluginXmlInput = ...;
> String pluginXmlId = ...;
> ResourceBundle pluginXmlResources = null; // or dig out the correct one
> registry.addContribution(pluginXmlInput,
> ContributorFactorySimple.createContributor(pluginXmlId), false,
> pluginXmlId, pluginXmlResources, masterToken);
>
> Later,
> PW
>
>
> --
> Paul Webster
> http://wiki.eclipse.org/Platform_Command_Framework
> http://wiki.eclipse.org/Command_Core_Expressions
> http://wiki.eclipse.org/Menu_Contributions
> http://wiki.eclipse.org/Menus_Extension_Mapping