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;
}
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;
}
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;
}
Aggregations