I've been looking through the spec/code relating so SCAClient and
there may be an issue related to running it in an OSGi environment. My
understanding is as follows:

tuscany-sca-api
  SCAClientFactory
  SCAClientFactoryFinder

tuscany-sca-client-impl
  SCAClientFactoryImpl

There is no direct dependency from sca-api to sca-client-impl and, in
an OSGi environment the factory finder, found in sca-api, can't
immediately load the factory impl class, found in sca-client-impl.

The factory finder is provided by the spec and has an algorithm to
find the factory impl class name which is something like

- check properties passed from application
- check system properties
- check META-INF/services (will work in JSE but not OSGi)

Once it has the classname it loads the class from the classloader, either

- TCC
or if that's null
-  The classloader that loaded the finder class

Now we expect the client to work in OSGi and non-OSGi environments. In
the non-OSGi environment we would require that some part of the
Tuscany runtime (TBD) is made available on the client apps classpath
in order to provide connectivity to the rest of the domain. In this
way the finder can get at META-INF/services and the classes inside
tuscany-sca-client-impl and load the factory implemention.

In OSGi the runtime bundles will be loaded into the runtime but there
is no direct way to access the contents of tuscany-sca-client-impl
from tuscany-sca-api. What we could do with is an activation step on
the tuscany-sca-client-impl bundle that makes the implementation class
available to the tuscany-sca-api bundle. However this is a little
tricky as there's nowhere on the SCAClientFactoryFinder  or
SCAClientFactory to inject anything by default.

Now the spec says that we are free to replace the
SCAClientFactoryFinder  with our own version. However currently the
SCAClientFactory hard codes this version so we would have to go in and
edit what is there already. Now this is OK but would be made easier if
the factory finder were in a separate bundle from the SCAClientFactory
so that we can just replace the finder bundle rather than having to
unpack the api bundle and replace the class.

Assuming that we do edit the finder we could add a static field to
hold the implementation class from which SCAFactory instances are
created on demand. We could inject the right class into here during
activation.

Any thoughts from our dependency experts?

Regards

Simon

-- 
Apache Tuscany committer: tuscany.apache.org
Co-author of a book about Tuscany and SCA: tuscanyinaction.com

Reply via email to