Hi Nicole, Joel, and others,

Sorry it took me so long to respond (I was out a few days, traveling, and then backlogged)...Here are some thoughts on the slides Nicole put together (Thanks!) as well as to the email thread.

I was thinking the OSGi container would be a host environment that Tuscany would be integrated with, similar to Tomcat, Jetty, or a J2EE server. As such, it would have some special capabilities:

1. As Nicole mentioned, there would be a special OSGi binding for composite references and services. For references, the OSGi binding would provide a "connection" to an OSGi service. For services, the OSGi binding would essentially "publish" an SCA component (to be technically correct, a "service offered by an SCA component" to the OSGi service registry. This would allow OSGi services to consume SCA services. This is somewhat analogous to ServletHost (e.g. "OSGiHost") where Tuscany deployed on a servlet container can register Servlets in that container (related to this, we probably want to have the ability for the OSGi container to provide an implementation of ServletHost that registers Servlets using the OSGi http service mechanism). We will have to address the more dynamic nature of OSGi services. I would also like to avoid proxying the OSGi services if possible.

2. The OSGi container would isolate SCA application composites according to its classloader semantics.


Currently, Tuscany has two composite trees, an application and system tree:


        Runtime
                |
               /\
             /    \
           /     Root System Composite
          /     
Root Application Composite

The root composites may contain child composites. The system composite tree contains runtime extensions such as Axis. Each composite has its own classloader. This maintains isolation between application composites and runtime extensions.We plan on introducing a multi-parent classloader for system composites. This is arises from the need to support scenarios where application code may need to access dependencies associated with a system extension. For example, application code may need to access classes in Spring. These classes need to be shared with the application composite classloader. We were planning on loading dependencies that needed to be shared in a parent classloader of the system extension classloader. The former classloader would then also become a parent of the application classloader (which would have multiple parents).

One issue is going to be reconciling this scheme with OSGi's classloading infrastructure. In relation to this, I was thinking we would want a common packaging mechanism for Tuscany extensions across host environments. For example, the Axis2 extension should not have to be repackaged or modified when deployed on Tomcat or Equinox. Application composites, however, could be bundles. I was thinking there would be one Tuscany runtime deployed to an OSGi container. This would get bootstrapped (as Joel mentioned) by a BundleActivator and would look similar to the web app launcher with one exception. Namely, while the web app launcher boots the runtime in a separate classloader, the BundleActivator would not need to do this and would instead boot Tuscany in the bundle classloader. The Tuscany runtime bundle would consequently have to export classes used by applications such as SCA API.

Applications would be deployed as bundles as well. It would be nice if we could listen to bundles coming online and check for SCA scdl (configuration files). If one is found, we load the bundle as an application composite and stick it in the runtime application tree. The classloader for this composite would be the bundle's. The bundle itself would have to import certain SCA packages (i.e. the ones exported by the runtime bundle).

The hard part is going to be figuring out how to deal with extensions. Specifically, in the case I mentioned above where application code needs to reference certain extension classes. I would like to avoid having special packaging for Tuscany extensions when deployed to an OSGi container versus the Servlet container. So, we could deploy the same Axis2 extension to Tuscany on an OSGi container and Tuscany on a Servlet container. This would mean the runtime would have to behave slightly differently depending on this host. In this respect, perhaps what we could do is instead of creating a parent classloader to the extension and also having it as a parent to the application, we could have OSGi manage this? One way to do this would be for a particular extension to use just the bundle classloader and programmatically export packages that need to be shared (is there an OSGi api to do this, I recall a "dynamic export/ import")? One the application side, the bundle import those packages.

Do you guys think this makes sense? I have some skeletal code checked into the OSGi and Equinox projects.

Also, I would like to try and get any code checked into the trunk since this will make things easier. Joel, when you get things synced back up submit a patch and I can apply it. Similarly, Nicole, if you have code that could benefit from being checked in, let me know.

I'm happy to set up an IRC chat if it would be convenient so we could talk about some of these things since it is a bit difficult to do so in email exchanges. Let me know.

Sorry again to take so long in responding.
Jim

On Nov 3, 2006, at 10:54 AM, Hawkins, Joel wrote:

Nicole,

More comments inline -

it would be great if you could send us your sample code :-)
Playing with the source code will help us to understand.
Packaging it now. You'll get the samples and the prototype runtime as
well. I'll have it in the mail to you and Robert today. I think it'll
really help our discussions, instead of me waving my hands about my head
and writing about things you haven't seen! ;-)

I have some comments to your EMail:
I don't want to propose something antithetical to OSGi's philosophy.
We had the OSGi R4 Declarative Service(DS) specification in mind. In
the
bundle manifest you can configure the component.xml files for the
components
contained in the bundle. The DS 'scans" or "searches" for the
component.xml
files and is reponsible for the dependency management (as defined in
the
component.xml
files) and activation/registration of components.
We thought that the proposed "Tuscany runtime service" could do
something similar
to the DS.
Perhaps 'antithetical' is too strong a word... My 'scanner' is basically
a bundle listener. Scdls in activated bundles get deployed as
applications into the Tuscany runtime. My thought was, don't try and
replace DS. Let DS deal with interdependencies between OSGi services,
and let the OSGi service binding be the mediator between DS and Tuscany.


The next question (which is not easy to answer for me) is if every SCA
component should get its
own Tuscany runtime. I would say this depends on the view or the level
of integration.
From my understanding we're currently talking about "SCA/Tuscany
embedded in OSGi". That's one
level of integration. Another level of integration might be an "OSGi
based SCA container".

For "SCA embedded in OSGi" I have one Tuscany runtime (which consists
of
a small number of
OSGi bundles) in mind and which is able to host many SCA components.
I should probably make a distinction here - if you look at the WebApp
runtime, for example, it creates a single Tuscany system runtime, and
deploys a single application into it. The runtime interface definition
even reflects this mapping. What I've got takes a single system runtime
and deploys multiple applications into it. So when I said multiple
runtimes, what I meant was multiple application runtimes.

For "OSGi based SCA container" I have an OSGi container in mind, which
supports 'out-of-the-box'
SCA. We could have an entry in the Manifest pointing to the scdl file
(like today a link to
the component.xml file). Every OSGi service can use the full feature
set
of SCA. In addition we
have implementation types like an EJB implementation type. The
implementation type itself
would provided in another OSGi bundle, e.g. an EJB container running in
an OSGi bundle. All EJBs will
be deployed in the EJB container bundle. This would mean we have SCA
components written in EJB
technology running in one OSGi bundle and SCA components written in
'OSGi technology' running in
separate bundles.
Here's one way to deal with that - if the bundle has a default.scdl in a
Tuscany folder under meta-inf, give it it's own system runtime
corresponding to the default.scdl, and deploy it's apps into that
runtime.

If the bundle had application scdls under an Sca folder, then use the
default runtime to deploy into. That way we can provide a single runtime
to support both models. Sound good?


Best regards
Nicole


-----Original Message-----
From: Hawkins, Joel [mailto:[EMAIL PROTECTED]
Sent: Friday, November 03, 2006 4:55 PM
To: [email protected]
Cc: Jasny, Robert
Subject: RE: OSGi Binding

Hi guys - answers (and more questions) inline:

-----Original Message-----
From: Wengatz, Nicole [mailto:[EMAIL PROTECTED]
Sent: Friday, November 03, 2006 10:32 AM
To: [email protected]
Cc: Jasny, Robert
Subject: RE: OSGi Binding

Hi Joel,

I discussed your EMail with my colleague Robert.

We have a lot of questions, I assume because we are new to Tuscany and
SCA :-)

I'm having issues with the Axis2 binding right now.
What is your use case, using the Axis2 binding to invoke an OSGi
Service from a SCA component running outside of the container?
Have you deployed a SOAP bundle in the OSGi container?
(We're using a SOAP bundle provided by the Knopflerfish project, it
runs
in the Equinox container).
I've got an Axis2 bundle that we use for apache Muse. I'd like to try
the Knoplerfish bundle. I'll pop out to their site and grab it. Thanks!

dual classloader hierarchy' requirement
What exactly do you mean? Do we want to have different classloaders for

the bindings and the applications?

The down side is that we lose the capacity to start and stop extension

bundles,
Our understanding about fragments bundles is the following:
If OSGi bundle B has defined a 'Fragment-Host: bundle A', bundle A will

have one classloader which will be extended by bundle B's exported
classes as soon bundle B is started. As much we understood the OSGi
spec
there's
only
one classloader in bundle A which holds all classes from bundle A as
well from it's fragment bundle B. How can this help to support the
'dual classloader hierarchy'
requirement for SCA applications?
Fragment bundles can be started and stopped independently from their
host bundle.
If you stop a fragment bundle, the host bundle must be refreshed (or
restarted)
to update the host's classloader. Why would we lose the capacity to
start/stop extension bundles?

Well, in equinox, if you try to stop a fragment bundle you get:
org.osgi.framework.BundleException: A fragment bundle cannot be stopped: [EMAIL PROTECTED]:file:../../../../workspaces/CORONA_SCA/tuscany- binding
-osgi/

You can uninstall/re-install to you hearts content, and that will
require a refresh.

Perhaps this is an equinox problem?

One of the major pains of porting existing extensions is the
assumption
about
file locations.
I assume you're talking about the scdl files?
Yup. And wsdls. And schema. ;-)

For each bundle with an application composite (scdls under an "sca"
folder), I create a Tuscany runtime using the extended system config,
and run the application composite inside it.
If we understand you correctly, this would mean that we have for a
number of x SCA components, x Tuscany runtimes running in the OSGi
container?
Yes.

We would prefer a solution where exactly one Tuscany runtime is
running.
What about having a Tuscany runtime service in the OSGi container
deployed which scans a given directly for scdl.files (contained in the
JARs of the SCA application composites)?

For every scdl the defined components will be started in the Tuscany
runtime and services with OSGi binding will be registered automatically

in the OSGi
registry.
It seems like your requirement would be met by just deploying one big
scdl for your application. My view of an OSGi host for Tuscany is
somewhere between an app server (where Tuscany components would
communicate over a remotable interface like WS) and a plain old SCA
composite (where components are directly wired). By supporting multiple SCA applications in a single OSGi, you can provide a degree of isolation
that isn't possible when dumping everything into a single SCA runtime.
You'll have the ability to stop and restart portions of your SCA
'fabric'. Plus, you can provide fast inter-application communication
using the OSGi service binding mechanism. I thought it was kind of nice!
I really want to stay away from any type of scanning solution, as that
seems antithetical to OSGi's philosophy. Of couse, I'm willing to be
voted down!

void doIt(BundleContext context){
String APP_FILTER =
"(& ((objectclass=org.apache.tuscany.sca.osgi.core.ApplicationContextSe
r
v
ice)(Name="SupplyChainShipper)))";
                ServiceReference[] refs =
context.getServiceReferences ("org.apache.tuscany.sca.osgi.core.Applica
t
i
onContextService"
Is there really a need to register the ApplicationContextService is
OSGi?
I thought we could directly register the service interface provided by
the SCA component. Otherwise I do not understand how a standard OSGi
service
is able to get the reference of the SCA service?
If an SCA component is bound as an OSGi service, all you need to do is
use the typical OSGi service registry code. If an SCA component isn't
bound and an osgi service, but you want to interact with it from
outside, the thought was that you could resolve the SCA context
containing the desired component and invoke it directly.

I'll send you my sample code. That might make it clearer. I'm trying
(really!) to get this stuff back in sync so that I can give Jim another
patch.

Cheers,
Joel

The contents of this e-mail are intended for the named addressee only.
It contains information that may be confidential. Unless you are the
named addressee or an authorized designee, you may not copy or use it,
or disclose it to anyone else. If you received it in error please notify
us immediately and then destroy it.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to