1) The ReferenceExtension has addtional setXXX(...) methods which are not 
required by the Reference interface. What are the usages? Are these just helper 
methods for subclasses to access the protected fields? If so, the modifiers 
should be protected, right?

2) Are the extension developers responsible to populate all the data such as 
inboundWire, outboundWire and referenceInterface? Do we have base classes for 
InboundWire and OutboundWire? referenceInterace usually is from 
BoundReferenceDefinition.getServiceContract().getInterfaceClass(), am I right?

An example will help. 

Please clarify.

Thanks,
Raymond

public abstract class ReferenceExtension<T> extends AbstractSCAObject<T> 
implements Reference<T> {

    protected InboundWire<T> inboundWire;
    protected OutboundWire<T> outboundWire;
    protected Class<T> referenceInterface;
    protected WireService wireService;

    protected ReferenceExtension(String name, CompositeComponent<?> parent, 
WireService wireService) {
        super(name, parent);
        this.wireService = wireService;
    }

    public Scope getScope() {
        return Scope.COMPOSITE;
    }

    public void setInboundWire(InboundWire<T> wire) {
        this.inboundWire = wire;
    }

    public InboundWire<T> getInboundWire() {
        return inboundWire;
    }

    public OutboundWire<T> getOutboundWire() {
        return outboundWire;
    }

    public void setOutboundWire(OutboundWire<T> outboundWire) {
        this.outboundWire = outboundWire;
    }

    public Class<T> getInterface() {
        return referenceInterface;
    }

    public void setInterface(Class<T> referenceInterface) {
        this.referenceInterface = referenceInterface;
    }

    public T getServiceInstance() throws TargetException {
        return wireService.createProxy(inboundWire);
    }

    public WireInvocationHandler getHandler() throws TargetException {
        //Map<Method, InboundInvocationChain> configuration = 
inboundWire.getInvocationChains();
        return wireService.createHandler(inboundWire);
        //return new JDKInboundInvocationHandler(configuration);
    }

    public void prepare() {
        assert inboundWire != null : "Inbound wire not set";
        for (InboundInvocationChain chain : 
inboundWire.getInvocationChains().values()) {
            
chain.setTargetInvoker(createTargetInvoker(outboundWire.getTargetName().getQualifiedName(),
                chain.getMethod()));
            chain.build();
        }
    }

}

Reply via email to