Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » adding a ILookupStrategy in an AddOn (to provide access to spring beans)
adding a ILookupStrategy in an AddOn (to provide access to spring beans) [message #663652] Wed, 06 April 2011 04:52 Go to next message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
I want to provide access to the beans in my spring context but not through OSGi services. Assuming I have access to the spring context, I would like to add a lookup strategy to the toplevel eclipse context so that it can check the spring context for values.

I see that the ILookupStrategy allows me to do that but it is only settable when the context is created.

How can I tie in my spring context as part of the lookup strategy for the toplevel context? I was thinking I could write an AddOn to add the lookup strategy but that does not look doable.

Re: adding a ILookupStrategy in an AddOn (to provide access to spring beans) [message #663755 is a reply to message #663652] Wed, 06 April 2011 12:07 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

On 04/06/2011 12:52 AM, aappddeevv@verizon.net wrote:
> I want to provide access to the beans in my spring context but not
> through OSGi services. Assuming I have access to the spring context, I
> would like to add a lookup strategy to the toplevel eclipse context so
> that it can check the spring context for values.
>
> I see that the ILookupStrategy allows me to do that but it is only
> settable when the context is created.
>
> How can I tie in my spring context as part of the lookup strategy for
> the toplevel context? I was thinking I could write an AddOn to add the
> lookup strategy but that does not look doable.

It doesn't look like it's supported. Our API for creating contexts is
IEclipseContext.createChild(*) and EclipseContextFactory.create(*).

One way using internals, so not supported at all. Get the MApplication
context. Get its parent context. Create your context as a child of the
parent context. Reparent the MApplication context under yours. You've
inserted your context between the MApplication context and the OSGi
context. Ta Da!

But I think you should look at how @Preferences was added for a
currently supported method. See the plugin
org.eclipse.e4.core.di.extensions. It creates an annotation and then
uses DS (/org.eclipse.e4.core.di.extensions/OSGI-INF/preferences.xml ) to
register an extended object supplier for that annotation.

PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: adding a ILookupStrategy in an AddOn (to provide access to spring beans) [message #663784 is a reply to message #663755] Wed, 06 April 2011 13:44 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 113
Registered: July 2009
Senior Member
Thanks.

I just looked at preferences, I'll check it out more. It could work although it may not signal the real intent.

I also looked at the eclipse context classes you mentioned. It looks like static singleton classes are being used to create the top level context (I traced the usage into the E4Application class). Even that code path leads to static methods and static singleton static factory methods so there really is no hope of even doing a simple subclass on E4Application (and specifying it in my product) and setting my own eclipse context subclass to handle the lookup logic.

I'll change tact here and look into creating a context function that takes a spring context and inserts all of the beans into the eclipse context automatically for some typical spring scopes and manages refs behind the scenes. I'm assuming a context function can add eclipse objects that are themselves context functions. That should do it.
Re: adding a ILookupStrategy in an AddOn (to provide access to spring beans) [message #663905 is a reply to message #663784] Wed, 06 April 2011 18:22 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You're right, if you are already creating an AddOn you can get the
MApplication context and set some ContextFunctions in it to provide your
values to the main context.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:e4 Workbenchmodel Editor in 3.6
Next Topic:Applying a patch
Goto Forum:
  


Current Time: Sun Dec 21 20:56:35 GMT 2014

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

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