I have a question about conformance item 50011 and hope some one could help
me.

Conformance item 50011 tells something about some constraints about
interface of <component>'s <reference>.  And here is the detailed
description:
 "A reference has zero or one interface, which describes the operations
required by the reference. The interface is described by an interface
element which is a child element of the reference element. If no interface
is specified, then the interface specified for the reference in the
componentType of the implementation is in effect. If an interface is
declared for a component reference it MUST provide a compatible superset of
the interface declared for the equivalent reference in the componentType of
the implementation, i.e. provide the same operations or a superset of the
operations defined by the implementation for the reference. "
In my opinion, I think it is to say that interface declared for a component
reference must have equal or more operations than its implementation
acturally need. So I write a composite file wire.composite and testcase to
verify it.

-----------------------------
wire.composite
-----------------------------
<composite>...
   <component name="FComponent">
     <implementation.java
class="org.apache.tuscany.sca.vtest.assembly.composite.impl.FServiceImpl"/>
     <reference name="d">
        <interface.java
interface="org.apache.tuscany.sca.vtest.assembly.composite.DSubService" />
     </reference>
     <reference name="c">
         <interface.java
interface="org.apache.tuscany.sca.vtest.assembly.composite.CSubService" />
     </reference>
  </component>
   <component name="CComponent">
        <implementation.java
class="org.apache.tuscany.sca.vtest.assembly.composite.impl.CServiceImpl"/>
        <service name="CService">
            <interface.java
interface="org.apache.tuscany.sca.vtest.assembly.composite.CService"/>
        </service>
    </component>
    <component name="DComponent">
        <implementation.java
class="org.apache.tuscany.sca.vtest.assembly.composite.impl.DServiceImpl"/>
        <service name="DService">
            <interface.java
interface="org.apache.tuscany.sca.vtest.assembly.composite.DService" />
        </service>
    </component>
    <wire source="FComponent/d" target="DComponent" />
    <wire source="FComponent/c" target="CComponent" />
</composite>

---------------------------
FServiceImpl.java
---------------------------
@Service(FService.class)
public class FServiceImpl implements FService {
    @Reference
    protected CService c;

    @Reference
    protected DService d;
}

Here, CSubService and DSubService are sub sets of CService and DService
respectively.

When loading this composite file, I haven't got any error message or even
warning message, which supposed to appear.
And when I switch the CSubService to  CSuperService and DSubService to
DSuperService (CSuperService and DSuperService are super sets of CService
and DService respectively), I got warning message this time.
WARNING: Component reference interface incompatible with reference
interface: Component = FComponent Reference = d
WARNING: Component reference interface incompatible with reference
interface: Component = FComponent Reference = c

It seems that it works just on the opposite to the specification. Is there
anything wrong with it? Thanks.

Reply via email to