Introduction
The Spring Framework [1] is a popular platform used to construct Java applications. It aims to reduce the complexity of the programming environment and it shares many of the same design principles as SCA. In particular, Spring provides a runtime container that provides dependency injection so that application components can avoid the need to program directly to middleware APIs. This is also one of the key principles of SCA.
SCA and Spring are natural partners. Spring can be used as a component implementation technology in SCA. The Spring Framework can be used to create service components and wire them within a composite using its dependency injection capabilities. SCA can be used to extend the capabilities of Spring components by publishing Spring beans as SCA component services to be accessed as services by other SCA components or by remote clients as well as by providing Spring beans for service references wired to services of other components. Developers and assemblers can leverage the strengths of both technologies in their applications.
SCA is an implementation-, framework-, and language-independent service composition and programming technology and SCA can add useful capabilities to an application implemented using Spring, for example:
- support for remote components
- support for communication using multiple protocols
- support for assembling applications from components written in a variety of programming languages
- support for an asynchronous programming model
- support for flexible application of policy to components and to communication between components
Integration between SCA and Spring makes Spring a natural way to build SCA components in Java.
Overview of Spring Component Implementation Specification
The SCA Spring Component Implementation Specification [2] specifies how the Spring Framework can be used as a component implementation technology in SCA.
Support for the Spring Framework in SCA is provided at a coarse-grained level. It is possible to use an existing Spring application context as a component implementation in SCA. An SCA runtime that supports Spring integration can use an application context as-is in an SCA assembly. For such a component it is possible to wire Spring services and references without the need to introduce SCA metadata into the Spring configuration. The Spring context needs to know very little about the SCA environment. Two points where the SCA metadata interacts with the Spring context are services and references. Any policy enforcement such as the provision of Security features is done by the SCA runtime on calls into the Spring application context before the final message is delivered to the target Spring bean. On outbound calls from the application context, references supplied by the SCA can provide policy enforcement.
It is also possible to specify SCA-related metadata as beans inside a Spring configuration. The Spring Component Implementation Specification makes it possible to specify:
- Spring beans that are made available to SCA as component services
- Spring beans that represent SCA properties
- Spring beans that represent SCA references
Three elements: sca:service, sca:reference and sca:property, can be used in a Spring application context configuration to identify a SCA service, a SCA reference or a SCA property, respectively.
Implementing BigBank Example Using Spring
In this section we will see how Spring application context can be used to implement a variation of the BigBank application [3], described in a white paper published with the SCA 0.9 specification. The bigbank.account composite assembly diagram is show below.

The bigbank.account composite consists of two components: AccountService and AccountDataService. It also exposes the AccountService service outside the composite and depends on a reference StockQuoteService that is external to the composite. The AccountService component has two dependencies. The first dependency is on the external reference and the second one is wired to the service offered by the AccountDataService component. Both the AccountService component and the AccountDataService component can be implemented using a Spring application context. In this case, AccountDataService component is implemented using an existing Spring bean AccountDataService as shown below.
<beans>
<bean id="AccountDataService" class="bigbank.account.AccountDataService"/>
</beans>
As this shows, there is no SCA metadata in the application context.
AccountService component is implemented using a Spring application context that is SCA-aware as shown below.
<beans>
<bean id="X">
<property name="aPropertyName" ref="Y"/>
</bean>
<bean id="Y">
<property name="SQRef" ref="StockQuoteService"/>
<property name="ADRef" ref="AccountDataService"/>
</bean>
<sca:service name="AccountService" type="bigbank.account.AccountService" target="X"/>
<sca:reference name="StockQuoteService" type="bigbank.account.StockQuoteService"/>
<sca:reference name="AccountDataService" type="bigbank.account.AccountDataService"/>
<beans>
This component is implemented using two Spring beans X and Y. The application context contains explicit declarations for the SCA service AccountService that is exposed and the two SCA references: StockQuoteService and AccountDataService. The reference AccountDataService is a reference that is external to this application context and is wired by SCA to the service exposed by the AccountDataService component described before. The reference StockQuoteService is also external to this application context and satisfied by a StockQuote Web service outside the SCA runtime.
The SCA assembly SCDL file that uses the Spring component implementation technology and corresponds to the diagram and Spring application contexts described above is show below.
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://bigbank.com" name="bigbank.account"> <service name="AccountService" promote="AccountServiceComponent"> <interface.java interface="services.account.AccountService"/> <binding.ws port="... #wsdl.endpoint(AccountService/AccountServiceSOAP)"/> </service> <component name="AccountServiceComponent"> <implementation.spring location="..." /> <reference name="AccountDataService" target="AccountDataServiceComponent"/> <reference name="StockQuoteService" target="StockQuoteService"/> </component> <component name="AccountDataServiceComponent"> <implementation.spring location="..."/> </component> <reference name="StockQuoteService" promote="AccountServiceComponent"> <interface.java interface="services.stockquote.StockQuoteService"/> <binding.ws port="...#wsdl.endpoint(StockQuoteService/StockQuoteServiceSOAP)"/> </reference> </composite>
Summary
SCA and the Spring Framework form a good partnership for building Java components as part of a business solution that is based on a service-oriented architecture. The philosophy of the two models is well aligned and SCA can provide for the wider assembly of components implemented in Java using the Spring Framework.
References
[1] Spring Framework![]()
[2] SCA Spring Component Implementation Specification![]()
[3] SCA Building Your First Application - Simplified BigBank![]()