Package org.apache.felix.ipojo.api

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


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

        SingletonComponentType type = createAProvider();
        ci = type.create();
        assertThat("Ci is valid", ci.getState(), is(ComponentInstance.VALID));
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(Foo.class
                .getName(), ci.getInstanceName());
        assertThat(ref, is(notNullValue()));
        type.disposeInstance(ci);

    }
View Full Code Here


    @Test
    public void killTheFactory() throws Exception {
        assertThat(context, is(notNullValue()));
        ComponentInstance ci = null;
        SingletonComponentType type = createAProvider();
        ci = type.create();
        assertThat("Ci is valid", ci.getState(), is(ComponentInstance.VALID));
        ServiceReference ref = ipojoHelper.getServiceReferenceByName(Foo.class
                .getName(), ci.getInstanceName());
        assertThat(ref, is(notNullValue()));
        type.stop();
        assertThat("Ci is disposed", ci.getState(),
                is(ComponentInstance.DISPOSED));
        assertThat(ipojoHelper.isServiceAvailableByName(Foo.class.getName(), ci
                .getInstanceName()), is(false));
    }
View Full Code Here

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

        SingletonComponentType type = createAConsumer();
        ci = type.create();
        assertThat("Ci is invalid", ci.getState(),
                is(ComponentInstance.INVALID));
        type.stop();
    }
View Full Code Here

        type.stop();
    }

    @Test
    public void createBoth() throws Exception {
        SingletonComponentType consFactory = createAConsumer();
        ComponentInstance cons = consFactory.create();
        // cons is invalid
        assertThat("cons is invalid", cons.getState(), is(ComponentInstance.INVALID));

        SingletonComponentType provFactory = createAProvider();
        ComponentInstance prov = provFactory.create();
        assertThat("prov is valid", prov.getState(), is(ComponentInstance.VALID));
        assertThat("cons is valid", cons.getState(), is(ComponentInstance.VALID));
        consFactory.stop();
        provFactory.stop();
    }
View Full Code Here

        provFactory.stop();
    }

    @Test
    public void createTwoCons() throws Exception {
        SingletonComponentType consFactory = createAConsumer();
        ComponentInstance cons1 = createAConsumer().create();
        // cons is invalid
        assertThat("cons is invalid", cons1.getState(), is(ComponentInstance.INVALID));

        ComponentInstance prov = createAProvider().create();
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(MyComponentImpl.class.getName())
                .setComponentTypeName("singleton.cons")
                .addDependency(new Dependency().setField("myFoo"))
                .setValidateMethod("start");
View Full Code Here

        return (SingletonComponentType) type;
    }

    private SingletonComponentType createAnOptionalConsumer() {
        PrimitiveComponentType type = new SingletonComponentType()
                .setBundleContext(context)
                .setClassName(MyComponentImpl.class.getName())
                .addDependency(new Dependency().setField("myFoo").setOptional(true))
                .setComponentTypeName("singleton.optional.consumer")
                .setValidateMethod("start");
View Full Code Here

                .setClassName(FooImpl.class.getName())
                .addService(new Service()); // Provide the FooService
    }

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

                .addDependency(new Dependency().setField("myFoo"))
                .setValidateMethod("start");
    }

    private PrimitiveComponentType createAnOptionalConsumer() {
        return new SingletonComponentType()
                .setBundleContext(context)
                .setComponentTypeName("cons.optional")
                .setClassName(MyComponentImpl.class.getName())
                .addDependency(new Dependency().setField("myFoo").setOptional(true))
                .setValidateMethod("start");
View Full Code Here

TOP

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

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.