@Test public void notifyListenersTest() { final EffectiveModelContext baseSchemaCtx = schemaService.getGlobalContext(); assertNotNull(baseSchemaCtx); assertTrue(baseSchemaCtx.getModules().size() == 1); final SchemaContextHolder actualSchemaCtx = new SchemaContextHolder(); final EffectiveModelContextListener schemaCtxListener = actualSchemaCtx::setSchemaContext; final ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener = schemaService.registerSchemaContextListener(schemaCtxListener); assertEquals(registerSchemaContextListener.getInstance(), schemaCtxListener); assertNotNull(actualSchemaCtx.getSchemaContext()); assertEquals(baseSchemaCtx, actualSchemaCtx.getSchemaContext()); addYang("/empty-test1.yang"); addYangs(schemaService); final EffectiveModelContext nextSchemaCtx = schemaService.getGlobalContext(); assertNotNull(nextSchemaCtx); assertTrue(nextSchemaCtx.getModules().size() == 2); assertNotEquals(baseSchemaCtx, nextSchemaCtx); schemaService.notifyListeners(nextSchemaCtx); assertEquals(nextSchemaCtx, actualSchemaCtx.getSchemaContext()); addYang("/empty-test2.yang"); addYangs(schemaService); final EffectiveModelContext unregistredListenerSchemaCtx = schemaService.getGlobalContext(); assertNotNull(unregistredListenerSchemaCtx); assertTrue(unregistredListenerSchemaCtx.getModules().size() == 3); assertNotEquals(baseSchemaCtx, unregistredListenerSchemaCtx); assertNotEquals(nextSchemaCtx, unregistredListenerSchemaCtx); registerSchemaContextListener.close(); schemaService.notifyListeners(unregistredListenerSchemaCtx); assertNotEquals(unregistredListenerSchemaCtx, actualSchemaCtx.getSchemaContext()); assertEquals(nextSchemaCtx, actualSchemaCtx.getSchemaContext()); schemaService.registerSchemaContextListener(schemaCtxListener); assertEquals(unregistredListenerSchemaCtx, actualSchemaCtx.getSchemaContext()); }
@VisibleForTesting @SuppressWarnings("checkstyle:IllegalCatch") public void notifyListeners(final EffectiveModelContext schemaContext) { synchronized (lock) { listeners.streamListeners().forEach(listener -> { try { listener.onModelContextUpdated(schemaContext); } catch (final Exception e) { LOG.error("Exception occured during invoking listener {}", listener, e); } }); } }
ScanningSchemaServiceProvider extends AbstractDOMSchemaService.WithYangTextSources implements AutoCloseable { @VisibleForTesting @SuppressWarnings("checkstyle:IllegalCatch") public void notifyListeners(final EffectiveModelContext schemaContext) { synchronized (lock) { listeners.streamListeners().forEach(listener -> { try { listener.onModelContextUpdated(schemaContext); } catch (final Exception e) { LOG.error("Exception occured during invoking listener {}", listener, e); } }); } } }
ScanningSchemaServiceProvider extends AbstractDOMSchemaService.WithYangTextSources implements AutoCloseable { @VisibleForTesting @SuppressWarnings("checkstyle:IllegalCatch") public void notifyListeners(final EffectiveModelContext schemaContext) { synchronized (lock) { listeners.streamListeners().forEach(listener -> { try { listener.onModelContextUpdated(schemaContext); } catch (final Exception e) { LOG.error("Exception occured during invoking listener {}", listener, e); } }); } }  }
ScanningSchemaServiceProvider extends AbstractDOMSchemaService.WithYangTextSources implements AutoCloseable { @VisibleForTesting @SuppressWarnings("checkstyle:IllegalCatch") public void notifyListeners(final EffectiveModelContext schemaContext) { synchronized (lock) { listeners.streamListeners().forEach(listener -> { try { listener.onModelContextUpdated(schemaContext); } catch (final Exception e) { LOG.error("Exception occured during invoking listener {}", listener, e); } }); } }  void tryToUpdateSchemaContext(); @VisibleForTesting @SuppressWarnings("checkstyle:IllegalCatch") void notifyListeners(final EffectiveModelContext schemaContext); List<Registration> registerAvailableYangs(final List<URL> yangs); boolean hasListeners(); @Override EffectiveModelContext getGlobalContext(); @Override ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
            final EffectiveModelContextListener listener); @Override ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier); @Override void close(); }
ScanningSchemaServiceProvider extends AbstractDOMSchemaService.WithYangTextSources implements AutoCloseable { @VisibleForTesting @SuppressWarnings("checkstyle:IllegalCatch") public void notifyListeners(final EffectiveModelContext schemaContext) { synchronized (lock) { listeners.streamListeners().forEach(listener -> { try { listener.onModelContextUpdated(schemaContext); } catch (final Exception e) { LOG.error("Exception occured during invoking listener {}", listener, e); } }); } }  void tryToUpdateSchemaContext(); @VisibleForTesting @SuppressWarnings("checkstyle:IllegalCatch") void notifyListeners(final EffectiveModelContext schemaContext); List<Registration> registerAvailableYangs(final List<URL> yangs); boolean hasListeners(); @Override EffectiveModelContext getGlobalContext(); @Override ListenerRegistration<EffectiveModelContextListener> registerSchemaContextListener(
            final EffectiveModelContextListener listener); @Override ListenableFuture<? extends YangTextSchemaSource> getSource(final SourceIdentifier sourceIdentifier); @Override void close();  }