Search in sources :

Example 6 with BazService

use of org.apache.felix.ipojo.runtime.core.services.BazService in project felix by apache.

the class TestSimpleExport method invoke.

private boolean invoke() {
    ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export1.getInstanceName());
    if (ref == null) {
        return false;
    }
    BazService fs = (BazService) getContext().getService(ref);
    return fs.foo();
}
Also used : BazService(org.apache.felix.ipojo.runtime.core.services.BazService) ServiceReference(org.osgi.framework.ServiceReference)

Example 7 with BazService

use of org.apache.felix.ipojo.runtime.core.services.BazService in project felix by apache.

the class TestFilteredExport method invoke.

private boolean invoke() {
    ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export1.getInstanceName());
    if (ref == null) {
        return false;
    }
    BazService fs = (BazService) getContext().getService(ref);
    return fs.foo();
}
Also used : BazService(org.apache.felix.ipojo.runtime.core.services.BazService) ServiceReference(org.osgi.framework.ServiceReference)

Example 8 with BazService

use of org.apache.felix.ipojo.runtime.core.services.BazService in project felix by apache.

the class TestMultipleExport method invoke.

private boolean invoke(int nb) {
    ServiceReference[] refs = osgiHelper.getServiceReferences(BazService.class.getName(), "(instance.name=" + export3.getInstanceName() + ")");
    if (refs == null) {
        return false;
    }
    if (nb > refs.length) {
        return false;
    }
    for (int i = 0; i < nb; i++) {
        BazService fs = (BazService) getContext().getService(refs[i]);
        getContext().ungetService(refs[i]);
        if (!fs.foo()) {
            return false;
        }
    }
    return true;
}
Also used : BazService(org.apache.felix.ipojo.runtime.core.services.BazService) ServiceReference(org.osgi.framework.ServiceReference)

Example 9 with BazService

use of org.apache.felix.ipojo.runtime.core.services.BazService in project felix by apache.

the class TestOptionalExport method invoke.

private boolean invoke() {
    ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export2.getInstanceName());
    if (ref == null) {
        return false;
    }
    BazService fs = (BazService) getContext().getService(ref);
    return fs.foo();
}
Also used : BazService(org.apache.felix.ipojo.runtime.core.services.BazService) ServiceReference(org.osgi.framework.ServiceReference)

Example 10 with BazService

use of org.apache.felix.ipojo.runtime.core.services.BazService in project felix by apache.

the class TestOptionalMultipleExport method invoke.

private boolean invoke() {
    ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export3.getInstanceName());
    if (ref == null) {
        return false;
    }
    BazService fs = (BazService) getContext().getService(ref);
    getContext().ungetService(ref);
    return fs.foo();
}
Also used : BazService(org.apache.felix.ipojo.runtime.core.services.BazService) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

BazService (org.apache.felix.ipojo.runtime.core.services.BazService)10 ServiceReference (org.osgi.framework.ServiceReference)8 Test (org.junit.Test)3 ComponentInstance (org.apache.felix.ipojo.ComponentInstance)2 Factory (org.apache.felix.ipojo.Factory)2 BaseTest (org.ow2.chameleon.testing.helpers.BaseTest)2 Properties (java.util.Properties)1 FooService (org.apache.felix.ipojo.runtime.core.services.FooService)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1