Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Add an Extension dynamically
Add an Extension dynamically [message #128196] Thu, 16 April 2009 13:00 Go to next message
Maghen Calinghee is currently offline Maghen CalingheeFriend
Messages: 23
Registered: July 2009
Junior Member
Hi,

I'm trying to create extension programmatically by contributing to the
ExtensionRegistry :
Platform.getExtensionRegistry().addContribution(inputStream, contributor,
false, null, null, null).

But it seems to be a problem in RAP, i get an error when i'm trying to add
a contribution.

This is what i get in my console :
!ENTRY org.eclipse.equinox.registry 4 2 2009-04-16 07:43:53.619
!MESSAGE Problems occurred when invoking code from plug-in:
"org.eclipse.equinox.registry".
!STACK 0
java.lang.IllegalStateException: No context available outside of the
request service lifecycle.
at
org.eclipse.rwt.internal.service.ContextProvider.getContext( ContextProvider.java:108)
at
org.eclipse.rwt.internal.service.ContextProvider.getStateInf o(ContextProvider.java:166)
at
org.eclipse.rwt.SessionSingletonBase.getInstance(SessionSing letonBase.java:84)
at org.eclipse.ui.internal.Workbench.getInstance(Workbench.java :466)
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:94)
at
org.eclipse.ui.internal.ExtensionEventHandler.registryChange d(ExtensionEventHandler.java:59)
at
org.eclipse.core.internal.registry.ExtensionRegistry$2.run(E xtensionRegistry.java:891)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at
org.eclipse.core.internal.registry.ExtensionRegistry.process ChangeEvent(ExtensionRegistry.java:889)
at
org.eclipse.core.runtime.spi.RegistryStrategy.processChangeE vent(RegistryStrategy.java:267)
at
org.eclipse.core.internal.registry.osgi.ExtensionEventDispat cherJob.run(ExtensionEventDispatcherJob.java:50)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Moreover, this code works fine in RCP.


Maghen.
Re: Add an Extension dynamically [message #128432 is a reply to message #128196] Fri, 17 April 2009 08:47 Go to previous messageGo to next message
Maghen Calinghee is currently offline Maghen CalingheeFriend
Messages: 23
Registered: July 2009
Junior Member
Hi,

Finally I will answer to my own post. I might be useful to someone.

In RCP, it's not that difficult to add an extension in a programmatic way.
I've added an extension into the createPartControl() method of a ViewPart
and it works fine.
But in RAP, we need to be careful because in the createPartControl(), i
think we work in a thread which is specific to a session (and it's logic).
In RAP, we have multiple session at a time so we need be careful about we
do. (see
http://dev.eclipse.org/newslists/news.eclipse.technology.rap /msg01335.html).
So as we work in a thread which is specific to a session, this thread is
not shared with the others sessions and i don't think from this thread we
can add contributions because we can not load a plugin onto an application
which is shared with the others sessions.
So the only solution that i have found to add an extension is to do it in
the Activator#start() method, because from the start() method's thread, we
can provide to the OSGI platform and load plugin. This thread is not
specific to a session.

I'm not sure about what i'm saying here but it will be great, if someone
could confirm this. Maybe it will help others developpers to understand
differences between RAP and RCP, and how we need to be careful about what
we do in RAP.

Thanks you.

Maghen.
Re: Add an Extension dynamically [message #128458 is a reply to message #128432] Fri, 17 April 2009 13:50 Go to previous message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
Hi Maghen,

let me try to clarify a bit on this topic.
Right, there is only one extension registry (same as in RCP). What
caused the exception was a registry change listener that was added
by the workbench, at least that's what the stack trace suggests.

A workbench in RAP lives in the "session scope". All workbench code
(e.g. the registry change listener) should be executed on the UI
thread that is associated to the session.

If you put the addContribution() call in the Activator, there is no
workbench yet - thus no listeners.
Calling addContribution() while there are workbench instances
listening should not cause this exception, but will most certainly
lead to unexpected results.

So goes the theory. What I am not sure about is, why the exception
occurred if you were calling addContribution() from within a
session. If you like to, open a bugzilla so we can investigate this
further. Attach a use case and/or the code to reproduce the problem.

HTH
Rüdiger


Maghen Calinghee wrote:
> Hi,
>
> Finally I will answer to my own post. I might be useful to someone.
> In RCP, it's not that difficult to add an extension in a programmatic
> way. I've added an extension into the createPartControl() method of a
> ViewPart and it works fine. But in RAP, we need to be careful because in
> the createPartControl(), i think we work in a thread which is specific
> to a session (and it's logic). In RAP, we have multiple session at a
> time so we need be careful about we do. (see
> http://dev.eclipse.org/newslists/news.eclipse.technology.rap /msg01335.html).
>
> So as we work in a thread which is specific to a session, this thread is
> not shared with the others sessions and i don't think from this thread
> we can add contributions because we can not load a plugin onto an
> application which is shared with the others sessions.
> So the only solution that i have found to add an extension is to do it
> in the Activator#start() method, because from the start() method's
> thread, we can provide to the OSGI platform and load plugin. This thread
> is not specific to a session.
>
> I'm not sure about what i'm saying here but it will be great, if someone
> could confirm this. Maybe it will help others developpers to understand
> differences between RAP and RCP, and how we need to be careful about
> what we do in RAP.
>
> Thanks you.
>
> Maghen.
>
Previous Topic:Invalid thread access problem
Next Topic:org.eclipse.ui.forms with RWT
Goto Forum:
  


Current Time: Tue Apr 16 10:43:12 GMT 2024

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

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

Back to the top