Package org.apache.felix.ipojo.api.composite

Examples of org.apache.felix.ipojo.api.composite.CompositeComponentType


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


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

       assertThat("ci is valid", ci.getState(), is(ComponentInstance.VALID));
View Full Code Here

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

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

       assertThat("ci is valid", ci.getState(), is(ComponentInstance.VALID));
View Full Code Here

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

       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()))
           .addService(new ExportedService().setSpecification(Foo.class.getName()));

       ComponentInstance ci = type.createInstance();

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

View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.api.composite.CompositeComponentType

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.