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

Compare with Current View Page History

« Previous Version 5 Next »

Unable to render {include} The included page could not be found.
Unable to render {include} The included page could not be found.

<implementation.spring>

The Tuscany Java SCA runtime supports components implemented with Spring Framework by using the <implementation.spring> SCDL extension.

Spring Framework are used with SCA by integration Spring at the SCA Composite level, where a Spring application context provides a complete composite, exposing services and using references via SCA. This means that a Spring application context defines the internal structure of a composite implementation.

The Spring Component implementation is one of the SCA extensions which is being formalized in the OASIS Open Composite Services Architecture with a published specifications document.

How to Use Spring Component Implementation

The Spring component implementation SCDL has the following format:

   <implementation.spring location="targetURI" />

Where the location attribute of that element specifies the target uri of an archive file or directory or the fully qualified path that contains the Spring application context files.

An example of all the three ways of specifying the target uri in the location attribute is shown below

a) Specifying Fully Qualified Path:

   <implementation.spring location="./spring/application-context.xml" />

b) Specifying a Directory:

   <implementation.spring location="./spring" />

Here the target uri specifies the resource as a directory named "spring", where all the spring related files are available.

c) Specifying an Archive file:

   <implementation.spring location="./spring.jar" />

Here the target uri specifies the resource as an archive file name "spring.jar", where all the spring related files are available.

IMPORTANT NOTE: In case of b) and c), If the resource identified by the location attribute is an archive file then the file META-INF/MANIFEST.MF is read from the archive. If the location URI identifies a directory, then META-INF/MANIFEST.MF must exist underneath that directory.

If the manifest file contains a header "Spring-Context" of the format: Spring-Context ::= path ( ';' path )*

Where path is a relative path with respect to the location URI, then the set of paths specified in the header identify the context configuration files. If there is no MANIFEST.MF file or no Spring-Context header within that file, then the default behaviour is to build an application context using application-context.xml file in the METAINF/spring directory.

How Spring Application Context is used as SCA Composite Implementation?

*A Spring Application Context is used as an implementation within an SCA composite component.
*A component that uses Spring for an implementation can wire SCA services and references without introducing SCA metadata into the Spring configuration. The Spring context knows very little about the SCA environment.
*All policy enforcement occurs in the SCA runtime implementation and does not enter into theSpring space.
*It should be possible to generate an SCA Composite from any Spring context and use that composite within an SCA assembly.

Some Examples

This example shows a simple composite with a component that uses <implemantation.java>:

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
    targetNamespace="http://sample"
    xmlns:sample="http://sample"
    name="SampleComposite">

    <component name="SampleComponent">
       <implementation.java class="sample.SampleImpl"/>
    </component>
    
</composite>

Spring SCA Namespace schema

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.springframework.org/schema/sca"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
	elementFormDefault="qualified" targetNamespace="http://www.springframework.org/schema/sca">
	<xsd:element name="composite">
		<xsd:complexType>
			<xsd:attribute name="component" use="required">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string" />
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name="sca-adapter-class" use="optional">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string" />
				</xsd:simpleType>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="reference">
		<xsd:complexType>
			<xsd:attribute name="name" use="required">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string" />
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name="type" use="required">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string" />
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name="default" use="optional">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string" />
				</xsd:simpleType>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="property">
		<xsd:complexType>
			<xsd:attribute name="id" use="optional">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string" />
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name="name" use="required">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string" />
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name="type" use="required">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string" />
				</xsd:simpleType>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name="service">
		<xsd:complexType>
			<xsd:attribute name="name" use="required">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string" />
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name="type" use="required">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string" />
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name="target" use="required">
				<xsd:simpleType>
					<xsd:restriction base="xsd:string" />
				</xsd:simpleType>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
</xsd:schema>

References

1 SCA Spring Component Implementation Specification - http://www.oasis-opencsa.org/sca-spring
1 Spring Framework - http://static.springframework.org/spring/docs/2.0.x/reference/index.html

  • No labels