ServiceInterface refIntf = getComponentReferenceInterface(reference);
ServiceMetadata metadata = ServiceMetadataBuilder.create()
.security(getDomain().getServiceSecurity(reference.getSecurity()))
.requiredPolicies(requires).registrant(impl)
.build();
ServiceReference svcRef = getDomain().registerServiceReference(refName, refIntf, null, metadata);
boolean wired = false;
// wire a reference if the name is different from promoted name
compositeReferenceLoop: for (CompositeReferenceModel compositeReference : getConfig().getComposite().getReferences()) {
for (ComponentReferenceModel componentReference : compositeReference.getComponentReferences()) {
if (componentReference != null && componentReference.equals(reference)) {
if (!componentReference.getQName().equals(compositeReference.getQName())) {
svcRef.wire(compositeReference.getQName());
wired = true;
break compositeReferenceLoop;
}
}
}
}
// if we didn't wire to a promoted reference, then default to unqualified service name
if (!wired) {
svcRef.wire(ComponentNames.unqualify(svcRef));
}
references.add(svcRef);
}
// register a service for each one declared in the component