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; }
/** * 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; }
for (int i = 0 ; i < components.size() && i < max; i++) { ComponentDeclaration decl = components.get(i).getComponentDeclaration(); System.out.printf("%-100s %10d %10d%n", decl.getClassName(), decl.getCallbacksTime().get("init"), decl.getCallbacksTime().get("start"));
/** * 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; }
@Override public Object addingService(@SuppressWarnings("rawtypes") ServiceReference reference) { try { ServiceEventImpl event = new ServiceEventImpl(m_component, reference, null); if (obtainServiceBeforeInjecting()) { Object service = event.getEvent(); // will dereference the service object. if (service == null) { // service concurrently removed, ignore return null; } } return event; } catch (IllegalStateException e) { // most likely our bundle is being stopped. Only log an exception if our component is enabled. if (m_component.isActive()) { m_component.getLogger().warn("could not handle service dependency for component %s", e, m_component.getComponentDeclaration().getClassName()); } return null; } }
m_component.getComponentDeclaration().getClassName());