hi,
Spec defines a component can provide multiple services.So how to
define multiple services and what are the differences between a component
provides single service and a component provides more.
In tuscany M1, with annotation, i tried many ways to define multiple
services in impl code, but i was failed. Does service annotation supports
multiple service definition, or i have to use annotation in a specific way?
With componentType file, i changed the supplychain example, and defined
multiple services, but some problems happened. I removed all the annotations
in CustomerComponentImpl and RetailerComponentImpl java file, and defined
services and references in their component type file. In order to verify my
thoughts about multiple service definition, i changed RetailerComponentImpl
and made it implements multiple interfaces which are Retailer and Customer,
and the below is the snippet of RetailerComponentImpl.componentType file:
<service name="CustomerService">
<interface.java interface="supplychain.Customer" />
</service>
<service name="RetailerService">
<interface.java interface="supplychain.Retailer" />
</service>
<reference name="warehouse" >
<interface.java interface="supplychain.Warehouse"/>
</reference>
After my modification, i ran the SupplyChainClient and it failed. The
error is:
Exception in thread "main"
org.apache.tuscany.core.builder.BuilderConfigException: Incompatible source
and target interface types for reference [retailer]
Context stack trace: [tuscany.root
][supplychain][supplychain][CustomerComponent][RetailerComponent][
tuscany.root]
at org.apache.tuscany.core.builder.impl.DefaultWireBuilder.connect(
DefaultWireBuilder.java:64)
at org.apache.tuscany.core.runtime.RuntimeContextImpl.connect(
RuntimeContextImpl.java:178)
at org.apache.tuscany.core.context.impl.AbstractCompositeContext.connect(
AbstractCompositeContext.java:823)
at org.apache.tuscany.core.context.impl.AbstractCompositeContext.wireSource
(AbstractCompositeContext.java:621)
at org.apache.tuscany.core.context.impl.AbstractCompositeContext.start(
AbstractCompositeContext.java:185)
at
org.apache.tuscany.core.context.scope.CompositeScopeContext.registerFactory(
CompositeScopeContext.java:95)
at
org.apache.tuscany.core.context.impl.AbstractCompositeContext.registerConfiguration
(AbstractCompositeContext.java:499)
at
org.apache.tuscany.core.context.impl.AbstractCompositeContext.registerModelObject
(AbstractCompositeContext.java:446)
at org.apache.tuscany.core.client.BootstrapHelper.registerModule(
BootstrapHelper.java:133)
at org.apache.tuscany.core.client.TuscanyRuntime.<init>(TuscanyRuntime.java
:104)
at supplychain.SupplyChainClient.main(SupplyChainClient.java:43)
If i delete CustomerService definition or move the RetailerService
definition to the first place, the client would run successfully.
So why that happens? Thx a lot!
------------------------------
guangqingzhong
2006-08-07