Fredrik,

I think this should just work already. Did you try it?

Unless you use something like DS, the framework does not attempt to
cast service objects for you, nor does it check that the registered
object actually implements the interface under which it is published.
It _does_ check the the consumer bundle has visibility of the same
version of that interface that was used by the publisher bundle, but
that would work just the same for an annotation.

So if you write your consumer bundle using ServiceTracker and you
avoid casting the service object to anything then this should work
fine. Of course you cannot use DS or Spring-DM or similar in your
consumer bundle, because they will attempt to cast or generate a proxy
object.

Regards
Neil

2009/3/17 Fredrik Alströmer <[email protected]>:
> Hi,
>
> I'm sure this has already been discussed, but I was working with some
> stuff that was using annotations, when it hit me that it's rather
> inconvenient to publish an OSGi service based on an annotation. You'd
> have to publish it using java.lang.Object, and come up with some (not
> standardized) property to contain the FQ-name of the annotation.
> There's also no 'type-safety' involved which checks to see if the
> class of the returned service-object does indeed carry the required
> annotation.
>
> Considering that it's not possible to 'implement' an annotation (which
> would produce clashes), would it be a viable addition to the spec to
> allow service objects to be registered (extrapolate as needed to
> service factories) using an FQ-name of an annotation as
> 'interface'-name, where the framework is responsible for checking that
> said service object does indeed carry the annotation? This is of
> course assuming that annotations are supported in the runtime
> environment, but it does not impose such an assumption on any
> interfaces, and so the spec is still valid in pre-annotation
> environments. As far as I can tell, annotations are used primarily
> (only?) in combination with reflection, so there's no real reason to
> provide an actual type-check.
>
> I can see that there might be concerns in the general direction of
> proxy objects, but then again, I believe those have a problem in
> general with respect to annotations?
>
> Greetings,
> Fredrik.
> _______________________________________________
> OSGi Developer Mail List
> [email protected]
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>

_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to