xmlcomponentssoaimplementationsca

What's the use of the component type file in SCA?


I am reading about Service Component Architecture (SCA). One thing that I did not understand its use, is the definition of a component type in a file with the extension .componenttype.

This source says:

"Component type represents the configurable aspects of an implementation. A component type consists of services that are offered, references to other services that can be wired and properties that can be set. The settable properties and the settable references to services are configured by a component that uses the implementation."

And here's an example for that file:

<?xml version="1.0" encoding="ASCII"?>
<!-- Component type schema snippet -->
<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
               constrainingType="xs:QName"? >

   <service … />*
   <reference … />*
   <property … />*
   <implementation … />?

</componentType>

My confusion is because we do define the component services, references, properties, and implementation in the composite file (the file with .composite extension). So why do we define it in both files (the component type file and the composite file) ? Aren't we repeating things here? What's really so special about the component type in SCA? Thanks.


Solution

  • The componentType and component configuration are actually two different things. The ComponentType describes a component implementation. It's analogous to type information that can be gathered from reflection on a Java class (hence the "type" in the name). Think "type" vs. "instance". This is an important distinction since a component implementation may be used more than once with different configuration.

    In practice, applications generally do not need to provide a componentType file as the information can be gathered (in most cases) via some type of reflection. For example, with Java implementations, the componentType file is never provided (it's actually not supported in the latest version of the Java spec).

    The only case where a componentType may be necessary is for languages where type information cannot be determined programmatically.