View Full Version : Spring DM and Eclipse RCP
scodifdo
May 28th, 2008, 10:08 AM
Hello
I have problems using Spring DM together with Eclipse RCP.
Is my attempt even possible?
Using Spring DM with OSGi plugins/bundles works fine and I can access my service:
ServiceTracker serviceTracker = new ServiceTracker(context, MyService.class.getName(), null);
serviceTracker.open();
MyService service = (MyService) serviceTracker.getService();
In my RCP Plugin, Spring DM seems to ignore my META-INF/spring/applicationContext.xml file.
It should be loaded by the Spring DM Plugins (extender...).
Does anybody know how to solve my issue?
I searched the web but all I could find is the link on the Spring OSGi page (Agile RCP - Presenter First using Spring Dynamic Modules).
Not really a Spring DM integration in my eyes, the services are grabed using an ApplicationContext and not the OSGi way with it's ServiceTracker.
Thanks for any help!
oleg.zhurakousky
May 28th, 2008, 07:32 PM
I know when working with PDE, you can enable Tracing options while setting up your Eclipse Target Platform.
I am not familiar with RCP that much, but assuming it is of the same "root" of products, is there something like that in RCP?
It is hard to guess without seeing any logs
Costin Leau
May 29th, 2008, 02:53 AM
Besides the additional logging which needs to be turned on as Oleg suggested, double check your configuration. Maybe the Spring extender is not deployed or not started ?
scodifdo
May 29th, 2008, 04:19 AM
Thanks for your replies!
You were right, when I launch my RCP application with the -console option and execute the "ss" command, I get the following output:
Framework is launched.
id State Bundle
0 ACTIVE org.eclipse.osgi_3.4.0.v20080521-1400
2 <<LAZY>> com.ibm.icu_3.8.1.v20080402
3 RESOLVED javax.activation_1.1.0.v200804101140
4 RESOLVED javax.mail_1.4.0.v200804091730
5 RESOLVED javax.servlet_2.4.0.v200803061910
6 RESOLVED org.apache.commons.logging_1.0.0
7 RESOLVED org.eclipse.core.commands_3.4.0.I20080509-2000
8 <<LAZY>> org.eclipse.core.contenttype_3.3.0.v20080414
9 ACTIVE org.eclipse.core.databinding_1.1.0.I20080514-2000
10 ACTIVE org.eclipse.core.expressions_3.4.0.v20080522-1800
11 ACTIVE org.eclipse.core.jobs_3.4.0.v20080512
12 ACTIVE org.eclipse.core.runtime_3.4.0.v20080512
13 ACTIVE org.eclipse.core.runtime.compatibility.auth_3.2.10 0.v20070502
14 RESOLVED org.eclipse.core.runtime.compatibility.registry_3. 2.200.v20070717
Master=18
15 ACTIVE org.eclipse.equinox.app_1.1.0.v20080421-2006
16 ACTIVE org.eclipse.equinox.common_3.4.0.v20080421-2006
17 ACTIVE org.eclipse.equinox.preferences_3.2.200.v20080421-2006
18 ACTIVE org.eclipse.equinox.registry_3.4.0.v20080516-0950
Fragments=14
19 ACTIVE org.eclipse.help_3.3.100.v20080515
20 ACTIVE org.eclipse.jface_3.4.0.I20080515-2000a
21 RESOLVED org.eclipse.jface.databinding_1.2.0.I20080515-2000a
22 RESOLVED org.eclipse.osgi.services_3.1.200.v20071203
23 RESOLVED org.eclipse.swt_3.4.0.v3446a
Fragments=24
24 RESOLVED org.eclipse.swt.win32.win32.x86_3.4.0.v3446
Master=23
25 ACTIVE org.eclipse.ui_3.4.0.I20080521-2000
26 ACTIVE org.eclipse.ui.workbench_3.4.0.I20080521-2000
27 RESOLVED org.springframework.bundle.osgi.core_1.0.2
28 RESOLVED org.springframework.bundle.osgi.io_1.0.2
29 RESOLVED org.springframework.bundle.spring.aop_2.5.1
30 RESOLVED org.springframework.bundle.spring.beans_2.5.1
31 RESOLVED org.springframework.bundle.spring.context_2.5.1
32 RESOLVED org.springframework.bundle.spring.core_2.5.1
33 RESOLVED org.springframework.osgi.aopalliance.osgi_1.0.0.SN APSHOT
34 RESOLVED org.springframework.osgi.log4j.osgi_1.2.15.SNAPSHO T
37 RESOLVED org.springframework.bundle.osgi.extender_1.0.2
38 RESOLVED org.springframework.osgi.asm.osgi_2.2.3.SNAPSHOT
44 ACTIVE ch.hi.test.rcp_1.0.0
45 RESOLVED ch.hi.test.serviceAPI_1.0.0
All the Spring Plugins are not active.
Maybe a dumb question, but how or what do I have to configure to start them automatically?
lakemove
May 29th, 2008, 04:59 AM
As u've found, it is because of the "Lazy" (ActivationPolicy formally)
To solve it , u just need to start the extender in config.ini file :
org.springframework.bundle.osgi.extender@4:start
Costin Leau
May 29th, 2008, 05:05 AM
There is something about this in the the Eclipse documentation. You can append something like @start to your bundles and they'll start automatically.
P.S. I don't think lazy has anything to do with it since the platform will resolve the bundles if there's such a need.
lakemove
May 29th, 2008, 05:19 AM
since no customer bundle (Spring based) depends on the extender, RCP decide not to start the bundle , so the customer bundle will not be available(even its status is ACTIVE), because the extender doesnt ACTIVE (to make customer bundle available).
Costin Leau
May 29th, 2008, 05:30 AM
Right - if there is no 'need' declared, as you pointed out, things won't start. I'm just pointing out that in general, lazy is a good thing :)
scodifdo
May 29th, 2008, 08:43 AM
Thanks guys!
I just added all the Spring DM plugins to my RCP Plugin dependenzies and it worked.
scodifdo
Jun 9th, 2008, 04:39 PM
I made a blog post, on how to create a RCP application together with Spring DM.
swissdev.blogspot.com/2008/06/eclipse-rcp-application-using-spring-dm.html
MrMagne
Jul 2nd, 2008, 10:38 AM
Hi all,
My RCP plugin depends on :
org.springframework.bundle.osgi.core
org.springframework.bundle.osgi.extender
org.springframework.bundle.osgi.io
org.springframework.bundle.spring
org.springframework.osgi.backport.util.concurrent
but Spring DM is not ACTIVE with the default config.ini
I know I can make it working by adding the @start in my config.ini but doing this ruins my product export... Of course I could still edit the config.ini automatically generated by the Eclipse Product Export Wizard but I think there is a brighter solution...
Has someone a clue on how to start SpringDM without customizing the config.ini ?
Costin Leau
Jul 3rd, 2008, 01:55 AM
the extender is a bundle at the end of the day - config.ini allows you to automatically start the bundle at startup. Whether you start the extender or start another bundle that in effect, starts the extender is your choice but you need to start at least one bundle after starting the platform.
MrMagne
Jul 3rd, 2008, 03:25 AM
thanks for your answer Costin.
I'm not sure I understand what you mean by 'the extender is a bundle at the end of the day'...
Anyway, what is the best way to make my bundle effectively start the extender ? Do I have to investigate the Osgi API ?
oleg.zhurakousky
Jul 3rd, 2008, 05:13 AM
If I understand it correctly the issue is with RCP Product Export which seem to override your changes. After all it is your product and you should be able to do and configure whatever you want.
As to "he extender is a bundle at the end of the day" - Extender is just another bundle as any other bundle in your Target Platform. That is the beauty of OSGi is the ability to make your Target Platform anything you want. Spring-DM is really a bunch of utility bundles that make development and deployment of Spring based applications inside of OSGi platform simple and elegant. For example: Extender bundle will see the Application Context and would bootstrap it for you
Nico
Jul 3rd, 2008, 06:05 AM
Has someone a clue on how to start SpringDM without customizing the config.ini ?
What you can do is start manually Spring-DM bundle when your application starts. You can do it from the start() (http://help.eclipse.org/ganymede/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/ui/plugin/AbstractUIPlugin.html#start(org.osgi.framework.Bun dleContext)) method of your RCP application main bundle.
The BundleContext (http://www.osgi.org/javadoc/r4/org/osgi/framework/BundleContext.html)argument passed to this method can be used to get all the installed bundles. You can use getBundles() (http://www.osgi.org/javadoc/r4/org/osgi/framework/BundleContext.html#getBundles()) to find the extender bundle and then start it (http://www.osgi.org/javadoc/r4/org/osgi/framework/Bundle.html#start()).
On application shutdown you can use the same way to stop Spring-dm extender.
MrMagne
Jul 3rd, 2008, 07:59 AM
Thanks for your answers, I used this code:
Bundle springDM = Platform
.getBundle("org.springframework.bundle.osgi.extender");
springDM.start(); in my Activator#start() method, it seems to work well.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.