felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Hess <MH...@orga-systems.com>
Subject Re: About the startlevel
Date Thu, 17 Mar 2011 14:30:39 GMT
> >> Hi,
> > Hi,
> >
> >> i am navie. i wanna ask a question about startlevel.
> >> is it important that set the startlevel, i mean what will happen if 
all
> > >  bundle on the same level.
> 
> Typically, this is not an issue. There are only a handful of reasons why 

> you should worry about the start level. In general, it is the normal 
> situation that all bundles have the same start level.

I'd better not show you our bundle startup sequence, then ... ;-)

> > You don't get any guarantee about the sequence in which bundles are
> > started then.
> 
> I think the spec says something about ordering withing a start level 
> too, but this is irrelevant really since you shouldn't depend on 
ordering.

Yes, absolutely. I should find some time to check out the spec concerning 
the ordering inside the level. I wonder which information is used to 
define the sequence.

> > If you need some package to be exported before hand, you MUST assure 
that
> > the exporting bundle is started before the importing one. This can be
> > assured by proper startlevels.
> 
> You do not need start levels at all for package sharing. In fact, the 
> resolver completely ignores start levels and will automatically handle 
> package dependencies irrespective of the start level. In other words, a 
> bundle can share packages even if it isn't started and/or its start 
> level isn't met.

Interesting. But in a way it makes sense, because a passive bundle that is 
not started still can provide exports.

> > This could (not must!) be a problem if your bundles rely on the 
presence
> > of a specific service when they start. If you build your software, so 
that
> > it is capable of coping with services to appear later on (i.e. after 
they
> > have already started), then it will not matter that much. Otherwise 
you
> > will want to assure that the service is there before you access it.
> 
> Rely on service dependency management, not ordering. Code that relies on 

> ordering should be considered broken.

Well, since bundles are started in a serial fashion (or not???), ignoring 
the sequence will force you to have some kind of support for late 
registration of services. I have built something like this with the help 
of the ServiceTrackerCustomizers, and it works. But it is still more 
complicated then simply creating a ServiceTracker, opening it, and 
retrieving the service. 
I understand your point there, and I think you are right from a 
theoretical perspective. But as I outlined further below, I think it 
really is not all black and white in that area. 

For example logging - which probably is a central service in every 
application. Would you really write code, that everytime it accesses the 
log service it first checks for the presence of the service by retrieving 
it from a ServiceTracker? Though, as far as I know this is the "right way 
to do it", I would still say it feels like I am "overdoing" it here.
In my current application, I simply expect logging to be a "core" service, 
which is simply not allowed to disappear. Hence my strategy is simple: I 
get a reference to the service in the activator of my bundles, and then I 
reuse it everywhere in that bundle. 

I think this also puts up the qestion of what the implacation of such a 
disappearing service would be from a business point of view. While the 
software could certainly work without logging (by work I mean, service the 
business case), it would still mean I am blindfolded when it comes to 
problems. So coming from that perspective I would say - once the logging 
is gone, the system is broken and should not commence working simply 
because I cannot tell anymore whether the system is out of control or not.
 
> > But keep in mind, that by doing so you essentially undermine the 
dynamic
> > nature of the OSGi system. Though the consumed service might be there 
when
> > your bundle starts, the service could nevertheless disappear later on. 
So
> > it also depends on how much "control" you have over the overall 
runtime.
> > If you build a closed source product, where everything is under your
> > control, you can of course put rules into place, that specific 
situations
> > are simply not supported. This means, that though you cannot prevent 
the
> > afforementioned service to disappear technically, you can still define
> > that it is not permitted to remove the service.
> 
> Yes, all of this depends on the given situation and what you can do 
> about it.

You're right. This is in fact something I missed very much when I first 
started with OSGI. You can find technically detailed answers, but 
best-practices or inspiring documents for the "depends on ..." moments are 
rare to come by. At least, that's my perception.
 
> > Though this might at first seem a bit like "cheating", I can tell from
> > first hand experience, that when it comes to parts of a running(!) 
system
> > to disappear, things WILL get tricky. So I think it is always a good
> > choice to check what you gain by this degree a flexibility in contrast 
to
> > the additional efforts in implementation and complexity.
> >
> > But back to the main topic: I think, that usually you will have some 
kind
> > of sequence, that simply "makes sense". So use the startlevels to 
achieve
> > this sequence. That's at least how I tend to do it. And it works out 
fine
> > so far.
> 
> Still, I'd recommend completely ignoring start levels unless you run 
> into some misbehaving bundle that requires otherwise.

I will take it into consideration.
 
Thanks for your view on this, Richard.

bye, Michael

The information included in this e-mail and any files transmitted with it is strictly confidential
and may be privileged or otherwise protected from disclosure. If you are not the intended
recipient, please notify the sender immediately by e-mail and delete this e-mail as well as
any attachment from your system. If you are not the intended recipient you are not authorized
to use and/or copy this message and/or attachment and/or disclose the contents to any other
person.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message