Example usage for org.eclipse.jgit.internal.storage.file FileSnapshot isModified

List of usage examples for org.eclipse.jgit.internal.storage.file FileSnapshot isModified

Introduction

In this page you can find the example usage for org.eclipse.jgit.internal.storage.file FileSnapshot isModified.

Prototype

private boolean isModified(Instant currLastModified) 

Source Link

Usage

From source file:com.google.gerrit.server.plugins.PluginLoader.java

License:Apache License

public synchronized void rescan() {
    Multimap<String, Path> pluginsFiles = prunePlugins(pluginsDir);
    if (pluginsFiles.isEmpty()) {
        return;/*ww  w .  j a  v  a 2  s .co m*/
    }

    syncDisabledPlugins(pluginsFiles);

    Map<String, Path> activePlugins = filterDisabled(pluginsFiles);
    for (Map.Entry<String, Path> entry : jarsFirstSortedPluginsSet(activePlugins)) {
        String name = entry.getKey();
        Path path = entry.getValue();
        String fileName = path.getFileName().toString();
        if (!isJsPlugin(fileName) && !serverPluginFactory.handles(path)) {
            log.warn("No Plugin provider was found that handles this file format: {}", fileName);
            continue;
        }

        FileSnapshot brokenTime = broken.get(name);
        if (brokenTime != null && !brokenTime.isModified(path.toFile())) {
            continue;
        }

        Plugin active = running.get(name);
        if (active != null && !active.isModified(path)) {
            continue;
        }

        if (active != null) {
            log.info(String.format("Reloading plugin %s", active.getName()));
        }

        try {
            Plugin loadedPlugin = runPlugin(name, path, active);
            if (!loadedPlugin.isDisabled()) {
                log.info(String.format("%s plugin %s, version %s", active == null ? "Loaded" : "Reloaded",
                        loadedPlugin.getName(), loadedPlugin.getVersion()));
            }
        } catch (PluginInstallException e) {
            log.warn(String.format("Cannot load plugin %s", name), e.getCause());
        }
    }

    cleanInBackground();
}