Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Starting plugin with a non UI contribution
Starting plugin with a non UI contribution [message #1821672] Tue, 18 February 2020 13:12 Go to next message
vlad tsepesh is currently offline vlad tsepeshFriend
Messages: 3
Registered: January 2012
Junior Member
Hi all,

I got two plugin:

    the first one contains all the logic of the user experience, i.e. button, text area and so on, and declare an extension point
    <plugin>
    <extension-point id="any.id" name="Save" schema="any.id.exsd"/>
    ...
    </plugin>

    #################
    #### any.id.exsd ####
    #################
    <element name="client">
    <complexType>
    <attribute name="class" type="string">
    <annotation>
    <documentation>

    </documentation>
    <appinfo>
    <meta.attribute kind="java" basedOn=":my.package.ISave"/>
    </appinfo>
    </annotation>
    </attribute>
    </complexType>
    </element>

    the purpose of this extension is to store some data to a datastore.

    the second one contains only the logic of implementing the way to persist the data, it implements the any.id plugin
    <plugin>
    <extension point="any.id">
    <client class="another.package.SaveToDatabase">
    </client>
    </extension>
    ....
    </plugin>

    where, obviusly SaveToDatabase class implement the ISave interface.


Given that there's many way to store the data, a database is only one of those, the second plugin is provided via a p2 repository, it means we don't know at deploy time of the product which plugin is available.
So when I try to invoke the implementors of my extension point via the following code
String saveExtensionPointId = "any.id";

IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(saveExtensionPointId);

Arrays.asList(config).forEach(c -> {
	try {
	   ISave s = (ISaveCounter) c.createExecutableExtension("class");
          s.save(...);
	} catch (Exception e) {
	}
});

the config[] is empty, which means the second plugin has not been started, the eclipse rcp framework did not analyze the plugin itself and register the extension point to the given id.
The only way I get everything works fine is


    to deploy both the plugin in the same product, in a monolithic way, and declare the autostart for second plugin, but in this way I did not have the advantages of the repo.


or


    declare some UI object, such as a menu, which do nothing, only to have the Activator started.
    Not elegant at all.


PS: changing the Bundle-ActivationPolicy: makes no effect

Am I missing something?
Or I am doing something wrong?

Hope everything is clear in order to understand what is wrong.
TIA.
Re: Starting plugin with a non UI contribution [message #1821718 is a reply to message #1821672] Wed, 19 February 2020 06:22 Go to previous messageGo to next message
Rolf Theunissen is currently offline Rolf TheunissenFriend
Messages: 179
Registered: April 2012
Senior Member
Maybe you can find the answer here:

https://wiki.eclipse.org/FAQ_When_does_a_plug-in_get_started%3F
Re: Starting plugin with a non UI contribution [message #1821949 is a reply to message #1821718] Mon, 24 February 2020 11:49 Go to previous messageGo to next message
vlad tsepesh is currently offline vlad tsepeshFriend
Messages: 3
Registered: January 2012
Junior Member
As stated in the post:
Quote:
If a plug-in contributes an executable extension, another plug-in may run it, causing the plug-in to be automatically loaded. For more details, read the API javadoc for IExecutableExtension in the org.eclipse.core.runtime package.

and I really do contribute with an executable extension but, unless I declare the plugin with an autostart set to true, there's no way to have the plugin runing, that is having the Activatro#start methond invoked.
Re: Starting plugin with a non UI contribution [message #1821958 is a reply to message #1821949] Mon, 24 February 2020 14:01 Go to previous message
Rolf Theunissen is currently offline Rolf TheunissenFriend
Messages: 179
Registered: April 2012
Senior Member
I missed your comment on the empty config array. AFIAK, the configuration elements are available before a plugin is active, i.e. as long as the plugin is resolved.
getConfigurationElementsFor "Returns an empty array if the extension point does not exist, has no extensions configured, or none of the extensions contain configuration elements"

Observations:
- "any.id" is not a valid extension-point id. I guess that is from anonymizing your example. Do not a fully qualified name in your plugin, it will automatically be prefixed with your plugin ID. Do use the fully qualified name in your second plugin that refers to the extension point.
- use RegistryFactory.getRegistry() instead of Platform.getExtensionRegistry()

If this doesn't help, you could try to use an debugger on ExtensionRegistry#getConfigurationElementsFor, to see if the extension point is correctly registered.
Previous Topic:Eclipse - Wizard Page
Next Topic:Eclipse Wizard - Back Button event
Goto Forum:
  


Current Time: Tue Oct 20 03:56:58 GMT 2020

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

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

Back to the top