Package org.apache.felix.dm

Examples of org.apache.felix.dm.DependencyManager.createServiceDependency()


        }

        void init(Component c) {
            m_e.step(2);
            DependencyManager dm = c.getDependencyManager();
            c.add(dm.createServiceDependency().setService(A.class).setRequired(true).setInstanceBound(true).setCallbacks("add", "remove"));
        }     
       
        public void add(A a) {
            m_e.step(3);
        }
View Full Code Here


        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        // create a resource provider
       
        Component component = m.createComponent().setInterface(MyService2.class.getName(), null).setImplementation(new MyComponent(e));
        ServiceDependency dependency = m.createServiceDependency().setService(MyService.class).setRequired(true);
        ServiceDependency dependency2 = m.createServiceDependency().setService(MyService.class).setRequired(true);
        ServiceTracker st = new ServiceTracker(context, MyService2.class.getName(), null);
        st.open();
        Component component2 = m.createComponent().setInterface(MyService.class.getName(), null).setImplementation(new MyImpl(e));
       
View Full Code Here

        Ensure e = new Ensure();
        // create a resource provider
       
        Component component = m.createComponent().setInterface(MyService2.class.getName(), null).setImplementation(new MyComponent(e));
        ServiceDependency dependency = m.createServiceDependency().setService(MyService.class).setRequired(true);
        ServiceDependency dependency2 = m.createServiceDependency().setService(MyService.class).setRequired(true);
        ServiceTracker st = new ServiceTracker(context, MyService2.class.getName(), null);
        st.open();
        Component component2 = m.createComponent().setInterface(MyService.class.getName(), null).setImplementation(new MyImpl(e));
       
        // add the component: it has no dependencies so it should be activated immediately
View Full Code Here

        }

        public void init(Component s) {
            DependencyManager dm = s.getDependencyManager();
            m_ensure.step(m_startStep);
            s.add(dm.createServiceDependency()
                .setInstanceBound(true)
                .setService(ProviderInterface.class)
                .setRequired(m_required)
                .setCallbacks("bind", null));
        }
View Full Code Here

        Ensure e = new Ensure();
       
        // create a service adapter that adapts to services S1 and has an optional dependency on services S2
        Component sa = m.createAdapterService(S1.class, null)
            .setImplementation(SA.class)
            .add(m.createServiceDependency().setService(S2.class).setCallbacks("add", "remove"));
        m.add(sa);
       
        // create a service S1, which triggers the creation of the first adapter instance (A1)
        Component s1 = m.createComponent().setInterface(S1.class.getName(), null).setImplementation(new S1Impl());
        m.add(s1);
View Full Code Here

        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        // create a service provider and consumer
        Component sp = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
        Component sp2 = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
        Component sc = m.createComponent().setImplementation(new ServiceConsumer(e)).add(m.createServiceDependency().setService(ServiceInterface.class).setRequired(true).setCallbacks("add", "remove"));
        m.add(sp);
        m.add(sp2);
        System.out.println("adding client");
        m.add(sc);
        System.out.println("waiting");
View Full Code Here

        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        // create a service provider and consumer
        Component sp = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
        Component sp2 = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
        Component sc = m.createComponent().setImplementation(new ServiceConsumer(e)).add(m.createServiceDependency().setService(ServiceInterface.class).setRequired(false).setCallbacks("add", "remove"));
        m.add(sp);
        m.add(sp2);
        m.add(sc);
        // wait until both services have been added to our consumer
        e.waitForStep(2, 5000);
View Full Code Here

        // create a resource provider
        ResourceProvider provider = new ResourceProvider(e);
        // activate it
        m.add(m.createComponent()
        .setImplementation(new ServiceProvider(e))
        .add(m.createServiceDependency()
            .setService(ServiceInterface.class)
        .setRequired(true)
        .setCallbacks("add", "change", "remove")
      )
    );
View Full Code Here

      )
    );
       
        m.add(m.createComponent()
        .setImplementation(provider)
        .add(m.createServiceDependency()
          .setService(ResourceHandler.class)
          .setCallbacks("add", "remove")
      )
    );
       
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 service provider and consumer
        Component s1 = m.createComponent().setImplementation(new ConfigurationConsumer2(e)).setInterface(Runnable.class.getName(), null).add(m.createConfigurationDependency().setPid("test").setPropagate(true));
        Component s2 = m.createComponent().setImplementation(new ConfigurationCreator(e)).add(m.createServiceDependency().setService(ConfigurationAdmin.class).setRequired(true));
        Component s3 = m.createComponent().setImplementation(new ConfiguredServiceConsumer(e)).add(m.createServiceDependency().setService(Runnable.class, ("(testkey=testvalue)")).setRequired(true));
        m.add(s1);
        m.add(s2);
        m.add(s3);
        e.waitForStep(4, 15000);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.