Package org.apache.felix.dm

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


        // 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);
        m.remove(s1);
View Full Code Here


        Ensure e = new Ensure();
        // create service providers and consumer
        Component sp1 = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
        Component sp2 = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
        ServiceConsumer sci = new ServiceConsumer(e);
        Component sc = m.createComponent().setImplementation(sci).add(m.createServiceDependency().setService(ServiceInterface.class).setRequired(false).setCallbacks("add", "remove"));
        Component sa2 = m.createAspectService(ServiceInterface.class, null, 20, null).setImplementation(new ServiceAspect(e, 3));
        Component sa1 = m.createAspectService(ServiceInterface.class, null, 10, null).setImplementation(new ServiceAspect(e, 4));
       
        // start with a service consumer
        System.out.println("Adding consumer");
View Full Code Here

         // Helper class that ensures certain steps get executed in sequence
         Ensure e = new Ensure();
         Component c1 = m.createComponent()
                         .setInterface(Service1.class.getName(), null)
                         .setImplementation(new MyComponent1(e))
                         .add(m.createServiceDependency()
                              .setService(Service2.class)
                              .setRequired(true)
                              .setAutoConfig("m_service2"));
        
         Component c2 = m.createComponent()
View Full Code Here

                              .setRequired(true)
                              .setAutoConfig("m_service2"));
        
         Component c2 = m.createComponent()
                         .setImplementation(new MyComponent2(e))
                         .add(m.createServiceDependency()
                              .setService(Service1.class)
                              .setRequired(false)
                              .setAutoConfig(false)
                              .setCallbacks("added", null, null));
             
View Full Code Here

        // Helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        Component c1 = m.createComponent()
                        .setInterface(Service1.class.getName(), null)
                        .setImplementation(new MyComponent1(e))
                        .add(m.createServiceDependency()
                             .setService(Service2.class)
                             .setRequired(true)
                             .setAutoConfig("m_service2"));
       
        Component c2 = m.createComponent()
View Full Code Here

                             .setRequired(true)
                             .setAutoConfig("m_service2"));
       
        Component c2 = m.createComponent()
                        .setImplementation(new MyComponent2(e))
                        .add(m.createServiceDependency()
                             .setService(Service1.class)
                             .setRequired(false)
                             .setAutoConfig(false)
                             .setCallbacks("added", null, null));
            
View Full Code Here

        void init(Component c) {
            m_ensure.step(1);
            DependencyManager dm = c.getDependencyManager();
            List l = new ArrayList();
            // Service3/xx currently available
            l.add(dm.createServiceDependency()
                     .setInstanceBound(true)
                     .setService(Service3.class, "(type=xx)")
                     .setRequired(true)
                     .setAutoConfig("m_service3_xx"));
           
View Full Code Here

                     .setService(Service3.class, "(type=xx)")
                     .setRequired(true)
                     .setAutoConfig("m_service3_xx"));
           
            // Service3/yy not yet available
            l.add(dm.createServiceDependency()
                  .setInstanceBound(true)
                  .setService(Service3.class, "(type=yy)")
                  .setRequired(true)
                  .setAutoConfig("m_service3_yy"));
            c.add(l);
View Full Code Here

        Ensure e = new Ensure();
        // create a service provider and consumer
        Component sp = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
        Component sc = m.createComponent().setImplementation(new ServiceConsumer(e))
                                      .setComposition("getComposition")
                                      .add(m.createServiceDependency().setService(ServiceInterface.class).setRequired(true).setCallbacks("add", null));
        m.add(sp);
        m.add(sc);
        // ensure we executed all steps inside the component instance
        e.step(6);
        m.clear();
View Full Code Here

        DependencyManager m = new DependencyManager(context);
        Ensure e = new Ensure();
        // create a service provider and consumer
        ServiceProvider provider = new ServiceProvider(e);
        Component sp = m.createComponent().setImplementation(provider).setInterface(ServiceInterface2.class.getName(), null);
        Component sc = m.createComponent().setImplementation(new ServiceConsumer()).add(m.createServiceDependency().setService(ServiceInterface2.class).setRequired(true));
        Component sc2 = m.createComponent()
            .setImplementation(new ServiceConsumerNamedInjection())
            .add(m.createServiceDependency().setService(ServiceInterface2.class).setRequired(false).setAutoConfig("m_service"))
            .add(m.createServiceDependency().setService(ServiceInterface2.class).setRequired(false).setAutoConfig("m_service2"))
            .add(m.createServiceDependency().setService(ServiceInterface2.class).setRequired(false).setAutoConfig("m_service3"))
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.