Search in sources :

Example 1 with BindParameters

use of org.apache.felix.scr.impl.inject.BindParameters in project felix by apache.

the class DependencyManager method doInvokeBindMethod.

private boolean doInvokeBindMethod(ComponentContextImpl<S> componentContext, final ReferenceMethod bindMethod, RefPair<S, T> refPair, int trackingCount) {
    if (!getServiceObject(componentContext, bindMethod, refPair)) {
        m_componentManager.getLogger().log(LogService.LOG_WARNING, "DependencyManager : invokeBindMethod : Service not available from service registry for ServiceReference {0} for reference {1}", null, refPair.getRef(), getName());
        return false;
    }
    MethodResult result = bindMethod.invoke(componentContext.getImplementationObject(false), new BindParameters(componentContext, refPair), MethodResult.VOID);
    if (result == null) {
        return false;
    }
    m_componentManager.setServiceProperties(result, trackingCount);
    return true;
}
Also used : BindParameters(org.apache.felix.scr.impl.inject.BindParameters) MethodResult(org.apache.felix.scr.impl.inject.MethodResult)

Example 2 with BindParameters

use of org.apache.felix.scr.impl.inject.BindParameters in project felix by apache.

the class BindMethodTest method testMethod.

private void testMethod(final String methodName, final T1 component, final DSVersion dsVersion, final String expectCallPerformed) {
    ComponentContainer container = newContainer();
    SingleComponentManager icm = new SingleComponentManager(container, new ComponentMethodsImpl());
    BindMethod bm = new BindMethod(methodName, component.getClass(), FakeService.class.getName(), dsVersion, false);
    RefPair refPair = new SingleRefPair(m_serviceReference);
    ComponentContextImpl<T1> cc = new ComponentContextImpl(icm, new MockBundle(), null);
    assertTrue(bm.getServiceObject(cc, refPair, m_context, icm));
    BindParameters bp = new BindParameters(cc, refPair);
    bm.invoke(component, bp, null, icm);
    assertEquals(expectCallPerformed, component.callPerformed);
}
Also used : SingleComponentManager(org.apache.felix.scr.impl.manager.SingleComponentManager) ComponentContextImpl(org.apache.felix.scr.impl.manager.ComponentContextImpl) BindMethod(org.apache.felix.scr.impl.inject.BindMethod) RefPair(org.apache.felix.scr.impl.manager.RefPair) SingleRefPair(org.apache.felix.scr.impl.manager.SingleRefPair) BindParameters(org.apache.felix.scr.impl.inject.BindParameters) ComponentContainer(org.apache.felix.scr.impl.manager.ComponentContainer) FakeService(org.apache.felix.scr.impl.manager.components.FakeService) MockBundle(org.apache.felix.scr.impl.MockBundle) T1(org.apache.felix.scr.impl.manager.components.T1) SingleRefPair(org.apache.felix.scr.impl.manager.SingleRefPair)

Aggregations

BindParameters (org.apache.felix.scr.impl.inject.BindParameters)2 MockBundle (org.apache.felix.scr.impl.MockBundle)1 BindMethod (org.apache.felix.scr.impl.inject.BindMethod)1 MethodResult (org.apache.felix.scr.impl.inject.MethodResult)1 ComponentContainer (org.apache.felix.scr.impl.manager.ComponentContainer)1 ComponentContextImpl (org.apache.felix.scr.impl.manager.ComponentContextImpl)1 RefPair (org.apache.felix.scr.impl.manager.RefPair)1 SingleComponentManager (org.apache.felix.scr.impl.manager.SingleComponentManager)1 SingleRefPair (org.apache.felix.scr.impl.manager.SingleRefPair)1 FakeService (org.apache.felix.scr.impl.manager.components.FakeService)1 T1 (org.apache.felix.scr.impl.manager.components.T1)1