Search in sources :

Example 31 with ComponentDescriptionDTO

use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.

the class Felix3680_2Test method test_concurrent_injection_with_bundleContext.

@Test
public void test_concurrent_injection_with_bundleContext() throws Throwable {
    for (int i = 0; i < 6; i++) {
        final ComponentDescriptionDTO main = findComponentDescriptorByName("org.apache.felix.scr.integration.components.felix3680_2.Main");
        enableAndCheck(main);
        // run test for 30 seconds
        delay(5);
        disableAndCheck(main);
        // async deactivate
        delay();
        if (log.getFirstFrameworkThrowable() != null) {
            throw log.getFirstFrameworkThrowable();
        }
        for (Iterator it = log.foundWarnings().iterator(); it.hasNext(); ) {
            String message = (String) it.next();
            TestCase.fail("unexpected warning or error logged: " + message);
        }
    }
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 32 with ComponentDescriptionDTO

use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.

the class MutablePropertiesTest method test_mutable_properties_consumer.

@Test
public void test_mutable_properties_consumer() throws Exception {
    ServiceReference<MutatingServiceConsumer> mscRef = bundleContext.getServiceReference(MutatingServiceConsumer.class);
    MutatingServiceConsumer msc = bundleContext.getService(mscRef);
    assertMsc(msc, null, null, null);
    String componentName = "components.mutable.properties.return2";
    ComponentDescriptionDTO cd = findComponentDescriptorByName(componentName);
    enableAndCheck(cd);
    assertMsc(msc, true, true, null);
}
Also used : MutatingServiceConsumer(org.apache.felix.scr.integration.components.MutatingServiceConsumer) ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) Test(org.junit.Test)

Example 33 with ComponentDescriptionDTO

use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.

the class ScrServiceImpl method getComponents.

/**
 * @see org.apache.felix.scr.ScrService#getComponents(java.lang.String)
 */
public Component[] getComponents(final String componentName) {
    List<Component> result = new ArrayList<Component>();
    final Collection<ComponentDescriptionDTO> descriptions = this.runtime.getComponentDescriptionDTOs();
    for (final ComponentDescriptionDTO descDTO : descriptions) {
        if (descDTO.name.equals(componentName)) {
            final Collection<ComponentConfigurationDTO> configs = this.runtime.getComponentConfigurationDTOs(descDTO);
            ComponentConfigurationDTO configDTO = null;
            if (!configs.isEmpty()) {
                configDTO = configs.iterator().next();
            }
            result.add(new ComponentWrapper(this.context, this.runtime, descDTO, configDTO));
        }
    }
    return result.isEmpty() ? null : result.toArray(new Component[result.size()]);
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) ArrayList(java.util.ArrayList) Component(org.apache.felix.scr.Component) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)

Example 34 with ComponentDescriptionDTO

use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.

the class ScrServiceImpl method getComponents.

/**
 * @see org.apache.felix.scr.ScrService#getComponents(org.osgi.framework.Bundle)
 */
public Component[] getComponents(final Bundle bundle) {
    List<Component> result = new ArrayList<Component>();
    final Collection<ComponentDescriptionDTO> descriptions = (bundle == null ? this.runtime.getComponentDescriptionDTOs() : this.runtime.getComponentDescriptionDTOs(bundle));
    for (final ComponentDescriptionDTO descDTO : descriptions) {
        final Collection<ComponentConfigurationDTO> configs = this.runtime.getComponentConfigurationDTOs(descDTO);
        ComponentConfigurationDTO configDTO = null;
        if (!configs.isEmpty()) {
            configDTO = configs.iterator().next();
        }
        result.add(new ComponentWrapper(this.context, this.runtime, descDTO, configDTO));
    }
    return result.isEmpty() ? null : result.toArray(new Component[result.size()]);
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) ArrayList(java.util.ArrayList) Component(org.apache.felix.scr.Component) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)

Example 35 with ComponentDescriptionDTO

use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.

the class ScrCommand method change.

void change(final String componentIdentifier, final PrintWriter out, final boolean enable) {
    final Result result = getComponentsFromArg(componentIdentifier, true);
    for (final ComponentDescriptionDTO component : result.components) {
        if (enable) {
            if (!scrService.isComponentEnabled(component)) {
                scrService.enableComponent(component);
                out.println("Component " + component.name + " enabled");
            } else {
                out.println("Component " + component.name + " already enabled");
            }
        } else {
            if (scrService.isComponentEnabled(component)) {
                scrService.disableComponent(component);
                out.println("Component " + component.name + " disabled");
            } else {
                out.println("Component " + component.name + " already disabled");
            }
        }
    }
    out.flush();
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)

Aggregations

ComponentDescriptionDTO (org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)36 ComponentConfigurationDTO (org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)18 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 Bundle (org.osgi.framework.Bundle)3 ServiceComponentRuntime (org.osgi.service.component.runtime.ServiceComponentRuntime)3 ReferenceDTO (org.osgi.service.component.runtime.dto.ReferenceDTO)3 UnsatisfiedReferenceDTO (org.osgi.service.component.runtime.dto.UnsatisfiedReferenceDTO)3 Iterator (java.util.Iterator)2 TreeMap (java.util.TreeMap)2 Component (org.apache.felix.scr.Component)2 Descriptor (org.apache.felix.service.command.Descriptor)2 JSONWriter (org.apache.felix.utils.json.JSONWriter)2 ServiceReferenceDTO (org.osgi.framework.dto.ServiceReferenceDTO)2 SatisfiedReferenceDTO (org.osgi.service.component.runtime.dto.SatisfiedReferenceDTO)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Pattern (java.util.regex.Pattern)1