/** * Creates a new configuration dependency. * * @return the configuration dependency */ public ConfigurationDependency createConfigurationDependency() { return m_manager.createConfigurationDependency(); }
public ConfigurationDependencyImpl(DependencyManager dm) { org.apache.felix.dm.DependencyManager dmDelegate = (org.apache.felix.dm.DependencyManager) dm.getDelegate(); m_delegate = dmDelegate.createConfigurationDependency(); }
@Override public ConfigurationDependency build() { String pid = m_pid == null ? (m_configType != null ? m_configType.getName() : null) : m_pid; if (pid == null) { throw new IllegalStateException("Pid not specified"); } ConfigurationDependency dep = m_component.getDependencyManager().createConfigurationDependency(); Objects.nonNull(m_pid); dep.setPid(pid); dep.setPropagate(m_propagate); dep.setRequired(m_required); if (m_updateMethodName != null) { dep.setCallback(m_updateCallbackInstance, m_updateMethodName, m_configType); } else if (m_refs.size() > 0) { // setup an internal callback object. When config is updated, we have to call each registered // method references. // Notice that we need the component to be instantiated in case there is a mref on one of the component instances (unbound method ref), or is used // called "needsInstance(true)". dep.setCallback(new Object() { @SuppressWarnings("unused") void updated(Component comp, Dictionary<String, Object> props) { m_refs.forEach(mref -> mref.accept(null, comp, props)); } }, "updated", m_hasComponentCallbackRefs); } return dep; }
private Dependency createConfigurationDependency(DependencyManager dm, Bundle b, String pid, String callback, String[] configTypes, boolean propagate, boolean required) throws ClassNotFoundException { if (pid == null) { throw new IllegalArgumentException( "pid attribute not provided in ConfigurationDependency declaration"); } ConfigurationDependency cd = dm.createConfigurationDependency(); cd.setPid(pid); cd.setCallback(callback); cd.setPropagate(propagate, true /* configuration will override default service properties */); cd.setRequired(required); if (configTypes != null) { Class<?>[] configTypeClasses = new Class<?>[configTypes.length]; for (int i = 0; i < configTypes.length; i ++) { configTypeClasses[i] = b.loadClass(configTypes[i]); } cd.setConfigType(configTypeClasses); } return cd; }