for (Operation operation : sourceContract.getInterface().getOperations()) {
Operation targetOperation = interfaceContractMapper.map(bindingContract.getInterface(), operation);
InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
if (operation.isNonBlocking()) {
chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
}
addBindingInterceptor(component, reference, binding, chain, operation, false);
wire.getInvocationChains().add(chain);
}
if (sourceContract.getCallbackInterface() != null) {
for (Operation operation : sourceContract.getCallbackInterface().getOperations()) {
Operation targetOperation = interfaceContractMapper.map(bindingContract.getCallbackInterface(),
operation);
InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
if (operation.isNonBlocking()) {
chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
}
addBindingInterceptor(component, reference, binding, chain, operation, true);
wire.getCallbackInvocationChains().add(chain);
}
}
runtimeRef.getRuntimeWires().add(wire);
wireProcessor.process(wire);
}
for (ComponentService service : reference.getTargets()) {
Component target = null;
SCABinding scaBinding = service.getBinding(SCABinding.class);
if (scaBinding != null) {
target = scaBinding.getComponent();
}
// FIXME: [rfeng] Ignore unresolved services
if (service.isUnresolved()) {
continue;
}
// FIXME: [rfeng] We might need a better way to get the impl interface contract
InterfaceContract targetContract = service.getService().getInterfaceContract();
EndpointReference wireSource = new EndpointReferenceImpl((RuntimeComponent)component,
(RuntimeComponentReference)reference, binding,
bindingContract);
EndpointReference wireTarget = new EndpointReferenceImpl((RuntimeComponent)target,
(RuntimeComponentService)service, binding,
targetContract);
RuntimeWire wire = new RuntimeWireImpl(wireSource, wireTarget);
for (Operation operation : bindingContract.getInterface().getOperations()) {
Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
if (operation.isNonBlocking()) {
chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
}
addBindingInterceptor(component, reference, binding, chain, operation, false);
if (target != null) {
addImplementationInterceptor(target, service, chain, targetOperation, false);
}
wire.getInvocationChains().add(chain);
}
if (bindingContract.getCallbackInterface() != null) {
if (reference.getName().startsWith("$self$.")) {
// No callback is needed
continue;
}
for (Operation operation : bindingContract.getCallbackInterface().getOperations()) {
Operation targetOperation = interfaceContractMapper.map(targetContract.getCallbackInterface(),
operation);
InvocationChain chain = new InvocationChainImpl(operation, targetOperation);
if (operation.isNonBlocking()) {
chain.addInterceptor(new NonBlockingInterceptor(workScheduler));
}
addBindingInterceptor(component, reference, binding, chain, operation, true);
addImplementationInterceptor(component, null, chain, targetOperation, true);
wire.getCallbackInvocationChains().add(chain);
}