You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by shaoguang geng <ge...@yahoo.com> on 2007/07/25 10:47:59 UTC

Why SCA10 specify

In SCA java component implementation 1.0, most of the spec was telling the story about <interface.java interface="[interface name]">. But in fact <implementation.java class="[class name]"/> has done every thing.

Dose osoa mean: using <interface.java> the interface MAY NOT BE an interface of the implementation class?

       
---------------------------------
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing. 

Re: Why SCA10 specify

Posted by Mike Edwards <mi...@gmail.com>.
Hi Shaoguang,

shaoguang geng wrote:
> In SCA java component implementation 1.0, most of the spec was telling the story about <interface.java interface="[interface name]">. But in fact <implementation.java class="[class name]"/> has done every thing.
> 
> Dose osoa mean: using <interface.java> the interface MAY NOT BE an interface of the implementation class?
> 

SCA follows the principle of Service Oriented Architecture in separating 
the interface of a service from its implementation.

So, where you have a service component implemented by a Java class, it 
is expected that there will be an interface definition for the service 
offered by the component.  This service interface must be one of the 
interfaces implemented by the Java class.

So, let us say that we have a service which is defined by the Java 
interface:

	com.foo.ServiceA

And that we have an implementation of the service provided by a class

	com.foo.ServiceImpl

The ServiceImpl class is going to look something like this:

package com.foo;

public class ServiceImpl implements ServiceA {

	public String someOperation( String bar ) {
		...
		...
	}

}


Note that the class implements the interface com.foo.ServiceA - if there 
is only one interface implemented by the class, this will be assumed to 
be the service interface provided by the class.  If there are multiple 
interfaces implemented by the class, the SCA @Service annotation can be 
used to indicate which service each interface belongs to.

In a composite file which holds the service component, the declarations 
could look something like this:

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

     ....

     <component name="ServiceAComponent">
         <implementation.java class="com.foo.ServiceImpl" />
	<service name="ServiceName">
		<interface.java interface="com.foo.ServiceA"/>
	</service>
     </component>

     ...

</composite>

So, this says that the component named ServiceAComponent is implemented 
by the class com.foo.ServiceImpl.  That component has a service with the 
name ServiceName which has an interface described by the Java interface 
com.foo.ServiceA.

Strictly speaking, writing out the <service.../> element in full like 
this is not necessary in the composite file - the information can be 
introspected from the Java class - but it is valid to do this.

Note that while the Java interface may be used to define the service in 
the Java class, it is possible to use a different interface language 
like WSDL in the composite file, as long as the WSDL definition and the 
Java definition of the interface match each other.


I hope that this helps explain things.

Yours,  Mike.

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org