Browse Source

Revert commit 40846fa (Rename PluginRepository.getPluginPaths to getPluginsPaths)

pull/320/head
Decebal Suiu 6 years ago
parent
commit
3cd26fc19d
  1. 10
      pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
  2. 4
      pf4j/src/main/java/org/pf4j/BasePluginRepository.java
  3. 4
      pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java
  4. 4
      pf4j/src/main/java/org/pf4j/DefaultPluginRepository.java
  5. 4
      pf4j/src/main/java/org/pf4j/PluginRepository.java
  6. 18
      pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java
  7. 8
      pf4j/src/test/java/org/pf4j/DevelopmentPluginRepositoryTest.java
  8. 8
      pf4j/src/test/java/org/pf4j/JarPluginRepositoryTest.java

10
pf4j/src/main/java/org/pf4j/AbstractPluginManager.java

@ -207,19 +207,19 @@ public abstract class AbstractPluginManager implements PluginManager {
return; return;
} }
// get all plugins paths from repository // get all plugin paths from repository
List<Path> pluginsPaths = pluginRepository.getPluginsPaths(); List<Path> pluginPaths = pluginRepository.getPluginPaths();
// check for no plugins // check for no plugins
if (pluginsPaths.isEmpty()) { if (pluginPaths.isEmpty()) {
log.info("No plugins"); log.info("No plugins");
return; return;
} }
log.debug("Found {} possible plugins: {}", pluginsPaths.size(), pluginsPaths); log.debug("Found {} possible plugins: {}", pluginPaths.size(), pluginPaths);
// load plugins from plugin paths // load plugins from plugin paths
for (Path pluginPath : pluginsPaths) { for (Path pluginPath : pluginPaths) {
try { try {
loadPluginFromPath(pluginPath); loadPluginFromPath(pluginPath);
} catch (PluginException e) { } catch (PluginException e) {

4
pf4j/src/main/java/org/pf4j/BasePluginRepository.java

@ -57,7 +57,7 @@ public class BasePluginRepository implements PluginRepository {
/** /**
* Set a {@link File} {@link Comparator} used to sort the listed files from {@code pluginsRoot}. * Set a {@link File} {@link Comparator} used to sort the listed files from {@code pluginsRoot}.
* This comparator is used in {@link #getPluginsPaths()} method. * This comparator is used in {@link #getPluginPaths()} method.
* By default is used a file comparator that returns the last modified files first. * By default is used a file comparator that returns the last modified files first.
* If you don't want a file comparator, then call this method with {@code null}. * If you don't want a file comparator, then call this method with {@code null}.
*/ */
@ -66,7 +66,7 @@ public class BasePluginRepository implements PluginRepository {
} }
@Override @Override
public List<Path> getPluginsPaths() { public List<Path> getPluginPaths() {
File[] files = pluginsRoot.toFile().listFiles(filter); File[] files = pluginsRoot.toFile().listFiles(filter);
if ((files == null) || files.length == 0) { if ((files == null) || files.length == 0) {

4
pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java

@ -56,10 +56,10 @@ public class CompoundPluginRepository implements PluginRepository {
} }
@Override @Override
public List<Path> getPluginsPaths() { public List<Path> getPluginPaths() {
Set<Path> paths = new LinkedHashSet<>(); Set<Path> paths = new LinkedHashSet<>();
for (PluginRepository repository : repositories) { for (PluginRepository repository : repositories) {
paths.addAll(repository.getPluginsPaths()); paths.addAll(repository.getPluginPaths());
} }
return new ArrayList<>(paths); return new ArrayList<>(paths);

4
pf4j/src/main/java/org/pf4j/DefaultPluginRepository.java

@ -48,9 +48,9 @@ public class DefaultPluginRepository extends BasePluginRepository {
} }
@Override @Override
public List<Path> getPluginsPaths() { public List<Path> getPluginPaths() {
extractZipFiles(); extractZipFiles();
return super.getPluginsPaths(); return super.getPluginPaths();
} }
@Override @Override

4
pf4j/src/main/java/org/pf4j/PluginRepository.java

@ -27,11 +27,11 @@ import java.util.List;
public interface PluginRepository { public interface PluginRepository {
/** /**
* List all plugins paths. * List all plugin paths.
* *
* @return a list with paths * @return a list with paths
*/ */
List<Path> getPluginsPaths(); List<Path> getPluginPaths();
/** /**
* Removes a plugin from the repository. * Removes a plugin from the repository.

18
pf4j/src/test/java/org/pf4j/DefaultPluginRepositoryTest.java

@ -49,18 +49,18 @@ public class DefaultPluginRepositoryTest {
} }
/** /**
* Test of {@link DefaultPluginRepository#getPluginsPaths()} method. * Test of {@link DefaultPluginRepository#getPluginPaths()} method.
*/ */
@Test @Test
public void testGetPluginArchives() { public void testGetPluginArchives() {
PluginRepository repository = new DefaultPluginRepository(pluginsPath); PluginRepository repository = new DefaultPluginRepository(pluginsPath);
List<Path> pluginsPaths = repository.getPluginsPaths(); List<Path> pluginPaths = repository.getPluginPaths();
assertEquals(3, pluginsPaths.size()); assertEquals(3, pluginPaths.size());
assertPathExists(pluginsPaths, pluginsPath.resolve("plugin-1")); assertPathExists(pluginPaths, pluginsPath.resolve("plugin-1"));
assertPathExists(pluginsPaths, pluginsPath.resolve("plugin-2")); assertPathExists(pluginPaths, pluginsPath.resolve("plugin-2"));
assertPathExists(pluginsPaths, pluginsPath.resolve("plugin-3")); assertPathExists(pluginPaths, pluginsPath.resolve("plugin-3"));
} }
/** /**
@ -76,10 +76,10 @@ public class DefaultPluginRepositoryTest {
assertTrue(repository.deletePluginPath(pluginsPath.resolve("plugin-3"))); assertTrue(repository.deletePluginPath(pluginsPath.resolve("plugin-3")));
assertFalse(repository.deletePluginPath(pluginsPath.resolve("plugin-4"))); assertFalse(repository.deletePluginPath(pluginsPath.resolve("plugin-4")));
List<Path> pluginsPaths = repository.getPluginsPaths(); List<Path> pluginPaths = repository.getPluginPaths();
assertEquals(1, pluginsPaths.size()); assertEquals(1, pluginPaths.size());
assertEquals(pluginsPath.relativize(pluginsPaths.get(0)).toString(), "plugin-2"); assertEquals(pluginsPath.relativize(pluginPaths.get(0)).toString(), "plugin-2");
} }
private void assertPathExists(List<Path> paths, Path path) { private void assertPathExists(List<Path> paths, Path path) {

8
pf4j/src/test/java/org/pf4j/DevelopmentPluginRepositoryTest.java

@ -46,12 +46,12 @@ public class DevelopmentPluginRepositoryTest {
public void testGetPluginArchivesInDevelopmentMode() { public void testGetPluginArchivesInDevelopmentMode() {
PluginRepository repository = new DevelopmentPluginRepository(pluginsPath); PluginRepository repository = new DevelopmentPluginRepository(pluginsPath);
List<Path> pluginsPaths = repository.getPluginsPaths(); List<Path> pluginPaths = repository.getPluginPaths();
// target and build should be ignored // target and build should be ignored
assertEquals(0, pluginsPaths.size()); assertEquals(0, pluginPaths.size());
assertPathDoesNotExists(pluginsPaths, pluginsPath.resolve(DevelopmentPluginRepository.MAVEN_BUILD_DIR)); assertPathDoesNotExists(pluginPaths, pluginsPath.resolve(DevelopmentPluginRepository.MAVEN_BUILD_DIR));
assertPathDoesNotExists(pluginsPaths, pluginsPath.resolve(DevelopmentPluginRepository.GRADLE_BUILD_DIR)); assertPathDoesNotExists(pluginPaths, pluginsPath.resolve(DevelopmentPluginRepository.GRADLE_BUILD_DIR));
} }
private void assertPathDoesNotExists(List<Path> paths, Path path) { private void assertPathDoesNotExists(List<Path> paths, Path path) {

8
pf4j/src/test/java/org/pf4j/JarPluginRepositoryTest.java

@ -46,13 +46,13 @@ public class JarPluginRepositoryTest {
assertFalse(repository.deletePluginPath(plugin1Path)); assertFalse(repository.deletePluginPath(plugin1Path));
List<Path> pluginsPaths = repository.getPluginsPaths(); List<Path> pluginPaths = repository.getPluginPaths();
assertEquals(1, pluginsPaths.size()); assertEquals(1, pluginPaths.size());
assertTrue(repository.deletePluginPath(plugin1JarPath)); assertTrue(repository.deletePluginPath(plugin1JarPath));
pluginsPaths = repository.getPluginsPaths(); pluginPaths = repository.getPluginPaths();
assertEquals(0, pluginsPaths.size()); assertEquals(0, pluginPaths.size());
} }
} }

Loading…
Cancel
Save