Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Prevent Bundle from being loaded
Prevent Bundle from being loaded [message #894056] Fri, 06 July 2012 13:56 Go to next message
Ralph P is currently offline Ralph P
Messages: 30
Registered: September 2010
Location: Frankfurt, Germany
Member
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
Re: Prevent Bundle from being loaded [message #894172 is a reply to message #894056] Sat, 07 July 2012 09:16 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar Wagenknecht
Messages: 451
Registered: July 2009
Location: Germany ✈ Vancouver
Senior Member

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 Go to previous message
Libor Jelinek is currently offline Libor Jelinek
Messages: 143
Registered: January 2012
Location: Prague, Czech Rep.
Senior Member

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
Previous Topic:Launching Equinox via srvany.exe
Next Topic:Problems with equinox console in 4.2M4
Goto Forum:
  


Current Time: Wed Oct 01 08:26:48 GMT 2014

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

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