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 a real, available, open source implementation for of the Service Component Architecture that provides a simple way to implement SOA solutions. This free open source project is called 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. 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 to into the specifications and some will be regarded as extensions available in Apache Tuscany. For example, support for Ruby, JavaScript, XqueryXQuery, web 2Web2.0 and distribution are currently extensions beyond the specification.

This article will walk you through what is available in Apache Tuscany , and therefore it highlights highlight the benefits of SCA, using some familiar scenarios. The sample code and configuration used in this article can be found in the Tuscany SCA Java distribution 3 and is available under the Apache License 4.

Using Tuscany SCA

A Common Approach To Application Construction and Deployment

...

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? compose the services into a 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 that applications work together. This common model also provides the hooks for tooling, governance, monitoring and management in the service oriented world.

...

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.

...

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 components referencecomponent'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 this the information about loosely coupled enterprise component integration 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.

...

In the SCDL examples, implementation.java indicates that the business logic of the AccountServiceComponent is written in Java. 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. Those developers comfortable with writing scripts can now provide server side component implementations in a manage manner that is consistent with other enterprise developers.

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

Here is and example of a component implemented using Javascript.the Javascript code in AddServiceImpl.js.

Code Block
function add(n1, n2) {
   return n1 + n2;
}

The precise relationship between the abstract components and runtime infrastructure is can be further refined using policy statements to apply organizationally agreed constrains on the behavior of the application in its deployed environment. For example, 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 authorized to do so can be expressed. authenticated before doing so.

Code Block
<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>

...

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 components Catalog component's Java implementation is associated with the JSONRPC binding (binding.jsonrpc).

...

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 SCA SCDL description of the service.

...

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

On of the main values of an SOA environment is to support a consistent framework for data exchange between business services. Business data comes from many different sources and is presented in many different formats. Tuscany SCA provides several features to ease data integration.

...

In this case, data are loaded/received from various data sources and manipulated as XML. As business data may be represented in many different ways even if they are for the same infoset Tuscany SCA provides a number of different databindings . For example, we can model a Customer business object as:

...

Application developers should have the freedom to choose their preferred data representation without being driven restricted by the above concerns. Tuscany SCA provides suitable data transformation mediations which are attached automatically the wires between components to take account of the difference different choices that the component developer and application deployer may make.

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

...

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 the XQuery to mediate data from many services and the capability of an XQuery can be extended by invoking other SCA components.

...

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

...

Code Block
 <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 infrastruture infrastructure can be adjusted and the components redeployed without having to change any .composite file information.

...

There is set of guides for the Tuscany Java SCA software available from the Apache Tuscany website. In particular the User Guide provides a simple walkthrough of the Tuscany Java SCA Calculator sample. There is also a paper giving detailed instructions of how to build a the simple Web2.0 application described in this paper using Tuscany Java SCA 8.

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.

Coming back 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 here will vary of course as it is unlikely that you will be starting with a clean sheet.

...

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

Provide deployment specific information

...

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 further 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://cwikiincubator.apache.org/confluence/display/TUSCANY/Getting+Started+with+Tuscany+Release+1.0Image Removed - TODO - Needs linking into the web pagetuscany/sca-java-10-incubating-release-summary.data/getting-started-1.0.pdfImage Added
9 From the Tuscany SCA distribution 3 look for samples/chat-webapp
10 Direct Web Remoting - https://dwr.dev.java.net/

...

A big thank you to the Apache Tuscany Incubator community for working hard to get recent SCA, SDO and DAS releases out.

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.