Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Running OSGi-DS as an "Eclipse Application"
Running OSGi-DS as an "Eclipse Application" [message #134219] Fri, 03 July 2009 21:58 Go to next message
Oliver Wong is currently offline Oliver WongFriend
Messages: 47
Registered: July 2009
Member
I'm working on a small declarative services OSGi example (for what it's
worth, it's the "org.equinoxosgi.toast" example). When I try to run the
example using an "OSGi framework" launch configuration, the example runs
fine (it prints the intended output to System.out). But when I try to run
the same code using an "Eclipse Application" launch configuration, the
example doesn't print anything out at all.

After some debugging, we realized one of the big difference between an
OSGi launch config and an Eclipse launch config is that OSGi has "Default
autostart" set to true, and Eclipse has it set to false. When I change my
plugins so that their autostart is "true" instead of default, the example
finally works in the Eclipse launch config.

Now my question is: Does this imply that the "immediate='true'" attribute
of the "component" element in my OSGI-INF/component.xml file doesn't
actually do anything in an Eclipse launch? I'd like to build a system
involving multiple components that will need to start up "immediately".
Shouldn't I be able to specify this behaviour in my component.xml file,
rather than in the launch configurations?
Re: Running OSGi-DS as an "Eclipse Application" [message #134481 is a reply to message #134219] Mon, 06 July 2009 17:14 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 452
Registered: July 2009
Location: Germany ✈ Vancouver
Senior Member

Oliver Wong schrieb:
> After some debugging, we realized one of the big difference between an
> OSGi launch config and an Eclipse launch config is that OSGi has "Default
> autostart" set to true, and Eclipse has it set to false. When I change my
> plugins so that their autostart is "true" instead of default, the example
> finally works in the Eclipse launch config.

That's the intended behavior. The "Eclipse Application" launch config
launches the Eclipse way which prefers lazy vs. eager. However, the DS
bundle need to be started eager in order make DS work. Thus, you can put
it into the config.ini and it will work as an "Eclipse Application" too.

-Gunnar

--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: Running OSGi-DS as an "Eclipse Application" [message #134505 is a reply to message #134481] Mon, 06 July 2009 17:51 Go to previous messageGo to next message
Chris Aniszczyk is currently offline Chris AniszczykFriend
Messages: 674
Registered: July 2009
Senior Member
Gunnar Wagenknecht wrote:
> Oliver Wong schrieb:
>> After some debugging, we realized one of the big difference between an
>> OSGi launch config and an Eclipse launch config is that OSGi has "Default
>> autostart" set to true, and Eclipse has it set to false. When I change my
>> plugins so that their autostart is "true" instead of default, the example
>> finally works in the Eclipse launch config.
>
> That's the intended behavior. The "Eclipse Application" launch config
> launches the Eclipse way which prefers lazy vs. eager. However, the DS
> bundle need to be started eager in order make DS work. Thus, you can put
> it into the config.ini and it will work as an "Eclipse Application" too.

On top of what Gunnar mentioned, PDE goes out of its way to ensure that
the DS bundle is started in launch configurations. If you're building a
product definition, make sure you include DS in the list of bundles to
be auto-started. The DS bundle is the rare case where it actually needs
to be started before it's really useful.

Hope this helps.

Cheers,

Chris Aniszczyk | EclipseSource Austin | +1 860 839 2465
http://twitter.com/eclipsesource | http://twitter.com/caniszczyk
Re: Running OSGi-DS as an "Eclipse Application" [message #134529 is a reply to message #134505] Mon, 06 July 2009 18:41 Go to previous messageGo to next message
Mike Evans is currently offline Mike EvansFriend
Messages: 237
Registered: July 2009
Senior Member
Oliver,
I have just attached some project files to:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=282563
These have DS services starting automatically in an RCP app.
Whilst I have a problem with DS service taking too long to instantiate,
they do at least start!
So feel free to check out the service.xml, .MF and .product files I used
to get them working.

Mike E.
Re: Running OSGi-DS as an "Eclipse Application" [message #134670 is a reply to message #134505] Tue, 07 July 2009 14:37 Go to previous messageGo to next message
Oliver Wong is currently offline Oliver WongFriend
Messages: 47
Registered: July 2009
Member
Thanks for the replies everyone (including Mike Evans). I've got a few
more questions:

Chris Aniszczyk wrote:

> Gunnar Wagenknecht wrote:
>> Oliver Wong schrieb:
>>> After some debugging, we realized one of the big difference between an
>>> OSGi launch config and an Eclipse launch config is that OSGi has "Default
>>> autostart" set to true, and Eclipse has it set to false. When I change my
>>> plugins so that their autostart is "true" instead of default, the example
>>> finally works in the Eclipse launch config.
>>
>> That's the intended behavior. The "Eclipse Application" launch config
>> launches the Eclipse way which prefers lazy vs. eager. However, the DS
>> bundle need to be started eager in order make DS work. Thus, you can put
>> it into the config.ini and it will work as an "Eclipse Application" too.

I'm not sure what you mean by config.ini, but I guess perhaps you're
talking about making an Eclipse product? I.e. shipping your own branded
exe file? By "Eclipse Application" I meant one of the possible type of
run configurations in your "Run" or "Debug" menu.

> On top of what Gunnar mentioned, PDE goes out of its way to ensure that
> the DS bundle is started in launch configurations. If you're building a
> product definition, make sure you include DS in the list of bundles to
> be auto-started. The DS bundle is the rare case where it actually needs
> to be started before it's really useful.

Back when I first posted this, I'm pretty sure my org.eclipse.equinox.ds
bundle *was* autostarted. However, I could not get the example working
unless I also set my own plugins (org.equinoxosgi.toast.client.emergency)
to start, even though I've specified the "immediate='true'" attribute in
that plugin's component.xml file.

Just to confirm: What I initially experienced was abnormal, and in theory,
you only need the org.eclipse.equinox.ds to be autostarted, and all the
others can be set to lazily started in the launch config; and the
org.eclipse.equinox.ds plugin may start up my bundles eagerly despite what
I've specified in the launch configuration if the component.xml file
states that they should be eagerly started?
Re: Running OSGi-DS as an "Eclipse Application" [message #134696 is a reply to message #134670] Tue, 07 July 2009 15:47 Go to previous messageGo to next message
Mike Evans is currently offline Mike EvansFriend
Messages: 237
Registered: July 2009
Senior Member
Oliver,

CONFIG.INI
The config.ini is a file used to configure osgi start-up.
You will find it in the config directory of any Eclipse install (and your
RCP if you deploy it).
Conventionally you simply let PDE do all the work. However you can control
the generation of the config.ini - see the 'Configuration' tabs in run
configurations and product editors.
I cannot help you much in working out how to edit it as I have not done so.
Note though that the Eclipse install config.ini actually references
another file bundles.info that lists all the bundles, their start levels
and whether they start automatically.

DS AUTOSTART
However all the above should be unnecssary. I am using DS services where:
- the bundles are all conventional Eclipse plug-ins (singletons, activated
when classs loaded)
- the application bundle depends on org.eclipse.equinox.ds
- in the DS declarations, my components are enabled when started and
immediately activated.
And this works without any mucking about with the config.ini file.

Mike E.
Re: Running OSGi-DS as an "Eclipse Application" [message #502714 is a reply to message #134696] Wed, 09 December 2009 14:23 Go to previous messageGo to next message
Niels Bech Nielsen is currently offline Niels Bech NielsenFriend
Messages: 16
Registered: July 2009
Junior Member
A follow up question on this one.

I use eclipse RCP 3.4.2 with the ds1.0.0, having interface and implementation split into two bundles, and of course a client bundle.

My component specification is immediate and enabled (not sure whether 1.0.0 honour these?).

When I specify default_auto_start to true, as suggested first, it works. All bundles are activated, and the scr has found my declarative service.

Specifying default_auto_start as false, leaves the service and implementation bundle as resolved and hence the component is never loaded by scr.

So basically, is this because 1.0.0 does not recognize immediate/enabled or if that is the case. How would I specify the default_auto_start in a config.ini (without having to list all bundles explicitly).
Re: Running OSGi-DS as an "Eclipse Application" [message #502828 is a reply to message #502714] Wed, 09 December 2009 20:38 Go to previous message
Bruce Kelly is currently offline Bruce KellyFriend
Messages: 63
Registered: July 2009
Member
My understanding is that DS needs the bundle started event from the OSGi
framework in order to look for the service component definition files.

So if your bundles are not started by "something", then DS will not know
your bundles exist and so will not attempt to create any service components.

Namaste, Bruce

"Niels Bech Nielsen" <niels.b.nielsen@jpmorgan.com> wrote in message
news:hfobt1$kml$1@build.eclipse.org...
>A follow up question on this one.
>
> I use eclipse RCP 3.4.2 with the ds1.0.0, having interface and
> implementation split into two bundles, and of course a client bundle.
>
> My component specification is immediate and enabled (not sure whether
> 1.0.0 honour these?).
>
> When I specify default_auto_start to true, as suggested first, it works.
> All bundles are activated, and the scr has found my declarative service.
>
> Specifying default_auto_start as false, leaves the service and
> implementation bundle as resolved and hence the component is never loaded
> by scr.
>
> So basically, is this because 1.0.0 does not recognize immediate/enabled
> or if that is the case. How would I specify the default_auto_start in a
> config.ini (without having to list all bundles explicitly).
Previous Topic:Disconnect from OSGi console
Next Topic:add "Available Software Site"
Goto Forum:
  


Current Time: Thu Nov 27 09:49:38 GMT 2014

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

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