{panel:title=Apache Tuscany SCA Java Kernel Architecture Guide |borderStyle=solid|borderColor=#6699ff|titleBGColor=#D5EFFF|bgColor=#ffffff}
*This page is work in progress. Thanks for your contribution* :-)
* [Overview|#Overview]
** [Core|#Core Definition]
** [Extension|#Extension Definition]
** [Runtime|#Runtime Definition]
* [Internal High Level View|#Internal High Level View]
* [Bootstrap|#Bootstrap]
* [Metadata|#Metadata]
* [Contribution|#Contribution]
* [Binding Extension|#Binding Extension]
* [Component Implementation Extension|#Component Implementation Extension]
* [Data Binding Extension|#Data Binding Extension]
* [Spring Integration|#Spring Integration]
\**{Spring as component implementation\|#Spring as component implementation\]
\*\*[Spring as IOC container|#Spring as IOC container]
\\
{panel}{section}{section}
h3. {anchor:Overview} {color:#0099cc}Overview{color}
The SCA Java runtime is composed of core and extensions. The core is essentially a multi-VM wiring engine that connects components together using the principles of [Dependency Injection|http://en.wikipedia.org/wiki/Dependency_injection], or [Inversion of Control|http://en.wikipedia.org/wiki/Inversion_of_control].
h4. Core
The Core is designed to be simple and limited in its capabilities. It wires functional units together and provides SPIs that extensions can interact with. Capabilities such as service discovery, reliability, support for transport protocols, etc. are provided through extensions.
h4. Extension
Extensions enhance SCA runtime functionality. Extension types are not fixed and core is designed to be as flexible as possible by providing an open-ended extension model. However, there are a number of known extension types defined including:
* *Component implementation types*, e.g. Spring, Groovy, and JavaScript
* *Binding types*, e.g. Axis, CXF, AMQP, ActiveMQ, JXTA
* *DataBinding types*, e.g. JAXB, SDO, XmlBeans
* *Interface Binding types*, e.g. WSDL, Java
Details of how to implement an extension can be can be found in the [Extensions Guide| Java SCA Extension Guide].
h4. Runtime
The core is designed to be embedded in, or provisioned to, a number of different host environments. For example, the core may be provisioned to an OSGi container, a standalone runtime, a servlet engine, or J2EE application server. Runtime capabilities may vary based on the host environment.
{HTMLcomment:hidden}{children:sort=creation}{HTMLcomment}
h3. {anchor:Modules}{color:#0099cc}Module Structure{color}
\[Note: Do we want to link to [Kernel-Structure|Java SCA Modulization Design Discussions]\]?
As illustrated below, the Tuscany runtime consists of the following key modules/packages:
# SCA Spec API: The APIs defined by the SCA Java Client and Implementation Spec
# API: Tuscany APIs which extend the SCA spec APIs
# Core: The runtime implementation
# SPI: SPI and base classes to extend the Tuscany runtime. It defines all the contract that Core interacts with Container/Binding/Databinding extensions.
# Extensions:
## Container
## Binding
## Databinding
# Host API: The interface between hosting environments and the Tuscany runtime
# Host Platforms: The environments that host the Tuscany runtime
!tuscany_layers.jpg!
h3. {anchor:InternalInternals High Level View}{color:#0099cc}InternalInternals High Level View{color}
\[Note: Do we want to link to [Kernel-Structure|Java SCA Modulization Design Discussions]\]?
h3. {anchor:ArtifactsKernel Bootstrap}{color:#0099cc}Runtime ArtifactsBootsrap{color}
* Component
** Basic unit of executable code
** Offer services and have references
* Service
** A contract Bootstrap process is controlled by Host environment. The default process is implemented in DefaultBootstrapper.
!bootstrap.jpg!
h3. {anchor:Metadata}{color:#0099cc}Metadata{color}
* Component
** Basic unit of executable code
** Offer services and have references
* Service
** A contract for component clients consisting of 0..n operations
** Services may be local or remote
* Reference
** A dependency on a service
** Component references are wired to services by the runtime
h3. {anchor:RecursionsBinding Extension}{color:#0099cc}RecursiveBinding CompositeExtension{color}
Components may be Atomic or Composite
* Composite components contain 0..n components
Composite services are exposed over 1..n bindings (e.g. SOAP/HTTP, JMS, RMI)
Composite references have 1..n bindings and may target
* A service exposed by another composite
* A service outside the SCA system, e.g. "Google search"
A composite may contain just a service wired to a references (mediation) [Haleh: Clarify]
h3. {anchor: Kernel Wiring}{color:#0099cc}Wiring{color}
To understand how wiring works, we need to detail how Components function in the system. Let's start with Atomic Components and then discuss Composite Components.
h4. Atomic Component
AtomicComponent is the most basic component form. It corresponds to the spec concept which offers services, has references and properties
* Implementation types e.g. Java, XSLT, etc.
* Are wired
* Have properties
Atomic Components have implementation instances. Instances are associated with a scope: e.g. request, conversation, composite. A SCDL entry is used to define a Component. [Haleh: Define scope]
Atomic components use a ScopeContainer to manage implementation instances:
* Composite, HTTP Session, Request, Stateless
* ScopeContainers track implementation instances by scope id and the AtomicComponent instance identity
* Instances are stored in an InstanceWrapper which is specific to the component implementation type (e.g. PojoInstanceWrapper.java)
h4. Component Wiring
Component references are connected to services through wires
* Two sides
** InboundWire - handles the source side of a wire, including policy
** OutboundWire - handles the target side of a wire, including policy
* The runtime connects inbound and outbound wires, performing optimizations if possible
** Inbound and outbound wires may be associated with different service contracts
** Different implementation types
** "Standard" wires contain invocation chains that have Interceptors that perform some form of mediation (e.g. policy)
** Other wire types exist that, for example, do not perform mediations
h4. Invocation Chains
A wire has an InvocationChain per service operation. An InvocationChain may have interceptors - "around-style" mediation. Component implementation instances access a wire through a WireInvocationHandler associated with a reference.
* WireInvocationHandlers may (or may not depending on the component type) be fronted by a proxy
* WireInvocationHandlers dispatch an invocation to the correct chain
A wire has a TargetInvoker that is created from the target side AtomicComponent or Reference and is stored on the source wire invocation handler. The TargetInvoker is resposnible for dispatching the request to the target instance when the message hits the end of the target invocation chain.
h4. Invocation Overview
* An invocation is dispatched to the WireInvocationHandler
* The WireInvocationHandler looks up the correct InvocationChain
* It then creates a message, sets the payload, sets the TargetInvoker, and passes the message down the chain
* When the message reaches the end of the chain, the TargetInvoker is called, which in turn is responsible for dispatching to the target
* Having the TargetInvoker stored on the outbound side allows it to cache the target instance when the wire source has a scope of equal or lesser value than the target (e.g. request-->composite
The runtime provides components with InboundWires and OutboundWires. InvocationChains are held in component wires and are therefore stateless which allows for dynamic behavior such as introduction of new interceptors or re-wiring.
h3. {anchor:Kernel Bootstrap}{color:#0099cc}Bootsrap{color}
Bootstrap process is controlled by Host environment. The default process is implemented in DefaultBootstrapper.
!bootstrap.jpg!
h3. {anchor:Kernel Composite Hierarchy}{color:#0099cc}Composite Hierarchy{color}
!tuscany_composite_hierarchy.jpg|thumbnail!
h3. The sequence diagram for the bootstrapping
!bootstrap_seq.jpg|thumbnail!
h3. {anchor:Java SCA Deployment}{color:#0099cc}Deployment{color}
The runtime processes service assemblies serialized using SCA XML vocabulary, SCDL, but can take other forms.
* The load phase processes SCDL and creates an in-memory model
* The build phase evaluates the model and produces corresponding runtime artifacts (e.g. components, services, references)
* The connect phase wires references to services
h3. {anchor:Java SCA Loaders}{color:#0099cc}Loader{color}
SCA service assemblies are deployed to the SCA domain in the format of SCDL files. Tuscany runtime uses loader to load the SCDLs into model objects which are a set of java beans to hold the metadata.
There are two types of loaders:
* StAXElementLoader: Load the XML element from the StAX events
* ComponentTypeLoader: Load the Component Type for an implementation either by introspection or paring a side file
h3. {anchor:Java SCA model}{color:#0099cc}Model{color}
!assembly.jpg!
h3. Loading Component Type
Loads the component type definition for a specific implementation
* How it does this is implementation-specific
* May load XML sidefile (location set by implementation)
* May introspect an implementation artifact (e.g. Java annotations)
* ... or anything else
Composite ComponentType Loader
* Load SCDL from supplied URL
* Extract and load SCDL from composite package
POJO ComponentType Loader
* Introspect Java annotations
* Uses a pluggable "annotation processing" framework to introspect Java classes
h3. {anchor:Java SCA Builder}{color:#0099cc}Builder{color}
Java SCA builder creates a runtime component from the configuration model
* Builder for each implementation type
* Builder for each binding type (service or reference component)
Runtime component manages:
* Implementation instances
* Inbound and Outbound wires
Every implementation is likely to be different
* Different artifacts, programming model, ...
Composite implementation recurses for contained components
* Re-invokes the Builder for every child
h3. Class diagram for the runtime artifacts
!runtime-model.jpg!
h3. Connecting
The connector is reponsible to connect the wires for the components, services and references.
h2. Federated Assembly
<notes from Meeraj's email on 2/1/07 - Haleh included here>
I have been working on the stuff around federated assembly and enabling
distributed SCA domains. Here is a quick summary of what has been done
so far,
Work in progress
h3. Discovery Service
* Provides the low-level communication abstraction for
enabling runtimes participating in the domain to exchange information
* The abstraction supports directed message delivery to a
given runtime, asynchronous message reception and broadcast to all
runtimes participating in the domain
* To start with we are following a model, where one
runtime in the domain assumes the master role and is responsible for
managing the logical assembly
* This runtime creates the physical artifacts and
trensport them to the target slave runtimes
* The discovery abstraction is defined in SPI
* There are two implementations in runtime/services - JXTA
and Bonjour
* JXTA implementaion is getting pretty much there, it
mainly uses the JXTA Peer Discovery protocol (PDP) and Peer Resolver
Protocol (PRP)
h3. Marshalling Framework
* This is similar to our loader framework, however
supports bi-directional marshalling and unmarshalling of physical model
objects
* This framework is used by the assembly service to
serialize and transport physical model information to slave runtimes
using the discovery services
* On the receiving end the serialized information is
unmarshalled by the federated deployer for being applied to the slave
runtime
* The abstraction is defined in SPI
* I am working on an implementation in core
* The framework supports versioning of physicla model
objects if the participating runtimes are at different versions
h3. Federated Deployer
* This is similar to the local deployer, however registers
itself with the discovery service for receiving physical model updates
* The federated deployer doesn't use the loader framework
* The federated deployer accepts serialized physical model
information in XML, rather than raw SCDL as with local deployer
* It uses the current builder framework to build, prepare
and start the components {note:title=A note from Jeremy on federated deployment Feb. 9, 2007.}The design is that there is a "master" node that is working out which"physical" nodes components are going to run on. It then
passes PhysicalComponentDefinition's to the worker nodes to get them tocreate the component and any transport bindings it needs
to talk toother nodes. The PCDs are portable, independent of the type ofruntime, instead tied to the type of component.Picking on
Ruby as an example as we know we can run that on Java andNative runtimes, there could be one common PCD for a Ruby componentthat
was supported by all container implementations. The master couldsend that to any node to have it run a Ruby component. A runtimecould
also offer "enhanced" Ruby support with additional featuresthat required additional configuration. If would offer support for adifferent
PCD with that additional metadata. Which one is selected bythe master would be part of its component allocation algorithm.So basically,
any runtime that can connect to the federated fabricand handle a PCD can join the SCA domain. We picked JXTA and XML forthe fabric and
PCD encoding as there is support for those in bothJava and C++. Adding support for that to the Native runtime wouldalso be good if you
were skeptical of all the Java stuff. {note}
h3. Work outstanding
* Define the physical model in Java
* Define the corresponding XML infoset
h3. Supported Extensions
h4. Spring
1) it allows a Spring application context to act as the
implementation of an SCA component - this allows users to bring
existing Spring applications into an SCA assembly
2) it allows SCA components to act as Spring beans so that users can
use services over SCA from their applications.h3. {anchor:Component Implementation Extension}{color:#0099cc}Component Implementation Extension{color}
h3. {anchor:Data Binding Extension}{color:#0099cc}Data Binding Extension{color}
h3. {anchor:Spring Integration}{color:#0099cc}Spring Integration{color}
h3. {anchor:Wiring}{color:#0099cc}Wiring{color}
To understand how wiring works, we need to detail how Components function in the system. Let's start with Atomic Components and then discuss Composite Components.
h4. Atomic Component
AtomicComponent is the most basic component form. It corresponds to the spec concept which offers services, has references and properties
* Implementation types e.g. Java, XSLT, etc.
* Are wired
* Have properties
Atomic Components have implementation instances. Instances are associated with a scope: e.g. request, conversation, composite. A SCDL entry is used to define a Component. [Haleh: Define scope]
Atomic components use a ScopeContainer to manage implementation instances:
* Composite, HTTP Session, Request, Stateless
* ScopeContainers track implementation instances by scope id and the AtomicComponent instance identity
* Instances are stored in an InstanceWrapper which is specific to the component implementation type (e.g. PojoInstanceWrapper.java)
h4. Component Wiring
Component references are connected to services through wires
* Two sides
** InboundWire - handles the source side of a wire, including policy
** OutboundWire - handles the target side of a wire, including policy
* The runtime connects inbound and outbound wires, performing optimizations if possible
** Inbound and outbound wires may be associated with different service contracts
** Different implementation types
** "Standard" wires contain invocation chains that have Interceptors that perform some form of mediation (e.g. policy)
** Other wire types exist that, for example, do not perform mediations
h4. Invocation Chains
A wire has an InvocationChain per service operation. An InvocationChain may have interceptors - "around-style" mediation. Component implementation instances access a wire through a WireInvocationHandler associated with a reference.
* WireInvocationHandlers may (or may not depending on the component type) be fronted by a proxy
* WireInvocationHandlers dispatch an invocation to the correct chain
A wire has a TargetInvoker that is created from the target side AtomicComponent or Reference and is stored on the source wire invocation handler. The TargetInvoker is resposnible for dispatching the request to the target instance when the message hits the end of the target invocation chain.
h4. Invocation Overview
* An invocation is dispatched to the WireInvocationHandler
* The WireInvocationHandler looks up the correct InvocationChain
* It then creates a message, sets the payload, sets the TargetInvoker, and passes the message down the chain
* When the message reaches the end of the chain, the TargetInvoker is called, which in turn is responsible for dispatching to the target
* Having the TargetInvoker stored on the outbound side allows it to cache the target instance when the wire source has a scope of equal or lesser value than the target (e.g. request-->composite
The runtime provides components with InboundWires and OutboundWires. InvocationChains are held in component wires and are therefore stateless which allows for dynamic behavior such as introduction of new interceptors or re-wiring.
h3. {anchor:Kernel Bootstrap}{color:#0099cc}Bootsrap{color}
Bootstrap process is controlled by Host environment. The default process is implemented in DefaultBootstrapper.
!bootstrap.jpg!
h3. {anchor:Kernel Composite Hierarchy}{color:#0099cc}Composite Hierarchy{color}
!tuscany_composite_hierarchy.jpg|thumbnail!
h3. The sequence diagram for the bootstrapping
!bootstrap_seq.jpg|thumbnail!
h3. {anchor:Java SCA Deployment}{color:#0099cc}Deployment{color}
The runtime processes service assemblies serialized using SCA XML vocabulary, SCDL, but can take other forms.
* The load phase processes SCDL and creates an in-memory model
* The build phase evaluates the model and produces corresponding runtime artifacts (e.g. components, services, references)
* The connect phase wires references to services
h3. {anchor:Java SCA Loaders}{color:#0099cc}Loader{color}
SCA service assemblies are deployed to the SCA domain in the format of SCDL files. Tuscany runtime uses loader to load the SCDLs into model objects which are a set of java beans to hold the metadata.
There are two types of loaders:
* StAXElementLoader: Load the XML element from the StAX events
* ComponentTypeLoader: Load the Component Type for an implementation either by introspection or paring a side file
h3. {anchor:Java SCA model}{color:#0099cc}Model{color}
!assembly.jpg!
h3. Loading Component Type
Loads the component type definition for a specific implementation
* How it does this is implementation-specific
* May load XML sidefile (location set by implementation)
* May introspect an implementation artifact (e.g. Java annotations)
* ... or anything else
Composite ComponentType Loader
* Load SCDL from supplied URL
* Extract and load SCDL from composite package
POJO ComponentType Loader
* Introspect Java annotations
* Uses a pluggable "annotation processing" framework to introspect Java classes
h3. Class diagram for the runtime artifacts
!runtime-model.jpg!
|