[ https://issues.apache.org/jira/browse/IGNITE-15409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17420622#comment-17420622 ]
Ivan Bessonov commented on IGNITE-15409: ---------------------------------------- Looks good, thanks a lot for the improvements! Merged to main branch > Configuration registry: register listener with any placeholder on > NamedConfigurationTree > ---------------------------------------------------------------------------------------- > > Key: IGNITE-15409 > URL: https://issues.apache.org/jira/browse/IGNITE-15409 > Project: Ignite > Issue Type: Improvement > Reporter: Alexander Lapin > Assignee: Kirill Tkalenko > Priority: Major > Labels: iep-55, ignite-3 > Fix For: 3.0.0-alpha3 > > Time Spent: 3h > Remaining Estimate: 0h > > Ability to add listeners with "any()" placeholder will ease the logic of > registering ones. > Let's say that we want to listen to a changes of a column type within any > column of any table. Now the only option is to register type listeners from > within column listeners within table listeners: > {code:java} > clusterCfgMgr.configurationRegistry().getConfiguration(TablesConfiguration.KEY).tables().listenElements( > new ConfigurationNamedListListener<TableView>() { > @Override > public @NotNull CompletableFuture<?> onCreate(@NotNull > ConfigurationNotificationEvent<TableView> tblCtx) { > > clusterCfgMgr.configurationRegistry().getConfiguration(TablesConfiguration.KEY).tables(). > get(tblCtx.newValue().name()).columns().listenElements( > new ConfigurationNamedListListener<ColumnView>() { > @Override public @NotNull CompletableFuture<?> onCreate( > @NotNull ConfigurationNotificationEvent<ColumnView> > columnCtx) { > > clusterCfgMgr.configurationRegistry().getConfiguration(TablesConfiguration.KEY).tables(). > > get(tblCtx.newValue().name()).columns().get(columnCtx.newValue().name()).listen((typeCtx) > -> null); > return CompletableFuture.completedFuture(null); > } > }); > return CompletableFuture.completedFuture(null); > } > {code} > With any placeholder it will look like much simpler: > {code:java} > clusterCfgMgr.configurationRegistry().getConfiguration(TablesConfiguration.KEY).tables().any().columns(). > any().type().listen(ctx -> null); > {code} > Besides obvious there are at least two important points here: > * It should be possible to retrieve full context/"full configuration > locator" from the listener's context. In this particular case, > _type().listen(ctx -> null)_ should provide context of the table and the > column that were changed. > * It should be possible to remove such "any" listeners. -- This message was sent by Atlassian Jira (v8.3.4#803005)