Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
#6699ff#D5EFFF Kernel section
Section
borderfalse
Column
width15%
Include Page
SCA Java Subproject Menu
SCA Java Subproject Menu
Include Page
Java SCA Menu New
Java SCA Menu New
Column
width85%
Panel
borderColor
#ECF4D1
bgColor#ffffff
titleBGColor
#ECF4D1
titleApache Tuscany SCA Java
Architecture Guide
borderStylesolid

This page is work in progress. Thanks for your contribution (smile)

 

Anchor
Overview
Overview

...

Overview

This is a high level architecture document for Tuscany Java implementation of Service Component Architecture (SCA) which is defined in the specifications located at (http://wwww.osoa.orgImage Removed).

This is a live document and is more focused on what is implemented rather than the end vision.
Goal of this document is to help users/developers better understand what Tuscany SCA offers and enable them to help with the development if interested.

Tuscany provides the infrastructure for creating, assembling and deploying services in a distributed environment.
At a high level it aims to provide for the following:

  • Infrastructure for creating, wiring, deploying and managing service assemblies in single runtime or across runtimes (federated)
  • Infrastructure for leveraging qualities of service provided by host environments (transactions, security)
  • Support for different host environments: Standalone, Tomcat, J2EE, OSGI (in progress, more can be added)
  • plug-points for supporting variety of bindings such as Axis2, RMI, more can be added
  • plug-points for adding component implementations such as Java Script, Spring, JRuby, Python (started), more can be added

...

[Note: Do we want to link to Kernel-Structure]?

...

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, or Inversion of Control.

Anchor
Core Definition
Core Definition
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.

Anchor
Extension Definition
Extension Definition
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.

Anchor
Runtime Definition
Runtime Definition
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.

HTML Comment
hiddentrue
Children Display
sortcreation

High level overview of Java SCA runtime

The diagram shown below is a high level view of the SCA runtime which consists of the following key modules/packages:

  1. SCA Spec API: The APIs defined by the SCA Java Client and Implementation Spec
  2. API: Tuscany APIs which extend the SCA

...

  1. Spec APIs
  2. Core: The runtime implementation

...

  1. and the SPIs to extend it
  2. Extensions:
    1. Container implementation - For extending language support, for example BPEL, Python, C++, Ruby,..
    2. Binding - for extending protocol support, for example Axis2, CXF,..
    3. Interface Binding - for extending types of service definition, for example WSDL, Java, ...
    4. Databinding

...

    1. - for extending data support, for example SDO, JAXB, ...
  1. Host

...

  1. Platforms: The environments that host the Tuscany runtime.

...

Image Added

Anchor

...

  • 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

...

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) Clarify

...

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.

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. 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)

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

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.

Internals High Level View
Internals High Level View
Internals High Level View

[Note: Do we want to link to Kernel-Structure]?

Anchor
Bootstrap
Bootstrap
Bootsrap

Bootstrap process is controlled by Host environment. The default process is implemented in DefaultBootstrapper.
The runtime processes service assemblies serialized using SCA Assembly XML which can take other forms.

  • The load phase processes SCDL and creates an in-memory model and produces corresponding runtime artifacts (e.g. components, services, references)
  • The connect/wire phase wires references to services

Image Added

Anchor
Assembly Model
Assembly Model
Assembly Model

The SCA assembly model is represented as a set of interfaces in Tuscany. The following are some key elements.

  • SCA components are configured instances of SCA implementations, which provide and consume services.
  • SCA services are used to declare the externally accessible services of an implementation.
  • SCA references represent a dependency that an implementation has on a service that is supplied by some other implementation, where the service to be used is specified through configuration.
  • An implementation is concept that is used to describe a piece of software technology such as a Java class, BPEL process, XSLT transform, or C++ class that is used to implement one or more services in a service-oriented application. An SCA composite is also an implementation. 
  • ComponentType refers to the configurable aspects of an implementation.
  • Interfaces define one or more business functions. These business functions are provided by Services and are used by components through References. Services are defined by the Interface they implement. SCA currently supports two interface type systems:
    • Java interfaces
    • WSDL portTypes
  • An SCA composite is the basic unit of composition within an SCA Domain. An SCA Composite is an assembly of Components, Services, References, and the Wires that interconnect them.
  • SCA wires connect service references to services.
  • Bindings are used by services and references. References use bindings to describe the access mechanism used to call the service to which they are wired. Services use bindings to describe the access mechanism(s) that clients should use to call the service.
  • Properties allow for the configuration of an implementation with externally set data values. The data value is provided through a Component, possibly sourced from the property of a containing composite.
  • Image Added

Anchor
Contribution
Contribution
Contribution

The Tuscany runtime provides a framework to support SCA contributions. The framework can be extended against the following two extension points:

PackageProcessorExtensionPoint: It accepts extensions that can handle different packaging format/archives such as a directory, a JAR, an OSGi bundle, an EAR, a WAR and a ZIP. 

ArtifactProcessorExtensionPoint: It accepts extensions that can handle specific types of artifacts such as WSDL, XSD, composite, java class, BPEL.

Image Added

  • Package processors scans the contribution being installed and generate a list of artifacts that needs to be processed. Currently there is support for folder/file system and jar contribution packages. In order to be available to the contribution service, a package processors needs to register itself with the package processor extension.
  • Artifact processors are used to process each artifact available on the contribution. In order to be available to the contribution service, a artifact processor needs to register itself with the artifact processor extension. An artifact processor will be called for each artifact in two phases :
    • read phase : This is where you read an artifact (a document, an XML element, classes etc.), populate a model representing the artifact and return it. The SCA contribution service calls ArtifactProcessor.read() on all artifacts that have an ArtifactProcessor registered for them. If your model points to other models, instead of trying to load these other models right away, you should just keep the information representing that reference, which you'll turn into a pointer to the referenced model in the resolve() phase. Note that you don't necessarily need to fully read and populate your model at this point, you can choose to complete it later.
    • resolve phase : This phase gives you the opportunity to resolve references to other models (a WSDL, a class, another composite, a componentType). At this point, all models representing the artifacts in your SCA contribution have been read, registered in the contribution's ArtifactResolver, and are ready to be resolved.
  • All deployable composites should be now ready to get deployed to the SCA Domain

Anchor
Implementation Extension
Implementation Extension
Implementation Extension

Implementation extension is responsible for supporting an implementation type, such as Java, Script, and BPEL

Anchor
Binding Extension
Binding Extension
Binding Extension

Binding extension is responsible for supporting a binding type such as Web Service, JMS,  JSON-RPC and RMI

Anchor
Interface Extension
Interface Extension
Interface Extension

Interface extension is responsible for supporting an interface type such as Java interface and WSDL 1.1 portType

Anchor
Data Binding Extension
Data Binding Extension
Data Binding Extension

Please refer to: Tuscany Databinding Guide

Anchor
Composite Activation
Composite Activation
Composite Activation

After a composite is fully configured, it can be activated in the SCA domain. The Tuscany runtime activates a composite in the following steps:

  1. Build the composite: In this phase, the composite model is further normalized to facilitate the runtime interactions. The metadata is consolidated following the service/reference promotions. With the flattened model, we can get all the information at component level.
  2. Configure the composite: In this phase, the composite hierarchy is navigated to configure the component implementation, reference binding and service binding with provider factories which will be used in later steps to create runtime wires among components and external services.   
  3. Create the runtime wires: In this phase, runtime wires are created for component references and component services over selected bindings. The runtime wire is a collection of invocation chains that are patitioned by operations. Each invocation chain consists of a set of invokers and interceptors s. Invokers provides the invocation logic to binding protocols and implementation technologies. Interceptors are speical kind of invokers that provide additional logic for the invocation, such as data transformation and transaction control. For a component reference, we create runtime wires to represent the outbound invocation over the selected binding. For a component service, we create runtime wires to represent the inbound invocation to the implementation type. Callback wires can be attached to component services to represent the callback invocations from the service.
  4. Start the composite: In this phase, the start() callback methods defined by the ImplementationProvider, ReferenceBindingProvider and ServiceBindingProvider will be invoked. As a result, components, component references and component services are initialized to serve the component interactions. Service listeners are started to accept inbound requests from the binding layer.Image Added
    Image Added

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.

Anchor

...

Bootstrap process is controlled by Host environment. The default process is implemented in DefaultBootstrapper.

Image Removed

...

Loading SCA assemblies
Loading SCA assemblies
Loading SCA assemblies

Artifact Processor

Artifact processors are responsible for processing each artifact available in a contribution package, these processors are going to be invoked in two phases

  • read phase : This is where you read an artifact (a document, an XML element, classes etc.), populate a model representing the artifact and return it. The SCA contribution service calls ArtifactProcessor.read() on all artifacts that have an ArtifactProcessor registered for them. If your model points to other models, instead of trying to load these other models right away, you should just keep the information representing that reference, which you'll turn into a pointer to the referenced model in the resolve() phase. Note that you don't necessarily need to fully read and populate your model at this point, you can choose to complete it later.
  • resolve phase : This phase gives you the opportunity to resolve references to other models (a WSDL, a class, another composite, a componentType). At this point, all models representing the artifacts in your SCA contribution have been read, registered in the contribution's ArtifactResolver, and are ready to be resolved.

Loading Java SCA

Image Removed

The sequence diagram for the bootstrapping

Image Removed

...

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

...

SCA service assemblies are deployed to the SCA domain in the format of SCDL files. Tuscany runtime

...

artifact processor loads 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

...

Image Removed

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

Loading 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

...

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

Class diagram for the runtime artifacts

Image Removed

Connecting

The connector is reponsible to connect the wires for the components, services and references.

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

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)

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

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
titleA 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.

Work outstanding

  • Define the physical model in Java
  • Define the corresponding XML infoset

Supported Extensions

Spring

...

Image Added

Anchor
Spring Integration
Spring Integration
Spring Integration