Hi Scott,

Replies inline.

On Sun, Feb 20, 2011 at 3:58 PM, Scott Lewis <sle...@composent.com> wrote:
> First a little background
>
> ServiceTracker has two open methods:
>
> public void open(boolean trackAllServices) and public void open()    (which
> calls open(false))
>
> The javadocs for trackAllServices is:
>
>     * @param trackAllServices If {@code true}, then this
>     *        {@code ServiceTracker} will track all matching services
>     *        regardless of class loader accessibility. If {@code false},
>     *        then this {@code ServiceTracker} will only track matching
>     *        services which are class loader accessible to the bundle whose
>     *        {@code BundleContext} is used by this
>     *        {@code ServiceTracker}.
>
>
> 2.  ECF's Remote Services Admin proxy creation
>
> In the Enterprise Remote Service Admin spec (chap 122) in section 122.5.6
> (Proxying) it describes an approach for using a ServiceFactory to create a
> proxy, and using the classloader of the invoking bundle to load interface
> classes for creating the proxy.  I believe this is for security...it ensures
> that the service interface classes are accessible to the bundle
> accessing/creating the proxy.

Not really for security but for class-space consistency, which boils
down to not getting ClassCastExceptions on objects which seem to be of
the correct type, but have been loaded by a different classloader.

> We/ECF fully implement this approach...i.e. using a ServiceFactory and using
> the classloader of the invoking bundle to load proxy interface classes.  It
> generally works fine.
>
> BUT, it seems that by using this approach, the ServiceTracker.open(false)
> does not allow proxies to be discovered by ServiceTrackers that have been
> opened via open()/open(false).  Rather, it's necessary to use
> ServiceTracker.open(true)...and this allows the proxy to be discovered by
> the service tracker.
>
> Is this expected?  That is...the scheme for proxying described in 122.5.6
> (that we implement) seems to require that clients using ServiceTracker use
> open(true) rather than open(false) in order to discover the created proxy.
>  Using open(true) is doable, of course, but is inconvenient for some
> consumers that are used to using open().

No this doesn't sound right. Using open(true) is dangerous precisely
because of the risk of getting ClassCastExceptions -- it explicitly
returns service instances that are incompatible with the client's
classloader. The open(true) method is really only useful for clients
that don't actually need to call the services they are tracking, e.g.
because they are only interested in the metadata.

If you are only seeing the proxy services when calling
ServiceTracker.open(true), then it suggests something is going wrong.
It sounds like a bug either in your code or in the framework's
compatibility checking.

Cheers
Neil

>
> Thanks,
>
> Scott
>
>
>
>
>
> _______________________________________________
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>

_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to