@Test public void testAddConfig() { assertThat(configService.getSubjectFactory(String.class), nullValue()); assertThat(configService.getSubjectFactory("key"), nullValue()); registry.registerConfigFactory(config1Factory); registry.registerConfigFactory(config2Factory); configService.addConfig("configKey", BasicConfig1.class); Config newConfig = configService.getConfig("configKey", BasicConfig1.class); assertThat(newConfig, notNullValue()); assertThat(configService.getSubjectFactory(String.class), notNullValue()); assertThat(configService.getSubjectFactory("key1"), notNullValue()); Set<Class> classes = configService.getSubjectClasses(); assertThat(classes, hasSize(1)); Set<String> subjectsForClass = configService.getSubjects(String.class); assertThat(subjectsForClass, hasSize(1)); Set<String> subjectsForConfig = configService.getSubjects(String.class, BasicConfig1.class); assertThat(subjectsForConfig, hasSize(1)); Class queriedConfigClass = configService.getConfigClass("key1", "config1"); assertThat(queriedConfigClass == BasicConfig1.class, is(true)); Set<? extends Config> configs = configService.getConfigs("configKey"); assertThat(configs.size(), is(1)); configs.forEach(c -> assertThat(c, instanceOf(BasicConfig1.class))); configService.removeConfig("configKey", BasicConfig1.class); Config newConfigAfterRemove = configService.getConfig("configKey", BasicConfig1.class); assertThat(newConfigAfterRemove, nullValue()); }
@Override public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) { checkPermission(CONFIG_WRITE); checkNotNull(subject, NULL_SUBJECT_MSG); checkNotNull(configClass, NULL_CCLASS_MSG); return store.createConfig(subject, configClass); }
NetworkConfigManager extends AbstractListenerManager<NetworkConfigEvent, NetworkConfigListener> implements NetworkConfigRegistry, NetworkConfigService { @Override public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) { checkPermission(CONFIG_WRITE); checkNotNull(subject, NULL_SUBJECT_MSG); checkNotNull(configClass, NULL_CCLASS_MSG); return store.createConfig(subject, configClass); } }
NetworkConfigManager extends AbstractListenerManager<NetworkConfigEvent, NetworkConfigListener> implements NetworkConfigRegistry, NetworkConfigService { @Override public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) { checkPermission(CONFIG_WRITE); checkNotNull(subject, NULL_SUBJECT_MSG); checkNotNull(configClass, NULL_CCLASS_MSG); return store.createConfig(subject, configClass); }  }
NetworkConfigManager extends AbstractListenerManager<NetworkConfigEvent, NetworkConfigListener> implements NetworkConfigRegistry, NetworkConfigService { @Override public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) { checkPermission(CONFIG_WRITE); checkNotNull(subject, NULL_SUBJECT_MSG); checkNotNull(configClass, NULL_CCLASS_MSG); return store.createConfig(subject, configClass); }  @Activate void activate(); @Deactivate void deactivate(); @Override @SuppressWarnings("unchecked") void registerConfigFactory(ConfigFactory configFactory); @Override void unregisterConfigFactory(ConfigFactory configFactory); @Override Set<ConfigFactory> getConfigFactories(); @Override @SuppressWarnings("unchecked") Set<ConfigFactory<S, C>> getConfigFactories(Class<S> subjectClass); @Override ConfigFactory<S, C> getConfigFactory(Class<C> configClass); @Override Set<Class> getSubjectClasses(); @Override SubjectFactory getSubjectFactory(String subjectClassKey); @Override SubjectFactory getSubjectFactory(Class subjectClass); @Override Class<? extends Config> getConfigClass(String subjectClassKey, String configKey); @Override Set<S> getSubjects(Class<S> subjectClass); @Override Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass); @Override Set<Config<S>> getConfigs(S subject); @Override C getConfig(S subject, Class<C> configClass); @Override C addConfig(S subject, Class<C> configClass); @Override C applyConfig(S subject, Class<C> configClass, JsonNode json); @Override @SuppressWarnings("unchecked") C applyConfig(String subjectClassKey, S subject,
                                                  String configKey, JsonNode json); @Override void removeConfig(S subject, Class<C> configClass); @Override void removeConfig(String subjectClassKey, S subject, String configKey); @Override void removeConfig(S subject); @Override void removeConfig(); }
NetworkConfigManager extends AbstractListenerManager<NetworkConfigEvent, NetworkConfigListener> implements NetworkConfigRegistry, NetworkConfigService { @Override public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) { checkPermission(CONFIG_WRITE); checkNotNull(subject, NULL_SUBJECT_MSG); checkNotNull(configClass, NULL_CCLASS_MSG); return store.createConfig(subject, configClass); }  @Activate void activate(); @Deactivate void deactivate(); @Override @SuppressWarnings("unchecked") void registerConfigFactory(ConfigFactory configFactory); @Override void unregisterConfigFactory(ConfigFactory configFactory); @Override Set<ConfigFactory> getConfigFactories(); @Override @SuppressWarnings("unchecked") Set<ConfigFactory<S, C>> getConfigFactories(Class<S> subjectClass); @Override ConfigFactory<S, C> getConfigFactory(Class<C> configClass); @Override Set<Class> getSubjectClasses(); @Override SubjectFactory getSubjectFactory(String subjectClassKey); @Override SubjectFactory getSubjectFactory(Class subjectClass); @Override Class<? extends Config> getConfigClass(String subjectClassKey, String configKey); @Override Set<S> getSubjects(Class<S> subjectClass); @Override Set<S> getSubjects(Class<S> subjectClass, Class<C> configClass); @Override Set<Config<S>> getConfigs(S subject); @Override C getConfig(S subject, Class<C> configClass); @Override C addConfig(S subject, Class<C> configClass); @Override C applyConfig(S subject, Class<C> configClass, JsonNode json); @Override @SuppressWarnings("unchecked") C applyConfig(String subjectClassKey, S subject,
                                                  String configKey, JsonNode json); @Override void removeConfig(S subject, Class<C> configClass); @Override void removeConfig(String subjectClassKey, S subject, String configKey); @Override void removeConfig(S subject); @Override void removeConfig();  }