Package org.apache.felix.dm

Examples of org.apache.felix.dm.Component


    public void testDynamicComponentStateListingLifeCycle() {
        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()
            .setInterface(MyInterface.class.getName(), null)
            .setImplementation(new DynamicComponentStateListeningInstance(e));
        // 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


    public void testDynamicComponentStateListingLifeCycle2() {
        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()
            .setInterface(MyInterface.class.getName(), null)
            .setImplementation(new DynamicComponentStateListeningInstance2(e));
        // 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();
       
        Component shellClient = m.createComponent()
            .setImplementation(new ShellClient(e))
            .add(m.createServiceDependency()
                .setService(CommandProcessor.class)
                .setRequired(true)
            );
        m.add(shellClient);
        e.waitForStep(3, 5000);
        // now create a component with a missing dependency
        Component missing = m.createComponent()
            .setImplementation(new Object() { public String toString() { return "Object"; }})
            .add(m.createServiceDependency()
                .setService(Object.class)
                .setRequired(true)
            );
View Full Code Here

        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)
                .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()
            .setFactory(new ResourceConsumerFactory(e), "create")
            .add(m.createResourceDependency()
                    .setFilter("(path=*.doc)")
                    .setCallbacks("add", null));
        ResourceProvider provider = new ResourceProvider(e);
        Component resourceProvider = m.createComponent()
            .setImplementation(provider)
            .add(m.createServiceDependency()
                .setService(ResourceHandler.class)
                .setCallbacks("add", "remove"));
       
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;
        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)
                .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
        m.add(sc);
View Full Code Here

        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
        // create a provider
        Provider provider = new Provider();
        // activate it
        Component p = m.createComponent()
            .setInterface(Service.class.getName(), null)
            .setImplementation(provider);
       
        Consumer consumer = new Consumer(e);
        Component c = m.createComponent()
            .setImplementation(consumer)
            .add(m.createServiceDependency()
                .setService(Service.class)
                .setRequired(true)
                );
View Full Code Here

   public void testAbstractClassDependency() {
       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 sp = m.createComponent()
           .setInterface(ServiceAbstract.class.getName(), null)
           .setImplementation(new ServiceProvider(e))
           ;
       Component sc = m.createComponent()
           .setImplementation(new ServiceConsumer(e))
           .add(m.createServiceDependency()
               .setService(ServiceAbstract.class)
               .setRequired(true)
               .setCallbacks("bind", "unbind")
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.