We have discussed this behaviour before and I was sort of convinced last
time but now I'm playing with the store sample I'm not so sure. This
features comes about because of the store composite, for example,

    <component name="Store">
        <t:implementation.widget location="uiservices/store.html"/>
        <service name="Widget">
            <t:binding.http uri="http://localhost:8101/ui"/>
        </service>
        <reference name="catalog" target="Catalog">
             <t:binding.jsonrpc/>
         </reference>
         <reference name="shoppingCart" target="ShoppingCart/Cart">
             <t:binding.atom/>
         </reference>
         <reference name="shoppingTotal" target="ShoppingCart/Total">
             <t:binding.jsonrpc/>
         </reference>
    </component>

To keep the composite tidy many of the URIs are omitted and they rely on the
default value. However the URI for one of the bindings is provided so that
the node will detect this and use this as the default for all service
bindings (where this kind of URI is applicable). All the bindings must be
the same here as store.html relies on the services being accessible from the
same root.

There are several places that the default port for the servlet host comes
from when setting up the SCA runtime.

1. The web app container. In this case no matter how you configure SCA you
will get whatever the web app container gives you
2. Node URI. This is used to tell what endpoints SCA should use by default
and also as a unique ID for the node. When running inside a web app this
must be the host/port you expect the web app to expose your services on.
Otherwise SCA can't tell what values the web app container is going to use
and hence can't register services with the domain. In the case that SCA
starts Tomcat/Jetty itself then the Node URI is just the default value that
will be used if a URI is not provided explicitly on a binding.
3. Binding uri attribute. If SCA is running inside a web app container this
value is ignored and Node URI is used (see 2). If SCA has started
Tomcat/Jetty itself this value will be used to configure the endpoint of the
service. If no value is provided then the default value is used  (see 1 and
2).

So what's the drawback of using

    <component name="Store">
        <t:implementation.widget location="uiservices/store.html"/>
        <service name="Widget">
            <t:binding.http uri="/ui"/>
        </service>
        <reference name="catalog" target="Catalog">
             <t:binding.jsonrpc/>
         </reference>
         <reference name="shoppingCart" target="ShoppingCart/Cart">
             <t:binding.atom/>
         </reference>
         <reference name="shoppingTotal" target="ShoppingCart/Total">
             <t:binding.jsonrpc/>
         </reference>
    </component>

And setting Node URI = http://localhost:8101

I'm uncomfortable about the current feature because I could easily include a
component in front of the existing component, e.g.

<component name"SomeComponent"
   <implementation .../>
   <service name="SomeService">
     <binding.ws url="http://localhost:8100/SomeService"/>
   </service>
</component>


    <component name="Store">
        <t:implementation.widget location="uiservices/store.html"/>
        <service name="Widget">
            <t:binding.http uri="http://localhost:8101/ui"/>
        </service>
        <reference name="catalog" target="Catalog">
             <t:binding.jsonrpc/>
         </reference>
         <reference name="shoppingCart" target="ShoppingCart/Cart">
             <t:binding.atom/>
         </reference>
         <reference name="shoppingTotal" target="ShoppingCart/Total">
             <t:binding.jsonrpc/>
         </reference>
    </component>

And mess it up as now the majority services in the composite are at 8100 and
not 8101 where store.html expects them to be.

Regards

Simon

Reply via email to