|
Re: Prevent Bundle from being loaded [message #894172 is a reply to message #894056] |
Sat, 07 July 2012 09:16 |
|
Am 06.07.2012 15:56, schrieb Missing name Mising name:
> Do you have any ideas how to do this?
The extension registry is bound to resolved state. Thus, as soon as your
bundle is resolved, the extensions are discovered. Start/stop won't
help. You need to uninstall the bundle.
There are some other options though.
Use capabilities to hide/show (depending on license check) the entries
in the UI.
http://help.eclipse.org/juno/topic/org.eclipse.platform.doc.user/reference/ref-capabilitiespref.htm
However, that won't prevent your views from working. You should better
implement a license check in the view and show a message if no license
is available. That's IMHO better usability if items are always
visibility. It signals the user that they installed your plug-ins
correctly and the messages helps them to understand that just the
license is missing. Otherwise they might get lost if no entry is there
and they don't know if the installation succeeded.
Another option is to implement a license check in your activator and
prevent bundle activation if no license is available. The view will
still be visible in the menu but the platform won't be able to load its
class.
-Gunnar
--
Gunnar Wagenknecht
gunnar@xxxxxxxx
http://wagenknecht.org/
|
|
|
Re: Prevent Bundle from being loaded [message #894338 is a reply to message #894056] |
Sun, 08 July 2012 13:31 |
|
Hello,
one method to consider may be something like this:
1. Create IStartup class that will be checking licence (or whatever
appropriate) and bind it using org.eclipse.ui.startup extension point
(1). Plug-in referred in this extension point will be started when
Eclipse starts.
2. If license check failed in early startup plug-in, uninstall bundle
programmatically with Bundle.uninstall() method (2). List of installed
bundles can be achieved from BundleContext.getBundles() method.
3. As Gunnar said, uninstalled bundles, not surprisingly, do not
contribute to UI anymore.
(1)
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Freference%2Fref-capabilitiespref.htm
(2)
http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/Bundle.html#uninstall()
Libor
On 07/06/2012 03:56 PM, Missing name Mising name wrote:
> Hi,
>
> I have a Plug-In which makes contributions to the Eclipse UI
> (Views/Perspectives) via Extensions (plugin.xml). Depending on a license
> check I want the views not to be visible at all.
> My idea was to prevent the bundle from being loaded or stop/uninstall it
> after the license check was negative. Unfortunately all my attempts
> failed (the views are visible but their classes can not be loaded, so
> they only show exceptions).
>
> Do you have any ideas how to do this?
>
> Thanks in advance!
> Ralph
|
|
|
Powered by
FUDForum. Page generated in 0.03703 seconds