SCA
Service Component Architecture
(SCA) Tutorial : Part 1
Mike Edwards - IBM
Anish Karmarkar – Oracle
Jim Marino – BEA
OSOA Collaboration | 30th May 2007 | SOA Roadmap
SCA
Service Component Architecture
A model for building components, assembling them into
applications, and deploying them to various runtime
environments
Components can be built from new or existing code using
SOA principles
vendor-neutral – supported across the industry
language-neutral – components written using any language
technology-neutral – use any communication protocols and
infrastructure to link components
OSOA Collaboration | SOA Roadmap
SCA
Part 1 Outline
Composite example
Implementation using Java component implementation
Introduction to SCA concepts
Advanced composition – nested composites
Packaging and deployment
Extension points
Component Implementation types
Spring Framework
BPEL
Demonstrations
OSOA Collaboration | SOA Roadmap
SCA
Part 2 Outline
Bindings
Web service binding
JMS binding
EJB session bean binding
Policies – Intents and Policy Sets
Security
Reliable Messaging
Transactions
OSOA Collaboration | SOA Roadmap
SCA
AccountsComposite
Example SCA assembly External
Banking
Payment Payments
Reference
Service Component
Order
Processing OrderProcessing
Component
Service Accounts
Ledger
Component
EventLog
Component
External
WarehouseComposite Warehouse
Reference
Warehouse
Warehouse Warehouse
Broker
Service Component
Component
EventLog
Reference
OSOA Collaboration | SOA Roadmap
SCA
Simple Example
[Link]
Reference
StockQuote
Service
Service AccountService
AccountService Component
AccountData
Service
Component
OSOA Collaboration | SOA Roadmap
SCA
<composite xmlns="[Link] XML Representation
name="[Link]" >
<service name="AccountService“ promote=“AccountServiceComponent”>
<[Link] interface="[Link]"/>
<[Link] port="[Link]
[Link](AccountService/AccountServiceSOAP)"/>
</service>
<component name="AccountServiceComponent">
<[Link] class="[Link]"/>
<property name=“currency”>EURO</property>
<reference name="accountDataService" target="AccountDataServiceComponent"/>
<reference name="stockQuoteService"/>
</component>
<component name="AccountDataServiceComponent">
<[Link] class="[Link]"/>
</component>
<reference name="StockQuoteService“ promote=“AccountServiceComponent/stockQuoteService”>
<[Link] interface="[Link]"/>
<[Link] port="[Link]
[Link](StockQuoteService/StockQuoteServiceSOAP)"/>
</reference>
</composite>
OSOA Collaboration | SOA Roadmap
SCA
Java Implementation Example:
Service Interface
Interface is callable
package [Link]; remotely
eg. as a Web service
@Remotable
public interface AccountService {
public AccountReport getAccountReport(String customerID);
}
OSOA Collaboration | SOA Roadmap
SCA
Java Implementation Example – Implementation (part 1)
package [Link];
import [Link].*; Defines the
service interface
@Service([Link])
public class AccountServiceImpl implements AccountService {
private String currency = "USD";
private AccountDataService accountDataService; Defines a property
private StockQuoteService stockQuoteService; “currency”
public AccountServiceImpl(
@Property("currency") String currency,
@Reference("accountDataService") AccountDataService dataService,
@Reference("stockQuoteService") StockQuoteService stockService) {
[Link] = currency;
[Link] = dataService;
[Link] = stockService;
} // end constructor
Defines references
“accountDataService”
and
“stockQuoteService”
OSOA Collaboration | SOA Roadmap
SCA
Java Implementation Example – Implementation (part 2)
public AccountReport getAccountReport(int customerID) Get the basic account
throws AccountDataUnavailableException { report using the
account data service
AccountReport accountReport =
[Link](customerID);
List<Stock> stocks = [Link](); Obtain up to date
stock values using the
List<StockValues> stockValues = stock quote service
[Link]( stocks, currency );
[Link]( values );
return accountReport;
} Update the account
} // end class report with the latest
stock values
OSOA Collaboration | SOA Roadmap
SCA
SCA Java Implementation principles
Code only to business interfaces
“Don’t program to SCA, just program…”
Use Java idioms
Minimal middleware APIs used only in special cases
Principles apply to other languages
Components declare both the services they offer and references
to other services they need
Injection of required service References and Property values
via constructor
via setter methods
via direct field injection
Java annotations for SCA elements
services, references, properties
+ more advanced features such as intents, bindings
OSOA Collaboration | SOA Roadmap
SCA
SCA Concepts: Component
Properties
Implementation
Services configuration attribute
Business function
provided to clients
through an interface
contract
Component
…
…
References
Implementation
dependency on an
Implementation external service
The implementation code
for the component. In any
one of many languages,
eg. Java, BPEL, C++, PHP,
Composite….
OSOA Collaboration | SOA Roadmap
SCA
SCA Concepts: Wire, Interface, Binding
Wire
Connects services to references
Component Component
…
Interface Binding
Description of business functions of services Access mechanism used by services and
& references. For example, Java interface, references. For example, Web services binding,
WSDL 1.1 portType, WSDL 2.0 interface JMS binding, EJB Session bean binding
OSOA Collaboration | SOA Roadmap
SCA
Bigbank Composite - multiple components,
service, reference & property
[Link]
Reference
StockQuote
Service
Service AccountService
AccountService Component
AccountData
Service
Component
OSOA Collaboration | SOA Roadmap
SCA
<composite xmlns="[Link]
targetNamespace="[Link]
name="[Link]" >
<service name="AccountService" promote="AccountServiceComponent">
<[Link] interface="[Link]"/>
<[Link] port="[Link]
[Link](AccountService/AccountServiceSOAP)"/>
</service>
<component name="AccountServiceComponent">
<[Link] class="[Link]"/>
<reference name="StockQuoteService"/>
<reference name="AccountDataService"
target="AccountDataServiceComponent/AccountDataService"/>
<property name="currency">EURO</property>
[Link]
StockQuote
</component>
Reference
StockQuote
Service
Service AccountService
<component name="AccountDataServiceComponent"> AccountService Component
AccountData
<[Link] process=“QName"/> Service
Component
<service name="AccountDataService">
<[Link] interface="[Link]"/>
</service>
</component>
<reference name=“StockQuoteService" promote="AccountServiceComponent/StockQuoteService">
<[Link] interface="[Link]"/>
<[Link] port="[Link]
[Link](StockQuoteService/StockQuoteServiceSOAP)"/>
</reference>
<composite>
OSOA Collaboration | SOA Roadmap
SCA
Reuse in SCA
Inclusion
Recursive composition
Implementation reuse through configurable components
Reusable services through composite references
OSOA Collaboration | SOA Roadmap
SCA
ComponentType
Describes component implementation type details
Services
References
Properties
Extensibility elements
Can be introspected from the implementation or specified in
an XML sidefile
Typically will be introspected from the implementation
Component implementations may use annotations to specify
componentType information
• eg Java
OSOA Collaboration | SOA Roadmap
SCA
Java Implementation Example: componentType
<componentType xmlns="[Link]
xmlns:xsd="[Link]
<service name="AccountService">
<[Link] interface="[Link]"/>
</service>
<reference name="accountDataService">
<[Link] interface="[Link]"/>
</reference>
<reference name="stockQuoteService">
<[Link] interface="[Link]"/>
</reference>
<property name="currency" type="xsd:string"/>
</componentType>
OSOA Collaboration | SOA Roadmap
SCA
Top-Down Design: constrainingType
constrainingType
Implementation independent
Specifies the shape -- constraints in terms of
services/references/properties
composites, components, componentType and implementations can
be constrained using the “constrainingType” attribute
Allows an architect to specify constrainingTypes which can be used
by developers as a template
SCA provides runtime validation of artifacts with its constrainingType
OSOA Collaboration | SOA Roadmap
SCA
constrainingType Example
<constrainingType name=“myCT” ... >
<service name="MyValueService">
<[Link] interface="[Link]"/>
</service>
<reference name="customerService">
<[Link] interface="[Link]"/>
</reference>
<property name="currency" type="xsd:string"/>
</constrainingType>
<component name="MyValueServiceComponent" constrainingType="myns:myCT” >
<[Link] process=“..."/>
<service name=“MyValueService”>
<[Link] interface="[Link]"/>
<[Link] .../>
</service>
<reference name="customerService" target="CustomerService">
<[Link] ...>
</reference>
<property name="currency">EURO</property>
</component>
OSOA Collaboration | SOA Roadmap
SCA
Recursive Composition
Composites and Implementations look the same
services
references
properties
composites have associated ComponentType
“Recursive composition” = nesting of composites
composite can be a component implementation in a higher level
composite
promotes reuse of assemblies
<[Link]../> as component implementation
component can be implemented by “atomic” implementation or by
composite
OSOA Collaboration | SOA Roadmap
SCA
Implementing AccountDataService Using A
Composite
[Link]
Reference
StockQuote
Service
Service AccountService
AccountService Component
AccountData
Service
Component
implements
[Link]
Service
AccountData Logging
AccountDataService
OSOA Collaboration | SOA Roadmap
SCA
[Link] Composite
<composite xmlns="[Link]
targetNamespace="[Link]
name="[Link]" >
<service name="AccountDataService" promote="AccountData">
<[Link] interface="[Link]"/>
</service>
<component name="AccountDataServiceComponent">
<[Link] process=“..."/>
<reference name=“LoggingService"
target=“LoggingServiceComponent"/>
</component>
<component name=“LoggingServiceComponent">
<[Link] location=“..."/>
</component>
<composite>
OSOA Collaboration | SOA Roadmap
SCA
AccountDataService ComponentType
<componentType>
<service name="AccountDataService">
<[Link]
interface="[Link]"/>
</service>
</componentType>
OSOA Collaboration | SOA Roadmap
SCA
[Link] Composite (recursion)
<composite xmlns="[Link]
targetNamespace="[Link]
name="[Link]" >
<service name="AccountService" promote="AccountServiceComponent">
<[Link] interface="[Link]"/>
<[Link] port="[Link]
</service>
<component name="AccountServiceComponent">
<[Link] class="[Link]"/>
<reference name="StockQuoteService"/>
<reference name="AccountDataService"
target="AccountDataServiceComponent/AccountDataService"/>
<property name="currency">EURO</property>
</component>
<component name="AccountDataServiceComponent">
<[Link] name=“bb:[Link]"/>
<[Link] process=“QName"/>
<service name="AccountDataService">
<[Link] interface="[Link]"/>
</service>
</component>
<reference name="" promote="AccountServiceComponent/StockQuoteService">
<[Link] interface="[Link]"/>
<[Link] port="[Link]
</reference>
<composite>
OSOA Collaboration | SOA Roadmap
SCA
Packaging and Deployment: Domains
Composites deployed, configured into SCA Domain
Defines the boundary of visibility for SCA
Typically an area of functionality controlled by single
organization/division
• E.g.: accounts
Configuration represented by virtual composite
potentially distributed across a network of nodes
contains components, services, references, wires
configured using composites
Composites make deployment simpler
individual composites created, deployed independently
may contain only wires or components or externally provided
services or references
Abstract services provided for management of the domain
OSOA Collaboration | SOA Roadmap
SCA
Packaging and Deployment: Contributions
Contributions hold artifacts available for use in the Domain
Package containing artifacts necessary for SCA
SCA defined artifacts
• E.g.: composites, constrainingType, etc
Non-SCA defined artifacts
• E.g.: WSDL, XML schema, Java classes, object code etc
Packaging must be hierarchical
Metadata included in the “META-INF” directory
<contribution xmlns=[Link]
<deployable composite="xs:QName"/>*
<import namespace="xs:String" location=”xs:AnyURI”?/>*
<export namespace="xs:String"/>*
</contribution>
Interoperable packaging format: ZIP
Other formats possible: filesystem directory, OSGi bundle, JAR file
OSOA Collaboration | SOA Roadmap
SCA
SCA Runtime Example Runtime Topology
SCA JEE Containers SCA Java Containers SCA CPP Containers
…
SCA PHP Container SCA BPEL Container
Assigned to be
hosted by SCA
Deployment Java container Assigned to be
hosted by SCA
Mapping CPP container
SCA Domain
[Link]
[Link]
Service Compositions
OSOA Collaboration | SOA Roadmap
SCA
Extensibility in SCA
Designed for extensibility
Extensible artifacts:
Implementation types
• <implementation.*>
Interface types
• <interface.*>
Binding types
• <binding.*>
OSOA Collaboration | SOA Roadmap
SCA
Assembly: Summary
SCA Assembly models systems composed of reusable services
A model for service-based system:
construction
assembly
deployment
Heterogeneity
Multiple languages
Multiple container technologies
Service access methods
Metadata driven
OSOA Collaboration | SOA Roadmap
SCA
Component Implementation Types
SCA supports a number of programming models and technologies
for authoring components
The SCA Java Implementation type based on POJOs
Spring
EJB
BPEL
C++
PHP
In the future, potentially others
OSOA Collaboration | SOA Roadmap
SCA
Spring Framework Component Implementation
SCA = integration at coarse-grained level
Spring = integration at fine grained level
Spring application context used as component implementation
SCA component implemented by a collection of Spring beans
Two ways:
1. No SCA-related metadata in Spring
2. SCA-related metadata specified as Spring beans
• sca:service
• sca:reference
• sca:property
Uses <[Link] ...”/>
<component name="AccountServiceComponent">
<[Link] location="/spring/application-context/"/>
...
</component>
OSOA Collaboration | SOA Roadmap
SCA
Bigbank implementation using Spring
AccountService component
<beans>
<bean id=“FirstBean”>
<property name="aPropertyName" ref=“SecondBean"/>
</bean>
<bean id=“SecondBean">
<property name="SQRef" ref="StockQuoteService"/>
<property name="ADRef" ref="AccountDataService"/>
</bean>
<sca:service name="AccountService"
type="[Link]" target=“FirstBean"/>
<sca:reference name="StockQuoteService"
type="[Link]"/>
<sca:reference name="AccountDataService"
type="[Link]"/>
<beans>
OSOA Collaboration | SOA Roadmap
SCA
BPEL Component Implementation
SCA and BPEL are complementary
BPEL provides business sequencing & orchestration of services
SCA provides a compositional view of interconnection of service components
Supports WS-BPEL 1.1 and 2.0
Uses WSDL interfaces
SCA service = partnerLink with single role belonging to the BPEL process
SCA reference = partnerLink with single role belonging to partner
When partnerLink defines two roles, directionality defines whether it is a service
or a reference
OSOA Collaboration | SOA Roadmap
SCA
BPEL Component Implementation (cont.)
SCA extensions for BPEL (not mandatory)
Attribute “sca:property” on a variable declaration defines a property
Element “sca:multiReference” on a variable declaration defines a multivalued
reference (multiple partners for one partnerLink, called in sequence)
Uses <[Link] process=“bpel-process-QName”/>
<component name="AccountServiceComponent">
<[Link] process=“myns:Process1"/>
...
</component>
OSOA Collaboration | SOA Roadmap
SCA
Summary
SCA models systems built using a Service Oriented
Architecture
supports Service Implementation, Service Assembly
open to many kinds of service implementation
open to many types of service access
declarative intent & policy approach to application of
Security & Transaction
OSOA Collaboration | SOA Roadmap
SCA
Demonstrations
IBM Demo:
HelloWorld sample with a callback (SCA V0.95)
Oracle Demos:
Oracle Fusion Middleware (SCA 0.95) Overview
Simple SayHello Example Using Jdeveloper (Synchronous)
Simple HelloWorld Example (Asynchronous)
OrderBooking Application
BEA Demo
Based on the Fabric3 open source SCA implementation
([Link])
Component provisioning in distributed SCA domain across multiple
JVMs
Java SCA 1.0 programming model support
OSOA Collaboration | SOA Roadmap
SCA
IBM Demo: HelloWorld Sample with Callback
Service
WSDL PortType
HelloWorldWSClient
JSP
HelloWorldService
Component Reference
Hello Service
Implementation
Binding - Java
Web Service
Service
Implementation WSDL PortType
- Java
HelloWorldWS
HelloWorldService
Service Component
Hello Service
Binding
Web Service
OSOA Collaboration | SOA Roadmap
SCA
IBM Demo: HelloWorld Sample with Callback - Client
<composite xmlns="[Link]
xmlns:system="[Link]
name="helloworldwsclient">
<component name="HelloWorldServiceComponent">
<[Link] class="[Link]"/>
<reference name="helloWorldService">HelloWorldService</reference>
</component>
<reference name="HelloWorldService">
<[Link] xmlns:wsdli="[Link]
interface="[Link]
callbackInterface="[Link]
wsdli:wsdlLocation="[Link] wsdl/[Link]" />
<[Link] endpoint="[Link]
[Link](HelloWorldService/HelloWorldSoapPort)"
location="wsdl/[Link]" />
</reference>
</composite>
OSOA Collaboration | SOA Roadmap
SCA
IBM Demo: HelloWorld Sample with Callback - Service
<composite xmlns="[Link]
xmlns:wsdli="[Link]
name="helloworldws">
<service name="hwwsasync">
<[Link] xmlns:wsdli="[Link]
interface="[Link]
callbackInterface="[Link]
wsdli:wsdlLocation="[Link] WEB-INF/wsdl/[Link]" />
<[Link] endpoint="[Link]
[Link](HelloWorldService/HelloWorldSoapPort)"
location="WEB-INF/wsdl/[Link]" />
<reference>HelloWorldServiceComponent</reference>
</service>
<component name="HelloWorldServiceComponent">
<[Link] class="[Link]" />
</component>
</composite>
OSOA Collaboration | SOA Roadmap
SCA
Oracle Demo: Fusion (SCA 0.95) Overview
Service Engines
Scheduler
BPEL Routing Rules
…
Bindings
SCA Runtime MDS
HTTP (Fusion Middleware)
Normalized message bus
JMS Component lifecycle management
Inter-component “wiring”
Policy enforcement (binding UDDI
JCA independent)
… Monitoring
J2EE + Spring
OSOA Collaboration | SOA Roadmap
SCA
Oracle Demo: SayHello Example
(Synchronous)
<componentType ...>
<service name="client">
Service <[Link]
WSDL PortType interface="[Link]
[Link](SayHello)"/>
</service>
</componentType>
SayHello
<composite name="SayHello“ ... >
<service name="SoapService1">
Service SayHello <[Link]
SoapService1 Component
interface="[Link]
[Link](SayHello)"/>
<[Link]
port="[Link]
[Link](SoapService1/SayHello_pt)"/>
</service>
<component name="SayHello">
<[Link] src="[Link]"/>
</component>
Binding
Web Service
<wire>
<[Link]>SoapService1</[Link]>
<[Link]>SayHello/client</[Link]>
Implementation </wire>
- BPEL </composite>
OSOA Collaboration | SOA Roadmap
SCA
Oracle Demo: HelloWorld Example
(Asynchronous)
<componentType ...>
<service name="client">
Service <[Link]
WSDL PortType interface="[Link]
[Link](HelloWorld)"
callbackInterface="[Link]
[Link](HelloWorldCallback)"/>
</service>
</componentType>
HelloWorld
<composite name="HelloWorld“ ...>
<service name="client">
HelloWorld <[Link]
Service
SoapService1 Component interface="[Link]
[Link](HelloWorld)"
callbackInterface="[Link]
[Link](HelloWorldCallback)" />
<[Link] port="[Link]
[Link](HelloWorld/HelloWorld)"/>
</service>
<component name="HelloWorld">
<[Link] src="[Link]"/>
Binding </component>
Web Service <wire>
<[Link]>client</[Link]>
Implementation <[Link]>HelloWorld/client</[Link]>
- BPEL </wire>
</composite>
OSOA Collaboration | SOA Roadmap
SCA
Oracle Demo: OrderBooking Application [Link]
ApproveOrder OrderFulfillment Order
Component Component
.
.
. [Link] [Link] .
OrderProcessor
Component .
.
EventLogger SelectManufacturer
Component Component [Link]
[Link]
ApprovalRequired
[Link] Component [Link]
OSOA Collaboration | SOA Roadmap
SCA
<composite name="OrderProcessing" ...>
<service name="Client">
<[Link] interface="[Link]
[Link](SOAOrderBooking)"/>
<[Link] port="[Link]
[Link](OrderBooking/OrderBookingPort)"/>
</service>
<component name="OrderFulfillment">
<[Link] src="[Link]"/>
</component>
<component name="ApproveOrder">
<[Link] src="[Link]"/>
</component>
<component name="ApprovalRequired">
<[Link] src="[Link]"/>
</component>
<component name="SelectManufacturer">
<[Link] src="[Link]"/>
</component>
<component name="EventLogger">
<[Link]
className="[Link]"/>
<business-events>
<subscribeAll consistency="guaranteed"/>
</business-events>
</component>
<reference name="Order">
<[Link] interface="[Link]
[Link](Order_ptt)"/>
<[Link] config="OrderService_db.jca"/>
</reference>
...
OSOA Collaboration | SOA Roadmap
</composite>
SCA
BEA/Fabric3 Demo
Open source CodeHaus Foundation project ([Link])
Apache Licensed
Built around a small embeddable kernel that is highly extensible
Less than 1MB
Extension ecosystem, e.g. Spring, OpenJPA
Focused on
Implementation quality
SCA 1.0 support
“Agile” development experience and SDK
Management of distributed SCA domains
Federated deployment to multiple runtime types
WebLogic
Manage and provision Cluster
components
Servlet
SCA Domain Engine •Domains are heterogenous
Controller
•Fabric3 may be embedded in a
OSGi variety of containers
Other
Containers
OSOA Collaboration | SOA Roadmap
SCA
BEA/Fabric3 Demo
Provision and deploy a Calculator Composite
Calculator service wired to Add, Subtract, Multiply and Divide services
Instantiate components
Provision components 4
on runtime nodes
3 to multiple runtime
nodes Service Node
SCA Domain
Process the composite,
2 resolve wires and
allocate to runtime
nodes
1 Deploy the SCA
composite
SCA Composite
OSOA Collaboration | SOA Roadmap
SCA
Thank you!
Questions?
OSOA Collaboration | 30th May 2007 | SOA Roadmap