* Look for the implementation (i.e. component) dependency for the given service-level requirement metadata.
* @param element : the service-level requirement metadata
* @return the Dependency object, null if not found or if the DependencyHandler is not plugged to the instance
*/
private Dependency getAttachedDependency(Element element) {
DependencyHandler handler = (DependencyHandler) getHandler(HandlerFactory.IPOJO_NAMESPACE + ":requires");
if (handler == null) { return null; }
String identity = element.getAttribute("id");
if (identity != null) {
// Look for dependency Id
for (int i = 0; i < handler.getDependencies().length; i++) {
if (handler.getDependencies()[i].getId().equals(identity)) { return handler.getDependencies()[i]; }
}
}
// If not found or no id, look for a dependency with the same specification
String requirement = element.getAttribute("specification");
for (int i = 0; i < handler.getDependencies().length; i++) {
if ((handler.getDependencies()[i].getSpecification().getName()).equals(requirement)) { return handler.getDependencies()[i]; }
}
return null;
}