private boolean requiresThreadPool(Component c, String parallel) { // The component declared from our DM Activator can not be parallel. ComponentDeclaration decl = c.getComponentDeclaration(); if (ComponentScheduler.class.getName().equals(decl.getName())) { return false; } for (String prefix : parallel.trim().split(",")) { prefix = prefix.trim(); boolean not = prefix.startsWith("!"); if (not) { prefix = prefix.substring(1).trim(); } if ("*".equals(prefix) || c.getComponentDeclaration().getClassName().startsWith(prefix)) { return !not; } } return false; }
@Override public int compare(Component c1, Component c2) { Map<String, Long> c1Times = c1.getComponentDeclaration().getCallbacksTime(); Map<String, Long> c2Times = c2.getComponentDeclaration().getCallbacksTime(); Long c1Start = c1Times.get("start"); Long c2Start = c2Times.get("start"); if (c1Start != null) { if (c2Start != null) { return c1Start > c2Start ? 1 : -1; } else { return 1; } } else { if (c2Start != null) { return -1; } else { return 0; } } } });
/** * Is a dependency required by default ? * * @param c the component on which the dependency is added * @param ctx the bundle context * @return true if the dependency is required by default, false if not */ public static boolean isDependencyRequiredByDefault(Component c) { BundleContext ctx = ((ComponentContext) c).getBundleContext(); String defaultRequiredDependency = ctx.getProperty(DEFAULT_REQUIRED_DEPENDENCY); if (defaultRequiredDependency != null) { defaultRequiredDependency = defaultRequiredDependency.trim(); String componentName = c.getComponentDeclaration().getClassName(); for (String pkg : defaultRequiredDependency.split(",")) { if (componentName.startsWith(pkg)) { return true; } } } return false; }
private void buildComponentNodes() { List<DependencyManager> dependencyManagers = DependencyManager.getDependencyManagers(); for(DependencyManager dm : dependencyManagers) { List<Component> components = dm.getComponents(); for(Component c : components) { ComponentDeclaration cd = c.getComponentDeclaration(); if(componentMustBeAddedToGraph(cd)) { m_componentToNode.put(cd, new ComponentNode(cd)); } } } }
ComponentDeclaration decl = components.get(i).getComponentDeclaration(); System.out.printf("%-100s %10d %10d%n", decl.getClassName(), decl.getCallbacksTime().get("init"), decl.getCallbacksTime().get("start"));