You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 87 Next »

Introduction

Many articles have been written about SOA and Service Component Architecture already12. This article focuses on an 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.

This article will walk you through what is available in Apache Tuscany and therefore highlight the benefits of SCA.

Using Tuscany SCA

A Common Approach To Application Construction and Deployment

Enterprise software development is increasingly influenced by technology choices, regulations, competition and expectations for responsiveness to change. Enterprises need the flexibility to adopt new business practices (like outsourcing of mortgage handling by a bank), enforce new regulations and extend or down-size without much cost (mergers and acquisitions). In addition, as the complexity of the enterprise grows, a common management paradigm becomes a necessity for managing business applications. Service Component Architecture provides a simple programming model to address these challenges. SCA's simple language maps easily to the business. Let's consider we are building a banking application that handles account inquiries. The following table maps business level questions to SCA.

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 flexibility in business processes?

ability to configure different currencies

Properties

How to handle regulations or quality of service?

ability to handle account security

Intent/policy

What is the end to end solution?

separate banking functions working together

Composite/Wire

SCA provides a consistent model of distributed applications and of the components from which they are constructed. This model explicitly separates business logic (Component/Services/References) from the details of how a running application is assembled (Composite/Wire) and deployed. This promotes a common terminology and supports a common understanding of the capability of applications and the way those applications work together. This common model also provides the hooks for tooling, governance, monitoring and management in the service oriented world.

When it comes to building a solution for real the next most important question is likely to be "how can existing IT infrastructure and skills be used?". Tuscany SCA does not invent new technologies for component implementations (Implementation) and message exchange (Binding). It neither requires you to learn a new programming language or communications protocol. You are free to leverage your existing investment in applications, technology and skills with the one proviso that suitable support exists in Tuscany SCA. This is not much of a hurdle though as Tuscany SCA has a straightforward extensibility model so new or proprietary technologies can easily be included.

The following sections describe Tuscany SCA in the context of three familiar scenarios. It should be noted that Tuscany SCA is not restricted to these scenarios. The sample code and configuration used here can be found in the Tuscany SCA Java distribution 3 and is available under the Apache License 4.

Enterprise Applications

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

  • 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 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 business logic is implemented using Java and various scripting languages. Components are assembled by wiring references to services. This 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 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.

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

    <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 also provides a mechanism to separate organizational infrastructure concerns from business logic through policy statements which enable agreed to constraints to be applied at deployment time. This could range from dictating which communications should be encrypted to describing what level of monitoring and logging is required. For example, the helloworld-ws-service-secure sample 6 shows how to express the intention that clients accessing a service must be authenticated before doing so.

<component name="HelloWorldServiceComponent">
    <implementation.java class="helloworld.HelloWorldImpl" />
    <service name="HelloWorldService" requires="authentication">
        <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
        <binding.ws uri="http://localhost:8085/HelloWorldService"/>
    </service>
 </component>

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 flexibility of 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. 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 below, implementation.script indicates that the business logic of the AccountServiceComponent is written in Javascript.

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

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.

Tuscany demonstrates how a Web2.0 application, and the services it relies on, can be constructed using an internet shopping example called "Store" 7. There is a guide which walks through the steps required to build this sample 8.

From this sample you can see a Catalog component providing a service to the Web2.0 application over JSONRPC. The Catalog component provides information about the products the store has for sale and has been constructed without regard for how it might be accessed. Using Tuscany SCA the Catalog component's Java implementation is associated with the JSONRPC binding (binding.jsonrpc).

<component name="Catalog">
    <implementation.java class="services.CatalogImpl"/> 
    <service name="Catalog">
        <t:binding.jsonrpc/>
    </service>
     ...
</component> 

Based solely on this information Tuscany SCA makes three things available automatically;

  • The Catalog JSONRPC service
  • The JSONRPC service description (SMD)
  • A generated Javascript JSONRPC proxy for accessing this service

A browser based application can access this service directly using either the generated JSONRPC proxy or whatever JSONRPC client the application developer is familiar with, for example, the store sample uses the following javascript:

catalog = (new JSONRpcClient("../Catalog")).Catalog;
catalog.get(catalog_getResponse);

function catalog_getResponse(items) {
    var catalog = "";
    for (var i=0; i<items.length; i++)
        catalog += '<input name="items" type="checkbox" value="' + 
			 items[i] + '">' + items[i]+ ' <br>';
        document.getElementById('catalog').innerHTML=catalog;
    }

Clearly this pattern can be extended to any service your Web2.0 style application is required to communicate with. The full range of SCA features is then available to these services. For example, our Catalog service could easily be exposed as a web service (binding.ws) by extending the SCDL description of the service.

    ...
    <service name="Catalog">
        <t:binding.jsonrpc/>
        <binding.ws/>
    </service>
    ...

Note that no changes to the Catalog component code are required. The Tuscany SCA runtime is doing all the hard work.

SCA has provided services to the Web2.0 application with very little effort on behalf of the developer. What effort is expended is not particular to supporting Web2.0 applications as the services
are now part of the wider enterprise service orientation approach.

Tuscany SCA supports other modes of operation that will be of interest to Web2.0 application developers. For example, the Tuscany Java SCA Chat sample 9 uses binding.dwr to implement a Direct Web Remoting 10 connection between a Javascript browser based application and an SCA service. Using this binding, service to browser communication is supported alongside browser to service communication.

Data integration

In a typical enterprise, business data comes from many different sources and is presented in many different formats. Tuscany SCA provides a databinding framework which seamlessly handles data format mapping and therefore freeing the developers from such concerns.

Let's look at a simple scenario that deals with aggregation of XML data from different sources. This demo will be available in a future release of Tuscany. The business function here calculates the total value of all the accounts (checking, saving and stock) that a customer owns.

In this scenario, data is received from various data sources and manipulated as XML. The following data exchanges are occuring.
1) Use an RSS feed to retrieve the currency exchange rates from the web
2) Load the account data for a customer from an XML file or database.
3) Invoke a live web service to get the quotes for a list of symbols.
4) Calculate of the total value by joining the XML data from 2 and 3.

Handling of different data formats in the enterprise can be complex. For example,business data may be represented in many different ways, even if they are for the same infoset. A Customer business object can be defined as JavaBean, SDO, JAXB, XMLBeans or DOM. At the same time, protocol implementation stacks require different data representations. For example, in the Web Service domain, Axis1 uses DOM, Axis2 uses AXIOM ad JAX-WS uses JAXB. Implementation technologies may also impose requirements on the data as well; for example Apache ODE BPEL engine consumes/produces data using DOM, SAXON XQuery engine consumes/produces data using NodeInfo and script Implementation uses AXIOM.

Application developers should have the freedom to choose their preferred data representation without being restricted by the above concerns and worrying about the mappings. Tuscany SCA automatically handles this for them. LIST WHAT IS SUPPORTED

WHY IS IT IMPORTANT TO SHOW THESE BINDINGS AGAIN. READER KNOWS HOW TO DO THIS ALREADY

In the sample here the exchange rate is retrieved (step 1) using the feed binding (binding.rss) as follows.

    <component name="ExchangeRate">
        <implementation.java class="bigbank.ExchangeRateImpl" />
        <reference name="exchangeRate">
            <tuscany:binding.rss
                uri="http://ansuz.sooke.bc.ca/rippy/exchange/?M=R&amp;B=USD&amp;F=CAD,CNY,EUR&amp;T=F&amp;S=O&amp;I=S" />
        </reference>
    </component>

Step 3 uses the web service binding (binding.ws) to retrieve stock from the internet.

    <reference name="StockQuoteReference" promote="AccountService/stockQuote">
        <binding.ws wsdlElement="http://swanandmokashi.com#wsdl.port(StockQuotes/StockQuotesSoap)" />
    </reference>

The various XML data are joined together using XQuery (implementation.xquery) in step4. XML is most popular data representation in the SOA world. XQuery is becoming the most applicable language for extracting and transforming XML data. Its SQL-like syntax is relatively easy to learn. The XQuery implementation type brings the power of XQuery and SCA together. With the help of the databinding framework, we can use XQuery to mediate data from many services and the capability of an XQuery can be extended by invoking other SCA components. WHY IS IT RELEVANT TO TALK ABOUT XQUERY VALUE?! THIS IS AN SCA PAPER. WHAT ARE WE TRYING TO SAY HERE? ARE WE TALKING ABOU USING IT FOR MEDIATION? THIS WOULD BE SEPARATE FROM DATABINDING FRAMEWORK DISCUSSION ABOVE

    <component name="StockValue">
        <tuscany:implementation.xquery location="stock.xq" />
    </component>

Deploying Tuscany Solutions

The service oriented approach to building applications promotes the benefits of deploying running solutions as a collection of loosely coupled services. Tuscany Java SCA provides a runtime that will host these loosely couple services in a single JVM or across multiple JVMs.

Tuscany Java SCA uses the term Node to describe a single Tuscany SCA runtime and the term Domain to describe a collection of nodes that together run related but distributed services in an SCA application.

SCA allows the location of target services to be described explicitly, for example, from the bigbank-account demo 5

 <component name="AccountServiceComponent">
     <implementation.java class="bigbank.account.AccountServiceImpl"/>
     <reference name="stockQuoteService">
         <binding.ws uri="http://localhost:8081/services/StockQuoteWebService"/>
     </reference>
 ...

This is very useful for contacting external services or, in the case of services, for exposing SCA service to external applications. This approach would require ..... CAN WE REWORD THE FOLLOWING AS A CONTINUATION OF THIS SENTENCE INSTEAD? is used for all references and services within an SCA Domain then reference and service bindings are likely to require changing as services are moved between nodes in a domain.

As a convenient alternative any service within the SCA Domain can be identified simply by name.

 <component name="AccountServiceComponent">
     <implementation.java class="bigbank.account.AccountServiceImpl"/>
     <reference name="stockQuoteService" target="StockQuoteServiceComponent/StockQuoteService">
         <binding.ws/>
     </reference>
 ...

Tuscany SCA will automatically use a default binding to communicate with the target service regardless of whether the service is local or remote to the calling component. In this way the infrastructure can be adjusted and the components redeployed without having to change .composite file information. FIRST TIME WE USE .composite in the paper. Can this be changed to... without changing the SCLD?

Choosing how to run the Tuscany SCA runtime depends on your local environment but there are several options currently supported.

NEED A STRONGER STATEMENT HERE. Can we say Tuscany SCA runtime can be emebedded or run with any available application servers or web servers. The following are available with release 1.0 of Tuscany: Tomcat, Geronimo, Websphere, ...

  • Embed into Java application
  • As a WAR file contributed to a suitable web application server
  • As a plugin to the Geronimo application server (available as an plugin to Geronimo)

Getting Started With Your Own Project

The easiest way to get started with Tuscany SCA is to download the latest release 3 and try some of the samples.

Java SCA web pageTODO provides user documentation and extension guide. The User Document provides a simple walkthrough of the Tuscany Java SCA Calculator sample. There is also a paper giving detailed instructions of how to build the simple Web2.0 application described in this paper8.

There are many more samples provided in the "samples" directory of the release. The file samples/README gives an overview of each of them and each sample comes with its own README and a graphical representation (.png file) of the services that the sample is demonstrating.

Once you have a feel for how Tuscany operates you will likely want to build a project of your own. You can of course take a suitable sample and use that as a starting point.

Returning to the business questions we discussed earlier in the paper your application development process will involve some of the following steps. The order of the steps can vary since Tuscany SCA allows a top-down or bottom-up development approach. DOES THIS SOUND OK?

Model the application in a ".composite" file.

  • Identify what business functions are required and describe them using SCA Components and Services
  • Identify what dependencies each component has and provide each component with suitable SCA References.
  • Introduce SCA Properties for any values that will have to change as the application is reconfigured or redeployed.
  • Compose the services within an SCA composite structure and connect references to services using Wires

Provide business logic

  • Implement each component and reference the implementation from the component in the .composite file. The implementation may simply wrap existing application logic or maybe completely new.

Provide deployment specific information

  • Describe any specific protocols that need to be used using bindings. References and Services without bindings will adopt a default communication strategy
  • Attach organizational policy intents to the model, for example, security intents such as authorization or confidentiality

The application model and its component implementation dependencies can now be contributed to the Tuscany SCA runtime. CONTRIBUTION IS NEW TO THIS PAPER. HOW ELSE CAN THIS BE SAID

I am wondering if we really need to have this kind of detail here. User doc covers these steps, why repeat it?

Summary

In this paper, we selected a few scenarios to demonstrate some of the powerful aspects of SCA programming model and how it applies to the real world. Apache Tuscany currently implements version 1.0 of the specification and extends the SCA programming model with its support for many different protocols (bindings), different component implementation types and runtime environments. It can be embedded as a solution or run standalone. Apache Tuscany's modular and extensible architecture makes it possible to easily incorporate new ideas. Many businesses are using Apache Tuscany and their feedback is helping to solidify Apache Tuscany as a simple SOA infrastructure as well as making it a nursery for new ideas. You are welcome to come and try the software and contribute to the project.

References

1 Real SOA - Web Services and Service Oriented Architecture, http://www.java.sys-con.com/read/299972.htm
2 What Is SCA, http://www.java.sys-con.com/read/325183.htm
3 Tuscany SCA Java downloads, http://incubator.apache.org/tuscany/sca-java-releases.html
4 Apache License Version 2.0 , http://www.apache.org/licenses/LICENSE-2.0
5 From the Tuscany SCA distribution 3 look for demos/bigbank-account
6 From the Tuscany SCA distribution 3 look for sample/helloworld-ws-service-secure
7 From the Tuscany SCA distribution 3 look for samples/store
8 Getting Started With SCA - Store - http://incubator.apache.org/tuscany/sca-java-10-incubating-release-summary.data/getting-started-1.0.pdf
9 From the Tuscany SCA distribution 3 look for samples/chat-webapp
10 Direct Web Remoting - https://dwr.dev.java.net/
11 From the SCA distribution3 look for Documentations

Acknowledgements

A big thank you to the Apache Tuscany Incubator community.

Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. Other company, product, or service names may be trademarks or service marks of others.

  • No labels