Hi Richard
Let me give you a quick summary of how the Tuscany runtime works and then
I've put some comments in line below.
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.
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.
Regards
Simon
On Thu, Jun 19, 2008 at 4:06 PM, Richard Jones <[EMAIL PROTECTED]>
wrote:
> Hi Simon,
>
> Thanks for the pointers, I've taken a trawl through some more code, and
> have a couple more questions if you don't mind ...
>
No problem at all
>
>
> Hi Folks,
>>>
>>> I'm brand new to Tuscany, and I've been working my way through the
>>> documentation on the website. I don't use Eclipse, but much of the
>>> documentation is geared towards using the Eclipse plugin to start the
>>> tuscany application server. I can't find documentation on how to do this
>>> /without/ eclipse, can someone point me in the right direction?
>>>
>>> I'm trying to do the very basic "Hello World" example.
>>>
>>> Is there perhaps a TuscanyServlet that I can set in my own web.xml, and
>>> do
>>> my normal deployment through tomcat?
>>>
>>> Cheers,
>>>
>>> Richard
>>>
>>>
>>>
>>
> Hi Richard. Welcome to Tuscany.
>>
>> There are a few words about how to develop an SCA application from the
>> command line in [1] but it doesn't cover doing webapp development. You
>> could
>> take a look at one of the Tuscany samples that do this. For example, look
>> in
>> samples/calculator-webapp [2]. You will see that the basic layout of this
>> webapp is that an SCA application (the calculator sample) is packaged as a
>> webapp and a jsp is fired up and makes a call to the Calculator component
>> described in the SCA composite file [3]. The web.xml file in this case
>> defines a servlet filter as follows.
>>
>>
>
> OK, I see, it uses an SCADomain created by the TuscanyServletFilter, and
> pulls the appropriate service out of that:
>
> SCADomain scaDomain = (SCADomain)
> application.getAttribute("org.apache.tuscany.sca.SCADomain");
> CalculatorService calculatorService =
> (CalculatorService)scaDomain.getService(CalculatorService.class,
> "CalculatorServiceComponent");
>
> 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.
>
> That last part might be a classpath problem* which I haven't figured out
> yet, but supposing it didn't balk, is this the right approach to launching
> the application?
It depends what you want to do. It's an excellent approach when you want to
learn Tuscany and play around with a few things. You may want to deploy
Tuscany in a webbapp in the future but I wouldn't recommend you start by
doing that. Running from a command line launcher like you have here is much
simpler to start with.
>
> * - 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.
>
> 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".
> ========================================================================
>
>