Package org.apache.felix.scr

Examples of org.apache.felix.scr.Component


    @Test
    public void testLocationChangeToRegionBinding() throws Exception
    {
        final String pid = COMPONENT_NAME;
        final Component component = findComponentByName( pid );

        deleteConfig( pid );
        delay();

        TestCase.assertNotNull( component );
        TestCase.assertFalse( component.isDefaultEnabled() );

        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
        TestCase.assertNull( SimpleComponent.INSTANCE );

        component.enable();
        delay();

        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
        TestCase.assertNull( SimpleComponent.INSTANCE );

        Configuration config = configure( pid );
        delay();

        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
        TestCase.assertNotNull( SimpleComponent.INSTANCE );
        TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
       
       
        Bundle b2 = installBundle( descriptorFile, COMPONENT_PACKAGE, "simplecomponent2", "0.0.11", null );
        b2.start();
        Component[] components = findComponentsByName( pid );
        TestCase.assertEquals( 2, components.length );
        Component c2 = components[0] == component? components[1]: components[0];
       
        c2.enable();
        delay();
        TestCase.assertEquals( Component.STATE_UNSATISFIED, c2.getState() );
       
        bundle.stop();
        delay();
       
        TestCase.assertEquals( Component.STATE_UNSATISFIED, c2.getState() );

        ConfigurationListener listener = new ConfigurationListener() {

            public void configurationEvent(ConfigurationEvent event)
            {
                if (event.getType() == ConfigurationEvent.CM_LOCATION_CHANGED)
                {
                    eventReceived = true;
                }
            }
           
        };
        ServiceRegistration<ConfigurationListener> sr = bundleContext.registerService( ConfigurationListener.class, listener, null );
        config.setBundleLocation( REGION );
        delay();
       
        if ( eventReceived )
        {
            TestCase.assertEquals( Component.STATE_ACTIVE, c2.getState() );
        }
       
        sr.unregister();
       
       
View Full Code Here


        {
            return;//not an R5 CA
        }
       
        final String pid = COMPONENT_NAME;
        final Component component = findComponentByName( pid );

        deleteConfig( pid );
        delay();

        TestCase.assertNotNull( component );
        TestCase.assertFalse( component.isDefaultEnabled() );

        TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
        TestCase.assertNull( SimpleComponent.INSTANCE );

        component.enable();
        delay();

        TestCase.assertEquals( Component.STATE_UNSATISFIED, component.getState() );
        TestCase.assertNull( SimpleComponent.INSTANCE );

        Configuration config = configure( pid, REGION );
        delay();

        TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
        TestCase.assertNotNull( SimpleComponent.INSTANCE );
        TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
       
       
        Bundle b2 = installBundle( descriptorFile, COMPONENT_PACKAGE, "simplecomponent2", "0.0.11", null );
        b2.start();
        Component[] components = findComponentsByName( pid );
        TestCase.assertEquals( 2, components.length );
        Component c2 = components[0] == component? components[1]: components[0];
       
        c2.enable();
        delay();
        TestCase.assertEquals( Component.STATE_ACTIVE, c2.getState() );
    }
View Full Code Here

        }
    }

    public int componentState(String componentName) {
        int state = -1;
        final Component component = findComponent(componentName);
        if (component != null)
            state = component.getState();
        else
            LOGGER.warn("No component found for name: " + componentName);
        return state;
    }
View Full Code Here

            LOGGER.warn("No component found for name: " + componentName);
        return state;
    }

    public void activateComponent(String componentName) {
        final Component component = findComponent(componentName);
        if (component != null)
            component.enable();
        else
            LOGGER.warn("No component found for name: " + componentName);
    }
View Full Code Here

        else
            LOGGER.warn("No component found for name: " + componentName);
    }

    public void deactivateComponent(String componentName) {
        final Component component = findComponent(componentName);
        if (component != null)
            component.disable();
        else
            LOGGER.warn("No component found for name: " + componentName);
    }
View Full Code Here

        else
            LOGGER.warn("No component found for name: " + componentName);
    }

    private Component findComponent(String componentName) {
        Component answer = null;
        if (scrService.getComponents(componentName) != null) {
            Component[] components = scrService.getComponents(componentName);
            for (Component component : safe(components)) {
                answer = component;
            }
View Full Code Here

     * @return
     * @throws Exception
     */
    public int componentState(String componentName) throws Exception {
        int state = -1;
        final Component component = findComponent(componentName);
        if (component != null)
            state = component.getState();
        else
            LOGGER.warn("No component found for name: " + componentName);
        return state;
    }
View Full Code Here

     *
     * @param componentName
     * @throws Exception
     */
    public void activateComponent(String componentName) throws Exception {
        final Component component = findComponent(componentName);
        if (component != null)
            component.enable();
        else
            LOGGER.warn("No component found for name: " + componentName);
    }
View Full Code Here

     *
     * @param componentName
     * @throws Exception
    */
    public void deactivateComponent(String componentName) throws Exception {
        final Component component = findComponent(componentName);
        if (component != null)
            component.disable();
        else
            LOGGER.warn("No component found for name: " + componentName);
    }
View Full Code Here

        else
            LOGGER.warn("No component found for name: " + componentName);
    }

    private Component findComponent(String componentName) {
        Component answer = null;
        if (scrService.getComponents(componentName) != null) {
            Component[] components = scrService.getComponents(componentName);
            for (Component component : safe(components)) {
                answer = component;
            }
View Full Code Here

TOP

Related Classes of org.apache.felix.scr.Component

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.