/*
* First analyze the component references
*/
if (relToResolve.getTarget() instanceof SpecificationReference) {
Specification spec = CST.componentBroker.getSpec(name);
if (spec == null) {
return null;
}
if (relToResolve.getTargetKind() == ComponentKind.SPECIFICATION) {
return new Resolved<Specification>(spec);
}
impls = spec.getImpls();
} else if (relToResolve.getTarget() instanceof ImplementationReference) {
Implementation impl = CST.componentBroker.getImpl(name);
if (impl == null) {
return null;
}
if (relToResolve.getTargetKind() == ComponentKind.IMPLEMENTATION) {
return new Resolved<Implementation>(impl);
}
impls = new HashSet<Implementation>();
impls.add(impl);
} else if (relToResolve.getTarget() instanceof InstanceReference) {
Instance inst = CST.componentBroker.getInst(name);
if (inst == null) {
return null;
}
if (relToResolve.getTargetKind() == ComponentKind.INSTANCE) {
return new Resolved<Instance>(inst);
}
logger.debug("if (relToResolve.getTarget() instanceof InstanceReference) ") ;
return null;
} else if (relToResolve.getTarget() instanceof ComponentReference<?>) {
logger.error("Invalid target reference : " + relToResolve.getTarget());
return null;
}
/*
* We have computed all component references It is either already
* resolved, or the implems are in impls. Now Resolve by resource.
*/
else if (relToResolve.getTarget() instanceof ResourceReference) {
if (relToResolve.getTargetKind() == ComponentKind.SPECIFICATION) {
Set<Specification> specs = new HashSet<Specification>();
for (Specification spec : CST.componentBroker.getSpecs()) {
if (spec.getProvidedResources().contains(relToResolve.getTarget())) {
specs.add(spec);
}
}
return relToResolve.getResolved(specs, false);
}