/** * Creates a new factory configuration adapter service. * * @return the factory configuration adapter service * @deprecated use {@link DependencyActivatorBase#createFactoryComponent()} */ public Component createFactoryConfigurationAdapterService(String factoryPid, String update, boolean propagate) { return m_manager.createFactoryConfigurationAdapterService(factoryPid, update, propagate); }
/** * Creates a new factory configuration adapter service, using a specific callback instance * * @return the factory configuration adapter service * @deprecated use {@link DependencyActivatorBase#createFactoryComponent()} */ public Component createFactoryConfigurationAdapterService(String factoryPid, String update, boolean propagate, Object callbackInstance) { return m_manager.createFactoryConfigurationAdapterService(factoryPid, update, propagate, callbackInstance); }
/** * Creates a new factory configuration adapter service, using a specific callback instance * * @return the factory configuration adapter service * @see DependencyManager#createFactoryConfigurationAdapterService(String, String, boolean, Class) * @deprecated use {@link DependencyActivatorBase#createFactoryComponent()} */ public Component createFactoryConfigurationAdapterService(String factoryPid, String update, boolean propagate, Class<?> configType) { return m_manager.createFactoryConfigurationAdapterService(factoryPid, update, propagate, configType); }
/** * Creates a new factory configuration adapter service, using a specific callback instance * * @return the factory configuration adapter service * @see DependencyManager#createFactoryConfigurationAdapterService(String, String, boolean, Object, Class) * @deprecated use {@link DependencyActivatorBase#createFactoryComponent()} */ public Component createFactoryConfigurationAdapterService(String factoryPid, String update, boolean propagate, Object callbackInstance, Class<?> configType) { return m_manager.createFactoryConfigurationAdapterService(factoryPid, update, propagate, callbackInstance, configType); }
@Override public Component build() { Objects.nonNull(m_factoryPid); Component c = null; if (m_hasMethodRefs) { Object wrapCallback = new Object() { @SuppressWarnings("unused") public void updated(Component comp, Dictionary<String, Object> conf) { m_refs.forEach(mref -> mref.accept(null, comp, conf)); } }; c = m_dm.createFactoryConfigurationAdapterService(m_factoryPid, "updated", m_propagate, wrapCallback); } else { c = m_dm.createFactoryConfigurationAdapterService(m_factoryPid, m_updateMethodName, m_propagate, m_updateCallbackInstance, m_configType); } ComponentBuilderImpl cb = new ComponentBuilderImpl(c, false); m_compBuilder.accept (cb); return cb.build(); }
private FactoryConfigurationAdapterImpl createConfigurationDependency(Object service, Class<?> configType) { BundleContext bc = mock(BundleContext.class); DependencyManager dm = new DependencyManager(bc); Component result = dm.createFactoryConfigurationAdapterService("does.not.matter", "updated", false, service, configType); // Normally, when creating a factory pid adapter, you specify the class of the adapter implementation which will be instantiated // for each created factory pid. To do so, you invoke the setImplementation(Object impl) method, and this methods // accepts a class parameter, or an object instance. Usually, you always pass a class, because the intent of a factory pid adapter is to // create a component instance for each created factory pid. But in our case, the "service" parameter represents our adapter instance, // so just use it as the factory adapter implementation instance: result.setImplementation(service); // *Important note:* the semantic of the factory conf pid adapter is really similar to a ManagedServiceFactory: // - when the factory pid is created, a component is created; called in updated; and called in start(). // - when the factory pid is updated, the component is called in updated(). // - but when the factory pid is removed, updated(null) is not invoked (unlike in case of ConfigurationDependency), and the component is simply // stopped. This is actually the same semantic as ManagedServiceFactory: when factory pid is removed, ManagedServiceFactory.deleted() is called // and the deleted() method is assumed to stop and unregister the service that was registered for the pid being removed. dm.add(result); return (FactoryConfigurationAdapterImpl) result; }