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;
}
// get all plugins paths from repository
List<Path> pluginsPaths = pluginRepository.getPluginsPaths();
// get all plugin paths from repository
List<Path> pluginPaths = pluginRepository.getPluginPaths();
// check for no plugins
if (pluginsPaths.isEmpty()) {
if (pluginPaths.isEmpty()) {
log.info("No plugins");
return;
}
log.debug("Found {} possible plugins: {}", pluginsPaths.size(), pluginsPaths);
log.debug("Found {} possible plugins: {}", pluginPaths.size(), pluginPaths);
// load plugins from plugin paths
for (Path pluginPath : pluginsPaths) {
for (Path pluginPath : pluginPaths) {
try {
loadPluginFromPath(pluginPath);
} 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}.
* 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.
* 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
public List<Path> getPluginsPaths() {
public List<Path> getPluginPaths() {
File[] files = pluginsRoot.toFile().listFiles(filter);
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
public List<Path> getPluginsPaths() {
public List<Path> getPluginPaths() {
Set<Path> paths = new LinkedHashSet<>();
for (PluginRepository repository : repositories) {
paths.addAll(repository.getPluginsPaths());
paths.addAll(repository.getPluginPaths());
}
return new ArrayList<>(paths);

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

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

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

@ -27,11 +27,11 @@ import java.util.List;
public interface PluginRepository {
/**
* List all plugins paths.
* List all plugin paths.
*
* @return a list with paths
*/
List<Path> getPluginsPaths();
List<Path> getPluginPaths();
/**
* 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
public void testGetPluginArchives() {
PluginRepository repository = new DefaultPluginRepository(pluginsPath);
List<Path> pluginsPaths = repository.getPluginsPaths();
List<Path> pluginPaths = repository.getPluginPaths();
assertEquals(3, pluginsPaths.size());
assertPathExists(pluginsPaths, pluginsPath.resolve("plugin-1"));
assertPathExists(pluginsPaths, pluginsPath.resolve("plugin-2"));
assertPathExists(pluginsPaths, pluginsPath.resolve("plugin-3"));
assertEquals(3, pluginPaths.size());
assertPathExists(pluginPaths, pluginsPath.resolve("plugin-1"));
assertPathExists(pluginPaths, pluginsPath.resolve("plugin-2"));
assertPathExists(pluginPaths, pluginsPath.resolve("plugin-3"));
}
/**
@ -76,10 +76,10 @@ public class DefaultPluginRepositoryTest {
assertTrue(repository.deletePluginPath(pluginsPath.resolve("plugin-3")));
assertFalse(repository.deletePluginPath(pluginsPath.resolve("plugin-4")));
List<Path> pluginsPaths = repository.getPluginsPaths();
List<Path> pluginPaths = repository.getPluginPaths();
assertEquals(1, pluginsPaths.size());
assertEquals(pluginsPath.relativize(pluginsPaths.get(0)).toString(), "plugin-2");
assertEquals(1, pluginPaths.size());
assertEquals(pluginsPath.relativize(pluginPaths.get(0)).toString(), "plugin-2");
}
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() {
PluginRepository repository = new DevelopmentPluginRepository(pluginsPath);
List<Path> pluginsPaths = repository.getPluginsPaths();
List<Path> pluginPaths = repository.getPluginPaths();
// target and build should be ignored
assertEquals(0, pluginsPaths.size());
assertPathDoesNotExists(pluginsPaths, pluginsPath.resolve(DevelopmentPluginRepository.MAVEN_BUILD_DIR));
assertPathDoesNotExists(pluginsPaths, pluginsPath.resolve(DevelopmentPluginRepository.GRADLE_BUILD_DIR));
assertEquals(0, pluginPaths.size());
assertPathDoesNotExists(pluginPaths, pluginsPath.resolve(DevelopmentPluginRepository.MAVEN_BUILD_DIR));
assertPathDoesNotExists(pluginPaths, pluginsPath.resolve(DevelopmentPluginRepository.GRADLE_BUILD_DIR));
}
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));
List<Path> pluginsPaths = repository.getPluginsPaths();
assertEquals(1, pluginsPaths.size());
List<Path> pluginPaths = repository.getPluginPaths();
assertEquals(1, pluginPaths.size());
assertTrue(repository.deletePluginPath(plugin1JarPath));
pluginsPaths = repository.getPluginsPaths();
assertEquals(0, pluginsPaths.size());
pluginPaths = repository.getPluginPaths();
assertEquals(0, pluginPaths.size());
}
}

Loading…
Cancel
Save