Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Many articles have been written about SOA and Service Component Architecture already12. This article focuses on an a freely available, open source implementation of the Service Component Architecture that provides a simple way to implement SOA solutions. This freely available SCA implementation is being developed in the Apache Tuscany Incubator open source project. The project started in 2006 and is being used by many who are looking for a simple SOA infrastructure. The recent Apache Tuscany SCA version 1.0, which was released in September 2007, supports the Service Component Architecture specification 1.0. In addition to implementing the SCA specification, Tuscany is also a nursery for new ideas. Some of these ideas will find their way into the specifications and some will be regarded as extensions available in Apache Tuscany. For example, support for Ruby, JavaScript, XQuery, Web2.0 and distribution are currently extensions beyond the specification.

...

Business question

Banking example

SCA concept

What business functions are provided?

define services or use existing services: stock quote, account balance, etc.

Components/Services

What dependencies are there between business functions?

account balance depends on stock quote service

References

How to handle is flexibility in business processes handled?

ability to configure different currencies

Properties

How to handle are regulations or quality of service issues handled?

ability to handle account security

Intent/policy

What is the end to end solution?

separate independent banking functions working together

Composite/Wire

...

In a typical enterprise, business functions are implemented using various technologies, business data is represented in different formats and business applications communicate using heterogeneous protocols. It is almost impossible to converge all applications onto one technology stack such as web services and so it remains difficult and costly to integrate different applications in an enterprise. Some of the challenges that enterprises are faced with are listed belowEnterprises face many challenges including the following.

  • Business applications are tightly-coupled with the IT infrastructure and early design decisions have to be made before real deployment.
  • Application developers are forced to learn and understand many technologies beyond the business domain knowledge
  • Business logic is polluted and coupled by various technology-specific API calls imposed by the IT infrastructure. It's not easy to write and not easy to change.

SCA separates business services from the concerns related to specific hardware, software and network protocols by providing a unified programming model which allows the SCA runtime to handle these issues seamlessly. Let's look at a simple business scenario to see how Tuscany SCA can help enterprise application integration. The scenario here is the BigBank demo from the Tuscany distribution 5. As illustrated below, the application comprises a number of assembled components and ultimately returns a total account balance in response to account inquires. For demonstration purposes, the scenario uses a selection of implementation and binding options.

...

The use of the SCA programming model allows the BigBank developer to decouple the process of designing and creating the scenario from infrastructure concerns. In the BigBank composite, basic units of business logic are modelled as SCA components called AccountComponent, StockQuoteComponent etc. and their Their business logic is implemented using Java and various scripting languages. Components are assembled by wiring references to services. This . Once all business logic is implemented, appropriate bindings are applied to references and services to indicate how the components should communicate. The relationship between component references and services resolves to runtime proxies when the application is deployed. Where appropriate Tuscany SCA uses dependency injection to introduce proxies into each component's references. Once all business logic is implemented, appropriate bindings are applied to references and services to indicate how the components should communicate.

The XML based SCA configuration The XML based SCA configuration language, called Service Component Description Language (SCDL), describes all of the information about loosely coupled enterprise services and the bindings to be used. Since binding information can be changed in the SCDL without changing the business logic, the implementation code is not polluted with protocol handling information and furthermore bindings can be changed during deployment without impacting the application.

The following SCDL shows the AccountService exposed using JSONRPC (binding.jsonrpc) and WebServices (binding.ws). The service can easily be made accessible over RMI by simply adding binding.rmi.

Code Block
    <component name="AccountServiceComponent">
        <implementation.java class="bigbank.account.AccountServiceImpl" />

        <service name="AccountService">
            <tuscany:binding.jsonrpc uri="/AccountJSONService" />
            <binding.ws wsdlElement="http://bigbank#wsdl.port(AccountService/AccountServiceSoap)" />
            <binding.sca />
        </service>

        ...
    </component>

The following SCDL shows bindings applied to component references. Again these bindings can be changed or augmented without changing the business logic.

Code Block
    <component name="AccountServiceComponent">
        ...  
        <reference name="calculatorService">
            <tuscany:binding.rmi host="localhost" port="8099" serviceName="CalculatorRMIService" />
        </reference>
        
        <reference name="stockQuoteService">
            <binding.ws uri="http://localhost:8081/services/StockQuoteWebService" />
        </reference>
        ...
    </component>

This very simple mechanism of applying bindings to the services and references defined by a component is at the root of SCA's ability to separate business logic from deployment concerns. It works regardless of whether the component implementation is brand new or wraps some existing business logic. It is also the mechanism by which SCA components communicate with services outside of SCA. Bindings can be defined such that existing applications can access SCA services or can be referenced by SCA services. This flexibility allows the SCA approach to be introduced incrementally into an organization.

SCA further simplifies the business coding logic development with dependency injection by providing an Inversion of Control (IoC) container. As you can see from the java Java code snippet below, the component just has to declare simply declares references and properties using java annotations. The account service talks to account data service, stock quote service and calculator service by making direct calls on the interfaces. The code here deals with business logic only and no more traditional technology API calls are required. Tuscany handles how the services are located, who provides the services and how are services are communicatedmessages are delivered based on information in the SCDL.

Code Block
@Service(AccountService.class)
public class AccountServiceImpl implements AccountService {

    @Reference
    protected AccountDataService accountDataService;
    
    @Reference
    protected StockQuoteService stockQuoteService;
    
    @Reference
    protected CalculatorService calculatorService;
    
    @Property
    protected String currency;

    public double getAccountReport(String customerID) {

        // Get the checking, savings and stock accounts from the AccountDataservice component
        CheckingAccount checking = accountDataService.getCheckingAccount(customerID);
        SavingsAccount savings = accountDataService.getSavingsAccount(customerID);
        StockAccount stock = accountDataService.getStockAccount(customerID);
        
        // Get the stock price in USD
        double price = stockQuoteService.getQuote(stock.getSymbol());

        // Convert to the configured currency
        if (currency.equals("EURO")) {
            
            // Use our fancy calculator service to convert to the target currency
            price = calculatorService.multiply(price, 0.70);
            
            System.out.println("Converted to " + currency + ": " + price);
        }
        ...
    }
}

...

Note that the <service> element carries a policy intent that interactions require "authentication". How authentication is actually implemented is then a matter of policy within the organization.

We have demonstrated how the flexibility of the SCA programming model helps address enterprise challenges. Another area to point out is the ability to use any implementation language and therefore leverage existing skills and investments. Tuscany SCA provides support for a selection of languages for building business logic, for example, XQuery, BPEL, script, Spring and OSGi. The BigBank demo implements the various operations of the calculator using scripting languages. Tuscany SCA's implementation.script currently supports Javascript, Groovy, Ruby and Python. In the SCDL examples example below, implementation.script indicates that the business logic of the AccountServiceComponent is written in Javascript.

Code Block
<component name="AddServiceComponent">
    <tuscany:implementation.script script="calculator/AddServiceImpl.js"/>
</component>

In addtion to what's demonstrated in the sample, Tuscany also provides implementation types for other popular frameworks such as Spring and OSGi. The combination The combination of implementation types available, in particular Spring and OSGi, offers powerful capabilities for building service implementations from sets of simple Java Beans using very few APIs, with managed dependencies, version
control and dynamic update capabilities, and composing those implementations . Such implementations can easily be composed with other service components written in Java or in other languages and existing all components are deployed consistently in a distributed network of systems using a Tuscany SCA runtimes with the full range of communication methods made available to them.

Enabling Web 2.0

A typical Web2.0 application will reference several services in the organization and integrate the provided data in the browser. Tuscany SCA enables such services using popular technologies such as JSONRPC, RSS and Atom protocols.

...