Package org.apache.felix.ipojo.api

Examples of org.apache.felix.ipojo.api.PrimitiveComponentType.createInstance()


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

        ServiceReference[] refs = osgiHelper.getServiceReferences(Factory.class.getName(),
                "(component.providedServiceSpecifications=" + Foo.class.getName() + ")");
        assertThat(refs.length, is(not(0)));
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));
View Full Code Here

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

    }

    @Test
View Full Code Here

    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

    }

    @Test
    public void createAHost() throws Exception {
        PrimitiveComponentType type = createAWhiteboardHost();
        ComponentInstance ci = type.createInstance();
        assertThat(ci.getState(), is(ComponentInstance.VALID));
        HandlerDescription hd = ci.getInstanceDescription().getHandlerDescription(Whiteboard.NAMESPACE + ":" + Whiteboard.NAME);
        assertThat(hd, is(notNullValue()));
    }
View Full Code Here

    }

    @Test
    public void createDoubleHost() throws Exception {
        PrimitiveComponentType type = createASecondWhiteboardHost();
        ComponentInstance ci = type.createInstance();
        assertThat(ci.getState(), is(ComponentInstance.VALID));
        HandlerDescription hd = ci.getInstanceDescription().getHandlerDescription(Whiteboard.NAMESPACE + ":" + Whiteboard.NAME);
        assertThat(hd, is(notNullValue()));
    }
View Full Code Here

    public void createAServiceProvider() throws Exception {
        assertThat(context, is(notNullValue()));
        ComponentInstance ci;

        PrimitiveComponentType type = createAProvider();
        ci = type.createInstance();
        assertThat("Ci is valid", ci.getState(), is(ComponentInstance.VALID));
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(Foo.class
                .getName(), ci.getInstanceName());
        assertThat(ref, is(notNullValue()));
View Full Code Here

    public void killTheFactory() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
        assertThat(context, is(notNullValue()));
        ComponentInstance ci = null;

        PrimitiveComponentType type = createAProvider();
        ci = type.createInstance();
        assertThat("Ci is valid", ci.getState(), is(ComponentInstance.VALID));
        assertThat(ipojoHelper.isServiceAvailableByName(Foo.class.getName(), ci
                .getInstanceName()), is(true));
        type.stop();
        assertThat("Ci is disposed", ci.getState(),
View Full Code Here

    public void createAServiceCons() throws Exception {
        assertThat(context, is(notNullValue()));
        ComponentInstance ci = null;

        PrimitiveComponentType type = createAConsumer();
        ci = type.createInstance();
        assertThat("Ci is invalid", ci.getState(),
                is(ComponentInstance.INVALID));

    }
View Full Code Here

        x.start();

        assertThat(x, is(notNullValue()));
        assertThat(x.getFactory().getState(), is(Factory.VALID));

        ci = x.createInstance();
        ci.start();
        assertThat(ci.getState(), is(ComponentInstance.VALID));

        x.stop();
    }
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.