Versions Compared

Key

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

...

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

Image Modified

In the composite, basic units of business logic are modeled as SCA components, AccountComponent, StockQuoteComponent etc. Once all business logic is implemented, appropriate bindings are applied to references and services so that they can collaborate. The XML SCA configuration language, called Service Component Description Language (SCDL), describes loosely coupled enterprise component integration. It allows the developer to;

...

This very simple mechanism of applying applying bindings 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 component components communicate with services outside of SCA allowing the SCA approach to be introduced incrementally into an organization.

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" 2

Image Removed

From this sample 3 you can see a catalog component providing a service to the Web2.0 application over JSONRPC. The calog 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 the components Java implementation is associated with the JSONRPC binding (binding.jsonrpc).

Tuscany SCA provides implementation.script which currently supports Javascript, Groovy, Ruby and Python. Those developers comfortable with writing browser based scripts can now provide server side component implementations also. The Tuscany Java SCA Calculator Script (samples/calculator-script) shows scripts at work. Here is a component description.

Code Block

<component name="AddServiceComponent
Code Block

<component name="Catalog">
    <implementation<tuscany:implementation.javascript classscript="servicescalculator/AddServiceImpl.CatalogImpljs"/> 
    <service name="Catalog">
        <t:binding.jsonrpc/>
    </service>
</component>

Here is and example of a component implemented using Javascript.

Code Block

function add(n1, n2) {
   return  ...
</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 now access this service directly using either the generated JSONRPC proxy or whatever JSONRPC client the application developer is familiar with, for example, from the store sample uses the following javascript:

Code Block

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

Code Block

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

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

<SIMON: make it simple and say that this is now a first class service without much effort>
The services supporting your Web2.0 style applications are now provided using a single, consistent, SCA based mechanism. Hence Web2.0 services become part of the wider enterprise service orientation solution.

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 4 provides binding.dwr to implement a Direct Web Remoting3 <SIMON: Move to the end as a resource> (https://dwr.dev.java.net/Image Removed) 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.

TODO - the following diagram is the reality but is at odds with the diagram in the PDF which show what we would like it to be

Image Removed

TODO - we said we would move the following but it doesn't feel like there is a better home for it.

<RAYMOND: Move to enerprise section>
Tuscany SCA provides implementation.script which currently supports Javascript, Groovy, Ruby and Python. Those developers comfortable with writing browser based scripts can now provide server side component implementations also. The Tuscany Java SCA Calculator Script (samples/calculator-script) shows scripts at work. Here is a component description.

Code Block

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

Here is and example of a component implemented using Javascript.

Code Block

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

<QUESTION: Where to talk about dependency injection? Raymond>

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" 6. There is a guide which walks through the steps required to build this sample 7.

Image Added

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

Code Block

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

Code Block

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

Code Block

    ...
    <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 8 provides binding.dwr to implement a Direct Web Remoting 9 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.

Image Added<RAYMOND: End of Move>
<QUESTION: Where to talk about dependency injection? Raymond>

Data integration - Raymond

...

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.0Image Removed1.5 Tuscany SCA Java download
1.6 2.0 , http://www.apache.org/licenses/LICENSE-2.0
2
5 From the Tuscany SCA distribution 3 look for demos/bigbank-account
6 From the Tuscany SCA distribution 3 look for samples/store
7 Getting Started With SCA - Store - http://cwiki.apache.org/confluence/display/TUSCANY/Getting+Started+with+Tuscany+Release+1.0 - TODO - Needs linking into the web page
3 sample/store
4 samplel/chat-webapp 8 From the Tuscany SCA distribution 3 look for samples/chat-webapp
9 Direct Web Remoting - https://dwr.dev.java.net/Image Added

5 sample/helloworld-ws-service-secure
6 demo/bigbank-account

...