On 01/03/2008, Richard S. Hall <[EMAIL PROTECTED]> wrote:
>
> jaredmac wrote:
> > After an initial hiccup, I've found these tutorials immensely helpful,
> and
> > thought I'd offer a few suggestions to make better still.
> >
> > Tutorial Example 1
> > * Is missing the note about the trailing carriage return (which is
> > rightfully in every other tutorial).
> >
>
>
> Actually, I just added it to every tutorial (including the first one)
> after your first message. :-)
>
>
> > Tutorial Example 3
> > * The tutorial states that we don't have to unget or release the service
> in
> > the stop() method because the OSGi framework does so automatically, but
> this
> > line exists in the start() method:
> >
> >           // Unget the dictionary service.
> >           context.ungetService(refs[0]);
> >
> > So the service appears to be manually, not automatically, ungotten,
> unless
> > I'm missing something.
> >
>
>
> Well, you don't HAVE to do it, but there is nothing wrong with doing it.
> However, I understand why it may seem confusing since the two don't match.


I see this as an example of eagerly "ungetting" a service - ie. when you
know
that you don't need the service anymore - it would be automatically "ungot"
in
the stop method, but doing it early can have benefits for some apps...

for example, you'd then be able to safely remove the service without
stopping
the client bundle (as you could tell from the framework that it's not using
the
service at this point).

to give a Java analogy, it's the difference between waiting for a local
variable to
automatically go out of scope, and nulling it when you don't need it anymore
- nulling a reference early on can help in some situations.

of course this example should also use a separate thread for the query loop
as mentioned in the comments, so it shouldn't be taken as "best practice" ;)

> Tutorial Example 4
> > * Code is missing "import org.osgi.framework.InvalidSyntaxException"
> > * This line:
> > m_context.getServiceReferences(DictionaryService.class.getName(),
> > "(Language=*)");
> > is missing the assignment to "refs" (refs is always null).
> >
> > That's as far as I've gotten. Thanks again!
> >
>
>
> Great, thanks. Fixed. The web pages should reflect the changes now.
>
> Nice to get some feedback.
>
> -> richard
>
> > Jared
>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Cheers, Stuart

Reply via email to