Search in sources :

Example 1 with ComponentActivator

use of org.apache.felix.scr.impl.manager.ComponentActivator 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 ComponentActivator

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

the class ActivateMethodTest method newContainer.

private ComponentContainer newContainer() {
    final ComponentMetadata metadata = newMetadata();
    ComponentContainer container = new ComponentContainer() {

        @Override
        public ComponentActivator getActivator() {
            final ComponentActivator ca = Mockito.mock(ComponentActivator.class);
            Mockito.when(ca.getBundleContext()).thenReturn(Mockito.mock(BundleContext.class));
            return ca;
        }

        @Override
        public ComponentMetadata getComponentMetadata() {
            return metadata;
        }

        @Override
        public void disposed(SingleComponentManager component) {
        }

        public boolean isEnabled() {
            return false;
        }

        @Override
        public ComponentLogger getLogger() {
            return new MockComponentLogger();
        }
    };
    return container;
}
Also used : SingleComponentManager(org.apache.felix.scr.impl.manager.SingleComponentManager) ComponentActivator(org.apache.felix.scr.impl.manager.ComponentActivator) ComponentContainer(org.apache.felix.scr.impl.manager.ComponentContainer) MockComponentLogger(org.apache.felix.scr.impl.logger.MockComponentLogger) ComponentMetadata(org.apache.felix.scr.impl.metadata.ComponentMetadata) BundleContext(org.osgi.framework.BundleContext)

Aggregations

ComponentActivator (org.apache.felix.scr.impl.manager.ComponentActivator)2 ArrayList (java.util.ArrayList)1 MockComponentLogger (org.apache.felix.scr.impl.logger.MockComponentLogger)1 ComponentContainer (org.apache.felix.scr.impl.manager.ComponentContainer)1 ComponentHolder (org.apache.felix.scr.impl.manager.ComponentHolder)1 ConfigurableComponentHolder (org.apache.felix.scr.impl.manager.ConfigurableComponentHolder)1 SingleComponentManager (org.apache.felix.scr.impl.manager.SingleComponentManager)1 ComponentMetadata (org.apache.felix.scr.impl.metadata.ComponentMetadata)1 Bundle (org.osgi.framework.Bundle)1 BundleContext (org.osgi.framework.BundleContext)1