Hi Simon,
The Tuscany runtime runs SCA composite applications described in .composite
files. Components within these composite files can define references and
service and each can have bindings associated with them. When you specify a
service binding, for example, binding.ws the runtime will do it's best to
provide the endpoint that that binding describes and it may do slightly
different things depending on how the runtime is being hosted, for example,
If you are running from the command line and have a simple launcher than
creates an SCADomain then to create HTTP endpoints for the web service
bindings Tuscany will fire up an instance of Tomcat or Jetty depending on
whether you have host-tomcat or host-jetty on the classpath.
OK, I see! Very smart.
If you are packaging Tuscany in a webapp and want to use the web service
binding then we would expect you to have host-webapp on the classpath. This
allows the runtime to use the servlet container where the webapp is running
to provide the HTTP endpoints for bindings like binding.ws.
The bottom line being that the composite file should fully describe the
composite application and the runtime will honour what is in there.
<snip/>
So the bit I'm stuck on here is how to create the SCADomain for the
HelloWorld example automatically:
http://tuscany.apache.org/build-your-first-web-services-with-tuscany.html
It looks as though the Eclipse plugin can take the HelloWorld.composite and
turns it into a web application without having to add this extra layer of a
ServletFilter and a JSP. The differences that I can see are that the
Calculator.composite doesn't define a service, and instead the
TuscanyServletFilter is reading in that file and then making itself the
effective web-service interface. Meanwhile, the HelloWorld example has a
different kind of definition:
<component name="HelloWorldComponent">
<implementation.java class="hw.HelloWorldImpl"/>
<service name="HelloWorld">
<binding.ws uri="http://localhost:8080/HelloWorld"/>
</service>
</component>
The Eclipse plugin looks like it understands how to take this service
binding and turn it into an actual service. I think what I need to know is
how to deploy this particular type of composite definition (although I'm
also possibly off base here).
There is a bit of slight of hand happening with the Eclipse plugin. The
tutorial says...
"First select the "helloworld.composite" file, in your "ws" project. *Right
click* to get the
context menu, select *Run As*, and then *Tuscany*. The Tuscany runtime will
start up adding"
What this is doing behind the scenes is passing "helloworld.composite" to a
command line like launcher which fires up the Tuscany runtime to read the
composite file and create the endpoints for the specified bindings. As the
binding here is binding.ws here Tuscany will fire or Tomcat or Jetty to make
it work.
I tried writing a Launch class as per:
http://tuscany.apache.org/getting-started-with-tuscany.html
which basically did:
public static void main(String[] args)
throws Exception
{
SCADomain scaDomain = SCADomain.newInstance("HelloWorld.composite");
System.in.read();
scaDomain.close();
}
But this is throwing exceptions:
Exception in thread "main" org.osoa.sca.ServiceRuntimeException:
org.osoa.sca.ServiceRuntimeException: java.lang.IllegalArgumentException:
Composite not found: HelloWorld.composite
This should work but this error suggests that the composite file is not on
your classpath.
OK, so I've verified that the composite is on the classpath, but I'm
still getting the same error. I wedged in a check to show me where the
file actually is:
public class Launch
{
public static void main(String[] args)
throws Exception
{
URL url = (new
Launch()).getClass().getResource("HelloWorld.composite");
System.out.println(url.toString());
SCADomain scaDomain = SCADomain.newInstance("HelloWorld.composite");
}
}
outputs:
file:/home/richard/workspace/tuscany-helloworld/out/production/tuscany-helloworld/hw/HelloWorld.composite
Exception in thread "main" org.osoa.sca.ServiceRuntimeException:
org.osoa.sca.ServiceRuntimeException:
java.lang.IllegalArgumentException: Composite not found:
HelloWorld.composite
Am I still missing something? I'm stumped :)
* - what mechanism does SCADomain.newInstance use to locate the resource?
is it just a Class.getResource or somesuch?
Yes, Tuscany looks for the named file on the classpath and then uses the
directory in which it finds that file as what SCA calls the contribution.
The contribution should collect together all of the artifacts that are
required to run the composite application, e.g. the composite file itself
and the files that provide component implementations etc.
OK, so I'm pretty certain that I've done this right, in that I have in
the directory:
file:/home/richard/workspace/tuscany-helloworld/out/production/tuscany-helloworld/hw/
The files:
HelloWorld
HelloWorldImpl
HelloWorld.composite
Launch
Cheers,
Richard
--
=======================================================================
Richard Jones | Hewlett-Packard Limited
Research Engineer, HP Labs | registered office:
Bristol, UK | Cain Road, Bracknell,
| Berks, RG12 1HN.
| Registered No: 690597 England
eml: [EMAIL PROTECTED] -------------------------------------
blg: http://chronicles-of-richard.blogspot.com/
-----------------------------------------------------------------------
The contents of this message and any attachments to it are confidential
and may be legally privileged. If you have received this message in
error, you should delete it from your system immediately and advise the
sender. To any recipient of this message within HP, unless otherwise
stated you should consider this message and attachments as "HP
CONFIDENTIAL".
========================================================================