/** * Unregister a {@link DataChangedNotifier} previously registered by * {@link #registerDataChangedNotifier(DataChangedNotifier)} * * @param notifier the DataChangedNotifier to unregister */ public void unregisterDataChangedNotifier(DataChangedNotifier<?> notifier) { if (notifier == null) { return; } synchronized (notifiersLock) { Collection<SqlTable<?>> tables = notifier.whichTables(); if (tables == null || tables.isEmpty()) { globalNotifiers.remove(notifier); } else { for (SqlTable<?> table : tables) { List<DataChangedNotifier<?>> notifiersForTable = tableNotifiers.get(table); if (notifiersForTable != null) { notifiersForTable.remove(notifier); } } } } }
/** * Register a {@link DataChangedNotifier} to listen for database changes. The DataChangedNotifier object will be * notified whenever a table it is interested is modified, and can accumulate a set of notifications to send when * the current transaction or statement completes successfully. * * @param notifier the DataChangedNotifier to register */ public void registerDataChangedNotifier(DataChangedNotifier<?> notifier) { if (notifier == null) { return; } synchronized (notifiersLock) { Collection<SqlTable<?>> tables = notifier.whichTables(); if (tables == null || tables.isEmpty()) { globalNotifiers.add(notifier); } else { for (SqlTable<?> table : tables) { List<DataChangedNotifier<?>> notifiersForTable = tableNotifiers.get(table); if (notifiersForTable == null) { notifiersForTable = new ArrayList<>(); tableNotifiers.put(table, notifiersForTable); } notifiersForTable.add(notifier); } } } }
private void testNotifierConstructorsInternal(DataChangedNotifier<?> notifier, SqlTable<?>... tables) { Set<SqlTable<?>> whichTables = notifier.whichTables(); assertEquals(tables.length, whichTables.size()); assertTrue(whichTables.containsAll(Arrays.asList(tables))); }
/** * Unregister a {@link DataChangedNotifier} previously registered by * {@link #registerDataChangedNotifier(DataChangedNotifier)} * * @param notifier the DataChangedNotifier to unregister */ public void unregisterDataChangedNotifier(DataChangedNotifier<?> notifier) { if (notifier == null) { return; } synchronized (notifiersLock) { Collection<SqlTable<?>> tables = notifier.whichTables(); if (tables == null || tables.isEmpty()) { globalNotifiers.remove(notifier); } else { for (SqlTable<?> table : tables) { List<DataChangedNotifier<?>> notifiersForTable = tableNotifiers.get(table); if (notifiersForTable != null) { notifiersForTable.remove(notifier); } } } } }
/** * Register a {@link DataChangedNotifier} to listen for database changes. The DataChangedNotifier object will be * notified whenever a table it is interested is modified, and can accumulate a set of notifications to send when * the current transaction or statement completes successfully. * * @param notifier the DataChangedNotifier to register */ public void registerDataChangedNotifier(DataChangedNotifier<?> notifier) { if (notifier == null) { return; } synchronized (notifiersLock) { Collection<SqlTable<?>> tables = notifier.whichTables(); if (tables == null || tables.isEmpty()) { globalNotifiers.add(notifier); } else { for (SqlTable<?> table : tables) { List<DataChangedNotifier<?>> notifiersForTable = tableNotifiers.get(table); if (notifiersForTable == null) { notifiersForTable = new ArrayList<>(); tableNotifiers.put(table, notifiersForTable); } notifiersForTable.add(notifier); } } } }