@Override public void onEvent(EventIterator events) { reload(); } }, 1000, 5000);
/** * Calls onClear and reregister the nodes by calling onRegister. */ public synchronized void reload() { // Call onClear and reregister the nodes by calling onRegister onClear(); Session session = null; try { session = MgnlContext.getSystemContext().getJCRSession(RepositoryConstants.CONFIG); } catch (RepositoryException e) { throw new RuntimeException(e); } // copy to avoid ConcurrentModificationException since the list get changed during iteration List<String> uuidsAndPaths = new ArrayList<String>(registeredUUIDs); for (Iterator<String> iter = uuidsAndPaths.iterator(); iter.hasNext(); ) { String uuid = iter.next(); try { Node node = getNodeByIdentifierOrPath(session, uuid, UUIDToPathMap.get(uuid)); reload(new DefaultContent(node)); } catch (Exception e) { registeredUUIDs.remove(uuid); UUIDToPathMap.remove(uuid); log.warn("Can't reload the node with uuid [{}] and path [{}]", uuid, UUIDToPathMap.get(uuid)); } } return; }