Package org.apache.felix.dm

Examples of org.apache.felix.dm.Component


          Constants.OBJECTCLASS, Device.class.getName(),
          Constants.OBJECTCLASS, "*",
          org.osgi.service.device.Constants.DEVICE_CATEGORY, "*"
          } );

        Component svc = createComponent();

        svc.setImplementation( m_deviceManager );

        svc.add( createServiceDependency().setService( LogService.class ).setRequired( false ) );

        svc.add( createServiceDependency().setService( DriverSelector.class ).setRequired( false ).setAutoConfig( false )
        .setCallbacks( "selectorAdded", "selectorRemoved" ) );

        svc.add( createServiceDependency().setService( DriverLocator.class ).setRequired( false ).setAutoConfig( false )
            .setCallbacks( "locatorAdded", "locatorRemoved" ) );
       
        svc.add( createServiceDependency().setService( Driver.class, driverFilter ).setRequired( false )
        .setCallbacks( "driverAdded", "driverModified", "driverRemoved" ) );
       
        svc.add( createServiceDependency().setService( deviceFilter ).setRequired( false )
        .setCallbacks( "deviceAdded", "deviceModified", "deviceRemoved" ) );
       
        m_manager.add( svc );

    }
View Full Code Here


    public void testComponentThatDependsOnAOtheComponentShouldRegisterAsFailure() {
        setupEmptyBundles();
        DependencyManager dm = new DependencyManager(m_bundleContext);
        DependencyManager.getDependencyManagers().add(dm);
       
        Component component = dm.createComponent()
            .setImplementation(Object.class)
            .setInterface(Object.class.getName(), null)
            .add(dm.createServiceDependency().setService(Math.class).setRequired(true));
        dm.add(component);
       
View Full Code Here

    public void testComponentThatHaveCycliclyDependencyOnAOtheComponentShouldRegisterAsFailure() {
        setupEmptyBundles();
        DependencyManager dm = new DependencyManager(m_bundleContext);
        DependencyManager.getDependencyManagers().add(dm);
       
        Component component1 = dm.createComponent()
            .setImplementation(Cipher.class)
            .setInterface(Cipher.class.getName(), null)
            .add(dm.createServiceDependency().setService(Math.class).setRequired(true));
        dm.add(component1);
       
        Component component2 = dm.createComponent()
            .setImplementation(Math.class)
            .setInterface(Math.class.getName(), null)
            .add(dm.createServiceDependency().setService(Cipher.class).setRequired(true));
        dm.add(component2);
       
View Full Code Here

   
    @Test
    public void testCanFindRootFailure() {
        setupEmptyBundles();
       
        Component component1 = dm.createComponent()
            .setImplementation(Object.class)
            .setInterface(Object.class.getName(), null)
            .add(dm.createServiceDependency().setService(Math.class).setRequired(true));
        dm.add(component1);
       
        Component component2 = dm.createComponent()
            .setImplementation(Math.class)
            .setInterface(Math.class.getName(), null)
            .add(dm.createServiceDependency().setService(String.class).setRequired(true));
        dm.add(component2);
       
View Full Code Here

   
    @Test
    public void testCanFindRootFailureWithSecondair() {
        setupEmptyBundles();
       
        Component component1 = dm.createComponent()
            .setImplementation(Object.class)
            .setInterface(Object.class.getName(), null)
            .add(dm.createServiceDependency().setService(Math.class).setRequired(true));
        dm.add(component1);
       
        Component component2 = dm.createComponent()
            .setImplementation(Math.class)
            .setInterface(Math.class.getName(), null)
            .add(dm.createServiceDependency().setService(Float.class).setRequired(true));
        dm.add(component2);
       
        Component component3 = dm.createComponent()
            .setImplementation(Object.class)
            .setInterface(new String[] {Object.class.getName(), Float.class.getName()}, null)
            .add(dm.createServiceDependency().setService(String.class).setRequired(true));
        dm.add(component3);
       
View Full Code Here

   
    @Test
    public void testCanFindRootFailureWithTwoFailures() {
        setupEmptyBundles();
       
        Component component1 = dm.createComponent()
            .setImplementation(Object.class)
            .setInterface(Object.class.getName(), null)
            .add(dm.createServiceDependency().setService(Math.class).setRequired(true))
            .add(dm.createServiceDependency().setService(Long.class).setRequired(true));
        dm.add(component1);
View Full Code Here

        // note that we can provide an actual implementation instance here because there will be only one
        // adapter, normally you'd want to specify a Class here
        // also, create a callback instance which will be used for both callbacks on resource changes and
        // life cycle callbacks on the adapters themselves
        CallbackInstance callbackInstance = new CallbackInstance(e);
        Component component = m.createResourceAdapterService("(&(path=/path/to/*.txt)(host=localhost))", false, callbackInstance, "changed")
            .setImplementation(new ResourceAdapter(e))
            .setCallbacks(callbackInstance, "init", "start", "stop", "destroy")
            .add(m.createServiceDependency()
            .setService(ServiceInterface.class)
            .setRequired(true)
            .setInstanceBound(true));
        // add a component state listener
        component.addStateListener(new ComponentStateListenerImpl(e));
        // add the resource adapter
        m.add(component);
        // wait until the single resource is available (the adapter has been started)
        e.waitForStep(1, 5000);
        // trigger a 'change' in our resource
View Full Code Here

    public void testComponentLifeCycleCallbacks() {
        DependencyManager m = new DependencyManager(context);
        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        // create a simple service component
        Component s = m.createComponent()
            .setImplementation(new ComponentInstance(e));
        // add it, and since it has no dependencies, it should be activated immediately
        m.add(s);
        // remove it so it gets destroyed
        m.remove(s);
View Full Code Here

    public void testCustomComponentLifeCycleCallbacks() {
        DependencyManager m = new DependencyManager(context);
        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        // create a simple service component
        Component s = m.createComponent()
            .setImplementation(new CustomComponentInstance(e))
            .setCallbacks("a", "b", "c", "d");
        // add it, and since it has no dependencies, it should be activated immediately
        m.add(s);
        // remove it so it gets destroyed
View Full Code Here

        DependencyManager m = new DependencyManager(context);
        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        // create a simple service component
        ComponentStateListeningInstance implementation = new ComponentStateListeningInstance(e);
        Component s = m.createComponent()
            .setInterface(MyInterface.class.getName(), null)
            .setImplementation(implementation);
        // add the state listener
        s.addStateListener(implementation);
        // add it, and since it has no dependencies, it should be activated immediately
        m.add(s);
        // remove it so it gets destroyed
        m.remove(s);
        // remove the state listener
        s.removeStateListener(implementation);
        // ensure we executed all steps inside the component instance
        e.step(10);
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.dm.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.