[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.stp] Re: Reusing SCA Service Implementations

Hi Michael,


Michael Gebhart wrote:
Hi,

when using the SCA editor to create my service architecture, I can
easily implement services. I can write a java class and set it as the
implementation of a component.

My question is: Can I only use this implementation within a SCA runtime?

No. Your implementation doesn't depend on an particular SCA runtime. There is only a dependance with the SCA annotations (for instance @Remotable is necessary if you want to use a WS binding)


We have a typical application server running and don't wanna provide a
SCA runtime. But we'd like to use SCA for modeling the architecture.

Yep, I think that the SCA Designer is a great tool for modeling the architecture. ;)
But, what a pity that you don't use an SCA runtime... ;)



Or do we have to manually adapt the implementation that it works within a typical WS-compliant java application server?

I don't believe it. The service that you wrote for your SCA assembly contains only business logic.



Is the SCA way an alternative for the usual web service programming? Is it still necessary to write the web services as we have done it before? (Using JAX-WS etc.)

No. You only need to define a web service binding in your SCA assembly file. The SCA runtime will generate the wsdl file for the service.


Below a sample:

The interface:
package helloworld;
import org.osoa.sca.annotations.Remotable;
@Remotable
public interface HelloWorld {
    String sayHello(String name);
}

The implementation:
package helloworld;
public class HelloWorldImpl implements HelloWorld {
	public String sayHello(String name) {
		return "Hello " + name;
	}
}

Teh SCA assembly file:
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"; xmlns:c="http://helloworld"; xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"; name="helloworld" targetNamespace="http://helloworld";>
<component name="HelloWorldComponent">
<implementation.java class="helloworld.HelloWorldImpl"/>
<service name="HelloWorld">
<binding.ws uri="http://localhost:8080/HelloWorld"/>
</service>
</component>
</composite>


A class to run the SCA assembly with Tuscany:
package helloworld;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.tuscany.sca.host.embedded.SCADomain;
public class Client {
	public static void main(String[] args) throws Exception {
		SCADomain scaDomain = SCADomain.newInstance("helloworld.composite");
		HelloWorld hw = scaDomain.getService(HelloWorld.class, "helloworld");

		BufferedReader bufferedReader = new BufferedReader(
				new InputStreamReader(System.in));
		bufferedReader.readLine();
		scaDomain.close();
	}
}

Launch this class. You should have your web service live, and http://localhost:8080/HelloWorld?wsdl should give you back a generated wsdl for the service.

Stéphane Drapeau
Obeo


PS : Thanks Antoine