Package org.apache.felix.dm

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


            l.add(m_d1 = m.createServiceDependency()
                    .setService(Sequencer.class)
                    .setRequired(true)
                    .setInstanceBound(true)
                    .setAutoConfig("m_sequencer"));
            l.add(m_d2 = m.createServiceDependency()
                    .setService(ServiceProvider2.class)
                    .setRequired(true)
                    .setInstanceBound(true)
                    .setCallbacks("bind", "unbind"));
            c.add(l);
View Full Code Here


        {
            System.out.println("ServiceProvider2.init");
            DependencyManager m = c.getDependencyManager();
            List<ServiceDependency> l = new ArrayList<ServiceDependency>();
           
            l.add(m_d1 = m.createServiceDependency()
                  .setService(Runnable.class, "(foo=bar)")
                  .setRequired(false)
                  .setInstanceBound(true)
                  .setAutoConfig("m_runnable"));
            l.add(m_d2 = m.createServiceDependency()
View Full Code Here

            l.add(m_d1 = m.createServiceDependency()
                  .setService(Runnable.class, "(foo=bar)")
                  .setRequired(false)
                  .setInstanceBound(true)
                  .setAutoConfig("m_runnable"));
            l.add(m_d2 = m.createServiceDependency()
                  .setService(Sequencer.class)
                  .setRequired(true)
                  .setInstanceBound(true)
                  .setCallbacks("bind", null));
            c.add(l);
View Full Code Here

       Ensure e = new Ensure();
       // create a service provider and consumer
       Component provider = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
       Component provider2 = m.createComponent().setImplementation(new ServiceProvider2(e)).setInterface(ServiceInterface.class.getName(), null);
       Component consumer = m.createComponent().setImplementation(new ServiceConsumer(e))
         .add(m.createServiceDependency()
              .setService(ServiceInterface.class)
              .setRequired(true)
              .setCallbacks("add", "remove"));
       m.add(provider2);
       m.add(consumer);
View Full Code Here

        // create a client that invokes a method on boths services, validate that it goes
        // through the proxy twice
        Component sc = m.createComponent()
            .setImplementation(new ServiceConsumer(e))
            .add(m.createServiceDependency().setService(ServiceInterface.class).setRequired(true))
            .add(m.createServiceDependency().setService(ServiceInterface2.class).setRequired(true))
            ;
       
        // register both producers, validate that both services are started
        m.add(sp1);
View Full Code Here

        // create a client that invokes a method on boths services, validate that it goes
        // through the proxy twice
        Component sc = m.createComponent()
            .setImplementation(new ServiceConsumer(e))
            .add(m.createServiceDependency().setService(ServiceInterface.class).setRequired(true))
            .add(m.createServiceDependency().setService(ServiceInterface2.class).setRequired(true))
            ;
       
        // register both producers, validate that both services are started
        m.add(sp1);
        e.waitForStep(1, 2000);
View Full Code Here

        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        // create a resource provider
        ResourceProvider provider = new ResourceProvider(e);
        // activate it
        m.add(m.createComponent().setImplementation(provider).add(m.createServiceDependency().setService(ResourceHandler.class).setCallbacks("add", "remove")));
        // create a resource adapter for our single resource
        // 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
        m.add(m.createResourceAdapterService("(&(path=/path/to/*.txt)(host=localhost))", false, null, "changed")
              .setImplementation(new ResourceAdapter(e)));
View Full Code Here

       
        // Create Client2, which depends on "S2" service.
        Client2 client2Impl;
        Component client2 = m.createComponent()
                .setImplementation((client2Impl = new Client2()))
                .add(m.createServiceDependency()
                     .setService(S2.class)
                     .setRequired(true)
                     .setDebug("client")                    
                     .setCallbacks("add", "change", "remove"));
             
View Full Code Here

        .setImplementation(ServiceAdapter.class);
       
        // create a consumer for the adapted service
        Component consumer = m.createComponent()
            .setImplementation(new ServiceConsumer(e))
            .add(m.createServiceDependency()
                .setService(AdaptedService.class)
                .setCallbacks("add", "remove")
                .setRequired(true)
            );
       
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 provider = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
       Component providerWithHighRank = m.createComponent().setImplementation(new ServiceProvider2(e)).setInterface(ServiceInterface.class.getName(), new Properties() {{ put(Constants.SERVICE_RANKING, Integer.valueOf(5)); }});
       Component consumer = m.createComponent().setImplementation(new ServiceConsumer(e)).add(m.createServiceDependency().setService(ServiceInterface.class).setRequired(true));
       m.add(provider);
       m.add(providerWithHighRank);
       m.add(consumer);
       e.waitForStep(3, 15000);
       m.remove(providerWithHighRank);
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.