Package org.apache.felix.dm

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


       // 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 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);
View Full Code Here


        DependencyManager m = new DependencyManager(context);
        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
       
        // create two service providers, each providing a different service interface
        Component sp1 = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
        Component sp2 = m.createComponent().setImplementation(new ServiceProvider2(e)).setInterface(ServiceInterface2.class.getName(), null);
       
        // create a dynamic proxy based aspect and hook it up to both services
        Component a1 = m.createAspectService(ServiceInterface.class, null, 10, "m_service")
            .setFactory(new Factory(e, ServiceInterface.class, "ServiceInterfaceProxy"), "create");
View Full Code Here

        // helper class that ensures certain steps get executed in sequence
        Ensure e = new Ensure();
       
        // create two service providers, each providing a different service interface
        Component sp1 = m.createComponent().setImplementation(new ServiceProvider(e)).setInterface(ServiceInterface.class.getName(), null);
        Component sp2 = m.createComponent().setImplementation(new ServiceProvider2(e)).setInterface(ServiceInterface2.class.getName(), null);
       
        // create a dynamic proxy based aspect and hook it up to both services
        Component a1 = m.createAspectService(ServiceInterface.class, null, 10, "m_service")
            .setFactory(new Factory(e, ServiceInterface.class, "ServiceInterfaceProxy"), "create");
        Component a2 = m.createAspectService(ServiceInterface2.class, null, 10, "m_service")
View Full Code Here

        Component a2 = m.createAspectService(ServiceInterface2.class, null, 10, "m_service")
            .setFactory(new Factory(e, ServiceInterface2.class, "ServiceInterfaceProxy2"), "create");

        // 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))
            ;
       
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

        m_invokeStep = new Ensure();
       
        // Create our original "S" service.
        Dictionary props = new Hashtable();
        props.put("foo", "bar");
        Component s = m.createComponent()
                .setImplementation(new SImpl())
                .setInterface(S.class.getName(), props);
       
        // Create some "S" aspects
        Component[] aspects = new Component[ASPECTS];
View Full Code Here

                .setInterface(S2.class.getName(), null)
                .setImplementation(new S2Impl());
       
        // 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")                    
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
        Component provider = m.createComponent()
            .setImplementation(new ServiceProvider())
            .setInterface(OriginalService.class.getName(), null);

        // create a adapter on the provider
        Component adapter = m.createAdapterService(OriginalService.class, null)
View Full Code Here

        Component adapter = m.createAdapterService(OriginalService.class, null)
        .setInterface(AdaptedService.class.getName(), null)
        .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

   public void testMultipleServiceRegistrationAndConsumption() {
       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 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);
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.