if (reference.getInterfaceContract() == null ||
interfaceContractMapper.isCompatible(reference.getInterfaceContract(),
targetComponentService.getInterfaceContract())) {
// create endpoint reference - with a dummy endpoint which will be replaced when policies
// are matched and bindings are configured later
EndpointReference endpointRef = createEndpointRef( component, reference, false );
endpointRef.setTargetEndpoint( createEndpoint(targetComponent, targetComponentService, true) );
reference.getEndpointReferences().add(endpointRef);
// Stop with the first match for 0..1 and 1..1 references
if (multiplicity == Multiplicity.ZERO_ONE ||
multiplicity == Multiplicity.ONE_ONE) {
break;
} // end if
} // end if
} // end for
} // end for
if (multiplicity == Multiplicity.ONE_N ||
multiplicity == Multiplicity.ONE_ONE) {
if (reference.getEndpointReferences().size() == 0) {
warning(monitor, "NoComponentReferenceTarget",
reference,
reference.getName());
}
}
} else if (!refTargets.isEmpty()) {
// Check that the component reference does not mix the use of endpoint references
// specified via the target attribute with the presence of binding elements
if( bindingsIdentifyTargets( reference ) ) {
warning(monitor, "ReferenceEndPointMixWithTarget",
composite, composite.getName().toString(), component.getName(), reference.getName());
}
// Resolve targets specified on the component reference
for (ComponentService target : refTargets) {
String targetName = target.getName();
ComponentService targetComponentService = componentServices.get(targetName);
Component targetComponent = getComponentFromTargetName( components, targetName );
if (targetComponentService != null) {
// Check that target component service provides a superset of the component reference interface
if (reference.getInterfaceContract() == null ||
interfaceContractMapper.isCompatible(reference.getInterfaceContract(),
targetComponentService.getInterfaceContract())) {
// create endpoint reference - with dummy endpoint which will be replaced when policies
// are matched and bindings are configured later
EndpointReference endpointRef = createEndpointRef( component, reference, false );
endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true));
reference.getEndpointReferences().add(endpointRef);
} else {
warning(monitor, "ReferenceIncompatibleInterface",
composite,
composite.getName().toString(),
component.getName() + "." + reference.getName(),
targetName);
}
} else {
// add an unresolved endpoint reference with an unresolved endpoint to go with it
EndpointReference endpointRef = createEndpointRef( component, reference, true );
endpointRef.setTargetEndpoint(createEndpoint(component, targetName));
endpointRef.setIsRemoteReference(true);
reference.getEndpointReferences().add(endpointRef);
warning(monitor, "ComponentReferenceTargetNotFound",
composite,
composite.getName().toString(),
targetName);
} // end if
} // end for
} // end if
// if no endpoints have found so far the bindings hold the targets.
if (reference.getEndpointReferences().isEmpty()) {
for (Binding binding : reference.getBindings()) {
String uri = binding.getURI();
// user hasn't put a uri on the binding so it's not a target name and the assumption is that
// the target is established via configuration of the binding element itself
if (uri == null) {
// Regular forward references are UNWIRED with no endpoint if they have an SCABinding with NO targets
// and NO URI set - but Callbacks with an SCABinding are wired and need an endpoint
if( !reference.isCallback() && (binding instanceof SCABinding) ) continue;
// create endpoint reference for manually configured bindings with a resolved endpoint to
// signify that this reference is pointing at some unwired endpoint
EndpointReference endpointRef = createEndpointRef( component, reference,
binding, null, false );
endpointRef.setTargetEndpoint(createEndpoint(false));
endpointRef.setIsRemoteReference(true);
reference.getEndpointReferences().add(endpointRef);
continue;
} // end if
// user might have put a local target name in the uri - see if it refers to a target we know about
// - if it does the reference binding will be matched with a service binding
// - if it doesn't it is assumed to be an external reference
if (uri.startsWith("/")) {
uri = uri.substring(1);
}
// Resolve the target component and service
ComponentService targetComponentService = componentServices.get(uri);
Component targetComponent = getComponentFromTargetName( components, uri );
// If the binding URI matches a component in the composite, configure an endpoint reference with
// this component as the target.
// If not, the binding URI is assumed to reference an external service
if (targetComponentService != null) {
// Check that the target component service provides
// a superset of the component reference interface
if (reference.getInterfaceContract() == null ||
interfaceContractMapper.isCompatible(reference.getInterfaceContract(),
targetComponentService.getInterfaceContract())) {
// create endpoint reference with dummy endpoint which will be replaced when policies
// are matched and bindings are configured later
EndpointReference endpointRef = createEndpointRef( component, reference, binding, null, false );
endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true));
reference.getEndpointReferences().add(endpointRef);
} else {
warning(monitor, "ReferenceIncompatibleInterface",
composite,
composite.getName().toString(),
reference.getName(),
uri);
}
} else {
// create endpoint reference for manually configured bindings with resolved endpoint
// to signify that this reference is pointing at some unwired endpoint
EndpointReference endpointRef = createEndpointRef( component, reference, binding, null, false );
endpointRef.setTargetEndpoint(createEndpoint( false ));
endpointRef.setIsRemoteReference(true);
reference.getEndpointReferences().add(endpointRef);
} // end if
}
}
} // end method