Package org.apache.felix.ipojo.api

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


        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


        context = getContext();
    }

    @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

        assertThat(hd, is(notNullValue()));
    }

    @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

        HandlerDescription hd = ci.getInstanceDescription().getHandlerDescription(Whiteboard.NAMESPACE + ":" + Whiteboard.NAME);
        assertThat(hd, is(notNullValue()));
    }

    private PrimitiveComponentType createAWhiteboardHost() {
        return new PrimitiveComponentType()
                .setBundleContext(context)
                .setClassName(HostImpl.class.getName())
                .addHandler(new Whiteboard()
                        .onArrival("arrival")
                        .onDeparture("departure")
View Full Code Here

                        .setFilter("(foo=foo)")
                );
    }

    private PrimitiveComponentType createASecondWhiteboardHost() {
        return new PrimitiveComponentType()
                .setBundleContext(context)
                .setClassName(HostImpl.class.getName())
                .addHandler(new Whiteboard()
                        .onArrival("arrival")
                        .onDeparture("departure")
View Full Code Here

    @Test
    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

    @Test
    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(),
                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;

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

    }
View Full Code Here

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

        PrimitiveComponentType x= new PrimitiveComponentType()
                .setBundleContext(context)
                .setClassName(PlainHelloImpl.class.getName())
                .setValidateMethod("start")
                .setInvalidateMethod("stop");

        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

        x.stop();
    }

    private PrimitiveComponentType createAProvider() {
        return new PrimitiveComponentType()
                .setBundleContext(context)
                .setClassName(FooImpl.class.getName())
                .addService(new Service()); // Provide the FooService
    }
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.