/** * Reloads the configuration and notifies GWC of any externally removed layer. */ public void reload() { final Set<String> currLayerNames = new HashSet<String>(getTileLayerNames()); try { tld.reInit(); } catch (RuntimeException e) { log.log(Level.WARNING, "Unable to reinit TileLayerDispatcher", e); throw e; } Set<String> newLayerNames = getTileLayerNames(); SetView<String> removedExternally = Sets.difference(currLayerNames, newLayerNames); for (String removedLayerName : removedExternally) { log.info("Notifying of TileLayer '" + removedLayerName + "' removed externally"); layerRemoved(removedLayerName); } }
layerDispatcher.reInit(); String info = "TileLayerConfiguration reloaded. Read "
layerDispatcher.reInit(); String info = "Configuration reloaded. Read " + layerDispatcher.getLayerCount()
public void testReloadAndLayerRemovedExternally() throws Exception { final String removedLayer = tileLayer.getName(); final String remainingLayer = tileLayerGroup.getName(); final Set<String> layerNames = Sets.newHashSet(removedLayer, remainingLayer); when(tld.getLayerNames()).thenReturn(layerNames); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { layerNames.remove(removedLayer); return null; } }).when(tld).reInit(); ArgumentCaptor<String> argCaptor = ArgumentCaptor.forClass(String.class); mediator = spy(mediator); doReturn(true).when(mediator).layerRemoved(argCaptor.capture()); mediator.reload(); verify(tld, times(1)).reInit(); assertEquals(1, argCaptor.getAllValues().size()); assertEquals(removedLayer, argCaptor.getValue()); }
final Set<String> currLayerNames = new HashSet<String>(getTileLayerNames()); try { tld.reInit(); } catch (RuntimeException e) { log.log(Level.WARNING, "Unable to reinit TileLayerDispatcher", e);