Package org.apache.felix.ipojo.api

Examples of org.apache.felix.ipojo.api.PrimitiveComponentType


    }

   @Test
   public void createACompositeWithcontainedInstance() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
       // Define the component types
       PrimitiveComponentType prov = createAProvider();
       PrimitiveComponentType cons = createAConsumer();

       CompositeComponentType type = new CompositeComponentType()
           .setBundleContext(context)
           .setComponentTypeName("comp1")
           .addInstance(new Instance(prov.getFactory().getName()))
           .addInstance(new Instance(cons.getFactory().getName()));

       ComponentInstance ci = type.createInstance();

       assertThat("ci is valid", ci.getState(), is(ComponentInstance.VALID));

       // Stop cons
       cons.stop();
       assertThat("ci is invalid", ci.getState(), is(ComponentInstance.INVALID));

       // Restart cons
       cons.start();
       assertThat("ci is valid - 2", ci.getState(), is(ComponentInstance.VALID));

   }
View Full Code Here


   }

   @Test
   public void createACompositeWithAnInstantiatedService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
       // Define the component types
       PrimitiveComponentType prov = createAProvider();
       prov.start();
       PrimitiveComponentType cons = createAConsumer();

       ServiceReference[] refs = osgi.getServiceReferences(Factory.class.getName(),
               "(component.providedServiceSpecifications=" + Foo.class.getName() +")");
       assertThat(refs.length, is(not(0)));

       Factory factory = (Factory) osgi.getServiceObject(refs[0]);
       System.out.println(factory.getComponentDescription().getDescription());

       CompositeComponentType type = new CompositeComponentType()
           .setBundleContext(context)
           .setComponentTypeName("comp2")
           .addSubService(new InstantiatedService().setSpecification(Foo.class.getName()))
           .addInstance(new Instance(cons.getFactory().getName()));

       ComponentInstance ci = type.createInstance();

       System.out.println(ci.getInstanceDescription().getDescription());
View Full Code Here

   }

   @Test
   public void createACompositeWithAnOptionalInstantiatedService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
       // Define the component types
       PrimitiveComponentType prov = createAProvider();
       prov.start();

       CompositeComponentType type = new CompositeComponentType()
           .setBundleContext(context)
           .setComponentTypeName("comp3")
           .addSubService(new InstantiatedService().setSpecification(Foo.class.getName()).setOptional(true));

       ComponentInstance ci = type.createInstance();

       assertThat("ci is valid", ci.getState(), is(ComponentInstance.VALID));

       // Stop prov
       prov.stop();
       assertThat("ci is valid - 1", ci.getState(), is(ComponentInstance.VALID));

       // Restart prov
       prov.start();
       assertThat("ci is valid - 2", ci.getState(), is(ComponentInstance.VALID));

   }
View Full Code Here

   }

   @Test
   public void createACompositeWithAnImportedService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
       // Define the component types
       PrimitiveComponentType prov = createAProvider();
       prov.createInstance();
       PrimitiveComponentType cons = createAConsumer();

       ServiceReference[] refs = osgi.getServiceReferences(Factory.class.getName(),
               "(component.providedServiceSpecifications=" + Foo.class.getName() +")");
       assertThat(refs.length, is(not(0)));

       CompositeComponentType type = new CompositeComponentType()
           .setBundleContext(context)
           .setComponentTypeName("comp2")
           .addSubService(new ImportedService().setSpecification(Foo.class.getName()))
           .addInstance(new Instance(cons.getFactory().getName()));

       ComponentInstance ci = type.createInstance();

       System.out.println(ci.getInstanceDescription().getDescription());
View Full Code Here

   }

   @Test
   public void createACompositeWithAnOptionalImportedService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
       // Define the component types
       PrimitiveComponentType prov = createAProvider();
       prov.createInstance();

       CompositeComponentType type = new CompositeComponentType()
           .setBundleContext(context)
           .setComponentTypeName("comp3")
           .addSubService(new ImportedService().setSpecification(Foo.class.getName()).setOptional(true));

       ComponentInstance ci = type.createInstance();

       assertThat("ci is valid", ci.getState(), is(ComponentInstance.VALID));

       // Stop prov
       prov.stop();
       assertThat("ci is valid - 1", ci.getState(), is(ComponentInstance.VALID));

       // Restart prov
       prov.start();
       prov.createInstance();
       assertThat("ci is valid - 2", ci.getState(), is(ComponentInstance.VALID));

   }
View Full Code Here

   }

   @Test
   public void createACompositeWithExportingAService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
       // Define the component types
       PrimitiveComponentType prov = createAProvider();
       prov.start();
       PrimitiveComponentType cons = createAConsumer();
       ComponentInstance c = cons.createInstance();

         CompositeComponentType type = new CompositeComponentType()
           .setBundleContext(context)
           .setComponentTypeName("compExport")
           .addSubService(new InstantiatedService().setSpecification(Foo.class.getName()))
View Full Code Here


   }

    private PrimitiveComponentType createAProvider() {
        return new PrimitiveComponentType()
        .setBundleContext(context)
        .setClassName(FooImpl.class.getName())
        .setPublic(true)
        .addService(new Service()); // Provide the FooService
    }
View Full Code Here

        .setPublic(true)
        .addService(new Service()); // Provide the FooService
    }

    private PrimitiveComponentType createAConsumer() {
        return new PrimitiveComponentType()
        .setBundleContext(context)
        .setClassName(org.example.service.impl.MyComponentImpl.class.getName())
        .addDependency(new Dependency().setField("myFoo"))
        .setValidateMethod("start");
    }
View Full Code Here

        assertThat("cons is valid", cons.getState(), is(ComponentInstance.VALID));

    }

    private SingletonComponentType createAProvider() {
        PrimitiveComponentType type =  new SingletonComponentType()
        .setBundleContext(context)
        .setClassName(FooImpl.class.getName())
        .addService(new Service()); // Provide the FooService

        return (SingletonComponentType) type;
View Full Code Here

        return (SingletonComponentType) type;
    }

    private SingletonComponentType createAConsumer() {
        PrimitiveComponentType type =  new SingletonComponentType()
        .setBundleContext(context)
        .setClassName(org.example.service.impl.MyComponentImpl.class.getName())
        .addDependency(new Dependency().setField("myFoo"))
        .setValidateMethod("start");
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.api.PrimitiveComponentType

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.