Package org.apache.felix.dm

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


        DependencyManager m = new DependencyManager(context);
        Ensure e = new Ensure();

        Dictionary props = new Hashtable();
        props.put("foo", "bar");
        Component a = m.createComponent()
                .setImplementation(new AImpl(e))
                .setInterface(A.class.getName(), props);
       
        Component b = m.createAdapterService(A.class, null, "add", "change", "remove")
                .setInterface(B.class.getName(), null)
View Full Code Here


       
        Component b = m.createAdapterService(A.class, null, "add", "change", "remove")
                .setInterface(B.class.getName(), null)
                .setImplementation(new BImpl(e));               
       
        Component c = m.createComponent()
                .setImplementation(new CImpl())
                .setInterface(C.class.getName(), null)
                .add(m.createServiceDependency().setService(A.class, "(foo=bar)").setRequired(true));                    
             
        m.add(a);
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
        ResourceConsumer c = new ResourceConsumer(e);
        Component consumer = m.createComponent()
            .setImplementation(c)
            .add(m.createResourceDependency()
                .setFilter("(&(path=/path/to/*.txt)(host=localhost))")
                .setCallbacks("add", "change", "remove"));
        Component dynamicProxyConsumer = m.createComponent()
View Full Code Here

        Component consumer = m.createComponent()
            .setImplementation(c)
            .add(m.createResourceDependency()
                .setFilter("(&(path=/path/to/*.txt)(host=localhost))")
                .setCallbacks("add", "change", "remove"));
        Component dynamicProxyConsumer = m.createComponent()
            .setFactory(new ResourceConsumerFactory(e), "create")
            .add(m.createResourceDependency()
                    .setFilter("(path=*.doc)")
                    .setCallbacks("add", null));
        ResourceProvider provider = new ResourceProvider(e);
View Full Code Here

    public void testExtraDependencyWithAutoConfig() { 
        DependencyManager m = new DependencyManager(context);
        // Helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        // Create a service provider
        Component sp = m.createComponent().setInterface(ProviderInterface.class.getName(), null).setImplementation(ProviderImpl.class);
        // Create a service consumer with a required/autoconfig dependency over the service provider.
        Client c1;
        Component sc1 = m.createComponent().setImplementation((c1 = new Client(e, true, 1)));
        // Create a second service consumer with an optional/autoconfig dependency over the service provider.
        Client c2;
View Full Code Here

        Ensure e = new Ensure();
        // Create a service provider
        Component sp = m.createComponent().setInterface(ProviderInterface.class.getName(), null).setImplementation(ProviderImpl.class);
        // Create a service consumer with a required/autoconfig dependency over the service provider.
        Client c1;
        Component sc1 = m.createComponent().setImplementation((c1 = new Client(e, true, 1)));
        // Create a second service consumer with an optional/autoconfig dependency over the service provider.
        Client c2;
        Component sc2 = m.createComponent().setImplementation(c2 = new Client(e, false, 3));

        // Add service provider and consumer sc1 (required dependency over provider)
View Full Code Here

        // Create a service consumer with a required/autoconfig dependency over the service provider.
        Client c1;
        Component sc1 = m.createComponent().setImplementation((c1 = new Client(e, true, 1)));
        // Create a second service consumer with an optional/autoconfig dependency over the service provider.
        Client c2;
        Component sc2 = m.createComponent().setImplementation(c2 = new Client(e, false, 3));

        // Add service provider and consumer sc1 (required dependency over provider)
        m.add(sc1);
        m.add(sp);
        e.waitForStep(2, 5000);
View Full Code Here

        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
       
        Dictionary s1Properties = new Hashtable();
        s1Properties.put("foo", "bar");
        Component s1 = m.createComponent()
                .setImplementation(new S1Impl(e))
                .setInterface(S1.class.getName(), s1Properties);
       
        Component s1Adapter = m.createAdapterService(S1.class, null, "add", "change", null)
                .setInterface(S2.class.getName(), null)
View Full Code Here

       
        Component s1Adapter = m.createAdapterService(S1.class, null, "add", "change", null)
                .setInterface(S2.class.getName(), null)
                .setImplementation(new S1Adapter(e));
       
        Component s3 = m.createComponent()
                .setImplementation(new S3(e))
                .add(m.createServiceDependency()
                     .setService(S2.class)
                     .setRequired(true)
                     .setCallbacks("add", "change", null));
View Full Code Here

    public void testExtraDependencies() {
        DependencyManager m = new DependencyManager(context);
        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        // create a service consumer and provider
        Component sp1 = m.createComponent().setInterface(MyService1.class.getName(), null).setImplementation(new MyService1Impl());
        Component sc = m.createComponent().setImplementation(new MyClient(e, 1));
       
        // provides the MyService1 service (but not the MyService2, which is required by MyClient).
        m.add(sp1);
        // add MyClient (it should not be invoked in its start() method because MyService2 is not there
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.