Search in sources :

Example 1 with ComponentHolder

use of org.apache.felix.scr.impl.manager.ComponentHolder in project felix by apache.

the class ComponentRegistry method getComponentHolders.

public final List<ComponentHolder<?>> getComponentHolders(Bundle... bundles) {
    List<ComponentHolder<?>> all = getComponentHolders();
    List<ComponentHolder<?>> holders = new ArrayList<ComponentHolder<?>>();
    for (ComponentHolder<?> holder : all) {
        ComponentActivator activator = holder.getActivator();
        if (activator != null) {
            try {
                Bundle holderBundle = activator.getBundleContext().getBundle();
                for (Bundle b : bundles) {
                    if (b == holderBundle) {
                        holders.add(holder);
                    }
                }
            } catch (IllegalStateException ise) {
            // ignore inactive bundles
            }
        }
    }
    return holders;
}
Also used : ComponentActivator(org.apache.felix.scr.impl.manager.ComponentActivator) Bundle(org.osgi.framework.Bundle) ComponentHolder(org.apache.felix.scr.impl.manager.ComponentHolder) ConfigurableComponentHolder(org.apache.felix.scr.impl.manager.ConfigurableComponentHolder) ArrayList(java.util.ArrayList)

Example 2 with ComponentHolder

use of org.apache.felix.scr.impl.manager.ComponentHolder in project felix by apache.

the class ServiceComponentRuntimeImpl method getComponentDescriptionDTOs.

/**
 * @see org.osgi.service.component.runtime.ServiceComponentRuntime#getComponentDescriptionDTOs(org.osgi.framework.Bundle[])
 */
public Collection<ComponentDescriptionDTO> getComponentDescriptionDTOs(Bundle... bundles) {
    List<ComponentHolder<?>> holders;
    if (bundles == null || bundles.length == 0) {
        holders = componentRegistry.getComponentHolders();
    } else {
        holders = componentRegistry.getComponentHolders(bundles);
    }
    List<ComponentDescriptionDTO> result = new ArrayList<ComponentDescriptionDTO>(holders.size());
    for (ComponentHolder<?> holder : holders) {
        ComponentDescriptionDTO dto = holderToDescription(holder);
        if (dto != null) {
            result.add(dto);
        }
    }
    return result;
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) ComponentHolder(org.apache.felix.scr.impl.manager.ComponentHolder) ArrayList(java.util.ArrayList)

Example 3 with ComponentHolder

use of org.apache.felix.scr.impl.manager.ComponentHolder in project felix by apache.

the class ComponentRegistry method getComponentHoldersByPid.

/**
 * Returns the set of ComponentHolder instances whose configuration pids are matching
 * the given pid.
 * @param pid the pid candidate
 * @return the set of ComponentHolders matching the singleton pid supplied
 */
public final Collection<ComponentHolder<?>> getComponentHoldersByPid(TargetedPID targetedPid) {
    String pid = targetedPid.getServicePid();
    Set<ComponentHolder<?>> componentHoldersUsingPid = new HashSet<ComponentHolder<?>>();
    synchronized (m_componentHoldersByPid) {
        Set<ComponentHolder<?>> set = m_componentHoldersByPid.get(pid);
        // only return the entry if non-null and not a reservation
        if (set != null) {
            for (ComponentHolder<?> holder : set) {
                Bundle bundle = holder.getActivator().getBundleContext().getBundle();
                if (targetedPid.matchesTarget(bundle)) {
                    componentHoldersUsingPid.add(holder);
                }
            }
        }
    }
    return componentHoldersUsingPid;
}
Also used : Bundle(org.osgi.framework.Bundle) ComponentHolder(org.apache.felix.scr.impl.manager.ComponentHolder) ConfigurableComponentHolder(org.apache.felix.scr.impl.manager.ConfigurableComponentHolder) HashSet(java.util.HashSet)

Aggregations

ComponentHolder (org.apache.felix.scr.impl.manager.ComponentHolder)3 ArrayList (java.util.ArrayList)2 ConfigurableComponentHolder (org.apache.felix.scr.impl.manager.ConfigurableComponentHolder)2 Bundle (org.osgi.framework.Bundle)2 HashSet (java.util.HashSet)1 ComponentActivator (org.apache.felix.scr.impl.manager.ComponentActivator)1 ComponentDescriptionDTO (org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)1