public void redo() { // add the endChange marker to redo if we can undo if (!redoStack.empty()) { undoStack.push(endChange); undoNotifyStack.push(endChange); } // keep undoing until the undo stack is empty, or we hit a stop action while (!redoStack.empty()) { // get the current change Change currentChange = redoStack.pop(); // if it is a stop action, break the loop if (currentChange == endChange) break; currentChange.redo(); // add the change to the redo stack undoStack.push(currentChange); } // find everyone to notify while (!redoNotifyStack.empty()) { ChangeNotification currentNotification = redoNotifyStack.pop(); if (currentNotification == endChange) break; currentNotification.notifyChange(); undoNotifyStack.push(currentNotification); } }
public static Container setup( DataSource dataSource, Properties properties, Optional<ClassLoader> classLoader, Iterator<SystemAspect> aspects) throws IOException { ClassLoader loader = classLoader.orElse(Thread.currentThread().getContextClassLoader()); SimpleContainer container = new SimpleContainer("true".equals(properties.getProperty("revenj.resolveUnknown"))); container.registerInstance(properties); container.registerInstance(ServiceLocator.class, container, false); container.registerInstance(DataSource.class, dataSource, false); container.registerInstance(ClassLoader.class, loader, false); String ns = properties.getProperty("revenj.namespace"); SimpleDomainModel domainModel = new SimpleDomainModel(ns, loader); container.registerInstance(DomainModel.class, domainModel, false); container.registerFactory(DataContext.class, LocatorDataContext::asDataContext, false); container.registerFactory(UnitOfWork.class, LocatorDataContext::asUnitOfWork, false); PluginLoader plugins = new ServicesPluginLoader(loader); container.registerInstance(PluginLoader.class, plugins, false); PostgresDatabaseNotification databaseNotification = new PostgresDatabaseNotification( dataSource, Optional.of(domainModel), properties, container); container.registerInstance(EagerNotification.class, databaseNotification, false); container.registerInstance(DataChangeNotification.class, databaseNotification, true); ChangeNotification.registerContainer(container, databaseNotification); container.registerFactory(RepositoryBulkReader.class, PostgresBulkReader::create, false); container.registerInstance( PermissionManager.class, new RevenjPermissionManager(container), false); container.registerClass( new Generic<Serialization<String>>() {}.type, DslJsonSerialization.class, false); int total = 0; if (aspects != null) { JinqMetaModel.configure(container); while (aspects.hasNext()) { aspects.next().configure(container); total++; } } String nsAfter = properties.getProperty("revenj.namespace"); if (!Objects.equals(ns, nsAfter)) { domainModel.updateNamespace(nsAfter); } properties.setProperty("revenj.aspectsCount", Integer.toString(total)); return container; }