@Override public int compare(ComponentDeclaration cd1, ComponentDeclaration cd2) { long id1 = cd1.getBundleContext().getBundle().getBundleId(); long id2 = cd2.getBundleContext().getBundle().getBundleId(); if(id1 == id2) { // sort by component id long cid1 = cd1.getId(); long cid2 = cd2.getId(); return cid1 > cid2 ? 1 : -1; } return id1 > id2 ? 1 : -1; } }
/** * Checks if a component can be displayed. We make a logical OR between the three following conditions: * * - the component service properties are matching a given service filter ("services" option) * - the component implementation class name is matching some regex ("components" option) * - the component declaration name is matching some regex ("names" option) * * If some component ids are provided, then the component must also match one of them. */ private boolean mayDisplay(Component component, Filter servicesFilter, String[] components, List<Long> componentIds) { // Check component id if (componentIds.size() > 0) { long componentId = ((ComponentDeclaration) component).getId(); if (componentIds.indexOf(componentId) == -1) { return false; } } if (servicesFilter == null && components.length == 0) { return true; } // Check component service properties boolean servicesMatches = servicesMatches(component, servicesFilter); // Check components regexs, which may match component implementation class name boolean componentsMatches = componentMatches(((ComponentDeclaration) component).getClassName(), components); // Logical OR between service properties match and component service/impl match. return servicesMatches || componentsMatches; }